|
|
|
The Flight Controller. Interfacing the ADXL335 Accelerometer to the PIC
|
|
|
|
After spending some time familiarising myself with the ADXL202 and the ADXL335 accelerometers, came to the conclusion that the ADXL335 is the better option, speedier processing time. Never the less time spent on the ADXL202 was not a total waste of time.
|
|
|
|
Some relevant ADXL335 features:
The ADXL335 is a 3 axis accelerometer x,y,z
The maximum supply volts that the ADXL335 can support is 3.6v.
Decided on a 3.3v supply. Using an LM3940, a 3.3v low dropout regulator
The ADXL335 Outputs Analog Data (volts)
The ADXL335 Output Impedance is 35K Ohm
|
|
Three ADC’s (Analog Digital Converters) are required to convert the ADXL335 analog data to digital data. One ADC for each ADXL335 axis.
For the Flight Controller decided to use the now slightly dated Microchip PIC16F876 microcontroller since it incorporates five ADC’s and sufficient I/O for displaying the ADXL335 analog converted digital data on 8 Led’s. If necessary, later the program can be modified and transferred to a more up to date microcontroller. Sufficient to point out that the PIC16F876 is more than adequate for current program development.
According to the PIC16F876 data sheet, the ADC input impedance should be no more than 2K Ohms, as previously mentioned, the output impedance of the ADXL335 is 35K Ohms, therefore the outputs of the ADXL335 need buffering into the ADC’s for best digital conversion results.
For buffering, decided on the LM324 quad amp, an IC containing four individual op amps. The op amps are configured as voltage followeres, gain equal to one, one for each of the ADXL335 outputs. A good reason for using the LM324 is that it is a single ended op amp, no negative supply rail needed and functions normally with a 3.0v supply rail.
Although the microcontroller rail volts is 5v, the ADC’s reference volts is 3.3v so that the ADC’s are able to digitally convert the full range of the ADXL335 analog output.
Worth mentioning that the 3.3v supply could have been restricted to just the ADXL335 and 5v used for the LM324 supply and the ADC’s reference voltage. The downside being that the op amps would then have to be configured as amplifiers with a Gain=5v/3.3v=1.5, this would mean having to use additional components, fiddling around with resistor values. Worth keeping the alternative in mind in case the current arrangements hit a snag.
|
|
|
|
Flight Controller PCB
|
|
|
|
Asembled Development Board
|
|
|
|
The ADXL335 accelerometers are tiny chips that are not easy to solder. Advice using a presoldered breakout board (small red PCB). These boards are now available from various sources.
[Enlarged ADXL335 Breakout Board Image]
[Enlarged Development Board Image]
|
|
|
|
As previously mentioned the purpose of the Flight Controller board is to stabilise the Quadcopter during flight. To do this it takes the signal from the on board ADXL335 accelerometer and gyro (roll, pitch and yaw) then passes the signal to the microcontroller. These signals instruct the Electronic Speed Controllers (ESCs) to make fine adjustments to the motors rotational speed which in turn stabilises the Quadcopter,
|
|
|
|
Software for the Flight Controller Version 1
|
|
|
|
Two analog inputs of the PIC microcontroller read the ADXL335 accelerometer X and Y axis analog values, these analog values are converted to binary values, the binary values are then used as the index to a lookup table.
Without going into to greater detail the binary value read from the lookup table determine wether the accelerometers X or Y axis are level along their appropriate axis or inclined and if so wether the inclination is (+) or (-) .
The PIC microcontroller generates four PWM signals, each PWM controls one of four DC motors, the binary value read from the lookup table generates the appropriate Duty Cycles for each of the PWM signals.
Version 1 program excludes the gyro interface. The later version will incorporate it and more.
|
|
|
|
|
|
Assembled Version 1 Flight Controller PCB
|
|
|
|
 Completed Flight Controller to be coupled to the four DC motors Speed Controllers
(The Speed Controller currently in the development stage)
|
|
|
|
>> Source Code
|
|
|
|
|
|
|
|
|