Control Speed of DC Motor
Re: Control Speed of DC Motor
For your small-motor application I could suggest either of the following circuits depending on whether you have any BJTs or MOSFETs laying around:
-Bryan
In the BJT version the 1K resistor limits the base current to a reasonable level; in the MOSFET version the 10K resistor prevents any floating voltage from turning on the MOSFET before the PWM pin is initialized. The diode is there to prevent inductive/back-EMF currents from blowing up the transistor when it turns off, for a small enough motor it may not be necessary.-Bryan
Re: Control Speed of DC Motor
Dave:
I'm trying to control something with these exact motors in it:
Looking at the motor driver you suggested, I think you would actually have to go for something like http://www.pololu.com/product/1213 instead since you are driving two motors, but those motors are supposed to be driven at up to 3V. It looks like the VIN on that driver is 5V-28V, so would that actually work without putting more than the recommended voltage through the motor?
Is there a better way? Basically I would like to be able to control the speed of those two dc motors, forwards and backwards to power tank tracks.
Thanks as always for your advice, I think I'm finally going to have a little time to work on this again after a few weeks away from it.
I'm trying to control something with these exact motors in it:
(Basically two of the single motor gearbox combos, rather than the package with two in the same case.)Even small motors like these: http://www.pololu.com/product/114/specs have a stall current of 2.1A so you want your motor driver to be able to drive that much current. Something like http://www.pololu.com/product/1212 would work for those motors.
Looking at the motor driver you suggested, I think you would actually have to go for something like http://www.pololu.com/product/1213 instead since you are driving two motors, but those motors are supposed to be driven at up to 3V. It looks like the VIN on that driver is 5V-28V, so would that actually work without putting more than the recommended voltage through the motor?
Is there a better way? Basically I would like to be able to control the speed of those two dc motors, forwards and backwards to power tank tracks.
Thanks as always for your advice, I think I'm finally going to have a little time to work on this again after a few weeks away from it.
Re: Control Speed of DC Motor
Yeah using the dual motor controller makes more sense if you have 2 motors.UltraBob wrote:Dave:
I'm trying to control something with these exact motors in it:
(Basically two of the single motor gearbox combos, rather than the package with two in the same case.)Even small motors like these: http://www.pololu.com/product/114/specs have a stall current of 2.1A so you want your motor driver to be able to drive that much current. Something like http://www.pololu.com/product/1212 would work for those motors.
Looking at the motor driver you suggested, I think you would actually have to go for something like http://www.pololu.com/product/1213 instead since you are driving two motors, but those motors are supposed to be driven at up to 3V. It looks like the VIN on that driver is 5V-28V, so would that actually work without putting more than the recommended voltage through the motor?
Is there a better way? Basically I would like to be able to control the speed of those two dc motors, forwards and backwards to power tank tracks.
Thanks as always for your advice, I think I'm finally going to have a little time to work on this again after a few weeks away from it.
As for voltage, you can reduce the PWM percentage to effectively get a lower voltage.
The motors are inductors, and even though you're sending in a square wave, the currents take time to ebb and flow, so what the motor actually winds up seeing is more like a variable voltage.
So if you put 5V into your motor driver, and drive it at 50%, then what the motor sees is 2.5V
The 4QD website has lots of really useful background information if you want to understand more: http://www.4qdtec.com/pwm-01.html
Having said all that, I'd have absolutely no qualms overdriving those motors at 5V, especially if you keep your gearbox lubricated. I suspect you'll find that you don't need to use 100%.
Re: Control Speed of DC Motor
I've tried some of your example code, but it's not working with my pyboard. Is there something that I missing?dhylands wrote:That's whats available for now.
I have something working that hasn't been merged yet. I just need to code up the teensy version to make sure it works on both:
https://github.com/micropython/micropython/pull/815
Re: Control Speed of DC Motor
That's the simpler solution than using L293D. But for this time I still stuck making PWM outputblmorris wrote:For your small-motor application I could suggest either of the following circuits depending on whether you have any BJTs or MOSFETs laying around:In the BJT version the 1K resistor limits the base current to a reasonable level; in the MOSFET version the 10K resistor prevents any floating voltage from turning on the MOSFET before the PWM pin is initialized. The diode is there to prevent inductive/back-EMF currents from blowing up the transistor when it turns off, for a small enough motor it may not be necessary.
-Bryan
Re: Control Speed of DC Motor
The sample python code needs a firmware image built using the code on the PR to work (because the PR hasn't been merged into the main python codebase yet).yllumi wrote:I've tried some of your example code, but it's not working with my pyboard. Is there something that I missing?dhylands wrote:That's whats available for now.
I have something working that hasn't been merged yet. I just need to code up the teensy version to make sure it works on both:
https://github.com/micropython/micropython/pull/815
Re: Control Speed of DC Motor
I'm still stuck in generating PWM output. I have tried the sample code like in here http://wiki.micropython.org/contributedmodules/pwm but I got no output.
I have tried to check the signal using my multimeter but it is nothing changes. There is no voltage or current. I have updated the firmware to the latest and I am using pin X2. Any ideas?
I have tried to check the signal using my multimeter but it is nothing changes. There is no voltage or current. I have updated the firmware to the latest and I am using pin X2. Any ideas?
Re: Control Speed of DC Motor
Yllumi, the pwm module I put up on the wiki worked when I last tried it, which was several weeks ago.
It's possible that micropython has changed in the interim in ways that preclude it working on more recent builds. In particular dhyland has been working on pyb.timer, I note heading in a direction which will make my temporary pwm hack obsolete.
I'll try and check the module, and fix it if possible, in the next day or so, with a current micropython build.
It's possible that micropython has changed in the interim in ways that preclude it working on more recent builds. In particular dhyland has been working on pyb.timer, I note heading in a direction which will make my temporary pwm hack obsolete.
I'll try and check the module, and fix it if possible, in the next day or so, with a current micropython build.
Re: Control Speed of DC Motor
I just confirmed that it still works.
I downloaded the pwm.py from: http://wiki.micropython.org/contributedmodules/pwm
and if I do: then I see a 50% duty cycle on pin Y2.
When you said you measured using your multimeter, were you using the ground pin next to X2? There is a row of 4 ground pins and 4 VIN pins right next to X1-4
I downloaded the pwm.py from: http://wiki.micropython.org/contributedmodules/pwm
and if I do:
Code: Select all
Micro Python v1.3.1-14-gca6d75f on 2014-08-30; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import pwm
>>> p=pwm.PWM(pyb.Pin.board.Y2)
>>> p.duty(128)
When you said you measured using your multimeter, were you using the ground pin next to X2? There is a row of 4 ground pins and 4 VIN pins right next to X1-4
Re: Control Speed of DC Motor
Thanks! Didn't think what you'd added was likely to have broken it, and was planning to try to use some of the informational stuff you've added to timer to reduce size.