ATmega PPM Encoder Board

From PaparazziUAV
Jump to navigation Jump to search

Thanks to Chris we have a way to use virtually any RC receiver with Paparazzi without any modifications to the receiver.

This board plugs into the servo output ports on a R/C receiver and encodes them into a single PPM pulse suitable for the paparazzi autopilot. It is also possible to remap channels by changing the connection between the receiver and the encoder. Want Tx ch5 to be output on ch7 of the ppm stream? Just connect the Ch5 signal from the receiver to the Ch7 input on the encoder.

The ATmega PPM Encoder board has gone through several hardware and software revisions, and there are slight differences in setting up the boards. Be sure to double check your hardware if you are programming your own board.

See the Downloads section for the user manual, and hardware and source files.

Hardware Revision History

Version # Release Date Release Notes
v3 (current) 02/2010 16MHz crystal, smaller dimensions, i2c broken out, no more 3x8 header
v2 ??/???? 16MHz crystal, larger dimensions
v1 09/2009 8MHz internal oscillator, no xtal, initial release

The crystal oscillator was added to improve stability and reduce jitter of the ppm signal to the autopilot, which can be a problem. Originally this was dealt with using a software filter in the code, but this induced a slight delay during Manual control. The boards can use either the ATmega 168 or the ATmega 328p, if the fuses are set correctly.


Radio File Configuration

See the Radio_Control page for more details, but here is the short version:

1. The encoder board outputs 8ch by default so your radio.xml file must have 8 channels with distinct function names.
2. The encoder board outputs POSITIVE by default regardless of your R/C Transmitter so the first line of your radio.xml needs to be like:

<radio name="MyRadio" data_min="800" data_max="2200" sync_min="5000" sync_max="15000" pulse_type="POSITIVE">

3. If channels are not mapped properly don't worry, the file has 8 lines, one for each channel, just alter the order. The first row is ch1, the second ch2 and so on.

Here is a sample file used with an XTremelink 2.4gHz Mx-16Tx and Xtremelink 8ch Rx

<!DOCTYPE radio SYSTEM "radio.dtd">
<radio name="MX-16" data_min="800" data_max="2200" sync_min="5000" sync_max="15000" pulse_type="POSITIVE">
<channel ctl="B" function="THROTTLE" min="950" neutral="950" max="2050" average="0"/>
<channel ctl="C" function="ROLL" min="950" neutral="1500" max="2050" average="0"/>
<channel ctl="D" function="PITCH" min="2050" neutral="1500" max="950" average="0"/>
<channel ctl="A" function="YAW" min="950" neutral="1500" max="2050" average="0"/>
<channel ctl="E" function="MODE" min="950" neutral="1500" max="2050" average="1"/>
<channel ctl="F" function="FLAPS" min="950" neutral="1500" max="2050" average="0"/>
<channel ctl="G" function="GAIN1" min="950" neutral="1500" max="2050" average="1"/>
<channel ctl="H" function="GAIN2" min="950" neutral="1500" max="2050" average="1"/>
</radio>

Note on Ch3 (3rd channel row) the PPM signals are reversed from 950, 2050 to 2050, 950. That was because on the associated FunJet the ailerons were reversed. They were reversed in this radio conf file, not in the transmitter settings.

Programming the PPM encoder

There are more details in the README of the GitHub repo: https://github.com/paparazzi/ppm-encoder.

NOTE: IF YOU ARE PROGRAMMING YOUR BOARD MAKE SURE TO VERIFY THE FUSES ARE APPROPRIATE FOR YOUR HARDWARE REVISION. IN PARTICULAR, CHECK THE LOW FUSE FOR CLOCK SETTINGS. IT IS POSSIBLE TO BRICK YOUR PPM ENCODER IF YOU ARE NOT CAREFUL. THE BELOW SETTINGS ASSUME THE BOARD IS v2 or v3. IN ADDITION, THE DIYDRONES VERSION IS NOT THE SAME.

Programming the board can easily be accomplished using an AVR ISP (in-serial programming) programmer. These are inexpensive and can be found many places online. Once you have the ISP connected to the PPM encoder, simply use avrdude with the following command from inside the directory with the compiled source code:

For ATmega168:

avrdude -p atmega168 -P <Insert port here> -c <Insert ISP type here> -U lfuse:w:0b00100010:m -U efuse:w:0b111:m -U flash:w:servo2ppm+bootloader.hex

Fuse settings shown above may give unpredictable results and strange behaviour, depending on device and crystal.

So the better settings are:

avrdude -p atmega168 -P <Insert port here> -c <Insert ISP type here> -U lfuse:w:0b11110111:m -U efuse:w:0b111:m hfuse:w:0b11011001:m -U flash:w:servo2ppm+bootloader.hex

For ATmega328P set the fuse bytes as shown next:

avrdude -p m328p -P <Insert port here> -c <Insert ISP type here> -U lfuse:w:0b11110111:m -U efuse:w:0b111:m hfuse:w:0b11011001:m -U flash:w:ppm_encoder_v4_3+bootloader_16Mhz.hex

If you use 328P and a PonyProg-Cable for COM or a Mikrokopter SerCon, type the following: (replace COM1 with actual COM-port):

avrdude -p m328p -P COM1 -c ponyser -U lfuse:w:0b11110111:m -U efuse:w:0b111:m hfuse:w:0b11011001:m -U flash:w:ppm_encoder_v4_3+bootloader_16Mhz.hex

It is possible to customize the behavior of the PPM Encoder by changing settings in the source header file. Be sure you know what you are doing and read the documentation carefully.

Downloads

All of the files are now available on GitHub: https://github.com/paparazzi/ppm-encoder Please read the README carefully!

Original Source files (may be out of date)

Gerber & Drill files (may be out of date)