DC motor doesn't rotate with low duty cycle PWM using L293D

Thread Starter

MLuis

Joined Jul 20, 2017
17
Hello,
I'm controlling a 6V DC motor using a microcontroller (Atmega328) that creates a PWM signal that is fed to a H-bridge (L293D), the problem is that the motor only moves when I set the PWM with a duty cycle of 45% or higher, if it has a lower duty cycle it doesn't move and makes a noise. For duty cycles between 40%-45% if I give it a push with my hand it rotates. I've tried all PWM frequencies that the microcontroller can create and the higher the frequency the higher the duty cycle has to be to make the motor rotate.
But if I use a power supply, directly connected to the motor, it works perfectly, for any voltage.
All the test were made without any load.
I noticed that the L293D circuit drops some voltage, and instead of receiving 6V the motor was receiving a bit over 3V, so I fed the L293D with 9V instead of 6V and the motor was receiving around 5.8V, but it made no difference (beside moving faster). I even changed the L293D for a L298N that has lower voltage drops (I fed it with 6V and the motor was receiving the 6V) and is capable of driving higher currents, but it also made no difference.
The power supply I used shows the current aswell and the motor needs around 0.4A (measured when the motor is directly connected to the power supply) to start rotating but when driving the motor through the h-bridge and giving it a PWM with a duty cycle below 45% the motor doesn't move and the power supply shows around 0.13A.

Motor Datasheet:
http://ecksteinimg.de/Datasheet/MO01069/Datenblatt.pdf

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 a PID controller to control the motor position and I need those small values.
 

geekoftheweek

Joined Oct 6, 2013
1,201
Maybe not the right answer, but once I tried something similar just to play around with some motors I saved from junk printers. What I ran into was my overall PWM cycle time was too short and at low duty cycles some wouldn't work. After increasing the cycle time they would work with lower duty cycles.
 

Ylli

Joined Nov 13, 2015
1,086
I'm not going to be able to give you any design specifics (above my pay grade), but if you want to control a DC motor at low speeds, you really need to incorporate feedback in the controller.

You can use the Reverse EMF developed across the motor as a feedback. Check out some of the google hits here: https://www.google.com/search?num=2....crnk_qsd...0...1..64.serp..0.0.0.YDo9vWeFlRY . Looks like your processor has more than one built in ADC.

Or looking at the motor data sheet, it looks like the motor has a built in encoder. Feed the pulses from the encoder back into the processor and program it so that you get the pulse rate back that you desire (indicating a given speed.
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
Maybe not the right answer, but once I tried something similar just to play around with some motors I saved from junk printers. What I ran into was my overall PWM cycle time was too short and at low duty cycles some wouldn't work. After increasing the cycle time they would work with lower duty cycles.
Like I said in the beginning the the lower the frequency the lower the duty cycle can be, but the frequency can't be too low otherwise the motor won't run smoothly. And at the moment the frequency that I've set is the lowest possible but I still needs a duty cycle of 45% to run wich is to high for what I want to do.
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
At what voltage does the motor still run when applying DC?
I haven't measured that and I can't do it at the moment, but shouldn't the voltage, between the two output pins of the L293D (where the motor connects) when the motor is not connected, be the same as the voltage between the motor terminals when it is connected?
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
I'm not going to be able to give you any design specifics (above my pay grade), but if you want to control a DC motor at low speeds, you really need to incorporate feedback in the controller.

You can use the Reverse EMF developed across the motor as a feedback. Check out some of the google hits here: https://www.google.com/search?num=2....crnk_qsd...0...1..64.serp..0.0.0.YDo9vWeFlRY . Looks like your processor has more than one built in ADC.

Or looking at the motor data sheet, it looks like the motor has a built in encoder. Feed the pulses from the encoder back into the processor and program it so that you get the pulse rate back that you desire (indicating a given speed.
I'm reading the motor's encoder and I know the position and speed but I don't understand how can that help making the motor move at low speeds.
 

geekoftheweek

Joined Oct 6, 2013
1,201
Like I said in the beginning the the lower the frequency the lower the duty cycle can be, but the frequency can't be too low otherwise the motor won't run smoothly. And at the moment the frequency that I've set is the lowest possible but I still needs a duty cycle of 45% to run wich is to high for what I want to do.
I guess I should have read a little better...
 

BobTPH

Joined Jun 5, 2013
8,808
What you see is expected. Because the motor load is inductive, it takes time for the current to build. With PWM, it will never reach the same current you get with a constant voltage. And the higher the frequency, the worse it gets.

Bob
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
What you see is expected. Because the motor load is inductive, it takes time for the current to build. With PWM, it will never reach the same current you get with a constant voltage. And the higher the frequency, the worse it gets.

Bob
So it's not possible to make the motor run at low speeds? I know that there is a limit but isn't 45% too high?
 

Ylli

Joined Nov 13, 2015
1,086
I'm reading the motor's encoder and I know the position and speed but I don't understand how can that help making the motor move at low speeds.
If the processor knows the motor speed and it is less than desired, then have the processor increase the applied pulse width. Close the loop.
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
If the processor knows the motor speed and it is less than desired, then have the processor increase the applied pulse width. Close the loop.
I did that. Whenever the PID output is lower than the minimum, then the duty cycle is equal to the minimum, but it doesn't work properly that way.
 

crutschow

Joined Mar 14, 2008
34,281
I haven't measured that and I can't do it at the moment, but shouldn't the voltage, between the two output pins of the L293D (where the motor connects) when the motor is not connected, be the same as the voltage between the motor terminals when it is connected?
My question was "what is the minimum voltage the motor will still run when connected directly to a DC source?"
I'm trying to determine how that compares to the minimum PWM duty-cycle you are using.
 

Ylli

Joined Nov 13, 2015
1,086
I did that. Whenever the PID output is lower than the minimum, then the duty cycle is equal to the minimum, but it doesn't work properly that way.
Then you need to work on the loop parameters. If you are commanding an RPM of 10, and the processor sees (via the encoder feedback) and RPM of 0, then the processor must increase the duty cycle of the applied voltage. If under these conditions, the motor is sitting at zero or some higher than desired RPM, or if it is oscillating between a high and zero speed, then there is something wrong with the feedback loop.
 

Alec_t

Joined Sep 17, 2013
14,280
Is it a brushed motor or a brushless one? Externally applied PWM can conflict with the internal switching of some brushless motors.
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
What PID loop?
Lower than what minimum?
The minimum voltage the motor will still run when connected directly to a DC source is around 1V wich corresponds to 16.7%. (6V * 0.45 = 2.7V)
I implemented a PID controller to control the motor's position. The input is the position's error and the output is the duty cycle and since the PID loop gives values below the minimum duty cycle capable of making the motor move (45%) what I do is whenever the value calculated by the PID is lower than the minimum duty cycle capable of making the motor move (45%) I set the duty cycle equal to this minimum value (45%). I0ve seen many PID codes implemented like this but in my case it doesn't work properly because ( I think) the minimum duty cycle is too high.
 

Thread Starter

MLuis

Joined Jul 20, 2017
17
Then you need to work on the loop parameters. If you are commanding an RPM of 10, and the processor sees (via the encoder feedback) and RPM of 0, then the processor must increase the duty cycle of the applied voltage. If under these conditions, the motor is sitting at zero or some higher than desired RPM, or if it is oscillating between a high and zero speed, then there is something wrong with the feedback loop.
At the moment I only tested with Proportional gain, and with Kp=1 or Kp=200 the response is the exact same because in the end the value of the duty cycle will always be 45% since the output value of the PID will be lower than 45%.
 

crutschow

Joined Mar 14, 2008
34,281
At the moment I only tested with Proportional gain, and with Kp=1 or Kp=200 the response is the exact same because in the end the value of the duty cycle will always be 45% since the output value of the PID will be lower than 45%.
If the motor speed is too slow the PID loop should set the duty-cycle to the maximum value, not the minimum.
I don't understand why it's setting it to the minimum? :confused:
Sounds like you have the PID signal phase reversed from what it should be.
 
Top