Wednesday, July 24, 2013

PPM Output (Draft - Looking for testers)

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.





10 comments:

  1. Very interested in the library. Tried to reach you via Arduino forum with no luck. Could you check your account or contact me at laborenz-at-gmail.com
    THX a lot, Kai

    ReplyDelete
  2. Sent, let me know that you have received it.

    Duane.

    ReplyDelete
  3. Got it! Thanks. Will test it asap...

    ReplyDelete
  4. Duane,

    sent pm at arduino forum, but posting here just in case... also interested in trying out your library. contact info: timsenecal(at)comcast.net

    thanks

    Tim Senecal

    ReplyDelete
  5. Duane,

    I also forwarded you request via PM on the Arduino forums to test your new modified library.

    Does the PPM output modification change the entire functionality of the library or is it additional functionality to the original posted RCArduinoFastLib library?

    Thank You

    ReplyDelete
    Replies
    1. You should be able to download a zip here - https://drive.google.com/file/d/0B8WjAvuO3LnIQm5XQ1NwM3o5bTA/view?usp=sharing

      Duane.

      Delete
    2. Its basically the same library but instead of toggling lots of different pins to drive individual servo channels, it toggles a single pin to generate PWM. Apart from the pin toggling, its the same code.

      Duane

      Delete
  6. Hi Duane - very impressed by your Arduino RC work here. I've used a Duinotech compatible UNO and been able to interface my JRPROPO 6-channel XP662 TX and R700 RX such that I can read all 6 channels from the PPM stream. However I am most interested in getting the UNO to produce its own PPM output stream but after trying many things I've been unable to generate any PPM stream output. I see that some time has passed since you last posted on this.Are you still interested in PPM stream output? I'm available to help as required. Thanks!

    ReplyDelete
  7. Solved! Hi Duane, based on your Fast Servo library, I now have a Uno and a Mega 2560 which can generate a 6 channel Buddy Box signal - also known as Trainer or Direct Servo Control (DSC) signal. Check out my explanation / tutorial at: https://www.youtube.com/watch?v=ZyXZ_XSHgVo

    ReplyDelete
  8. Hello Duane .
    I keep looking and do not find anything as I wish . Your projects are the closest to what I seek . Any idea, can be as exiting the Arduino to have PWM signal and no servo or ESC ? I like the RC transmitter to control DC motors .

    Thank you.

    ReplyDelete