Motor Stall Detection ???

joe paul

Senior Member
Hi Folks,

I am playing around with an idea to detect motor stalling when using PWM with a simple 12 VDC permanent magnet motor. Do I have the voltage divider in the right configuration in relationship to the MOSFET?




Thanks!

Take care, Joe.
 

rq3

Senior Member
Hi Folks,

I am playing around with an idea to detect motor stalling when using PWM with a simple 12 VDC permanent magnet motor. Do I have the voltage divider in the right configuration in relationship to the MOSFET?




Thanks!

Take care, Joe.
Because the 10K ADC resistor is connected to ground, it will always read...ground (zero volts). I think what you intended was to place the 10K in series with the 20K to ground, and then have the ADC connection at the junction between the two resistors. If I was Hippy, I'd draw some neat Ascii art, but I haven't his skill!
 

joe paul

Senior Member
Because the 10K ADC resistor is connected to ground, it will always read...ground (zero volts). I think what you intended was to place the 10K in series with the 20K to ground, and then have the ADC connection at the junction between the two resistors. If I was Hippy, I'd draw some neat Ascii art, but I haven't his skill!
Hi rq3,

Thanks! I knew it looked wrong, will post the correction shortly for approval.
Take care, Joe.
 

joe paul

Senior Member
Hi Folks,

I corrected the diagram instead of leaving the wrong one up. Thanks again to rq3 for catching my blunder! Now I need to figure what values I should be getting when the motor stalls. Any input welcomed. (Laid up today, medicine-head stupor.)

Thanks, Take care, Joe.
 

premelec

Senior Member
Put a small resistor between the Source and V- and detect current [filtered because of PWM] on that so you don't have to rely on Rds ON value which is somewhat uncertain. [here it's snowing and 15 DegF].
 

joe paul

Senior Member
Put a small resistor between the Source and V- and detect current [filtered because of PWM] on that so you don't have to rely on Rds ON value which is somewhat uncertain. [here it's snowing and 15 DegF].
Hi Premelec,

Thanks for the info!

Take care, Joe
 

techElder

Well-known member
What are the power requirements of this "simple 12 VDC permanent magnet motor"?

What will determine "motor stalling when using PWM"?

Is there some pulsed/low frequency load situation that will be detected as a "stall" condition?

Is the motor "stalled" if the "MOSFET" goes to a constantly conducting state (shorted?) What makes that state different?
 

goom

Senior Member
Bear in mind that the stalled current of the motor will vary with the PWM duty cycle, so you may have to do some calculations which accommodate this. You could explore the relationship by experimentation with the shaft locked.
It may be better/easier to actually measure rotational speed via a sensor on the motor shaft. If the speed of detection does not need to be rapid, then perhaps a temperature sensor mounted on the motor casing would provide useful information.

Kevin
 

joe paul

Senior Member
What are the power requirements of this "simple 12 VDC permanent magnet motor"?

What will determine "motor stalling when using PWM"?

Is there some pulsed/low frequency load situation that will be detected as a "stall" condition?

Is the motor "stalled" if the "MOSFET" goes to a constantly conducting state (shorted?) What makes that state different?
Hi Tex,

Thanks for the reply! The motor: https://product.mabuchi-motor.com/detail.html?id=52
If I knew the answers to your questions, I probably wouldn't need any help. I was hoping to just retrieve some values from the ADC pin and see if I can make some sense of it all, a very crude attempt. The power supply would be various wall warts or converting AC to DC with a rectifier and capacitor. Perhaps I am in over my head, but I thought I'd try something.

Take care, Joe
 

joe paul

Senior Member
Bear in mind that the stalled current of the motor will vary with the PWM duty cycle, so you may have to do some calculations which accommodate this. You could explore the relationship by experimentation with the shaft locked.
It may be better/easier to actually measure rotational speed via a sensor on the motor shaft. If the speed of detection does not need to be rapid, then perhaps a temperature sensor mounted on the motor casing would provide useful information.

Kevin
Hi Kevin,

Thanks for the info! I saw something with the "Ardoonie" that seemed so simple. (Oh yes, I have strayed.) I just wanted a simple, crude solution to prevent motor burnout in a stall situation, something with just one IF/THEN statement, anything over a particular figure would trigger a restart or shutdown. This if for a trackside toy train circuit.

Take care, Joe.
 

Reloadron

Senior Member
I think you will find that measuring PWM current gets a little complex. Using a N-Channel MOSFET you can place a sense resistor of a low value like 1.0 Ohm Source to Common (Ground) with your motor between V+ and Drain. Place about a 10K resistor Gate to Common. As mentioned the motor current will change with the PWM Pulse Width. You take the voltage drop across the current sensing resistor and Integrate it since it will be pulsed current. Then amplify that following integration. This should give you the average current. That voltage, proportional to the motor average current can then be sent to your uC. This all being a guess on my part.

Ron
 

joe paul

Senior Member
I think you will find that measuring PWM current gets a little complex......

Ron
Hi Ron,

Thanks for the information! I'm putting this idea on the back burner. It is really more than I can handle right now. I have no electronics background. For example, with the PWM, I use a relay to reverse polarity to a motor, not an H bridge. I am somewhere between analog and digital, and take the simplest approach using what I understand.

Take care, Joe.
 

premelec

Senior Member
@joe paul - you can just look for change without much analysis - put the source to V- R in that will produce at least 1 volt on overcurrent and then put a diode from the source to a small capacitor's one end and capacitor's other end to V- . Put a 20K or so resistor across the capacitor to discharge it when no current coming into it. Watch the capacitor voltage with READADC. I don't know what your stalled currents will be but hopefully you do... To get an idea of how fast the capacitor will discharge from overcurrent calculate the 'time constant' which is simply R*C in seconds [keeping track of the decimal point is the main job. e.g. 1uF with 20000 = .000001 * 20000 = .02 seconds. [if I got the decimal point right...]. Go empirical with the values you are working with... ;-0
 

hippy

Technical Support
Staff member
Late with the ACII art but I would do it pretty much how premelec suggests, it may need an R across the cap to speed its discharge, or you could perhaps set the ADC input output low to discharge through the 22K -

Code:
12V >---.
       .|.
      -----
     /     \
    |   O   |
     \     /
      -----
       `|'             ___
        }-----|>|--.--|___|---> ADC
        |          |   22K
   __|--'        __|__
     |--.        --.--
       _|_        _|_
Make sure the cap is rated 16V or even 25V if electrolytic. The voltage on that C may be higher than the PICAXE input is rated for but the resistor will current limit that. You would have to test it to see what ADC readings you are getting. If lucky you might find you can read it as a digital input going high when it stalls, even interrupt on that.

You might need some delay after turning the motor on to avoid any in-rush current appearing to be a stall.

Of course, in a perfect world the FET will be a pure short to 0V when turned on even under stall conditions, so you might not get much voltage on the C at all. That's what prototyping is for :)
 

premelec

Senior Member
hippys' schematic is the right idea but wrong place as whenever the FET is off the full 12 volts goes out the diode - my suggestion is a small current sense resistor from source to V- so sense voltage never goes more than a few volts worst case. It's not good to rely on Rds ON as that's variable with parameters external to the part....
 

AllyCat

Senior Member
Hi,

IMHO this is not a particularly "difficult" problem, but several of the important details mentioned in this thread are being overlooked. Firstly. Joe has linked to the motor data which specifies the voltage range is 6 - 24 volts (nominal 12), the current at maximum efficiency is 110 mA and the stall current is 420 mA (presumably at 12 volts).

As premelec has said, to detect the stall you must measure the current, most simply by putting a resistor in series with the Source pin of the FET (so the voltage drop can be measured relative to earth). One Ohm is a very convenient value and probably optimum for this application. Half an amp (d.c.) dissipates a quarter of a watt in one ohm, which is the typical rating of a standard CR/MR25 resistor.

The PICaxe ADC input pin could measure the voltage directly across this resistor, but it would be better to connect via a resistor of 1k - 10k. This will protect the PICaxe against any "accidental" current flow and gives the option to add a capacitor (perhaps 100 nF) across the ADC input, to act as a low-pass-filter (to average the value of the current).

But as goom has indicated, the stall current will vary with the PWM ratio in a rather complex way. Firstly, the PWM reduces the effective voltage applied to the motor, so the stall current will be less. Secondly, the resistor is measuring the motor current only when the FET is switched ON*, but the motor current continues to flow (via the catching diode to the supply rail) when the FET is OFF. Normally, the inductance of the motor will filter the current to almost d.c. (with some ripple), unless the PWM frequency is very low**.

* A resistor directly in series with the motor could be better, but this would require measuring the voltage drop relative to the (12 volt) supply rail, or "inverting" the whole output stage (motor to ground) which would need a high side switch (e.g. P-channel FET and driver).

** Very low frequency PWM is sometimes used with small model motors because it offers subjectively higher torque, by giving "kicks" that overcome the static friction (rather as a hammer is more effective at fixing a nail than trying to just push on it). But the functional analysis is likely to be more complex.

The structure of the software for stall detection is mainly a matter of personal choice. The voltage drop across 1 ohm won't be high, but a READADC10 should give sufficient resolution, or the sensitivity could be increased by using a FVR for the ADC reference. A capacitor across the ADC input might help filter a (single) ADC reading, but taking a burst of multiple ADC readings may be more informative. They could be simply averaged, or a peak value extracted. Then the value will need to be scaled or compensated to take into account the present PWM value.

Finally, it hasn't been mentioned that the stall current is very easy to measure or calculate. Just Ohms Law: The stall current is given simply by the (effective) voltage applied to the motor divided by its dc resistance.

Cheers, Alan.
 
Last edited:

premelec

Senior Member
I'd go for current sense R at least 5 ohms and use series diode to make enough voltage at .4 amp to get the diode conducting well and give some room to play with what you want to consider 'stall'...
 

goom

Senior Member
For a stalled motor with 100% duty cycle (i.e. DC), the load is indeed purely resistive and hence fairly easy to measure the current and detect the stall, However, with <100% duty cycle (part speed) the inductive component of motor windings comes into play. The calculation of the effective impedance of the motor windings then becomes much more complicated, and way beyond my ability to calculate. So, if stall detection at part power is required this becomes really difficult.

In my view the only practical solution would be to measure the (averaged) stall current at various PWM duty cycles, and then use a lookup table to predict the current for a given duty cycle and compare it to the measured value.

Measuring the speed of a shaft somewhere in the drive train would seem to me to be one way to go. If the objective is to just to prevent motor burnout, then monitoring a temperature sensor attached to the motor casing may be the simplest solution.
 

AllyCat

Senior Member
Hi,

Yes, it really depends if the purpose of the stall detection is to protect against over-heating, or to automatically increase the PWM (duty cycle) drive to a motor stalled by inadequate voltage. A motor driven by a low duty cycle PWM is of course quite likely to stall.

Personally, I don't think the analysis is too difficult (but I did first work with PWM / Class D circuits almost 50 years ago). The inductance of the motor turns the circuit into a "real" (energy-recovery) switching mode power supply (the PWM doesn't just "chop" the current as may be the case with a LED string). There are (at least) two ways to consider its operation at (e.g.) 50% duty cycle and fortunately they both produce the same answer. ;) :

1. 50% duty cycle gives the equivalent of a 6 volt power rail, so the stall current will be halved and the power in the resistance of the motor reduced to one quarter (because the voltage is also halved). But PWM power supplies have high efficiency, so the average current into the overall circuit will be (approximately) 420 mA / 4 = 105 mA.

2. As described in my previous post, the (stall) current in the motor is halved at 50% duty cycle, but the resistor only "sees" half of that because half of the time the current flows through the catching diode. So the average current measured by the resistor will again be one quarter, or 105 mA.

In both cases the (average) stall current is proportional to the square of the duty cycle, which is not too difficult to estimate. Note of course that the duty cycle is always less than (or equal to) unity.

I'd go for current sense R at least 5 ohms and use series diode to make enough voltage at .4 amp to get the diode conducting well and give some room to play with what you want to consider 'stall'...
Make sure that the resistor is rated to at least one watt: 420 mA squared through 5 ohms = 0.88 watt. The diode should indeed detect the "peak" current in the resistor, i.e. 210 mA average at 50% duty cycle, plus any ripple during the PWM cycle, but of course then the diode forward voltage drop must be subtracted. FWIW, more often, I put a forward diode across a current sense resistor to limit the voltage/power "lost" under high/overload conditions.

Personally I would prefer to either measure the average current flow (by a hardware or software method) and compare it with the square of the duty cycle, or take the "maximum" of multiple ADC measurements and make a linear comparison (plus any required correction for PWM ripple).

Cheers, Alan.
 
Last edited:

joe paul

Senior Member
Hi Premelec, Hippy, Goom. Allen, and Everyone,

Many thanks for all the information, I'll post here if I get something going!

Take care, Joe
 
Top