Control Speed of DC Motor

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
yllumi
Posts: 37
Joined: Tue Aug 19, 2014 8:41 am
Location: Bandung, West Java, Indonesia
Contact:

Re: Control Speed of DC Motor

Post by yllumi » Sun Aug 31, 2014 7:40 am

After I try in other pin with the code written in REPL like in sample:
- I think my X1 pin has broken. It can't be used for input output.
- my X2 and X3 pin can't be used for PWM output. But it can be used for high() and low() output. My X3 can be used for output trigger to my HC-SR04 ultrasonic sensor
- another pin i've tried is Y3, Y4, Y7, Y8, Y9, X4, X9, X10 and those all pins work.

PinkInk
Posts: 61
Joined: Tue Mar 11, 2014 3:42 pm

Re: Control Speed of DC Motor

Post by PinkInk » Sun Aug 31, 2014 1:40 pm

You can't use all pins concurrently for PWM with my module i.e. if you're testing to determine which you can, some of the pins use the same timer/channel combination as others, so if you've already allocated that combo and try to do so again the second pin that needs to use the combo can't, so it will appear not to do pwm. Note (at least when I was testing) the 'allocation' of timer/channel combo to pwm survived a soft-reset of the board (the combo effectively becomes inaccessible), requiring a hard-reset to free it up again.

That's where the manually specifiable alternative functions for each pin come in, the pins that use the more common timer/channel combo's mostly have an alternate option available, which can be used (with care) to avoid conflict.

Hopefully things'll make more sense when pwm has been done 'properly', because there are some pins that the doc's say support TIMx_CHyN ... I couldn't fathom what the N meant, so I didn't try to implement the option.

User avatar
dhylands
Posts: 3507
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Control Speed of DC Motor

Post by dhylands » Sun Aug 31, 2014 4:33 pm

The N in TIM8_CH1N means that its a complementary channel.

For some motor control applications its useful to have a PWM signal and its inverse. Furthermore, you can do whats called dead-time insertion, so that the 2 signals aren't the exact inverse, rather, there is a small dead-time when neither signal is "active".

User avatar
dhylands
Posts: 3507
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Control Speed of DC Motor

Post by dhylands » Sun Aug 31, 2014 4:36 pm

yllumi wrote:After I try in other pin with the code written in REPL like in sample:
- I think my X1 pin has broken. It can't be used for input output.
- my X2 and X3 pin can't be used for PWM output. But it can be used for high() and low() output. My X3 can be used for output trigger to my HC-SR04 ultrasonic sensor
- another pin i've tried is Y3, Y4, Y7, Y8, Y9, X4, X9, X10 and those all pins work.
If you connected the motor directly to the microprocessor, then its quite possible that you blew portions of the circuitry on the chip. Especially if the motor was ever turned manually (motors act like generaters when you turn the shaft) and this could have generated large voltages which could damage the chip.

gerardoS
Posts: 1
Joined: Wed Feb 07, 2018 11:25 am

Re: Control Speed of DC Motor

Post by gerardoS » Wed Feb 07, 2018 11:28 am

Thank you for these suggestions. Have you ever tried this one?
https://www.moverica.com/motorreductore ... n/chp-1120
Regards.

User avatar
dhylands
Posts: 3507
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Control Speed of DC Motor

Post by dhylands » Wed Feb 07, 2018 5:37 pm

I haven't controlled that specific motor. It looks like a DC motor typically used in a car for raising and lowering the windows.

The automotive motors typically operate at 12VDC and looking at the data sheet for the one in the link it has a stall current of 27A, which means that you'll need quite a beefy motor driver (sometimes also called an HBridge) to handle that much current.

Pololu carries a few that can handle that: https://www.pololu.com/category/10/brus ... ontrollers and robot market place (which caters to the "BattleBot" crowd) also has quite a few: http://www.robotmarketplace.com/product ... _main.html

Note that high current motor drivers are not cheap.

I've used this HBridge: http://www.bdmicro.com/rx50/ to control your typical motors found in RC trucks and cars (which often have stall currents around 20A). Disclaimer: I worked with the creator of the Rx50 on his design and got a few units for free.

For some more background on how to control DC motors, I highly recommend this article: http://www.seattlerobotics.org/encoder/ ... ontrol.htm

This PDF: http://robotika.yweb.sk/skola/H-brigde/H-Bridge.pdf (of a presentation) gives some more specific background into how an HBridge works.

Post Reply