Source Code Walk-Through

Helmut LelkePublished on March 1, 2002

All registers of interest are initialized on power up. After initialization the processor waits for the start of the next refresh cycle signaled by the leading edge of CH1 control pulse. PWM (pulse-width-modulated) signals channels 1, 2, and 6 (Albatross II only) from RC receiver are converted to magnitude values between 0 and 255. A/D conversions of analog signal inputs on pins 3, 4, 5, and 7 are performed next.

Input signal conversion is followed immediately by the following input processing. RC receiver Ch6 input controls the gain of the three electrostatic sensors. Each of the D/A converted electrostatic sensor magnitudes is multiplied by CH6 magnitude value to form corresponding gain adjusted sensor magnitudes.

The following equations are then solved to generate left and right elevon deflection magnitudes from the processed inputs.

lel = c1m + c2m + (ls - rs) + ((ls + rs)/2 - ts) + aoa (2)
rel = c1m - c2m - (ls - rs) + ((ls + rs)/2 - ts) + aoa (3)

where

lel = left elevon magnitude
rel = right elevon magnitude
ls = gain adjusted left wing electrostatic sensor magnitude
rs = gain adjusted left wing electrostatic sensor magnitude
ts = gain adjusted tail electrostatic sensor magnitude
aoa = angle-of attack sensor magnitude

The lel and rel magnitudes are dynamic range limited (clipped) to values between 0 and 255. The final step is to convert and output the two values from magnitude to PWM format to meet the elevon servo control signal requirements. Servo control signal timing is shown in Figure 15. Refresh rate is determined by the RC transmitter but is typically around 50-60 Hz.

Figure 15. Servo Signal Timing

Figure 15. Servo Signal Timing