Pages: [1] 2   Go Down
Author Topic: Detecting "Physical" Resistance from Stepper Motor  (Read 2929 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
  // 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);
  }
}
Logged

Woodland Washington
Offline Offline
Newbie
*
Karma: 0
Posts: 33
Live life to it's fullest
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

David Smith

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1222
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12725
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Remind me what is being measured at A0?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1] 2   Go Up
Jump to: