Problems with Arduino + Easydriver + bipolar stepper

Hello,

this is my first post on this board. Since i have not found a propper solution so far i hope you guys whith much more experience can help me.
I am currently building a barndoor mount for astrotracking. The system is driven by a stepper motor and controlled with an arduino uno rev3 + easydriver v4.4. I am following the great tutorial here: http://fstop138.berrange.com/2014/01/building-an-barn-door-mount-part-1-arduino-stepper-motor-control/

The wiring is provided within the link.

I wired everything up, and from the debug output all my switches are working as intended. Then i tried to test it. To power the system I took 8 AA batteries in series, giving me a total measured voltage of 12.02 V. SO they were not fresh but they schould have still enough power.
The wiring is provided in the link above and i tried several motor test programms. The problam seems to be that the motor skips steps and only works occasionally. Most of the time the motor is just vibrating.
The polarity seems to be also correct: Black + Green and Red + Blue. Wired ABCD: I in the beginning i mixed the polarity witihin 1 phase, but not between phases. SO the easydriver should be still ok. To be 100% sure i checke the resistance of the coils per phase and i got 2 Ohms reading.
I am using 1/8 microstepping because i need smooth movement.

Else my power supply is to weak to drive arduino + stepper. ( I played around with the easydriver on board current limiter which can change the output to the stepper between 150 and 750 mA. From that fact i cannot overload my power supply, is that right? At certain values the motor starts turning but is not accepting any commands. Now the motor is just vibrating, with different magnitudes depending on set current.
I also noticed a drop of voltage form my power supply from 12 to ~ 10 V after initial connection and strange noise from my batteries ( that was when black and green wire were reverse). The measured current is 3A at the moment. Isn’t that strange given by the fact that the batteries only have 2A?

Hopefully, someone gan give me a tip. Do i have to select a different stepper?

Update i tested with a modified DC supply 5V 890mA, and still just rattling motor.

Here an overview of my specs:

Bipolar stepper:

Nema 17 standard
Step angle 1.8°
3.4 V
1.7 A/Phase
Resistance 2 Ohm
Inductivity 3 mH
4000g/cm torque

Easydriver v4,4
Arduino Uno rev 3

8 AA Battery power supply.

The code to test is the following using accel stepper libary

#include <AccelStepper.h>

int debug = 0;

int dgPinStep = 8;
int dgPinDirection = 9;

int anPinForeward = 4;
int anPinBackward = 5;
int anPinSpeed = 3;

AccelStepper stepper(AccelStepper::DRIVER, dgPinStep, dgPinDirection);

void setup() {
  pinMode(anPinForeward,  OUTPUT);
  pinMode(anPinBackward,  OUTPUT);  
  pinMode(anPinSpeed,  OUTPUT);  

  stepper.setMaxSpeed(3000);

  if (debug) {
    Serial.begin(9600);
  }
}

void loop() {
  int valForeward = analogRead(anPinForeward);
  int valBackward = analogRead(anPinBackward);
  int valSpeed = analogRead(anPinSpeed);
  int run = 0;

  if (debug) {
    Serial.print("Foreward: ");
    Serial.print(valForeward);
    Serial.print(" Backward: ");
    Serial.print(valBackward);
    Serial.print(" Speed: ");
    Serial.println(valSpeed);
  }
  if (valForeward < 512) {
    if (valSpeed < 512) {
      stepper.setSpeed(200);
    } else {
      stepper.setSpeed(2000);
    }
    run = 1;
  } else if (valBackward < 512) {
    if (valSpeed < 512) {
      stepper.setSpeed(-200);
    } else {
      stepper.setSpeed(-2000);
    }
    run = 1;
  } else {
    run = 0;
  }

  if (run) {
    stepper.runSpeed();
  } else {
    stepper.stop();
  }
}

Winding resistance way too low. I measured 33.8 ohms on my stepper motor that I biught from Sparkfun (#2398 ?). which would
probably work with AA batteries but if your winding resistance is really 2 ohms you might not even get it to work with “D” size batteries.

Check resistance again.
12V / 33.8 ohms = 0.355 A
This is about what I measured on my motor.
12V / 2 ohms = 6 A
good luck driving a 6A stepper motor with AA batteries.

First thing, an Easydriver can only supply about 0.75 amps. Even a BigEasydriver will be struggling with 1.7 amps. The Pololu DRV8825 might be better.

If you set the Easydriver to max amps it may be sufficient to make the motor move but I don’t know if it will be able to do any useful work.

This simple demo code should make the motor work - assuming you have the pins wired correctly

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0

byte directionPin = 6;
byte stepPin = 5;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 25; // milliseconds


void setup() 
{ 

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
}

void loop() 
{ 

}

One thing to watch out for is that I think the Easydriver boards default to microstepping whereas the Pololu boards default to full steps. If your board is doing microsteps you will need to increase the value of numberOfSteps accordingly.

Last but not least, if the batteries can’t comfortably supply all the amps required and their voltage falls it may result in the Arduino resetting itself. That can give very confusing symptoms. It only needs a voltage drop for a split second to cause a problem - remember the Arduino operates at 16 million instructions per second and it just needs a problem for one of them.

Try disconnecting your battery power from the Vin pin (but leave the ground connected) and power the Arduino from the USB connection.

…R

Thank you.
@rachemmel The stepper is rated 3.4 v so its 1.6 with 2 ohm. The guy in the guide is using a similar stepper in his project without any problem.
Thank you robin i will test it as soon as i have a sufficient wall wart. 12v 3A should be enough. Could you please give me an adivce on a bipolar stepper which works well with the easydriver? Found some in the range of 4 to 7 v and around 0.5A per phase.

I found 1 problem with the wiring i mixed step and dir. Now it is turning according to my switch position but not very smooth. The smoothest result is with 300mA. When the motor is set to stop its producing a a high frequency tone. Atm i just have a 5v 0.9A wall wart to test. And the controller is becoming quiet hot.

Xenotime:
Could you please give me an adivce on a bipolar stepper which works well with the easydriver?

I have some of these and Pololu A4988 drivers but they should work with the Easydriver. However they are nominally 12v motors and you may be better with lower voltage motors as I think the Easydriver's max voltage is lower than the A4988.

It is normal for the driver and the stepper motor itself to get hot - probably too hot to touch.

High frequency tones are also common - it's the stepper driver controlling the current.

How are you measuring the 300mA that you mention?

...R

The easydriver accept up to 30 V. I can measure the voltage on a test point and control the current with potentiometer on the ed. The specs give 1V for 150 mA and 5V for 750A. So i can figure it out. But i would like to use a 12v supply because i want to powery arduino wit the same supply and there are 12v lead batteries with enough Ah avaible for a portable solution.

Xenotime:
The easydriver accept up to 30 V. I can measure the voltage on a test point and control the current with potentiometer on the ed. The specs give 1V for 150 mA and 5V for 750A. So i can figure it out. But i would like to use a 12v supply because i want to powery arduino wit the same supply and there are 12v lead batteries with enough Ah avaible for a portable solution.

That all seems fine. If you want to stay with 12v then I suggest getting motors with the lowest nominal voltage that have a max current within the range of the Easydriver. Of course it is also essential to ensure the motor has enough torque for your application. The motors I gave a link to seem to work pretty well with 12v - though I haven't yet tested them with a heavy load. For my application the Arduino will be powered by the PC that is sending data for the motor movements.

And it may be unreasonable to expect it to provide 750mA unless you arrange for a heat sink and lot of cooling. 500mA might be more sensible.

...R

So i have now tested with a proper switchable powersupply with 3-12V and 2.5A.
I get the least lost steps with a voltage of my power supply as cloth as possible to my motor.
The roughest operation is with a 12 or 9 V supply. For all voltages i get the best results with low current ( ~ 200-300 mA), whith increasing current i am loosing more steps unti the motor stalls at 750 mA.
I simply tested it with setting the motor up to do 1600 ( steps) = full revolution.
When i understood stepper motor drivers correctly, the get a constant current from the driver and swapping the coils by ramping up and down the voltage.
Could it be possible that i have an acceleration issue? I played around with the acceleration but so far i have not noticed any improvement.
I have orderd now a polulu stepper with 4.5V and 0.67A hope this will solve the issue.
Has anyone a suggestion how to run my actual motor smooth?
Here again the parameters:
rated 3.4V
max I per coil 1.6A
200 steps,
2Ohms resistance per coil.

I really dont need a lot of torque i calculated that i am fine with less then 4 oz per in.

I don't understand why you are getting different behaviour at different voltages. I have tried my motors with 12v, 19v and 24v and at moderate speeds there is no difference. The higher voltages allow higher speeds. It is important for the power supply to have plenty of amps available.

What do you mean by "rough"? By its nature a stepper motor moves in steps and the step action will probably be more "snappy" with higher currents - but it shouldn't be missing steps.

Are you trying the motor with nothing connected to the shaft? - i.e. no load on it. If so acceleration should not be an issue.

Are you using my demo code? As written it does not make the motor move at a high speed that could cause a problem.

Have you tried your motor using full steps?

Can you draw a diagram of how you have everything wired up and post a photo of the drawing?

...R

With rough i am meaning it misses microsteps from time to time causing larger steps. Since i want to drive my camera with the motor, the stuttering of the motor will make this impossible.

at the moment I am using the stepper without load on the shaft.

I used your code for testing and it rotates 1 full turn with set to 1600 steps forth and back. With higher voltage i observe the same behaviour.

I wired it up like this:

So i am not sure whether my motor is just not good in combination with the easydriver or my easydriver is broken.

What i found strange that i cannot the motor at with higher current although the motor is rated with 1.6A and that the performance is so voltage dependent.

Update for fast speeds the motor runs smooth at any voltage like 3000 steps per sec with 1/8th microstepping. But i need much lower speeds like 1 revolution per minute. And there the staps are grouped like 4 fast and 1 slow.

IF your motor is 1.7A then set the EasyDriver for as close to 1.7A as you can and run it
from the highest possible voltage - its needs that voltage overhead to get any speed
from the motor. Use something like 1/8th microstepping or you'll get lots of resonance
issues - unloaded steppers are hopelessly resonant, just fixing a small flywheel to the shaft
can completely transform its behaviour.

Just to see what happens try the motor at full steps and half steps. I suspect the Easydriver may not be able to provide enough current for that motor. Microstepping is achieved by magnetizing the poles so they pull against each other.

…R

Full steps is the most likely to mis-step due to resonance.

Until the actual load is on the motor its impossible to know if it will be
stable at any given speed. Usually loading the motor improves the situation
especially if there is friction to damp down oscillations. With microstepping
you are most likely to avoid resonance (especially at low speeds).

Its always worth checking both windings are properly connected, having one
winding unconnected causes all sorts of erroneous behaviour.

MarkT:
Full steps is the most likely to mis-step due to resonance.

According to the OP it is already missing steps at 8x microstepping. My suspicion is that his driver can't provide enough current and I think it is worth trying all options to see what happens. The code I proposed moves the motor slowly at full steps.

...R

I am experiencing the same problems with a pololu 4.5V 0.67A stepper :~. With higher speeds the motor starts to stutter every few seconds after 30 seconds / the ic can still be touched although its hot). At lower speeds, what i am aiming fore with 1/8 microstepping, the motor jumps form step to step like in fullstepp and after every 3 steps there is a larger step, which causes a sudden movement. And the motor is again stronger with lower supply voltage. Is it possible that also this motor does not match the timings of the easydriver? Or do i have a somehow broken easydriver? I tested the whole current spectrum with the Pot on the ED but this changes basically nothing. Can a poor connection from soldering be the issue, so that the signal is not clean?

Xenotime:
I am experiencing the same problems with a pololu 4.5V 0.67A stepper

What power supply - voltage and current - are you using for the stepper motor?

Are you using an Easydriver or some other stepper motor driver?

How fast (steps per second) are you driving the motor when you get problems?

Can you post your code?

...R

I am using an easydriver v4.4. in 1/8th stepping. Power supply 12V 2.25A.

I get problems at any speed. It is only more obvious at lower speeds.

Always after like 30sec to 1 min the motor stops every seconds and then continues. Like a short thermal shutdown, but i can still touch it although its hot, and i set the poti to half.

Also my version of the arduino seems to be different from what it should actually be: See attached image there is an additonal smd right of the word motor.

#include <AccelStepper.h>

int debug = 0;

int dgPinStep = 9;
int dgPinDirection = 8;

int anPinForeward = 4;
int anPinBackward = 5;
int anPinSpeed = 3;

AccelStepper stepper(AccelStepper::DRIVER, dgPinStep, dgPinDirection);

void setup() {
  pinMode(anPinForeward,  OUTPUT);
  pinMode(anPinBackward,  OUTPUT);  
  pinMode(anPinSpeed,  OUTPUT);  

  stepper.setMaxSpeed(3000);

  if (debug) {
    Serial.begin(9600);
  }
}

void loop() {
  int valForeward = analogRead(anPinForeward);
  int valBackward = analogRead(anPinBackward);
  int valSpeed = analogRead(anPinSpeed);
  int run = 0;

  if (debug) {
    Serial.print("Foreward: ");
    Serial.print(valForeward);
    Serial.print(" Backward: ");
    Serial.print(valBackward);
    Serial.print(" Speed: ");
    Serial.println(valSpeed);
  }
  if (valForeward < 512) {
    if (valSpeed < 512) {
      stepper.setSpeed(20);
    } else {
      stepper.setSpeed(1600);
    }
    run = 1;
  } else if (valBackward < 512) {
    if (valSpeed < 512) {
      stepper.setSpeed(-20);
    } else {
      stepper.setSpeed(-1600);
    }
    run = 1;
  } else {
    run = 0;
  }

  if (run) {
    stepper.runSpeed();
  } else {
    stepper.stop();
  }
}

IMG_20140813_112241179[1].jpg

<update: I talked to the developer of the ED and i bought a bad china copy witch seems to be faulty. Hopefully a new ED will solve the problem else I will try another driver from pololu.
Thank you for helping.

Xenotime:
<update: I talked to the developer of the ED and i bought a bad china copy witch seems to be faulty. Hopefully a new ED will solve the problem else I will try another driver from pololu.
Thank you for helping.

Be sure to get a BigEasyDriver rather than an Easydriver.

…R

Since i will use the smaller stepper, i think i will be fine with the small ED.