If we have code capable of generating servo signals its very simple to adapt this to generate a PPM output instead.
In a previous post we looked at reading an incoming PPM signal and we saw how the PPM Signal describes the individual servo pulses -
http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-receiver-ppm-stream.html
To generate the PPM Stream from a set of servo commands all we need to do is change our code to toggle a single pin instead of individual pins for each servo.
If we look at the point where the channel 1 pulse ends and the channel 2 pulse starts in the diagram above. The code needs to find which pin is associated with the current chanel, then set the pin low to end the pulse. It then finds the next channel, sets its pin high and then sets the timer compare register so that a interrupt routine will be called again when its time to end the new channels pulse and start the next channels pulse.
To output PPM its actually a lot simpler. We are always dealing with the same pin so all we need to do is set the pin high, set the compare register so that the interrupt is called again to when we need start the next channel pulse and then we immediately set the PPM pin low again and exit. Systems which expect a PPM Input are only interested in the rising edge of the PPM Pulse so once we have set it high (giving the external system the rising pulse edge it is looking for) we can immediately set it low again and get out.
Timers, Compare Registers, Service Routines
The following posts provide an indepth background to how the standard Arduino Servo library uses timers, compare registers and interrupt service routines to control upto 12 Servos. The RCArduinoFastLib uses the same approach with a number of optimizations including support for more servos, faster refresh rates, dual refresh rates and reading incoming PPM signals. The remainder of this post presents a small modification of the RCArduinoFastLib which will provide a PPM output instead of individual servo channels.
Background posts
Standard Arduino servo library overview
http://rcarduino.blogspot.ae/2012/01/can-i-control-more-than-x-servos-with.html
RCArduinoFastLib
http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-channels-rcarduinofastlib.html
http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-receiver-ppm-stream.html
The Modified RCArduinoFastLib with PPM Output
Looking for testers, PM me Duane B on the Arduino forum for a zip folder to build the library and test sketch.
In a previous post we looked at reading an incoming PPM signal and we saw how the PPM Signal describes the individual servo pulses -
http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-receiver-ppm-stream.html
To generate the PPM Stream from a set of servo commands all we need to do is change our code to toggle a single pin instead of individual pins for each servo.
If we look at the point where the channel 1 pulse ends and the channel 2 pulse starts in the diagram above. The code needs to find which pin is associated with the current chanel, then set the pin low to end the pulse. It then finds the next channel, sets its pin high and then sets the timer compare register so that a interrupt routine will be called again when its time to end the new channels pulse and start the next channels pulse.
To output PPM its actually a lot simpler. We are always dealing with the same pin so all we need to do is set the pin high, set the compare register so that the interrupt is called again to when we need start the next channel pulse and then we immediately set the PPM pin low again and exit. Systems which expect a PPM Input are only interested in the rising edge of the PPM Pulse so once we have set it high (giving the external system the rising pulse edge it is looking for) we can immediately set it low again and get out.
Timers, Compare Registers, Service Routines
The following posts provide an indepth background to how the standard Arduino Servo library uses timers, compare registers and interrupt service routines to control upto 12 Servos. The RCArduinoFastLib uses the same approach with a number of optimizations including support for more servos, faster refresh rates, dual refresh rates and reading incoming PPM signals. The remainder of this post presents a small modification of the RCArduinoFastLib which will provide a PPM output instead of individual servo channels.
Background posts
Standard Arduino servo library overview
http://rcarduino.blogspot.ae/2012/01/can-i-control-more-than-x-servos-with.html
RCArduinoFastLib
http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-channels-rcarduinofastlib.html
http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-receiver-ppm-stream.html
The Modified RCArduinoFastLib with PPM Output
Looking for testers, PM me Duane B on the Arduino forum for a zip folder to build the library and test sketch.