36 CIRCUIT CELLAR ® • www.circuitcellar.com May 2011 – Issue 250 In the first part of this series, you were introduced to the SLUGS reprogrammable UAV autopilot system. This article details the system’s software and flight test results. Reprogrammable UAV Autopilot System (Part 2) I F EATURE ARTICLE by Mariano Lizarraga, Renwick Curry, and Gabriel Elkaim (USA) n the first part of this two-part series, we introduced the hardware used in the Santa Cruz Low-cost UAV GNC System (SLUGS), an open-source unmanned aerial vehicle (UAV) autopilot primarily focused on supporting guidance, navigation, and control (GNC) research. In this article, we’ll focus on the software architecture and algo- rithms. We’ll also present results from temperature com- pensation, sensor calibration, and flight tests. SOFTWARE ARCHITECTURE The SLUGS has two Microchip Technology dsPIC33 digital signal controllers (DSCs) that serve as its main processing units, running at 40 MIPS. These are interconnected via a SPI at 10 MHz and are called the “sensor” DSC and “control” DSC, respectively. The sen- sor DSC is in charge of reading the sensor data and converting it into a high-quality estimate of the aircraft position and atti- tude (3-D orientation). The control DSC interacts with the user through the ground station, generating signals to the UAV’s control surfaces to stabilize the aircraft and fly it along the user-designated mission (at its highest level, traversing waypoints at a given altitude and airspeed). One of the key advancements in the SLUGS autopilot is that the DSCs are pro- grammed directly from MATLAB Simulink using a block and signal flow metaphor for visual programming. This offers several advantages. Most researchers in the GNC field are already familiar with MATLAB and use it to prototype and simulate new algorithms. Com- plicated algorithms and changes are easy to implement, rapidly increasing the prototype-simulate-test cycle. Lastly, the software can be easily retargeted for better processors without having to rework the low-level, back-end code. While this environment sacrifices some efficiency, any per- formance issues are made insignificant by the speed with which changes can be made and tested. The sensor DSC’s low-level software architecture (see Figure 1) is a combination of blocks provided by Lubin Kerhuel’s dsPIC Simulink Embedded Target (ET) (shown in Figure 1—Low-level software architecture for the sensor DSC Parser K C Function call Simulink blocks Modifiable by end user (Simulink blocks) Simulink ET blocks Attitude and position estimation Protocol encoder To control DSC [SPI] Calibration and temperature compensation GPS [UART] Mags [I 2 C] RCRx [IC] Analog sensors [ADC] Accels and gyros [SPI] HIL Data [UART] Testing and Results