Stopping a Motor with a Current Sensor...

I need to stop a motor from turning when it hits the end of it's move. I'm wanting to do it when the motor hits a higher then average torque. I'm wanting to catch it just as it almost hits a stall.

I was thinking of putting a Current Sensor on the power lines, and build a function that would check the current. If it hit an abnormally higher then average current then stop the motor.

Is this a good way to do this? Is there a smarter simpler way of watching for the higher then normal / just about to stall the motor? Is it possible to do this with out a current sensor, and just use one of the io pins on the arduino?

Thanks for any feed back!
dan.

That's how automatic power windows work in cars. I don't like it (Microswitches are cheaper than hall effect sensors! Stalling the motor wastes energy!) but it does work every day in both my Honda and my Pontiac!

But Trum! what about my Ford? Does it use this advanced stalling technique? just kidding.... Thanks for the fast reply! To be honest, I have never seen it done before.. It was one of those late night ideas and didn't know if I was crazy.

Basically my project uses a large wheel and will very on the position, so the end of the move will never be the same. Or I would be all over the switch. I'm ordering a ACS712 today.... hopefully that will work like a champ...

Like this?

That's what I'm screaming MrBear! What are you using for the sensor? Would you be willing to share some code, or point me where I can look at other code like it?

Thanks guys for all of the help! Best forum on the internet!

If your motor is DC you could just use a shunt resistor. Place it between ground and your motor. Then monitor the voltage across the shunt on one of the Arduino analog pins. For low losses and / or higher precission choose a small value shunt and set your analog reference to 1.1 V (INTERNAL). It should be much cheaper than the IC. It should also be possible to use the low side current sensing shunt with some H-bridges if you need to run the motor both ways. It depends on the design of the H-bridge and peak voltage across the shunt.

Well - its not me on the video, but i guess it is quite straight forward.

First off you need something to measure Amps. This can be done by measuring the voltage drop over a resistor or (if you prefer to spend a bit of $$) you can find a hall-sensor solution on ebay if you search on hall sensor current.......or something like that. you can also find it on any electronics shop or website.
If you need to run the motor in both directions you will need a Bi-directional sensor.

Implementing it is very simple and the datasheet will tell you how to wire it up. Be sure to get one that takes 5V (or 3.3V) as input if you are using an Arduino. In the datasheet you will find a rating like 40mv/V which means that for every amp flowing through the sensor, its output voltage will increase by 40mV. Very straight forward.
The thing about motors is that they draw more current when you try to stop or slow down the rotation. This is because the BEMF (the voltage produced by a motor when it spins) becomes less as the speed is reduced. Conclusively you (as you wrote yourself) will be able to see if the motor has reached its stop if the Amps goes up. So your program will consist of a analogRead(ampSensor); compare that to the maximum allowable current and then either continue or stop.

hope it helped.

// Bear

You can always post your code here if you want to have it checked.

cheers

I'm only running one motor on my driver. Do you think it would be possible to use a sensor at the voltage into the driver? That way I can watch the current draw no matter the direction of the motor spin?

What motor and motor driver do you have?
If it is a switching driver, then the power supply current is not necessarily the same as the motor current.

Yes that is possible, no problem at all.
The only thing you have to keep in mind is that placing the sensor there you will sense both the motor and the drivers consumption.

// Bear

I realize you're talking about a DC motor, but some people may be interested to know it is also possible with a Stepper motor. I have written the code for it here on this subforum.

Okay, so I think I made a mistake....
I bought an ACS712-30A board. I think I needed to buy a ACS712-5A. My project pulls about 140mA max. When I run a simple analogRead it get the half voltage read of the VCC. as shown on other people project... about 512. Good that's normal.

The stink is I don't see any change on the reading when I run my motor and other parts. I can see the current being pulled on my desktop power supply. But no change on the ACS712-30A.

Do think the reason why is that it's not sensitive enough? the -30a or -5a stands for the max amp it can handle...

Thanks again for all of the help!

link to what I bought:
http://www.amazon.com/Amico-Electrical-Current-Sensor-Module/dp/B00BNQXAIY/

Data Sheet: http://www.allegromicro.com/~/media/Files/Datasheets/ACS712-Datasheet.ashx

The more amperage the ACS sensor can handle, the less "sensitive" it is to smaller currents. 140mA is quite small so you want the smallest ACS sensor available and even then the difference in analogRead() values will be quite small (roughly 14 for the +/-5A version, if my math is right).

A shunt resistor is a reasonable solution here, since overall current is so low. For higher currents they're wasteful but that's not the case here.

@dannyboyfl, you still haven't told us what motor driver you are using. Some motor drivers have provision for adding a current sense resistor.

I'm using a Board from Pololu http://www.pololu.com/product/1220

The Driver on it is a: Toshiba TB6612FNG
Data Sheet: http://www.pololu.com/file/0J86/TB6612FNG.pdf

You can't add a current sense resistor to that controller; all you can do is monitor the actual motor current by using either a very small resistor in series with the motor and measuring the (possibly bidirectional) voltage drop across it, or a Hall effect monitor.

What is the actual stall current of the motor? If you don't have a motor data sheet, you can measure this by applying a small voltage (like from a fresh 1.5 V alkaline D cell) and measuring the stall current using a multimeter. Then for your project, the expected stall current would be the value that you just measured multiplied by Vm/1.5, where Vm = motor supply voltage. That assumes, of course that you are not using PWM to control the speed.

Or you could measure the motor resistance with a multimeter and calculate the stall current at Vm. You may need to slowly rotate the motor shaft while measuring the resistance and look for the lowest value.

It might be easier to monitor the motor rotational speed with some sort of encoder.

jremington:
You can't add a current sense resistor to that controller; all you can do is monitor the actual motor current by using either a very small resistor in series with the motor and measuring the (possibly bidirectional) voltage drop across it, or a Hall effect monitor.

Can't the sense resistor be placed in the ground lead of the motor driver itself? This will also measure the current used by the driver chip, but that's probably just a handful of mA and you can test the idle current consumption and subtract that from further measurements.

dannyboyfl:
I'm using a Board from Pololu http://www.pololu.com/product/1220

The Driver on it is a: Toshiba TB6612FNG
Data Sheet: http://www.pololu.com/file/0J86/TB6612FNG.pdf

Thanks. The TB6612FNG has separate PGND pins for each motor channel, but unfortunately that Pololu board does not have provision for inserting current sense resistors in series with those pins.

140mA is rather low to measure using a Hall sensor. There are a couple of other possibilities:

  1. If the motor supply is separate from the Arduino power supply, and is floating (that is, does not instrinsically have a common ground with it - for example, a battery), then you could insert a current sense resistor between motor supply -ve and ground. Then use a voltage divider to +5V to monitor the resulting negative voltage (which is proprtional to the motor current) on the Arduino.

  2. You could insert a current sense resistor in the Vbat supply to the driver board, and use a high-side current sense IC such as MAX4172 to monitor the voltage drop across that resistor, giving you a voltage that you can feed to an Arduino analog input.

@OP: Are you programming the Baby Orangutan directly from the Arduino environment? If not, how are you using it?

jremington:
@OP: Are you programming the Baby Orangutan directly from the Arduino environment? If not, how are you using it?

I'm using the Arduino app.