How to stop DC motor using voltage monitoring

Hi everyone,

I am controlling a DC motor with L293D on a Arduino Uno and I am looking to make a system that shuts down when the motor is about to stall.
I believe the best way would be to monitor the voltage accros the motor but how?

Thank you in advance for your help.

People believe all sorts of strange things. The voltage across the motor will always be the same because you are supplying a PWM signal somewhere along the line.

You can not predict when the motor is about to stall because that depends on the load on the motor in terms of torque.

Monitor the motor current, not the voltage.

Pololu sells modern, efficient DC motor drivers (the L293D is neither), and most include current sense feedback. A couple of them include adjustable current limiting. Set that to below the stall current, or possibly, use the output as an overload signal.

Alternatively, use a shaft encoder to monitor RPM. Zero=stall.

1 Like

Wrong wording my bad, I meant I think :slight_smile: and I am a huge beginner. So I cannot believe myself at any point.
Thank you for your answer. I don't need to predict the stall, just shutdown the loop when it does.

Why shut down a loop?
You can tell if a motor stalls because the current it takes will increase.
Put a resistor in line with the ground side of the motor and measure the voltage across that. It will shoot up when it stalls.

1 Like

Yes exactly what I am trying to achieve.
The motor is lifting a small door so I need it to stop when the door has reach its maximum height to avoid breaking the cable over time.
So I put a resistor in line and I can read the voltage accross that through input A0 for example?

Sort of. If the current sensing resistor is in the power line, then it is likely to be at too high a voltage for the Arduino input (limited to 5V; the Arduino's supply). Putting the current sense resistor in the return line will mean the voltage is low and will not damage your Arduino.

Depending on the current value, the resistor an amplifier may be required.

A much better idea is to use a limit switch (micro switch, beam break switch, etc.) to detect when the door is up. It could cut motor power, activate a digital input or both.

For example:
Capture

1 Like

That's a way to do it indeed but not what I try to achieve. A switch is problematic for application reasons. Thank you anyway.

The Arduino motor shield Rev3 does exactly what you're asking for.
It has two 0.15ohm sense resistors (R1,R2) in the ground lines of the two motor channels.
With the resulting voltages amplified by two opamps before presenting it to two analogue pins.
Unfortunately the shield uses the L298, which is marginally better than your L293.
Leo..

Yes in the Ground line.

Now if the motor can go in different directions there is a problem that in one direction the voltage you read will be negative. So before you put this into A0 you have to put the sensor voltage through a bridge rectifier first so that no matter what the polarity of the voltage from the sense resistors is it will always be a positive value and not harm the A0 pin.

Given that we are looking for a stall current and that is normally 10 times the running current it is easy enough to spot. If not just change the value of the sense resistor until it is.

With a resistor in the ground line of the driver (not the motor), voltage across the sense resistor will always positive. You're effectively measuring motor power supply current.

You should switch to 1.1volt Aref, so the sense resistor can have a low value.
Leo..

You can't do that.
You will be dynamically shifting your logic input levels depending on the motor current.

Thank you all. I have many tracks to follow. I will test them all and come back posting what actually worked and how :slight_smile:
BR

You can if you keep that sense voltage low.
That's why I also recommended using 1.1volt Aref, which has A/D steps of ~1mV.
Leo..

Should probably start with the suggestion in post #3...

That's a easy fix indeed. But totally out of budget. The goal of this need is to avoid the addition of too much components.

Which fix?

You could even scrounge up spare wiring and hook it to a spring and flat contact. Upcycle all the components required for zero cost. It's best to detect when the door is in place as opposed to monitoring the motor (unless it has an encoder) for positional feedback. Too many weird things that can happen.

In fact, that is how motor current monitoring works and is implemented in most modern H-bridge chips.