© 2008 Science Publications Miniature-Autopilot Evaluation System

This research describes a Hardware in the Loop Simulator (HILS) that was developed to enhance the quality of attitude data received from autopilots. The described system aided in adjusting the contribution of individual IMU sensors and thereby improved the accuracy of IMU data. The HILS system outlined in this research is a gimbaled platform equipped with four stepper motors and two optical shaft encoders. The stepper motors simulated flight, while the shaft encoders reported the platform's exact angular position. Having exact attitude information to compare with IMU data allowed for the filtering of IMU errors. The HILS system was also used as an inertial frame of reference to which IMU data was synchronized.


INTRODUCTION
To more effectively support troops in the field, smaller Unmanned Aerial Vehicles (UAVs) are designed, ranging from back-packable systems to insect-sized mesicopters and miniature smart dust sensors. These systems can be launched by hand, deployed by larger UAVs, or ejected from artillery or mortar projectiles, as expendable sensors. These systems are broadly designated as Miniature Aerial Vehicles (MAVs) [13] .
Most MAVs are equipped with autopilots that govern their flight. Although fairly reliable, the autopilot is probably the weakest link in the MAV system. To verify the capabilities of an autopilot, the MAV is flown in different weather conditions, a task that is time consuming and hardly comprehensive. Therefore, to properly evaluate an autopilot an environment should be developed where the autopilot can be subjected to different flight scenarios. To this end, a Hardware-In-the-Loop Simulator (HILS) was developed. This simulator allowed for the evaluation of autopilots in the lab, under a variety of flight conditions.
Autopilots update the vehicle's attitude information at a fairly slow rate (1 to 5Hz). This slow rate and the accuracy of IMU data generated, although sufficient to maintain flight, is not accurate enough for systems such as target geolocation extraction [18,19] . The use of the HILS system allowed for the collection of precise attitude data that was used to create filters minimizing errors in autopilot's data [1,2,4] .
The platform described allows for the evaluation of autopilots' behavior. It facilitates the generation of precise attitude data that can be compared to autopilot's sensor data. By comparing accurate attitude data from the platform with that provided by the autopilot's sensors, filters can be developed to help produce more accurate attitude data from the autopilots sensor [5,13,14,15,16] .

THE PLATFORM
The HILS system designed is a computercontrolled gimbaled platform (GP). The platform is actuated by a set of Stepper Motors coupled with Optical Shaft Encoders [11,12] . The shaft encoders provide precise and continuous measure of the platform's attitude, while the stepper motors [10] driven by the control computer manipulate the platform's attitude. This system allowed for an autopilot to be mounted on it while it moved freely around the x and y axes. As show in Fig. 1, the stepper motors were placed on opposite sides of the platform. In doing so, the motors served as counterweights keeping the platform balanced. Furthermore, using an extra motor as a counter weight served to increase the torque generated at the platform. Two motors were used to turn the platform around the x-axis simulating pitch, while two larger motors would rotate the platform around the y-axis simulating roll.  The Platform has the ability to operate in two distinct modes. Open and closed loop modes. Both of these modes help to accurately evaluate the autopilot's performance under various scenarios.

Open loop HILS system:
In the open loop setting, Fig. 2, the autopilot is placed on the gimbaled platform while the computer control system supplies actuator signals. This system subjects the autopilot to different attitude conditions. The autopilot sensors report these attitudes, while the shaft encoders provide a more precise measure of the same attitudes. This setting allows for the calibration of the autopilot's IMU. To further minimize IMU errors, the open loop setting can be utilized to compile data from IMU with the corresponding more accurate shaft encoder information. Such data can then be used in filters such as Neural Networks or Kalman Filters that can render IMUs more accurate [3,5,14,15,16] . This data is then passed to the actuation system which will move the platform and autopilot, to assume the newly calculated attitude. This can be looked at as the autopilot flying the platform. However, for this system to operate correctly, GPS, Altitude and Wind Speed data will have to be simulated and fed back to the airframe model. Finally, external perturbations such as wind gusts and turbulences can be injected into the system allowing for a more through evaluation of autopilot's behavior. Using this HILS system makes it possible to quickly evaluate and/or fine tune autopilot systems prior to aerial flight [12] .

Software:
In the open loop setting, the Gimbaled Platform software comprises two independent components. The first is used to generate the signals necessary to run the stepper motors, while the second collects data from the autopilot and shaft encoders. In the closed loop setting an extra software component is added. This is the computer model of the airframe to be flown by the autopilot.

Actuation:
The stepper motor control system is responsible for moving the platform to simulate MAV flight. To achieve this, a separate microcontroller (PIC18F4520) was used together with stepper motor drivers (Gecko®). The stepper motor driver receives TTL signals from the microcontroller and generates high current signals that drive the steppers. The Gecko driver defaults to micro-stepping. In this case, for each falling TTL edge received, the Gecko moves the stepper 0.18 degrees [10] .
To affect smooth platform operation, the motor positions were updated at 10Hz. This was done using the PIC timers. One timer was used to punctuate the 10Hz updates while two other timers were used to generate the Pitch and Roll update signals. As these timers work independently and use interrupts, pitch and roll could be controlled independent of each other, while the update rate of 10Hz ensured smooth operation of the platform.
To operate this system the microcontroller board is provided with movement pattern of the platform. This pattern, predefined by the user, is meant to resemble the motion of MAV in flight. The software determines the number of pulses to be issued to each motor per 100ms. Using timer-interrupts, these pulses are sent to the stepper motor drivers. Overall, this system performed well. The 10Hz update rate ensured smooth change in motor rotation rates. The maximum rotation speeds of the stepper motors, being well above the limits of UAV flight, ensured that all flight conditions could be simulated.
Data Acquisition: While the actuation system controlled moving the platform, the acquisition system was used to gather information from the shaft encoders and the autopilot's IMU. The autopilot transmitted its information wirelessly to its ground station which was connected serially to a computer. The shaft encoders, on the other hand, were connected directly to the computer (RS232). The software for this system was developed using a Unix-like environment for Windows Operating System, Cygwin®.
In normal operation, the autopilot transmitted data at 4 Hz, which is the update rate of its Global Positioning System (GPS). To allow for better adjustment of IMU, faster transmission rate was needed. By disabling GPS and limiting the transmitted packets to only Pitch and Roll data, transmission rate was increased to 25Hz. Upon data collection, a significant phase shift between IMU and Encoder data was observed. This was attributed to delay caused by the wireless modems (Maxstream®) used by the autopilot. Shifting data by one sample greatly reduced this phase shift.
Data from autopilot and shaft encoders were acquired as follows. The system awaits completion of transmission of autopilot data. Once transmission is complete, data is requested from shaft encoders. Simultaneously, as data is gathered from shaft encoders, the autopilot collects a new set of values from the IMU. Once collected, this data is organized for transmission to ground station. Shifting data by one sample allowed shaft encoder data to be aligned with IMU data collected at a similar time frame. Although the shift eliminated most of the phase difference in data, a small phase shift could still be observed, especially when platform was rocked at high frequencies. This shift was attributed to fact that IMU and shaft encoder data are not collected at the exact same time. To eliminate this shift, the average error between IMU and Shaft encoders' data was minimized by shifting the IMU curve. The time shift resulting in minimum error was used to synchronize IMU and Shaft Encoders.
To affect this calculation, we assumed that the change in pitch and roll information between two consecutive data points is linear. Therefore, if M i and S i are the IMU and Shaft encoder i th sample, then f (g) is the average error in shaft encoder reading versus that of IMU, where g represents the time shift. The g value resulting in minimal error is the amount of time needed to synchronize IMU and shaft encoder data.

Synchronization:
With the platform and autopilot operating at 25 Hz and after data was shifted by one sample period T (40 ms), it was found that an extra delay of g = 0.7 T was necessary to synchronize the autopilot data with that of the shaft encoders. This can be seen in Fig. 4-6 respectively.
This implied that data collected form IMU should be shifted by 68 ms to be in synch with data obtained from shaft encoders. Similar techniques can be employed to synchronize any other system with the Hz, it is clear that shifting IMU data by 1.7 T (64 ms) provides a much better fit with shaft encoder data (Fig. 7).
At 4 Hz, shifting data by one T eliminated all visible phase shifts. A slight improvement was achieved by shifting data an extra 5 ms. Therefore, using the 4Hz program, IMU data shifted by 255 ms is in synch with shaft encoder data. Collecting data at 4 Hz the platform was rocked at a slower angular velocity and hence the better fit between IMU and shaft encoder data. (Fig. 8 and 9).
It can be concluded that different autopilot programs require different levels of phase shifting for synchronization with the platform. For this autopilot, The gimbaled platform can therefore be used as an inertial frame of reference to which all systems can be synchronized.

IMU Calibration:
Several experiments were performed to verify IMU operation. Initially experiments called for the platform to be rocked in a sinusoidal fashion at a frequency of less than one Hz. The IMU and the shaft encoder results were in good agreement, with a discrepancy of less than 5%. This error, although small, was thought to be a function of the weights assigned to the different IMU sensors, since the IMU's roll angle seemed to overshoot encoder data, while for pitch encoder results overshot. By adjusting the contribution of gyroscopes versus that of the accelerometers IMU performance was improved significantly. Figure 10 shows the behavior of the pitch before recalibrating the gyroscopes and accelerometer contributions.
By adjusting the weights of the various IMU sensors and repeating the experiment above, an optimal set of weights can be obtained. Such a set of weights can be optimized for expected flight conditions yielding a more accurate IMU output [7] . For this autopilot, the first calibration experiment resulted in a decrease in error of 36% for pitch and 38% for roll, as shown in Fig. 10 and 11.  Orthogonality pitch and roll was confirmed by rocking the autopilot in the pitch axis only and then on the roll axis only. By examining data from the other axis and seeing that no change was present, it was ascertained that pitch and roll has not effect on one another. Figure 12 shows that variations in pitch has no effect on roll. Orthogonality was also determined by rocking the gimbaled platform at a very high rate in the pitch direction while the roll was kept at a moderate rate of change. In both cases, pitch was found to have no effect on roll and vise versa Fig. 13.

CONCLUSIONS
A two-degrees-of-freedom gimbaled platform was described in this research. The platform was designed to compare IMU attitude data to that of optical shaft encoders, allowing for a way to verifying IMU performance in different conditions. The platform was then used to fine tune the IMU by changing the weights of the various IMU sensors while checking the resulting overall performance of the unit. The platform was found to be very effective in improving the performance of the autopilot's IMU. With the help of the platform there was a 38% and 36% reduction in roll and pitch error respectively. The platform could also be used to synchronize IMU data with Shaft encoder data. Using this process, different systems can be synchronized relative the shaft encoders.
The platform could therefore be used as an inertial frame of reference relative to which different systems may be synchronized. Results have shown that the exact time shift needed to synchronize the IMU and shaft encoders can be calculated and that such shift depends on the autopilot program in operation. Using such a platform is therefore instrumental in integrating multiple systems with the autopilot. Clearly, the performance of systems such as a Target Geolocation Extractor will be greatly enhanced by synchronizing it with the IMU.
Although very effective in improving IMU performance in pitch and roll, the proximity of the stepper motors to the IMU resulted in massive interference with the magnetometers performance. The use of a Faraday cage around the motors as well as increasing the distance between the motors and the IMU might lessen this interference.