HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Feb 12, 2009, 10:52 AM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Mini-HowTo
DIY Servo Signal (PWM) to PPM Converter

As promised here's a chip that combines 4 PWM servo signals into a PPM stream. It was originally developed for a wireless buddy box but also for FMA and Paparazzi autopilots so they don't have to use special receivers or hack into a regular one to get PPM. It only costs a couple bucks and can be built in minutes.

The conversion routine is only 20 something instructions long. Originally written for Tiny12(11) but tested on my Tiny13 failsafe and Mega8 autopilot platforms. Also works with Tiny25/45/85, Mega8515, Tiny26, 2313, and similar AVR chips w/o modification. 3-5 volt power can be obtained from a receiver, ESC, USB port, PC drive cable, or batteries (1 lipo or 3-4 NiMh).

The diagram shows Tiny13 pinout for a servo connector and Corona 410 RX. It works with 6, 8, and more channels but must be at least 4. Let me know if you see any typos or have questions.



SRVPPM12.HEX (fuseh=ef fusel=3a)

:020000020000FC
:100000007FE97DBFBC9A61E00AD062E008D064E07D
:1000100006D068E004D0C49A0CD0C498F4CF76B36C
:100020007623E9F3C49A05D0C49876B37623E9F72A
:10003000089593E00197F1F708952863292032305D
:0A004000303620522E536D697468AB
:00000001FF
rich smith is offline Find More Posts by rich smith
Last edited by rich smith; Jun 12, 2009 at 02:26 PM. Reason: fuse
Reply With Quote
Sign up now
to remove ads between posts
Old Feb 13, 2009, 05:55 PM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Fuse info has been added. h=ef l=3a (9.6mhz) Thanks for noticing Paul.
rich smith is offline Find More Posts by rich smith
Reply With Quote
Old Mar 22, 2009, 02:52 PM
Registered User
East London
Joined Feb 2009
49 Posts
Quote:
Originally Posted by rich smith
Also works with Tiny25/45/85, Mega8515, Tiny26, 2313, and similar AVR chips w/o modification. .....

The diagram shows Tiny13 pinout for a servo connector and Corona 410 RX. It works with 6, 8, and more channels but must be at least 4. Let me know if you see any typos or have questions.
Dear Rich,

This looks great - just what I need. I'd like to use it with a Tiny26, partly because that's what I have spare at home, but also because it would be great to use more channels - Could you let me know the appropriate pin outs, by any chance?

Thanks,

Pip
pipsqueak is offline Find More Posts by pipsqueak
Reply With Quote
Old Mar 22, 2009, 10:57 PM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Tiny26 is a great micro. Has more ADC than any other chip of it's type.

Just match b0 w/b0, b1 w/b1, etc.. Should work fine but different fuse bits are needed (internal osc). Note that a new program is required to process more than 4 chan. Works with 5ch, 6ch, etc. RX/TX but extra channels are ignored.


Quote:
Originally Posted by pipsqueak
Dear Rich,

This looks great - just what I need. I'd like to use it with a Tiny26, partly because that's what I have spare at home, but also because it would be great to use more channels - Could you let me know the appropriate pin outs, by any chance?

Thanks,

Pip
rich smith is offline Find More Posts by rich smith
Reply With Quote
Old Jun 07, 2009, 03:45 AM
Registered User
East London
Joined Feb 2009
49 Posts
Quote:
Originally Posted by rich smith
Tiny26 is a great micro. Has more ADC than any other chip of it's type.

Just match b0 w/b0, b1 w/b1, etc.. Should work fine but different fuse bits are needed (internal osc). Note that a new program is required to process more than 4 chan. Works with 5ch, 6ch, etc. RX/TX but extra channels are ignored.
Hi Rich,

I've been using your fantastic converter for a couple of months now - thanks again for posting the code.

I've been using your HEX on a Tiny13 (i.e. four channels only) - making an almost exact-looking replica of yours.

Btw, If there are any arduino users out there who'd want to decode the PPM that comes out of this, I'll post the modified sketch I use at the bottom:

However Rich, It would be really great to get a version to handle more channels - Ie. use the extra pins on the Tiny26 version. However, without the source I can't make the tweaks above that you mentioned.

So I was wondering, would you either possibly be up for (a) tweaking your code, and posting a HEX for a new version that could handle up to 8 inputs, or (b) posting the source so that I could have a go myself - If successful I'd post the version back to the thread

No matter what, I'm really grateful to have found such a neat 4 channel solution - So thanks again.

Cheers,

Pip

Code:
// TX PPM INPUT STUFF
#define TXINPUTPIN 8 // Define TX PPM input signal - HARDCODED (so changing this won't make any difference)
unsigned int serinp[8]; // For the input PPM signal
#define TX_PITCH serinp[0]  // Related to the PPM order and wiring 
#define TX_ROLL serinp[1]
#define TX_THROTTLE serinp[2]
#define TX_YAW serinp[3]

/*******************************************************************************
                      Setup
*******************************************************************************/ 
void pmm_setup() 
{
  // Setup the TX PPM input
  pinMode(TXINPUTPIN, INPUT); // Ensure the TX PPM pin is input
  setup_timer1(); // Start the timer that does the PPM
} 
 
/*******************************************************************************
                      Functions & Subroutines
*******************************************************************************/  

void setup_timer1(){
//disable all interupts
TIMSK1 &= ~( _BV(TOIE1) | _BV(ICIE1) | _BV(OCIE1A) | _BV(OCIE1B));

//set timer mode
TCCR1A &= ~( _BV(WGM11) | _BV(WGM10) );
TCCR1B &= ~( _BV(WGM12) | _BV(WGM13) | _BV(ICNC1));

//capture raising edge
TCCR1B |= _BV(ICES1); //capture raising edge

//prescaler 1/8
TCCR1B |= _BV(CS11);
TCCR1B &= ~( _BV(CS12) | _BV(CS10) );

//disable outputs
TCCR1A &= ~( _BV(COM1A0) | _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1));

//enable capture interupt
TIMSK1 |= (1<<ICIE1);
}


ISR(TIMER1_CAPT_vect){
static unsigned int lasticr; //icr at last caputre
static unsigned char cserinp; //current input servo

unsigned int licr;

//TCCR1B ^= _BV(ICES1);
licr=ICR1-lasticr;
lasticr=ICR1;

if (licr<10000) { //pulse not super long - so Ok, otherwise totally ignore


if(licr>5000){ //pulse too long, means start of new frame
cserinp=0;
serinp[cserinp]=licr;
cserinp++;
}else if(licr>500){ //pulse good, take reading, go to next channel
serinp[cserinp]=licr;
if(cserinp<8){
cserinp++;
}
}else{
//too short, nothing to see here
}
//updateTXVals();  // So at the end lets update our calibrate vals  
}

}
pipsqueak is offline Find More Posts by pipsqueak
Reply With Quote
Old Jun 07, 2009, 03:34 PM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Quote:
Originally Posted by pipsqueak
However Rich, It would be really great to get a version to handle more channels - Ie. use the extra pins on the Tiny26 version. However, without the source I can't make the tweaks above that you mentioned.
Unfortunately I don't have easy access to source on most of these build threads because the projects have been archived for years. Generally I just read the hex out of chips laying around. Fortunately fuses were not blown.

The fact that it runs on all those different chips tells me it's not limted by OC channels as I first thought but actually by the number of input pins. I was confusing this with another AVR build thread I put up.

I vaguely recall the method now and it is ridiculously simple. Must be if only 20 instructions long! It should be easy to do a 7 channel version that will run on all the same chips as this one. I'll see if I can throw something together (if somebody else don't put one up here first).
rich smith is offline Find More Posts by rich smith
Last edited by rich smith; Jun 08, 2009 at 09:21 AM. Reason: limit is pins not OC
Reply With Quote
Old Jun 07, 2009, 10:49 PM
R/C newbie
United States, TX, Austin
Joined Mar 2008
181 Posts
Just curious:

Where would you use the pwm-ppm converter ?
rkovvur is offline Find More Posts by rkovvur
Reply With Quote
Old Jun 08, 2009, 09:08 AM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Quote:
Originally Posted by rkovvur
Just curious: Where would you use the pwm-ppm converter ?
Quote:
Originally Posted by rich smith post #1
It was originally developed for a wireless buddy box but also for FMA and Paparazzi autopilots so they don't have to use special receivers or hack into a regular one to get PPM.
Posted here in response to a request from another thread which didn't involve either application but I don't recall the details.

One thing that puzzles me is Pips connection with Ardupilot. It already has excellent PWM inputs for regular unmodified RX. Don't really see where PPM is needed there.
rich smith is offline Find More Posts by rich smith
Reply With Quote
Old Jun 08, 2009, 10:24 AM
"MAYONNAISE"
Acetronics's Avatar
Le Treport, France
Joined Jun 2004
1,408 Posts
Quote:
Originally Posted by rkovvur
Just curious:

Where would you use the pwm-ppm converter ?
Hi, Rkovvur

Will be perfect for Wireless link between Master and Pupil transmitters ...

i.e.

Alain
Acetronics is offline Find More Posts by Acetronics
Reply With Quote
Old Jun 08, 2009, 10:39 AM
R/C Electro-Gadgeteer
Tomapowa's Avatar
N.E. USA
Joined Oct 2003
813 Posts
This might even be a simpler non-PIC/AVR solution for converting multiple PWM signals into a single PPM signal.. simply add more diodes for more channels/inputs:

http://www.rcgroups.com/forums/showp...6&postcount=35

Tomapowa is offline Find More Posts by Tomapowa
Reply With Quote
Old Jun 08, 2009, 10:49 AM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Quote:
Originally Posted by Tomapowa
This might even be a simpler non-PIC/AVR solution for converting multiple PWM signals into a single PPM signal.. simply add more diodes for more channels/inputs
Apparently simple is in the eye of the beholder. If you're going to hack into a RX then better to just tap into the PPM signal. One wire.

I do the one-wire mod on occasion but for standard RX a PWM to PPM converter comes in handy. Specially if your trying out different receivers.
rich smith is offline Find More Posts by rich smith
Reply With Quote
Old Jun 08, 2009, 11:02 AM
R/C Electro-Gadgeteer
Tomapowa's Avatar
N.E. USA
Joined Oct 2003
813 Posts
huh?
This diode-based circuit simply connects to the receiver outputs (using servo connectors or even a 3x? socket). It then combines the individual PWM signals together (since they are normally sequentially updated), outputing a single PPM signal (easier and safer than attempting to solder a wire on the fine lands of the PCB). Isn't that what your AVR solution/code does?
Tomapowa is offline Find More Posts by Tomapowa
Reply With Quote
Old Jun 08, 2009, 11:15 AM
"MAYONNAISE"
Acetronics's Avatar
Le Treport, France
Joined Jun 2004
1,408 Posts
Hi, Tomapowa ...

You just have forgotten the 300 Ás separating pulses ...

your scheme doesn't work at all ...even with a monostable multivibrator. it's not so simple as that.

And we do not talk here about receivers that output two or three channels at the same time ( Futaba T series ... )

Alain
Acetronics is offline Find More Posts by Acetronics
Reply With Quote
Old Jun 08, 2009, 11:25 AM
R/C Electro-Gadgeteer
Tomapowa's Avatar
N.E. USA
Joined Oct 2003
813 Posts
Quote:
Originally Posted by Acetronics
Hi, Tomapowa ...

You just have forgotten the 300 Ás separating pulses ...

your scheme doesn't work at all ...even with a monostable multivibrator. it's not so simple as that.

And we do not talk here about receivers that output two or three channels at the same time ( Futaba T series ... )

Alain
Separating pulses...?? Explain? These pulse timings are inherent in the PWM channels as they are output sequentially on most receivers (that is.. one after another... not at the same time as you are thinking). The diodes pretty much combined the individual servo PWM signals, one after the other... into one PPM signal... makes sense? Plus... it is not my "scheme".. others appears to be using it for the mikrocopter projects (see link I prev. pasted). I'm going to test it tonight in fact... looks too simple.
Tomapowa is offline Find More Posts by Tomapowa
Last edited by Tomapowa; Jun 08, 2009 at 11:32 AM.
Reply With Quote
Old Jun 08, 2009, 11:46 AM
"MAYONNAISE"
Acetronics's Avatar
Le Treport, France
Joined Jun 2004
1,408 Posts
there is ~ 15 ns between channels outputs with 4015/4017 decoders ... say hundreds of ns with ÁP decoders.

so, this scheme outputs a low level during the full 4 to 8 channels transmission, due to the diodes blocking time ... not exactly what you were telling us.

see Mr CAM Forum for a logic version of this sequence " reconstructor " ... that is working.

Alain
Acetronics is offline Find More Posts by Acetronics
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion how to convert PWM servo signal to DC voltage sahilkit DIY Electronics 15 Oct 05, 2008 09:23 PM
Mini-HowTo Motor PWM to PPM impulse converter quax DIY Electronics 27 Jun 16, 2008 11:38 PM
PWM to servo signal conversion? mcross DIY Electronics 13 Jul 05, 2005 08:48 PM
Futaba PCM receiver servo pulse other than PPM? risto Power Systems 14 Feb 14, 2002 12:18 PM