Detecting "Physical" Resistance from Stepper Motor

Hi guys,

I am working on a project and it would be very useful to know how to detect resistance from a stepper motor. When I say resistance, I mean the resistance the stepper motor experiences during its motion. For example, in my project I am using the stepper motor to open and close a door.
I want to be able to stop the motion of the stepper motor if there is an obstacle on the way of the door's path when opening or closing. I would like the stepper motor to stop its motion for a few seconds, then resume its motion.
I am using a 12V, 1.6A Bipolar stepper motor using the SN75441ONE H-Bridge: http://www.robotshop.com/geared-bipolar-stepper-motor-3v-233-oz-in.html?utm_source=google&utm_medium=base&utm_campaign=jos

The code works perfectly but I don't know how I could make what I am looking for happen. My thought was to use the speed and time to detect any type of resistance.
For example, setting the stepper motor at a certain speed, if the position is not found to be where it is supposed to in the required time, then that would be picked up as a resistance in the motion. Is there anyway to program something like this with the Arduino or is there a chip to use (maybe something like this? SparkFun Current Sensor Breakout - ACS723 (Low Current) - SEN-14544 - SparkFun Electronics). If there is such a code, what would it look like?

Any help will be greatly appreciated. Thank you!

Here is the code I am using:

#include <Stepper.h>

#define motorSteps 200

#define motorPin1 8
#define motorPin2 9
#define motorPin3 10
#define motorPin4 11
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);

void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(30);

// Initialize the Serial port:
Serial.begin(9600);

// set up the LED pin:
pinMode(ledPin, OUTPUT);
// blink the LED:
blink(3);
}

void loop() {
// Step forward 100 steps:
Serial.println("Forward");
myStepper.step(500);
delay(500);

// Step backward 100 steps:
Serial.println("Backward");
myStepper.step(-500);
delay(500);

}

// Blink the reset LED:
void blink(int howManyTimes) {
int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
}

Have you thought of using an encoder or home made rotary pulser. and compare the drive signal to the feed back signal. This is a bit crude but it would be an easy blockage detector. This sounds like a neat project but there is no one way to do this one. have fun!

You could mount the motor with a spring or sponge that will let the motor twist when resistance is felt, the motor hits a microswitch. They used this on garage doors here for years.

BTW when you post code, select it and hit the # icon up there above the smileys, and it will put it in a code box to save space.

1 Like

You can measure the voltage on the winding of the stepper. Any winding of 4. It may only be a few mV different when there is a load, depending on the motor and controller. You only need a resistor to hook it to A0 on Uno. Have you seen my code under the Motor section of this forum? It does exactly what you want.

Unless your stepper motor deliberately provides a torque output, I doubt that it will be possible to determine torque just from the stepper drive side. In any case, I would have thought that inertial loads would be high relative to the loads you'd need to detect to stop crushing somebody, and measuring motor torque is not the ideal approach for that. If you really need to go with this then I would think that a sprung switch mechanically connected to the motor so that the torque of the motor operated the switch would be the best way to detect excessive torque.

A light curtain or contact sensor along the leading edge seems like a much better approach, if you can do that.

Hey guys,

Thanks for the advice. I will look at your forum sbright33. Good call on the microswitch Boffin1, I did not know a garage door opener had this included...I just thought it was the light detector and would turn off automatically if it sensed anything on its path.
I will look into that.

Thanks guys!

So I always wondered how a CD/ROM tray on a desktop computer worked. When the user pushes on an open tray, the tray closes automatically. On the other hand, if you introduce resistance to the tray when trying to open, it stops and some clse again when detecting resistance (such as the CD being stock or the user's hand).
This is EXACTLY what I need for my project. Does anyone know how this mechanism works? is it part of the program or is it a mechanical system?

If anyone knows how it works, it will be greatlt beneficial. I believe the tray openers operate with Stepper motors as well.

Thank you!

It feels very similar to a CD-ROM tray when you test it. PeterH you're mistaken, it does exactly that with the specific hardware I mention in the link. The code is on Gist, the discussion here:

http://arduino.cc/forum/index.php/topic,85335.45.html

Unless your stepper motor deliberately provides a torque output, I doubt that it will be possible to determine torque just from the stepper drive side.

sbright33:
PeterH you're mistaken, it does exactly that with the specific hardware I mention in the link. The code is on Gist, the discussion here:

http://arduino.cc/forum/index.php/topic,85335.45.html

How then do you measure torque?

I didn't mean to imply you can measure torque accurately. And I don't understand how it works. It just does. You can detect when torque changes. Very small changes if you want by calibrating the code. Just hook any 1 stepper coil to analog input on Arduino with an arbitrary resistor to protect it.

That's the part I don't understand. Don't these stepper motors work by having multiple coils interacting with multiple rotating magnets, arranged so that the rotor tries to drop into alignment with the energized coils? The torque generated surely depends on the misalignment between the rotor and the coils, and the current through the coils, not just on the current. I don't see how you could know what the actual delivered torque is just by looking at the currents and voltages across the coils. If there was no load on the rotor then you could put as much current through the coil as you wanted (short of actually burning it out) and the nett output torque would still be zero.

arsene2conde:
So I always wondered how a CD/ROM tray on a desktop computer worked. When the user pushes on an open tray, the tray closes automatically. On the other hand, if you introduce resistance to the tray when trying to open, it stops and some clse again when detecting resistance (such as the CD being stock or the user's hand).
This is EXACTLY what I need for my project. Does anyone know how this mechanism works? is it part of the program or is it a mechanical system?

If anyone knows how it works, it will be greatlt beneficial. I believe the tray openers operate with Stepper motors as well.

Thank you!

CDrom trays use a simple DC brushed motor - overload would be detected by higher current being pulled by the motor.

Peter let me try to clarify. I can't measure torque with this method. I can only measure changes in torque. This only works while the motor is RUNNING at a constant speed. With a constant load to get the correct normal value. It must stay like this for some time to cancel the outlying values. Then when this load changes, the average value measured at A0 changes too. It works every time if the change is significant, well before any damage is done to the motor or the mechanism supporting it. I use it to detect when I get to the physical stop at the end of the movement range. I can also detect when the torque goes to zero when it was more.

CD trays are all DC motors as was said. They work just with mechanical switches. You push the tray and the end stop switch is broken, the motor then turns until the other end stop is broken.

sbright33:
when this load changes, the average value measured at A0 changes too.

Remind me what is being measured at A0?

Just hook a stepper motor winding thru a 10k resistor to Analog input 0. Couldn't be simpler. Try my code, or write your own to view that value while it's spinning.

So you're measuring current through a winding, then? I suppose that if you average it this gives you an indication of back EMF and hence speed. I don't see how it gives you any information about torque, but if the demanded speed is constant I can see how it would give you an indication of slip, especially if you only need to differentiate between the 0% and 100% cases.

No, I'm measuring voltage. The resistor is only there to protect the Uno, it works without it. I don't know how it works. It just does! Try it! It does not only measure slip. It measures a change in TORQUE when you lightly hold or release the shaft while it is spinning at a constant speed. It does this even before there is any slip. It is so sensitive, with the proper code, you can just barely touch a 1" radius disc mounted on the shaft which already has a constant torque applied. It will detect this touch. It takes a small bit of force to detect the torque of touching a thin shaft because the radius is much smaller. Keep in mind there is a ULN2003 driver wired up the normal way. The timing of the measurement may also be important, see my code.