Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Detecting motor stop with an AVR

Status
Not open for further replies.

LiquidKernel

New Member
I'm wondering how I would use a comparator on an Atmel AVR (ATtiny11 to be exact) to detect when a motor has been forced to stop. Should I be looking into detecting a change in current drain? Thanks.
 
LiquidKernel said:
I'm wondering how I would use a comparator on an Atmel AVR (ATtiny11 to be exact) to detect when a motor has been forced to stop. Should I be looking into detecting a change in current drain? Thanks.

Yes, assuming you can't use a simple limit switch at the end of travel.

Monitoring the current will also force a stop if the motor gets jammed in any way, which may be an advantage - if you could implement both current limiting and limit switches you have the best of both worlds.
 
Thanks for the help Nigel.

I am not interested in using a limit switch, as I only want to interface to the motor's power leads.

How would I detect a change in current using an AVR that doesn't have an ADC but only has a comparator? I've searched high and low around the 'net and have yet to find a valid answer to this solution. Even though I've seen this in lots of applications, I still don't know how it's done.
 
You can probably use the comparator to monitor the voltage across the motor. For instance, if your motor runs on 5V, use a voltage divider to setup one side of the comparator to your threshold value. Monitor the motor voltage with the other lead. When the motor is stalled, the current will go up, the voltage will go down and your system will detect it. You want to run another supply for the motor.
 
crust:

The motor gets about 10Vs during normal operation. I have a stable 12V supply, which is not connected to the motor. I noticed when the motor stalls it drops two volts to 8V. Is that enough to detect a stall?
 
LiquidKernel said:
crust:

The motor gets about 10Vs during normal operation. I have a stable 12V supply, which is not connected to the motor. I noticed when the motor stalls it drops two volts to 8V. Is that enough to detect a stall?

That's more than enough! - usually you would add a small value series resistor and monitor the voltage across it.
 
LiquidKernel said:
Sounds good.

I'm wondering what a current sensing resistor is, I am being told to use one with a value of 0.01ohms.

It depends what current you are trying to sense, and how much voltage you can afford to drop during normal use. This simple design will provide a high level output if the current exceeds about 700mA - you can increase it by decreasing the value of the 1 ohm resistor.
 

Attachments

  • Over_Current.GIF
    Over_Current.GIF
    2 KB · Views: 1,269
That sounds like something I could use! Thank you Nigel.

However, when the over current pin is not sent high, does it leak any amount of voltage? I'm wondering this because perhaps it might constantly send the AVR's input high.
 
LiquidKernel said:
That sounds like something I could use! Thank you Nigel.

However, when the over current pin is not sent high, does it leak any amount of voltage? I'm wondering this because perhaps it might constantly send the AVR's input high.

No, it shouldn't leak any current under normal use, however as there's no form of hysteresis (not quite sure about the spelling!) it won't give a sharp switch, but will gradually rise as current increases around it's switching point. By careful selection of the resistor value, and how the software reads it you should easily be able to get an extremely effective design.

Bear in mind that as the motor turns, and also from a cold start, it might briefly trigger the overcurrent sensor - your software should take account of this - simply by requiring the sensor line to be high for a specific amount of time. So if you sample the line every 50mS, you should wait for something like 10 sucessive over current readings before concluding it's reached the end.

You can obviously tailor these figures as you require, but presumably you get the idea?.

Obviously for testing purposes, you could simply use a voltmeter on the sensor line and see how it works - adjusting the value of the 1 ohm accordingly. As you can see, it's very simple and cheap, so you can afford to experiment a little!.
 
Big thank you for your help Nigel, I haven't gotten this much help on this subject for anyone else yet.

I have a question though, if the polarity changes to the motor, what would happen to the over current pin? I'm asking this because the motor I am monitoring has it's power change polarity to change direction and I am interested in detecting when it stalls in both cases.
 
LiquidKernel said:
I have a question though, if the polarity changes to the motor, what would happen to the over current pin? I'm asking this because the motor I am monitoring has it's power change polarity to change direction and I am interested in detecting when it stalls in both cases.

As long as you switch the motor after the current detection circuit it won't make any difference, it will work just the same in both directions.

It would also probably be a good idea to put a resistor in series with the base of the transistor - to limit base emitter current in the event of a short circuit on the output.
 
How would it still work if the NPN transistor will be getting a different polarity? That's what I'm wondering.

I am also finding in news groups that I can use an LM731 opamp to detect a change in current, I'll probably look into that as well.
 
LiquidKernel said:
How would it still work if the NPN transistor will be getting a different polarity? That's what I'm wondering.

It won't be getting a different polarity, that's why you switch the motor after the circuit and not before it. Obviously if you switched the supply going in to the circuit it wouldn't work, but there's no reason to want to do that.

I am also finding in news groups that I can use an LM731 opamp to detect a change in current, I'll probably look into that as well.

You can use pretty well any opamp to monitor the current drop across a resistor, but it's probably going to be more complicated than this simple circuit. The biggest problem is likely to be the supply for the opamp, you may need to provide a higher supply just for the opamp (and perhaps a negative supply as well). However, using a rail to rail opamp may overcome these problems.

The advantage of using an opamp is you can have a much smaller voltage drop across the resistor - with my simple design it needs 0.7V, which gives about 0.5W with the 1 ohm I used, correspondingly higher with lower resistors and higher currents.

But it's so simple, throw it together and try it with a meter!.
 
Since under stall conditions his motor drops 2V, I dont see a need to use the current sensing resistor. The motor is in effect the current sensing resistor. My suggestion is to just monitor the voltage across the motor. So his operating voltage is 10V I would set the reference voltage at the AVR to 3.6V or so with a voltage divider from the AVR supply. Then just use a simple voltage divider/capacitor combo to monitor the voltage on the positive leg of the motor. I would probably set each of the ratios to 0.4 so your reference is 3.6 and your motor is 4 during operation and 3.2 during stall conditions. The capacitor is just a low pass filter to get rid of any transients. You could also use an LM311 comparator and use its hystersis function. There is a post be me somewhere on these board with a trace from a system where I was monitoring a motor and running a comparator. Worked like a champ.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top