Need RC PWM signal to 0-5 volts for my robot.

Hi,

I am building (slowly) a 2 wheel hanging pendulum robot that uses 2 26" Bicycle wheels and Kelly reversing controllers.

The problem I have is that the controllers use a pot or 0-5 volt input for a throttle and not PWM pulse width.

While I am initially configuring the robot I would like it to be testable with an RC radio system only.

And for this what I would like to do is provide the simplest hardware conversion of the RC receivers PWM output directly to a 0 - 5 volt throttle signal.

The typical - simple RC filter approach for converting PWM to a voltage level won't work because the Radio Control PWM output signal is not a zero to 100% PWM pulse.

Rather it is a long low pulse with a short but variable high pulse the second half of which defines the 0-100% state of the PWM.

This is probably doable but complicated in discreet components (Op amps, pots and capacitors), but messy and is not something I think would be worthwhile to undertake.

Certainly it is doable to edit the Pixhawk code to allow it to drive a digital pot or D/A from I2C and that is what I am planning on doing eventually in any case.

But if anybody knows of an existing (module) specifically designed to accept a radio control style PWM signal as input and provide a variable voltage as output that is what I would very much like to implement at this stage.

I have looked but been unable to find anything online that can actually deal with a radio control style PWM input.

There are plenty that will take a zero to 100% style PWM input (including a simple RC circuit) but none that will deal appropriately with a radio control style PWM.

Any help appreciated.

Failing this I will simply start with either my Pixhawk or - more likely - my Beagle Bone Black.

Best Regards,

Gary

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hi Gary,

    Did you get this solution going? I have a golf cart motor controller that requires 0-5v for the speed control, same as your controller. Any other off the shelf solution available since this thread started? Otherwise I will try the Radio control type DC motor controller and an RC filter as mentioned above.

    Thanks,

    Phil

  • Hi Eric,

    I think for many uses, if we simply supply conservative defaults for low PWM values and High PWMs values that this may be a non issue for most users.

    Simply set low PWM high enough so that it is pretty much guaranteed to be at zero with transmitter stick in zero position and high PWM low enough so that it is also pretty much guaranteed to be full on when the transmitter stick is in full on position it will work for majority of applications.

    On my transmitter endpoints are adjustable, but even where they are not, full range would still be within stick travel.

    However, we probably still need to have some level of user adjustability and I think for that to be reasonable we will need 4 I/O lines, but one would be the existing LED.

    Possibly add 2 buttons and one additional LED.

    First button selects and sequences through programming options.

    Second button would cause currently selected low or high stick PWM endpoint to be set.

    The existing LED and added LED on / off and blink pattern could indicate channel selected and high or low endpoint to be set by pressing set button. (Possibly room for additional user adjustments as well).

    I notice we still have one I/O line (pin 6) which could be used as one of the I/O lines (the second LED).

    Possibly the other 2 could be (borrowed) from your 7 pin connector.

    The 2 buttons could go to 2 of the ADCs and if we used normally open buttons they wouldn't interfere with normal use and the additional LED could go to pin 6 set as a digital output and that plus your existing LED should provide sufficient information for a variety of programming indications.

    That way no functionality would be lost as exists in your current design. 

    Might want some weak pull down resistors on the 2 ADC lines the PWM set buttons are connected too and then run other side of button to +5. 

    Additional LED blink patterns and settable options could be also incorporated for more user setup if desired.

    The user could probably hold down both buttons during power up to cause it to go into user setup mode. (So long as the ADC inputs weren't allowed to both be 5 volts at power-up that should work.)

    This is the mechanically simplest and still somewhat straight forward user adjustment method I can think of.

    Also, I would like to see a second ground pin on the analog outs so that a two pin connector could connect to each output.

    So 4 pins instead of 3.

    This is just some thoughts and happy to hear any other ideas you have, board and capabilities look great so far.

    Fantastic Progress.

    Best,

    Gary

  • My point wasn't against the use of the 328 (I'm a huge fan of it), it's just that the 20Mhz version is an oddball.  The standard 328 is usually run at 16Mhz, and is wildly more powerful than what you need (not that that is a bad thing).

  • I really don't think you need to go to a 20Mhz processor.  Just use a standard 16Mhz unit.  If you're going to use a dedicated DAC, there's no advantage to the higher processor speed.

    Use the interrupts on pins 2 and 3 to detect the pulse edges to compute the RC pulse width.  This will be significantly more accurate than polling the inputs.

    Send the PWM out to the DAC using pins 9 and 10 and the analogWrite() function to take advantage of the hardware PWM built into the processor.  The Arduino PWM frequency no longer matters with a dedicated DAC.

    Implement a safety catch in the main loop to occasionally check if an interrupt has been triggered recently.  The output should be set to  a safe value if the RC input is cut.

    With this setup, the processor will be significantly under used, even at 16Mhz.

    Phillip

    *Addition*

    I just noticed the MCP4922 is an SPI interface, so the PWM output is of no significance, but the result is really the same.

  • Hi Eric,

    Totally on board with the ATMega 328, I was dubious of bandwidth as well especially to accommodate 2 PWMs / DACs.

    However, I am also not sure it needs to accommodate SBus / PPM-Sum.

    I think for most uses 2 independent single Radio control type PWM input channels would be the most common application.

    Although the Pixhawk wants PPM-Sum or SBus input it normally outputs independent PWM, so even if we wanted to use a Pixhawk for input to our DAC you still wouldn't need SBus.

    And if you want to run it straight from a receiver, even if it is outputting to an SBus or PPM-Sum device it will still have other independent RC PWM channels available.

    Also I am completely on board with dip form factor for both the skinny dip 28 pin Atmel chip and the dual DAC.

    I have actually designed and produced a lot of DIP based boards of my own over the years and it makes small to mid volume hand production infinitely easier.

    Given my preferences, if you are going to do that I would prefer the use of leaded components as opposed to surface mount throughout for the same reason though.

    DIP and leaded architecture does generally mean double sided with plate through's which likely means a hundred plus boards to make economical sense.

    At the small size of these boards and using break apart multi-board layout it should keep the per board cost really low.

    I have A Rigol 1074 scope and have the same problem, their software requires more software to do an actual printout although it does do PictBridge to a compatible printer.

    In any case I can fully visualize what you are talking about, an 8mhz micro is pretty squeezed with an SBus signal.

    I would think a 20MHz chip should work OK especially for individual PWM ins.

    I suppose you will use interrupts on the PWM ins and maybe 2 of the 3 hardware timers to acquire the PWM High period.

    Seems like this chip has plenty of power and possibly bringing out some of the other IO and Com pins at least to a pin header could make it suitable for other uses as well.

    Possibly also set up for user reprogramming (with suitable connector option) if feasible, it is a potent little Arduino after all.

    OK creeping featuritis got the better of me there, I promise to keep in check after this.

    Best Regards,

    Gary

  • Hi All,

    I am looking at the ATTiny solution with DAC suggested by Eric, but have also been thinking about using two small DC ESCs feeding a linear technology dual PWM input DAC as the most off the shelf solution potentially requiring no programming and very little extra circuitry:

    The Linear part is here:

    http://www.linear.com/product/LTC2644

    It takes conventional PWM and turns it into a voltage dependent on percent on of incoming PWM.

    It costs from $3.00 to $4.00 and comes in 8, 10 and 12 bit versions.

    From what I have read it does appear that DC ESCs simply take Radio Control PWM and effectively convert it into conventional PWM (along with sufficient current carrying capacity to drive rated motor).

    Alternatively of course you could use an Arduino or other micro to do the PWM to PWM conversion.

    Just tossing this out there to see what you guys think.

    I very much appreciate the information so far provided.

    I have several paths forward.

    Best Regards,

    Gary

    • Hi Gary, great thread - I need exactly the same. I have a BIG motor controller for a 12V DC motor that uses a pot as voltage input. I want to use a RC PWM as input.

      Thanks for sharing and keep us posted on your progress.

      Antonie

    • There are numerous boards for arduino that take i2c and support up to 16 pwm outputs. Ive ordered a few and have yet to try one out.

      http://www.adafruit.com/products/815

      ROBOTICS & CNC / ROBOTICS / ADAFRUIT 16-CHANNEL 12-BIT PWM/SERVO DRIVER - I2C INTERFACE

  • Hi Eric,

    That actually looks like a very nice compact solution and 12 bits is way plenty.

    I do not think that 25ma would be any problem as it is simply a control signal that is normally supplied by a 5K potentiometer connected 0 - 5 volts.

    Do you think it might be possible to use one ATTiny and 2 of the DACs for a 2 channel device?

    I know it has 6 IO pins so it seems like it would have the extra one you'd need for input and you could probably slave the DACs.

    I guess the bottom line would be if it had enough performance to work at normal Radio control PWM update rates.

    For my own use, certainly two single channel devices would work just as well.

    But I was thinking that you might almost have a viable, inexpensive and widely useful useful product if you could stuff 2 channels onto it.

    It has possibilities and ramifications beyond my project.

    In any case, if you are interested in carrying this further, please Email me at gary@dronesarefun.com

    Best Regards,

    Gary

  • I did a quick Google search for a PPM->analog converter,  and,

    Maybe  THIS   will work.  

    It's intended for RSSI and it may have some undocumented characteristics (glitches on power  up / down) that make it un-friendly as a final choice for a converter...

    I'm sure that there are more flavours of these type of converters around.

    Regards

    Chris

This reply was deleted.