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