Originally Posted by jetpr
Sounds to me like your talking about using pulse-width-modulation to run a DC motor on an R/C car or something.
Correct?
JDG
EDIT: Added a bunch of stuff
If you are talking about PWM, then it should be relatively easy.
An R/C servo signal is generally a 50-ish Hz signal with a variable pulse, somewhere between 1-2ms, with a 1.5ms center.
So, you set up an output to be a hardware PWM output (doesn't even have to be hardware, it could be an interrupt driven software PWM), say 5khz, and you vary the duty cycle according to the incoming pulse width.
Let's just assume that the incoming pulse from the receiver is actually what I said above, 1-2ms with a 1.5ms center.
You sample the incoming pulse width knowing those numbers (and they'll probably change depending on the software in the PIC, the R/C hardware, etc.etc. so you'll have to measure them somehow or set up something in software to do that for you).
We've got the pulse width in microseconds, we subtract 1000 from it. That gives us a number from 0-1000, representing 0 - 100%. Let's just pretend (to keep the numbers simple) that number would actually go from 0-1023 (10 bit number). You could either divide that by 4 to give you a BYTE value for your duty cycle in the PWM register, or multiply it by 64 to give you a WORD value for the duty cycle register.
And BAM. You're done. Feed that output into a few MOSFETs, and instant speed control.
Of course, that's only if you're talking about one direction. If you're talking about both directions, then you have to add another bit, some more software, and maybe an H-bridge with and more MOSFETs to run the motor.
Unless I've missed the point completely and you're talking about something entirely different, then I don't knowMaybe...
JDG


Maybe...

Bookmarks