SX speed control
Daniel M.
Posts: 14
I am currently attempting to build speed controls for the drive motors on my competition robot for school. The motors themselves are running off of 9.6v at about 2 amps. My first idea was to use a few variable voltage regulators and digital potentiometers (to control the regulators). I have been looking at digital potentiometers and have yet to understand how one with "SPI" works and how to use it. I'd appreciate any kind of help with that, and also if there are any better ways to design a custom speed control. Thanks!
Daniel
Daniel
Comments
That method would be very ineffecient.
You want to use PWM to control the speed of the motors.
Of course you will need a high power transistor or FET to interface to the motors.
Note that the PWM commands in SX/B are meant for generate analog voltages and not for controlling motors.
Basically instead of lowering the voltage you use full voltage but turn the motor on and off very quickly.
You control the speed by altering the duty cycle (percentage of on-time to off-time).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"Remember, you are unique, just like everyone else." Unknown.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
Post Edited (Kramer) : 7/18/2006 8:00:31 PM GMT
Does PWM from the SX require assembly to get a series of pulses appropriate for Motor Control?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
The method SX/B uses is the same as the method the stamps uses. It works better for generating analog voltages, because the pulses are spread-out more.
But DC motors "like" a longer on and off time.
Assembly is not required, but if you want to control multiple motors then the assembly will be more effecient.
Of course it depends on the PWM rate you want. For slower rates, assembly may not be required for multiple motors.
Usually 8-bit PWM is used, that means that the interrupt would need to be called 256 times for one PWM cycle.
So if the interrupt was called 100,000 times a second, the PWM rate would be 100,000/256 = 390Hz
Now if you were running the SX at 50MHz that would allow just less than 500 instructions in the interrupt.
If you interested I will whip-up an example...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"Remember, you are unique, just like everyone else." Unknown.
·
Thanks for the feedback. While I'm interested in taking you up on your example, let me look over at the PWM/Servo controller, and see if I can learn from that. I don't just want a sample "done" for me, I want to learn what's happening. In this case, you've given me a clue, using the interrupt clock. Thus far, I have not been using that much, I've been more of a "looper", putting a "pause" at the end of the loop, and adjusting the length based on what I see on the 'scope.
While I'm proficient at "Business" programming (ERP Systems), I am only starting to catch on to this uProcessor stuff. It's kind of fun learning something new. I'm currently working on a different project using a servo(s), but have some PWM motor control comming up on another project I'm starting to do some mock ups on.
I hope you enjoyed the beach!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
I'll just give you a quick overview...
Basically you use a byte variable as a counter that gets incremented each interrupt. (And of course rolls-over).
Then you just compare the PWM value to the counter. If the PWM value > counter then turn the output on, otherwise turn the output off.
That's it...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"Remember, you are unique, just like everyone else." Unknown.
·
Thank you very much.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
You would have to perform either the PWM or the serial (or both) in an interrupt routine.
The PWM would be easier to do in an interrupt.
And I DON'T mean to just put the PWM command in the interrupt routine.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"Remember, you are unique, just like everyone else." Unknown.
·
do
PWM ra.0, signal_out, 100
SERIN RB.0, N2400, data_in, 1
loop while data_in = 0
such that the PWM is the same until another signal is received. Do I have the SERIN timeout mixed up or something? Also, is there an example of what you mean by putting the PWM in an interrupt routine?