PDA

View Full Version : Scale from RC Radio 1% to 100% (Idea)



jetpr
- 11th December 2006, 01:57
I need to Run a DC Motor but in a scale...

If some one dons this please help


RadioScalefactor = ThrottleMax - ThrottleMin
CycleStep =10

Scale= ((Throttle - ThrottleMin) * 100/ RadioScalefactor )


If (CurrentStep < Scale) And (Scale <= 100) Then
While (CurrentStep * CycleStep < 100)
CurrentStep = CurrentStep + 1
Wend

While (CurrentStep * CycleStep > 100)
CurrentStep = CurrentStep - 1
Wend
End If
MotorDc=CurrentStep (Motor Speed)

skimask
- 11th December 2006, 03:51
I need to Run a DC Motor but in a scale...

If some one dons this please help


RadioScalefactor = ThrottleMax - ThrottleMin
CycleStep =10

Scale= ((Throttle - ThrottleMin) * 100/ RadioScalefactor )


If (CurrentStep < Scale) And (Scale <= 100) Then
While (CurrentStep * CycleStep < 100)
CurrentStep = CurrentStep + 1
Wend

While (CurrentStep * CycleStep > 100)
CurrentStep = CurrentStep - 1
Wend
End If
MotorDc=CurrentStep (Motor Speed)



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 know :) Maybe...
JDG

jetpr
- 12th December 2006, 03:54
hey JDG
Thanks
PWM :

yes one direction thanks but ken you send some code of how you do that.

i need one idea from where to start

skimask
- 12th December 2006, 13:11
hey JDG
Thanks
PWM :

yes one direction thanks but ken you send some code of how you do that.

i need one idea from where to start


I've made my own R/C speed control, I know it can be done.
I would give you code, but in the end, you will have learned absolutely nothing.

So....Why don't you write some code, come up with an idea, anything...draw up a small schematic, and post them. The rest of us will most likely try and help point you in the right direction and get it working. Because, quite frankly, I gave you practically all the information you'd need to know in my last post.

JDG