Go Down

### Topic: Detecting "Physical" Resistance from Stepper Motor (Read 9307 times)previous topic - next topic

#### arsene2conde

##### Dec 08, 2012, 06:48 am
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? https://www.sparkfun.com/products/8883).  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);
}

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);

}

int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
}

#### weldsmith

#1
##### Dec 08, 2012, 08:02 am
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!
David Smith

#### Boffin1

#2
##### Dec 08, 2012, 08:14 am
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.
45 years of editing projects with a knife and soldering iron, then I found Arduino !

#### sbright33

#3
##### Dec 08, 2012, 08:55 am
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.

#### PeterH

#4
##### Dec 08, 2012, 03:23 pm
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.

#### arsene2conde

#5
##### Dec 09, 2012, 10:03 pm
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!

#### arsene2conde

#6
##### Dec 11, 2012, 06:36 pm
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!

#### sbright33

#7
##### Dec 11, 2012, 07:37 pm
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

#### PeterH

#8
##### Dec 11, 2012, 08:46 pm
Quote

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.

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?

#### sbright33

#9
##### Dec 11, 2012, 11:40 pm
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.

#### PeterH

#10
##### Dec 12, 2012, 12:20 am
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.

#### MarkT

#11
##### Dec 12, 2012, 03:08 am

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.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### sbright33

#12
##### Dec 12, 2012, 06:08 am
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.

#### Grumpy_Mike

#13
##### Dec 12, 2012, 09:38 am
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.

#### PeterH

#14
##### Dec 12, 2012, 03:21 pm

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

Remind me what is being measured at A0?

Go Up