Bipolar Stepper Motor Problems

Hi,

I have a 4 wire stepper motor that I can't seem to get working properly. I tried setting it up with the example code for full revolutions. It turns anti-clockwise (but not fully) and won't turn clockwise at all, it just vibrates.

Any suggestions of what I might be doing wrong, I have tried many combinations of wires to inputs.

Thanks.

You will have to show us a diagram of how you have wired it (draw a sketch and take a photo of it?) and give details of the electronic hardware and software you are using.

...R

Thanks for your reply, its weird I now hooked it up again to take a picture and it started to turn a full 360 degrees anti-clockwise, however it is inconsistent, and still doesn't turn clockwise although sometimes turns a few degrees clockwise.

I am using the example code given within the arduino program:

/*
Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#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 pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(20);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(1000);

// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(1000);
}

I am using a Nema 17 stepper motor, 1.8 degree, marks on the motor read:

LDO 42STH47-1684A
121111 LDO MOTORS

Thanks for reading.

Try reducing the speed, it sounds like you are trying to drive it too fast.

Questions you need to answer:

What is the power supply for the motor?

Which motor driver board are you using?

How have you wired it up?

Do you understand that that's a 1.6ohm, 1.7A motor designed for chopper-drive only
and needs a decent stepper motor driver to it working properly?

Hi,

I am just using the given code to test the motor.

I also tried today using the L293D IC with this tutorial jonandnine: Stepper motor control using Arduino and L293 I also have issues using this, the stepper just shakes again.

In the example code it sets the speed at 60, which I changed to 20, it makes a difference but if you reduce it to about 5 it just gets worse again.

With the tutorial jonandnine: Stepper motor control using Arduino and L293 it doesn't call for an external power source, although I am sure I will need a bigger supply than the 5v from the arduino board.

hen:
although I am sure I will need a bigger supply than the 5v from the arduino board.

You are certainly correct about that. You need a proper motor driver too.

Wiring a motor like this can damage your arduino. I am supprised you got any movement at all.

I had no idea that it could damage the arduino, how come they put it in the examples?

Is the L293D driver suitable?

The L293 is not really suitable - it is really meant for DC motors. A Pololu a4988 would be a much better choice. It is specifically for stepper motors up to a max of 2 amps and just needs 2 connections to the Arduino - step and direction. If you want to consider other boards make sure they are for driving stepper motors.

...R

There are a lot of questionable examples on the web. And as pointed out, the motor you are using is designed to be used with a chopper driver IC.

A board based on a chip like the A4988, such as the Pololu A4988 carrier board, would be a good match for that board. It can drive up to 1A as-is, or up to 2A with a small heatsink and forced air. You can also find suppliers on eBay of compatible boards that include the heat sinks.

Note that these are not shields, you'll need to plug them into a protoboard to make the proper connections. Also, you do NOT use the stepper motor library with these. They only require !Enable, Step, and Direction. I am working on some code for several projects, I started with the Blink Without Delay sketch, changing it to use micros() instead of millis().

I don't think you've ever told us which motor shield you are using. That information is of prime importance.

Sorry I am very new to this, if I bought a Pololu A4988 would I still need a motor shield?

Thank you all for your replies, it really is appreciated.

No you would not need the motor shield. Nor the stepping libary.

The A4988 takes the place of the motor shield. I have written my own code to drive them so I don't know if there is a suitable library.

Basically you need to connect a Uno pin to the step input to the A4988 (and have a common ground) and turn the pin high and low in succession (it should work fine if highs and lows are 800 microseconds long or greater - I think shorter pulses will work if you need faster motion - you can experiment).

If you want to control direction you need to connect an Arduino pin to the direction input. High will go one way, low the other.

If you want to use microstepping you will need to set some other pins. This could be done by using more Arduino pins or by hardwiring - look at the specification sheet.

Obviously you also need to provide a motor power supply for the A4988.

...R

Thank you very much, I've ordered a A4988, I'll let you know in the next couple of days how it goes.

Cheers

Hi so I got the A4988 today, I am trying to write some code for it, but I am not sure weather it is my code that is wrong or my wiring.

int turn = 2;
int dir = 3;


void setup() {                

  pinMode(turn, OUTPUT);  
  pinMode(dir, OUTPUT);  
}


void loop() {
  
  digitalWrite(dir, HIGH);         
  digitalWrite(turn, HIGH);   
  delay(1000);     
}

Should I be using enable?

Thanks.

The motor will move one step for every pulse on your turn pin. A pulse is a short period high followed by a period low. The high period should work if it's 800 microseconds or so. The low shouldn't be shorter, but obviously it can be longer if you want slow steps.

The dir pin should stay high (or low) until you want to change direction.

...R

so I have changed to code to

int turn = 2;
int dir = 3;


void setup() {                

  pinMode(turn, OUTPUT);  
  pinMode(dir, OUTPUT);  
}


void loop() {

  digitalWrite(dir, HIGH);  

  digitalWrite(turn, HIGH);   
  delay(800); 
  digitalWrite(turn, LOW);  
  delay(800);
}

But still nothing, can you see what I am doing wrong?

Thanks

It looks from your diagram that you failed to connect /reset and sleep. A capacitor is strongly advised across the motor power supply, close to the driver board. Consult Pololu's recommended hookup at Pololu - A4988 Stepper Motor Driver Carrier, Black Edition