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.
That looks like a nice little microcontroller based board that does exactly what I want.
I looked for something like this without success on line myself.
Unfortunately as of September of last year it looks like it is no longer available.
Probably going to pursue both the DC ESC and Arduino methods.
Is the controller from http://kellycontroller.com ? Because , they seem to have set-up software tools and often there are multiple choices for the type of throttle input.. such as PWM 0 - 100% , PWM 50/50 , voltage input etc.
A PWM throttle input control would be more resistant to EMF & noise.
Yes it is, but this particular controller only has 0-5 volt (5K pot) input or Hall device input which is simply a pulse rate input for a hall device on a pedal sprocket to apply power only when pedaling and for which I have not been able to get any actual information as to rate duration = speed.
The controller is programmable for a number of options (and quite easily with the supplied PC program), but the throttle control options are only those listed above.
I agree that PWM in would have advantages.
If you want tips on how to get an Arduino to read Servo RC, you could look at our Jeep Rover Project's homebrew steering servo code: https://github.com/shimniok/diyrovers/tree/master/JeepServo
I would do this with an Arduino pro mini (the clones are dirt cheap).
Attached is a program I wrote to do this exact thing.
connect the RC signal to pin 3
connect pin 9 to the the PWM input of your controller
If you need a more analog signal, then switching the output to either pins 5 or 6 will increase the PWM update rate from 490Hz to 980Hz (without effecting duty cycle). Then a weak RC filter should be able to remove a reasonable amount of the "choppiness".
int PWM_Pin = 9; // PWM output pin
int PWM_Pin = 5; // PWM output pin
The problem isn't the update rate, the problem is that the radio control PWM signal is very different than the classic PWM signal.
In classic PWM pulse width simply varies from zero to 100% and a simple RC circuit can easily convert this from a 0 to X volt output.
The type of PWM output from our radio control systems however is completely different.
For a given update rate it has a fixed low period followed by a high pulse of which the first millisecond of which is equivalent to servo low position then at 1.5 milliseconds servo center position and 2 milliseconds servo right position or for our use 1 millisecond would equal zero volts and 2 milliseconds would equal 5 volts.
This means that not only do we have an in-determinant time before we get a positive pulse, but also the first millisecond of a maximum 2 millisecond pulse is just to get to zero.
A simple RC circuit can't make that work.
My program does exactly what you need (as I understand it).
Input: RC signal with pulse width variation from 1ms to 2ms (at any update rate faster than 2Hz)
Output: PWM signal that varies from 0% to 100% duty cycle (at 490Hz or 980Hz, depending on the output pin used)
I'm pretty sure that's what you've been describing, but I could be wrong.
I am sorry, you are absolutely right, your code with a bit of an RC filter should work perfectly well and you could get by with less capacitor on the faster one.
You are basically taking radio control PWM and converting to real - classic PWM.
I will likely take this route, but I am also looking at inexpensive DC ESCs to see if that might also be a viable option with a small RC circuit.
Hey I read the code it looks like it does what you need right>?
Did u read the code