RE: TimerOne Library & PPM

Hi Gang

I’ve been spending a fair bit of time trying to generate a PPM stream. I’ve tried a variety of approaches and have settled on Timer Interrupts using the TimerOne library. I am trying to get the following code to work but not having any luck. Basically I’m using a potentiometer to ‘try’ and move a servo via channel one. I know the frame length is 22500mS. Is there anything I’m missing? Any help would be greatly appreciated.

Cheers

Jase :slight_smile:

#include <TimerOne.h>
int channelOne;
int val;

void setup(){
  pinMode(4, OUTPUT);
  Timer1.initialize(22500);
  Timer1.attachInterrupt(ppmStream);
}
 
void loop(){
  val = analogRead(2);
  channelOne = map(val, 0, 1023, 700, 1700);
}

void ppmStream(){
  digitalWrite(4, LOW);
  delayMicroseconds(300);
  digitalWrite(4, HIGH);
  delayMicroseconds(channelOne);
  
  digitalWrite(4, LOW);
  delayMicroseconds(300);
  digitalWrite(4, HIGH); 
}

I've been spending a fair bit of time trying to generate a PPM stream.

Instead of using the Servo library? Just curious, but why?

Hi Paul

Thanks for the reply. I’m trying to generate a PPM pulse as opposed to PWM signal. I want to feed this pulse via the trainer port on my remote control transmitter.

Cheers

Jase :slight_smile:

ilovetoflyfpv : did you get this to work? I am trying to do exacly the same using my Graupner MX-20 RC TX.

What exactly is not working? What troubleshooting have you done? I'd suggest taking a look at the output on an oscilloscope. If you can't do that hook it up to a LED and slow down your timing. Use the serial port to make sure the numbers going out of map are what you think they should be, etc..

-Jim

Google suggests that you aren't the first person to attempt this, for example this thread points to a library which apparently can be used to generate a ppm stream:

http://www.rcgroups.com/forums/showthread.php?t=1808432