1
\$\begingroup\$

I'm using a 6V DC motor for the first time and I've set up a timer on an atmega328p to create the PWM signal that then goes to the H-bridge (L293D). My question is why, for example, using a 8 bit timer with a prescaler of 256, if I set the OCR below 80 the motor can't start moving but if I use a power supply, directly connected to the motor, it works perfectly to any voltage?

In other words: (80/256)*100% = 31% duty cicle ---> 6V *31% = 1.86V

When I use the power supply with 1.86V all the way down to 0V the motor moves.

What's the reason for this to happen and how can I make the motor to move at slower speeds if I can't use low values? I'm trying to make PID control to control the motor position, I haven't started programming the PID but I am sure that it will need small PWM signal.

The motor has a gearbox with a ratio of 10:1

Motor Datasheet: Micro DC-Motor Modellspezifikationen

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Which motor, and what is the PWM frequency? \$\endgroup\$ Commented May 17, 2017 at 0:53
  • \$\begingroup\$ It happens to every PWM frequency but the OCR value changes. I've tested with 8 bit timer and 16 bit timer in Fast PWM mode and PWM Phase correct and to all prescaler. At the moment I'm using a 16 bit timer in phase correct mode with no prescaler which means the PWM frequency is 122Hz. Motor Datasheet: ecksteinimg.de/Datasheet/MO01069/Datenblatt.pdf \$\endgroup\$
    – msantos
    Commented May 17, 2017 at 14:11
  • \$\begingroup\$ Your PWM frequency is much too low. It should be at least 3kHz. Higher PWM frequency makes the motor current smoother and reduces the capacitance required to suppress power supply ripple. With a high enough frequency there should be little difference between PWM and DC (bearing in mind that the L293D drops ~2.6V at 600mA, so a 6V supply will only deliver 3~4V to the motor). \$\endgroup\$ Commented May 17, 2017 at 18:03
  • \$\begingroup\$ Why 3kHz ? The problem is that increasing the frequency it also increases the minimum value of the OCR. With a 3kHz frequency the motor only moves if the OCR is between 190-255 (8 bit timer). \$\endgroup\$
    – msantos
    Commented May 17, 2017 at 20:02
  • \$\begingroup\$ 3kHz is an estimate based on expected inductance of your motor. What motor voltage (measured with a multimeter) do you get when OCR is 190? 255? What is your CPU clock frequency and how did you get 3kHz PWM? \$\endgroup\$ Commented May 18, 2017 at 2:57

1 Answer 1

2
\$\begingroup\$

Although it may seem counter-intuitive, running a DC brush motor efficiently at a low PWM ratio requires that the motor switch between being connected to the supply and being shorted (not open-circuit). It will be necessary to use an H-bridge driver that can switch quickly, with judge enough "dead" time to prevent accidentally shorting the supply itself.

Motors have a certain amount of inductance, so it takes a little while for current to start flowing, and once current is flowing it will take awhile to stop. If you try to drive a motor at e.g. 25% duty cycle then during the first quarter of each cycle, the motor will have supply voltage across it so current will increase as energy flows from the supply into the motor. During the second quarter, the clamp diodes on the H-bridge will clamp the motor at a voltage equal to the supply voltage, but opposite in sign, so the current will decrease as energy flows from the motor back to the supply. During the third and fourth quarters of the cycle, there won't be any energy so the motor will sit with zero voltage and zero current. The average current in the motor will thus be about 1/4 of the level to which the current managed to climb in 1/4 of a cycle--not very much.

If instead of making the motor open-circuit, one made it short-circuit during the off part of each wave, then during the first 1/4 of the first cycle, motor current would increase as above, but during the remainder of each cycle it would decrease only slowly (the rate at which current will decrease depends upon the voltage across the motor inductance, and that would be kept very lower). Then during the first 1/4 of the second cycle, the current would increase a bit more, then drop only a little bit during the next 3/4 cycle, etc. Once the motor starts moving, the back EMF that generates will increase the rate at which current drops during the "off" cycle [energy will be transferred from the inductance to the mechanical load in that scenario]. If there is minimal mechanical loading, the equilibrium current will be achieved when the motor speed is about 1/4 of the motor's full-supply zero-load speed.

Note that when using this technique, it's important that the PWM rate be fast enough that the current doesn't have time to get to zero during each cycle. If the current does get to zero and the motor is turning, the inductor will take rotational energy and use it to build up torque in the direction opposite rotation. If the motor spends half its time producing forward torque and half producing reverse torque, much of the energy directed toward it will get converted into heat.

\$\endgroup\$
6
  • \$\begingroup\$ Thanks for the answer but how can I use that technique? Is there any H-bridge circuit like the L293D that does that? \$\endgroup\$
    – msantos
    Commented May 17, 2017 at 14:15
  • \$\begingroup\$ @M_Luis: Most H-bridges that I've seen have an input-pin configuration that will short the motor as well as one that leaves it open-circuit. Use PWM to switch between the driving and shorting states, rather than between driving and open states. \$\endgroup\$
    – supercat
    Commented May 17, 2017 at 14:35
  • \$\begingroup\$ I'm having a hard time to find it, can you name one that has, or tell me how to look for it the datasheet? Can it be done with free wheeling diodes? \$\endgroup\$
    – msantos
    Commented May 17, 2017 at 16:56
  • \$\begingroup\$ @M_Luis: Keep the enable line associated with both sides of the motor high, keep one of the inputs high or low, and PWM the other. \$\endgroup\$
    – supercat
    Commented May 17, 2017 at 17:04
  • \$\begingroup\$ I don't think that works \$\endgroup\$
    – msantos
    Commented May 17, 2017 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.