Hello everyone.
I just got a Arduino Uno and a motor shield. I am hoping to run a stepper motor that I had laying around, but I fear it may be a little too big. It is an Applied Motion motor, here are the specs:
I only need about a half-pound of torque, so I think it may be possible.
All I need is a push-button start feature, and for it to ramp up to a constant rpm. say, 20hz.
Not sure on where to start with code for this. being an EE, I have a lot of experience with electronics, but only a little with arduinos. (push buttons turning outputs on and off, etc..) I have never done anything with steppers.
If the shield is not capable of running this motor, can anyone recommend an alternative driver circuit? Discrete or otherwise.
Thank you for all the help.
Hi,
I don't own a motor shield, but I have a stepper motor driver and a 2 phase stepper motor. The main point is to continuously switch on and off the poles so that it pushes the rotor. One such cycle of commands makes the motor turn one step.
The code for my motor:
int motorPin1 = 12; //ORG - wire 1
int motorPin2 = 8; //YEL - wire 2
int motorPin3 = 7; //PIK - wire 3
int motorPin4 = 4; //BLU - wire 4
//you have to lookup the correct order in the datasheet for the motor to make one step
int delayTime = 20; //
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void loop() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
I didn't have much luck with that code, but I got some life with this one:
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 12,13);
// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;
int x = 0;
void setup() {
Serial.begin(9600);
// set the PWM and brake pins so that the direction pins // can be used to control the motor:
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
Serial.begin(9600);
// set the motor speed (for multiple steps only):
myStepper.setSpeed(40);
}
void loop() {
myStepper.step(200);
delay(2000);
myStepper.step(-200);
delay(2000);
}
In line 27 the speed can be set. But when I try to put anything over "50" the motor just sort of grumbles slowly. Anybody know what the cause of this may be?
Also, When I try and hook up an external 12 volts to the shield, the big chip on the shield gets pretty hot very quickly. Polarity is ok, but what else may be the cause of that?
precisionb:
I only need about a half-pound of torque, so I think it may be possible.
All I need is a push-button start feature, and for it to ramp up to a constant rpm. say, 20hz.
A pound isn't a unit of torque, and Hz is per second, not per minute, so what values
do you actually mean?
Can you say which motor shield and show how its wired up to the two windings of the motor?
The datasheet implies its an 8 wire motor, so there are two ways to wire it up for bipolar use.
Can you provide a diagram of how you have the motor wired up?
What are you using to power the motor? Has it enough amps and volts?
It's much easier to drive a stepper motor with a specialized driver board such as the Pololu A4988 which allows you to set a current limit and only needs two connections to the Arduino - step and direction.
Robin2:
You haven't said how the motor is powered?
The drawing you have provided is how it is supposed to be connected. Are you sure it really is connected properly?
...R
Robin2,
I appreciate your help, but if you read the whole thread, I stated earlier that I have gotten the motor to run, but I'm having trouble getting it to run at faster speeds. If I had made the simple mistake of connecting it incorrectly, wouldn't I have an issue of no motor movement at all?
I have plenty of electronic experience, just that I am somewhat of a "noobie" when it comes to Arduino microcontrollers. I could be wrong, and I have certainly made my fair share of silly mistakes in the past, but I think I deserve at least a little more slack...
Again, I appreciate yours and anyone's advice and input. But please read the whole thread (or at the very least my posts) before throwing up obvious knee-jerk speculations... Thank you.
-P
@precisionb - I wasn't trying to take away your slack. You must take into account that
(1) you have all your stuff there in front of you but all I have is what you say.
(2) how can I know whether you already know the top from the bottom of a screwdriver.
(3) after reading several threads it can be difficult to remember what may have been previously said in your thread.
(4) it would take me a long time to learn enough about your project to understand it without detailed help from you.
So ...
The answer to the question "Are you sure it really is connected properly?" is YES
And the answer to the question "What are you using to power the motor? Has it enough amps and volts?" is ????
precisionb:
In line 27 the speed can be set. But when I try to put anything over "50" the motor just sort of grumbles slowly. Anybody know what the cause of this may be?
To drive steppers at high speed, you generally need to do 2 things:
Use a chopper-type stepper motor driver (for example, a A4988-based board from Pololu or eBay) and a higher supply voltage
Accelerate and decelerate the stepper gradually (see the AccelStepper library)
precisionb:
Also, When I try and hook up an external 12 volts to the shield, the big chip on the shield gets pretty hot very quickly. Polarity is ok, but what else may be the cause of that?
That's hardly surprising. With the windings connected in parallel, the current rating of that stepper is 1.4A per phase and the resistance is 3.6 ohms. That give a maximum steady voltage per phase of 1.4 * 3.6 = 5.04V. Adding in about 3V voltage drop in the L298 chip on the board, this means the the maximum supply voltage you should use is about 8V. If you apply 12V, you will exceed the current rating of both the stepper motor and the motor driver chip.