# How to detect high current

I am working on the project which involves running a DC motor which is used to raise/lower window glass in the vehicle.

While running, motor draws about 1.5A of current. However, when the window reaches the end of the sliders and the motor can no longer raise/lower the glass, it starts drawing up to 15A until you release the button.

I want to use AVR microcontroller to control this motor and would like to stop the motor when the window reaches the barrier. I managed to come up with three solutions thus far:

1. Use switches which will trigger and inform microcontroller when the window reaches the barrier. I'd like to avoid this because this means installing two switches per window and running extra cables to the microcontroller.
2. Use timer function which will turn off the motor after a specific amount of time. This is not applicable because the voltage may vary and the motor might turn faster or slower than normal. Also, the window might be in an unknown position when starting the timer (all the way up, in the middle...).
3. Use some kind of high current detector and route it to microcontroller's input, alerting the program when the current threshold is reached (say 5A). Something like a transistor, relay or similar device which can handle the current this high on the input.

I am pretty much a beginner when it comes to electronics, so I was thinking if there is a way to detect this high current (motor is running on ~12V) and provide this signal to microcontroller (which is running on 5V).

I'll appreciate any help. Thanks!

-
Similar question: electronics.stackexchange.com/questions/17246/… –  m.Alin Aug 9 '12 at 10:56

This should be pretty easy. You can detect the difference between 1.5A and 15A using a simple resistor. A value of 0.3 ohms will give 0.45v at 1.5A and 4.5v at 15A.

A digital input pin on the microcontroller will read 0 at 1.5A, and 1 at 15A.

You could wire this straight to the microcontroller's input pin, but it would probably be best to add a little filtering and protection.

RF and C1 provide a low-pass filter to make the voltage more stable.

D1 provides over-voltage protection in case the current greatly exceeds 15A.

-
A 12V motor which stalls at 15A has an armature resistance of 0.8Ω so there will be about 3.3V across R1 which will dissipate nearly 36W! –  MikeJ-UK Aug 9 '12 at 11:48
@MikeJ-UK - How long for? The MCU will switch off the motor within a millisecond or two. The typical power dissipation will be only 0.675W. –  Rocketmagnet Aug 9 '12 at 11:59
True I suppose, as long as the OP doesn't set inconvenient breakpoints in his debugger! –  MikeJ-UK Aug 9 '12 at 12:05
@MikeJ-UK - Haha! Yes. I've burned out motors before because of breakpoints. But that problem is the same whatever is used to sense current. Don't forget that the motor dissipation will be 180W during stall! –  Rocketmagnet Aug 9 '12 at 12:21

Allegro has a number of current sensor ICs, based on Hall effect sensors. The ACS712 can detect currents up to 50 A.

The ACS712ELCTR-20A-T has a sensitivity of 100 mV/A, so you can use the microcontroller's ADC to detect when the 500 mV (5 A) threshold is reached, or better, use a comparator, which interrupts the microcontroller. Many AVRs have a comparator on-chip, with an interrupt exclusively assigned to it.

The ACS712 has a current sense path resistance of only 1.2 mΩ, so even at 15 A it will only dissipate 270 mW, which it can sustain forever. That's the main advantage over a more traditional current sense resistor as in Rocketmagnet's answer. There you need a relatively high resistance to get the high level at 15 A. Mike calculated that Rocketmagnet's sense resistor will dissipate 36 W when the motor stalls, so timing is critical there (for a moment disregarding the 131 W dissipation in the motor). Even so, a 5 W type is recommended for the sense resistor.

-
Timing is critical no matter what the solution. Everyone's focusing on the 36W dissipation of the resistor, but completely forgetting about the 180W dissipation of the motor! That motor is going to burn out pretty quickly. –  Rocketmagnet Aug 9 '12 at 16:45
@Rocket - I did mention the motor, only mine is 131 W, which is high enough. You're right though, that you should respond fast, but at least the Allegro sensor won't be a problem. I mention the 5 W because most resistors won't allow > 10 x nominal power, even for a moment. I think your sense resistor can be chosen smaller, since most controllers will see 0.7 Vcc already as high, and then at 15 A that's 0.23 &Omega;. –  stevenvh Aug 9 '12 at 16:58