Espritmodel.com Telemetry Radio
Reply
Thread Tools
Old Nov 03, 2012, 12:08 AM
Registered User
Joined Jul 2012
25 Posts
Mini-HowTo
Convert your PWM RX to PPM

I needed to use all 8 channels on my Turnigy RX but my 328 based FC can accept only 6 channels, so I added a circuit to convert the 8 channel PWM into a Serial Sum PPM signal.

The circuit consists only of an atMega328 chip with a simple 20 line program. Chip is running using internal oscillator at 8mhz. I added the FTDI header so I can reprogram if needed and also serves as servo connector to FC PPM input. You can buy atmega328 on ebay for $3.33.


The atmega328 chip/prototype board attaches to the side of the RX


This is the logic analyzer capture for 4 channels. I used a pulse width of 300us (this screen shot still shows 200us)


Works great. Now I have 5 extra pins on my FC.

This is the program. 20 lines long not counting comments. Compiles to 566 bytes.
Code:
#define PPMHI PORTD |= _BV(7);
#define PPMLO PORTD &= ~_BV(7);
//written by doughboy @RCGroups and @multiwii.com 
//8 channel Serial Sum PPM using atmega328 minimal circuit running on 8mhz internal oscillator
//wiring
//connect RX pins 0-7 to atmega PortB pins 0-7, chip pins 14 to 19, 10 and 11
//ppm output on digital pin 7, atmega chip pin 13
//                  +-\/-+
//            PC6  1|    |28  PC5       
//            PD0  2|    |27  PC4       
//            PD1  3|    |26  PC3       
//            PD2  4|    |25  PC2        
//            PD3  5|    |24  PC1       
//            PD4  6|    |23  PC0       
//      +5v-> VCC  7|    |22  GND  <-Gnd
//      Gnd-> GND  8|    |21  AREF
//      RX6-> PB6  9|    |20  AVCC <-+5v
//      RX7-> PB7 10|    |19  PB5 <-RX5
//            PD5 11|    |18  PB4 <-RX4
//            PD6 12|    |17  PB3 <-RX3     
//   PPMSUM<- PD7 13|    |16  PB2 <-RX2     
//      RX0-> PB0 14|    |15  PB1 <-RX1  
//                  +----+
//
//this code will run only on minimal 8mhz atmega328.
//you must modify the code and move PB6 and PB7 to another port if you use a setup with oscillator

void setup() {
  PCICR |= (1<<PCIE0); //Pin Change Interrupt 0
  PCMSK0 = 0xFF; //all 8 pins
  TCCR2A = 0;
  TCCR2B |= (1<<CS22) | (1<<CS20); //div 128 prescaler
  TIMSK2 |=(1<<OCIE2B);
  DDRD |= _BV(7);  //digital pin 7 output
}

void loop() {
}

ISR(PCINT0_vect) {
    PPMHI;
    TCNT2=0; 
    OCR2B=19; //300us PPM pulse
}

ISR(TIMER2_COMPB_vect) {
  PPMLO;
}
doughboy is offline Find More Posts by doughboy
Reply With Quote
Sign up now
to remove ads between posts
Old Nov 03, 2012, 06:45 AM
Registered User
Romania, Dolj, Craiova
Joined Sep 2007
14,225 Posts
Don't work for any receiver, most brand digital RC systems pulses two or even more channels simultaneously.
A hint to make wiring even streamline, but only for receivers having no channel delimiter strips, and same vertical and horizontal spacing between pins: use servo leads to get 3 channels signals in a single plug/cable. With three servo leads you can get 7 channels, one of them plugged normal to get power for your board, and another two plugged twisted at 90 degrees, to get signals only.
renatoa is offline Find More Posts by renatoa
Reply With Quote
Old Nov 03, 2012, 10:49 AM
Stop me before I build again!
United States, NY, Albany
Joined Sep 2012
1,320 Posts
Have you put a trace on the Rx board, with the pwm broken out so nicely I wonder if its on the board somewhere.
brontide is offline Find More Posts by brontide
Reply With Quote
Old Nov 03, 2012, 01:57 PM
Registered User
Joined Jul 2012
25 Posts
thanks. I would think most receivers would make the pwm pulse one right after another. Or is that not the normal case? That was my understanding of the PWM frame specs. 20ms frame divide by 8 channels gives you a max pulse of 2500us per channel.

As for wiring, I leave that up to the user how to wire it. On Turnigy 9X, there is a plastic border betweeen channels 5 and 6 (see the picture above), so that defeats the purpose of using servo connectors. Using individual pins allow a little more flexibility, in case the TX cannot rearrange channels.

As to finding if there is a PPM signal inside the receiver, I thought of it but never actually got around to do it. The idea for using atmega328 is I plan to add a serial GPS to I2C converter and support for up to 5 ultrasonic sensors (front, left, right, rear and bottom) and output data via I2C.
doughboy is offline Find More Posts by doughboy
Reply With Quote
Old Nov 03, 2012, 02:43 PM
jab
Unregistered User
Joined Aug 2007
1,055 Posts
Quote:
Originally Posted by doughboy View Post
thanks. I would think most receivers would make the pwm pulse one right after another. Or is that not the normal case?
If only.. You will find pretty much any output sequence imaginable as you start testing different receivers and brands.
jab is offline Find More Posts by jab
Reply With Quote
Old Nov 03, 2012, 03:07 PM
Registered User
Joined Jul 2012
25 Posts
Quote:
Originally Posted by jab View Post
If only.. You will find pretty much any output sequence imaginable as you start testing different receivers and brands.
Ok. My first program was actually detecting each pwm pulse then serializing it to ppm. This way, it does not matter how the pwm pulses arrive. However, there is very little documentation to tell me otherwise, and whatever little documentation I found tells me the pulses are aligned one after another. So I modified / simplified the program down to 20 lines of code to take advantage of that fact. If your receiver outputs pulses one on top of each other, then you will need to modify the program to work with your receiver.

My motivation for building this is to serve my own needs and I simply shared the information, and it is not my intent to make this into a product that works with every receiver out there and make money out of it.
doughboy is offline Find More Posts by doughboy
Last edited by doughboy; Nov 03, 2012 at 03:14 PM.
Reply With Quote
Old Nov 04, 2012, 09:08 AM
Registered User
Hochiminh City
Joined Mar 2004
547 Posts
THis is a very simple and good converter . I used them for my Mk, and other FC also
http://lea.hamradio.si/~s56wix/pwm2ppm/
caotri is offline Find More Posts by caotri
Reply With Quote
Old Nov 04, 2012, 06:59 PM
Registered User
Joined Oct 2005
1,662 Posts
If you want to save the building time and have one with proper external clock, you can consider the ppm board from www.multircshop.com.
dt8666 is offline Find More Posts by dt8666
Reply With Quote
Old Nov 04, 2012, 07:29 PM
Registered User
danger_mouse's Avatar
Australia, QLD, Gatton
Joined Jan 2007
927 Posts
Or you could upgrade your 9x TX module to Frsky. The 6gram D4R-II 4 channel rx's output 8 channels in CPPM mode. You only need one wire from the RX to FC. As a benefit you get failsafe on all channels (unlike the std 9x rx's with no failsafe) and other useful features.
danger_mouse is offline Find More Posts by danger_mouse
Reply With Quote
Old Nov 04, 2012, 08:26 PM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,575 Posts
Where is the spirit of DIY or can that be purchased too?
rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Old Nov 04, 2012, 10:40 PM
Registered User
danger_mouse's Avatar
Australia, QLD, Gatton
Joined Jan 2007
927 Posts
Quote:
Originally Posted by rimshotcopter View Post
Where is the spirit of DIY or can that be purchased too?
LOL. Diy is all well and good, but I just would hate someone to have a flyaway due to the std turnigy 9x module/rx's with no failsafe.
danger_mouse is offline Find More Posts by danger_mouse
Reply With Quote
Old Nov 05, 2012, 05:14 AM
Stop me before I build again!
United States, NY, Albany
Joined Sep 2012
1,320 Posts
Quote:
Originally Posted by danger_mouse View Post
LOL. Diy is all well and good, but I just would hate someone to have a flyaway due to the std turnigy 9x module/rx's with no failsafe.
Hey, with a few more lines of code the chip can signal loss of signal to the FC or provide limited fs capability itself.
brontide is offline Find More Posts by brontide
Reply With Quote
Old Nov 05, 2012, 05:22 AM
Registered User
danger_mouse's Avatar
Australia, QLD, Gatton
Joined Jan 2007
927 Posts
Quote:
Originally Posted by brontide View Post
Hey, with a few more lines of code the chip can signal loss of signal to the FC or provide limited fs capability itself.
True, that could be a possibility. As you were.
danger_mouse is offline Find More Posts by danger_mouse
Reply With Quote
Old Nov 05, 2012, 06:03 AM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,575 Posts
Quote:
Originally Posted by brontide View Post
Hey, with a few more lines of code the chip can signal loss of signal to the FC or provide limited fs capability itself.
+1 and the it could made to handle XBee and other protocols for example: SPEKTRUM
rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Old Dec 09, 2012, 11:55 AM
Registered User
rimshotcopter's Avatar
United States, CA, Los Angeles
Joined Aug 2009
11,575 Posts
Here is a picture of my PWM RX to PPM Build. Now I need to fully ground test it.

I added two more pins in addition to the PPM pin for future expansion.
rimshotcopter is online now Find More Posts by rimshotcopter
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Mini-HowTo DIY Servo Signal (PWM) to PPM Converter rich smith DIY Electronics 179 Dec 05, 2012 12:40 PM
Sold Serializer PWM-PPM converter -8 channel -$30 shipped CONUS Mactadpole Aircraft - Electric - Multirotor (FS/W) 2 Mar 18, 2012 11:38 AM
Mini-HowTo PIC 10f202 pwm to ppm converter (BL-converter) Cesco DIY Electronics 15 Apr 01, 2011 04:29 AM
Mini-HowTo Motor PWM to PPM impulse converter quax DIY Electronics 27 Jun 16, 2008 11:38 PM