Reconfigurable Embedded Control for UAVs Tim Arrowsmith, Darren Brown and James E. Lumpp, Jr. University of Kentucky, Department of Electrical and Computer Engineering SERVO/TIM SERVOS/ TIM Autopilot The goal of this project is to develop reconfigurable distributed embedded computer systems particularly for the control of Unmanned Aerial Vehicles (UAVs). Reconfigurable computing platforms with hardware and software fault recognition capability can identify and compensate for run-time faults (i.e., fault tolerance). Reconfigurable systems also enable UAVs to be quickly reconfigured between missions by adding or removing processors and sensors. To date, the Intelligent Dependable Embedded Architectures (IDEA) Lab at the University of Kentucky has developed a generic hardware and firmware configuration for an 8051 based 8-bit processor, Real-Time Operating System (RTOS) and Communication Library based on the Controller Area Network (CAN) 2.0 Standard. The prototype hardware measures 1.4 inch x 1.6 inch on a custom PCB allowing easy integration into small UAV airframes. The small easily adaptable Tiny Interface Module (TIM) includes CAN, SPI, and two RS-232 communications channels, timer counter arrays as well as up to seven GPIO pins and a header configuration that allows directly interfacing with servos typically used in aircraft control. The TIM firmware includes a configuration macro for easy user selection of microcontroller peripherals. Finally the TIM includes the MicroC/OSII RTOS and a custom communication layer that supports dynamic reconfiguration of the network topology. TIM (Tiny Interface Module) JTAG custom harness UART0 Custom harness with level shifter UART1 SPI 4-wire compatible Servo header (x4) Standard Servo plug-in GPIO (x4) CAN (x2) Four pin header LED (x3) Power Status 0 Status 1 Push Button (x2) Reset Generic Push Button TIM Applications 4th Annual AUVSI Student UAV Competition – This student competition requires the students to develop an UAV capable of flying autonomously through waypoints taking high resolution photographs of ground targets. Ready UAV – Through Ready UAV the TIM will be utilized to help provide the infrastructure for a fully modular, reconfigurable, UAV. General Student Education – The TIM will be used for future development of student embedded applications. Homeland Security - Milk Truck Security Future Embedded Applications Development TIM MicroController TIM CUSTOM API (CONFIGURATION) #ifndef genconfig_h #define genconfig_h #define CAN_EN 1 //Enable/Disable CAN (1 or 0) #define CAN_BAUD //125k 250k 500k 1M #define UART0_EN 1 //Enable/Disable UART0 (1 or 0) --will be set to Mode 3 by default #define BAUDRATE0 9600 // Baud rate of UART in bps. Can be set to: 1200,9600,57600,115200. #define UART1_EN 1 //Enable/Disable UART0 (1 or 0) --will be set to Mode 3 by default #define BAUDRATE1 9600 // Baud rate of UART in bps. Can be set to: 1200,9600,57600,115200. #define SPI_MODE MM //Master - multi-master, 3-wire single-master, 4-wire single-master, //Slave - 4-wire, 3-wire //(Master - MM, M3, M4, Slave - S4, S3) #define I2C_MODE M //Master or Slave #define PCA_IN 3 //Defines number of PCA inputs (0 to 6) #define PCA_OUT 1 //Defines number of PCA outputs (0 to 6) #define PCA_TSRC SYS12 //Defines the timer source of the PCA (SYSCLK/12 =>SYS12, //SYSCLK/4 =>SYS4, Timer0 =>TIMER0, //SYSCLK => SYSC) ?-- ECI, External Clock/8 #define GPIO_IN 2 //Defines number of GPIO inputs (0 to 9 - #PCA) #define GPO_OUT 2 //Defines number of GPIO outputs (0 to 9 -(#PCA + #GPIO_IN)) #define GPO_PSHPUL 1 //Defines number of pushpull outputs(0 to 9), the first n are pushpull #define Timer0_EN 0 //Disabled =>0,13-bit=>1, 16-bit=>2, 8-bit auto reload=>3, Two 8- //bit=>4 #define Timer1_EN 0 //Disabled =>0,13-bit=>1, 16-bit=>2, 8-bit auto reload=>3 #define Timer2_EN 0 //Disabled =>0,16-bit auto reload=>1, 16-bit capture=>2, Toggle //Output=>3 #define Timer3_EN 0 //Disabled =>0,16-bit auto reload=>1, 16-bit capture=>2, Toggle //Output=>3 #define Timer4_EN 0 //Disabled =>0,16-bit auto reload=>1, 16-bit capture=>2, Toggle //Output=>3 #define SYSCLK 24500000 // Internal oscillator frequency in Hz (can be either 24500000 or //2500000) // Other options ?-- 22.1184M, 18.432M, 11.0592M, 3.6864M #define SAMPLE_RATE 50000 // Sample frequency in Hz #define INT_DEC 256 // integrate and decimate ratio C8051F040/1/2/3/4/5/6/7 Analog Peripherals High-Speed 8051 µC Core -Pipelined instruction architecture; executes 70% of instruction set in 1 or 2 system clocks -Up to 25 MIPS throughput with 25 MHz clock Memory -4352 bytes internal data RAM (4 k + 256) -64 kB (C8051F041) Flash; Digital Peripherals -Bosch Controller Area Network (CAN 2.0B), hardware SMBus™ (I2C™ Compatible), SPI™, and two UART Programmable 16-bit counter/timer array with 6 capture/compare modules -5 general purpose 16-bit counter/timers Clock Sources -Internal calibrated programmable oscillator: 3 to 24.5 MHz -Real-time clock mode using Timer 2, 3, 4, or PCA Supply Voltage: 2.7 to 3.6 V Controller Area Network (CAN) Is a high-integrity serial data communications bus for real-time applications Operates at data rates of up to 1 Megabits per second Has excellent error detection and confinement capabilities Was originally developed by Bosch for use in cars Is now being used in many other industrial automation and control applications TIM Communication Library / Firmware Driver API This API is the method of communication between the IDEAnix message router and the CAN driver. UINT8 init_can ( void ); Sets up the hardware prior to any other API calls. i.e. initializes one channel to receive all and one to send all in "implementation one“ or four channels for sending and 28 for receiving in "implementation two.“ UINT8 send_pkt ( CAN_ID_TYPE can_id , PAYLOAD_TYPE payload ); Pumps a CAN frame contaning the ID and 4-byte payload out on the bus. BLOCKING call. UINT8 reg_pkt ( CAN_ID_TYPE can_id ); Tells the driver layer to capture CAN messages with the passed ID. UINT8 unreg_pkt ( CAN_ID_TYPE can_id ); De-allocates space (or hardware capture channel) previously allocated by reg_pkt(). UINT8 get_pkt ( CAN_ID_TYPE *can_id_ptr, PAYLOAD_TYPE *payload_ptr ) Places the first can_id and payload in the pipe/queue/buffer into the memory space referred to by the pointers. User API This is the API used between user code and the IDEAnix message router. UINT8 send_msg ( CAN_ID_TYPE can_id , PAYLOAD_TYPE payload ); Passes a CAN message and it's ID to the router layer to be stuffed into the D' input queue. UINT8 reg_msg ( CAN_ID_TYPE can_id ); Tells the IDEAnix router layer to grab incoming messages with can_id off the bus and to place them into the tasks incoming queue. UINT8 unreg_msg ( CAN_ID_TYPE can_id ); De-allocates space in hardware for this can_id and stops messages of this type from being placed into the tasks' incoming buffer. UINT8 get_msg ( CAN_ID_TYPE *can_id_ptr, PAYLOAD_TYPE *payload_ptr ); Places the first can_id and payload in the pipe/queue/buffer into the memory space refered to by the pointers. UINT8 check_msg ( void ); Returns 1 if there is any data waiting in the pipe/queue/buffer. Returns 0 if there is no data waiting in the pipe/queue/buffer.