Go Down

Topic: EasyDriver v4.3 and sparkfun Stepper motor woes (Read 6163 times) previous topic - next topic

pingy

I have:

Arduino Uno
Sparkfun Stepper motor
EasyDriver4.3

Im having some issues here. When I power the stepper via the arduino; the sample codes run fine. Once I wire up the EasyDriver and put it in place I can not get the motor to do anything. It just stays fully energized all the time. I am powering the EasyDriver via a wallwart I found laying around.

Wallwart output specs: 12v 1.5A

Im sure I am missing something basic, but I have been at it for two days now and can not figure this one out. Im sure all my wiring is correct. What am I missing. I could provide photos if anyone thinks that would help.

TIA

mmcp42

there are only 10 types of people
them that understands binary
and them that doesn't

pingy


pingy

http://picasaweb.google.com/lh/photo/lmrcbANq2Abfzi_k2SJ_zA?feat=directlink

Lets try this. Having some issues posting a image.

mmcp42

Hmm! I guess it's not powered up. Does the yellow LED come on when you apply power?
What code are you driving it with?
How was it wired when it worked?
Did I read right that it worked when you ran the motor without the Easy Driver???
there are only 10 types of people
them that understands binary
and them that doesn't

pingy

Yes it is powered up and yes the LED comes on. it even energizes the motor (all mags on) to where the motor is stationary and difficult to turn.

It worked when I did not use the EasyDriver. When I put the Green Red Blue Yellow stepper wires right into the arduino and used some test code the motor would turn fine (just not enough torque for my liking)

I have tried to use multiple codes with the EasyDriver. Here is the most recent one I have tried.

Code: [Select]
int DIR = 3;          // PIN  3 = DIR
int STEP = 2;        // PIN  2 = STEP
int MS1 = 13;        // PIN 13 = MS
int MS2 = 9;         // PIN  9 = MS2
int SLEEP = 12;      // PIN 12 = SLP


void setup() {
  Serial.begin(9600);     // open the serial connection at 9600bps
  pinMode(DIR, OUTPUT);   // set pin 3 to output
  pinMode(STEP, OUTPUT);  // set pin 2 to output
  pinMode(MS1, OUTPUT);   // set pin 13 to output
  pinMode(MS2, OUTPUT);   // set pin 9 to output
  pinMode(SLEEP, OUTPUT); // set pin 12 to output
}



void loop()
{
  int modeType = 1;                         // This number increases by multiple of 2 each through the while loop..
                                            // ..to identify our step mode type.                                           
  while (modeType<=8){                      // loops the following block of code 4 times before repeating .
    digitalWrite(DIR, LOW);                 // Set the direction change LOW to HIGH to go in opposite direction
    digitalWrite(MS1, MS1_MODE(modeType));  // Set state of MS1 based on the returned value from the MS1_MODE() switch statement.
    digitalWrite(MS2, MS2_MODE(modeType));  // Set state of MS2 based on the returned value from the MS2_MODE() switch statement.
    digitalWrite(SLEEP, HIGH);              // Set the Sleep mode to AWAKE.
   
    int i = 0;                              // Set the counter variable.     
    while(i<(modeType*200))                 // Iterate for 200, then 400, then 800, then 1600 steps.
                                            // Then reset to 200 and start again.
    {
      digitalWrite(STEP, LOW);              // This LOW to HIGH change is what creates the..
      digitalWrite(STEP, HIGH);             // .."Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(1600/modeType);     // This delay time determines the speed of the stepper motor.
                                            // Delay shortens from 1600 to 800 to 400 to 200 then resets 
                                                 
      i++;                     
    }                             
    modeType = modeType * 2;                // Multiply the current modeType value by 2 and make the result the new value for modeType.
                                            // This will make the modeType variable count 1,2,4,8 each time we pass though the while loop.
   
    delay(500);
  }
  digitalWrite(SLEEP, LOW);                 // switch off the power to stepper
  Serial.print("SLEEPING..");
  delay(1000);
  Serial.print("z");
  delay(1000);
  Serial.print("z");
  delay(1000);
  Serial.print("z");
  delay(1000);
  Serial.println("");
  digitalWrite(SLEEP, HIGH);
  Serial.println("AWAKE!!!");                // Switch on the power to stepper
  delay(1000);
}



int MS1_MODE(int MS1_StepMode){              // A function that returns a High or Low state number for MS1 pin
  switch(MS1_StepMode){                      // Switch statement for changing the MS1 pin state
                                             // Different input states allowed are 1,2,4 or 8
  case 1:
    MS1_StepMode = 0;
    Serial.println("Step Mode is Full...");
    break;
  case 2:
    MS1_StepMode = 1;
    Serial.println("Step Mode is Half...");
    break;
  case 4:
    MS1_StepMode = 0;
    Serial.println("Step Mode is Quarter...");
    break;
  case 8:
    MS1_StepMode = 1;
    Serial.println("Step Mode is Eighth...");
    break;
  }
  return MS1_StepMode;
}



int MS2_MODE(int MS2_StepMode){              // A function that returns a High or Low state number for MS2 pin
  switch(MS2_StepMode){                      // Switch statement for changing the MS2 pin state
                                             // Different input states allowed are 1,2,4 or 8
  case 1:
    MS2_StepMode = 0;
    break;
  case 2:
    MS2_StepMode = 0;
    break;
  case 4:
    MS2_StepMode = 1;
    break;
  case 8:
    MS2_StepMode = 1;
    break;
  }
  return MS2_StepMode;
}



While I do not have the MS1/MS2/SLP/RST/Enable or PFD pins wired up I have tried other test code that doesnt call for them and it still doesnt work.

Please advise! :)

pingy

Any chance it could be as simple as the wallwart? I do not have another to test with, but can the EasyDriver handle 1.5A?


41south

According to the Easy Driver web site

"Each EasyDriver can drive up to about 750mA per phase of a bi-polar stepper motor."

mmcp42

the delay inside the step loop is too short
it just won't step that fast
change delayMicroseconds(x) to delay(x)

also
just set MS1 and MS2 low to give full stepping (to start with)
one less variable to worry about
there are only 10 types of people
them that understands binary
and them that doesn't

pingy


According to the Easy Driver web site

"Each EasyDriver can drive up to about 750mA per phase of a bi-polar stepper motor."


Ok so I'll take that to mean that my AC power adapter is spot on then. Thanks.

pingy


the delay inside the step loop is too short
it just won't step that fast
change delayMicroseconds(x) to delay(x)

also
just set MS1 and MS2 low to give full stepping (to start with)
one less variable to worry about


Ok Well i took a day to get back because I wanted to test this. It sounded like a great idea, but it didn't work.

I changed the delay and just removed the MS pins. The motor just locks up. It stays fully energized the whole time.

BUT! the sleep does seem to work, when the code I run get to the "sleep zzz" portion the motor does sleep and i can turn it freely.

Any other advise or maybe even some simple test code I would run to try to narrow down what the issue is here.

thanks for your help thus far

mmcp42

I just posted some code elsewhere to drive a stepper @ 1rpm
I'll post it here - you can give that a try...
Code: [Select]

//============================
// slow speed stepping
// Mike McPherson 4th Feb 2011
// aka mmcp42
//============================

// we use serial for debugging/monitoring
//=======================================
#include <HardwareSerial.h>

// define some pins
//=================
#define DIR_PIN 3
#define STEP_PIN 12
#define MS1_PIN 11
#define MS2_PIN 10
#define SLEEP_PIN 9
#define ENABLE_PIN 8
#define HEARTBEAT_PIN 13

// define stepper
//===============
#define STEPS_PER_REV 200

// define speed required in rpm
//=============================
float Speed = 1.0;

// some globals
//=============
int StepsPerSecond;    // speed converted to steps/second
int StepDelay;         // = delay in mS per step

void setup()
{
  // set all the pins as outputs
  //============================
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
  pinMode(MS1_PIN, OUTPUT);
  pinMode(MS2_PIN, OUTPUT);
  pinMode(SLEEP_PIN, OUTPUT);
  pinMode(ENABLE_PIN, OUTPUT);
  pinMode(HEARTBEAT_PIN, OUTPUT);
 
  // calculate the required delay (we're using 1/8 stepping)
  //========================================================
  StepsPerSecond = Speed * STEPS_PER_REV * 8 / 60;
  StepDelay = 1000 / StepsPerSecond;
 
  // initialise the EasyDriver
  //==========================
  digitalWrite(ENABLE_PIN, HIGH);  // = enabled
  digitalWrite(SLEEP_PIN, HIGH);   // = not aslepp
  digitalWrite(MS1_PIN, HIGH);     //
  digitalWrite(MS2_PIN, HIGH);     // might as well use 1/8 stepping
  digitalWrite(DIR_PIN, HIGH);     // arbitrary direction, LOW to spin the other way
 
  // initialise serial port for monitoring/debugging
  //================================================
  Serial.begin(19200);
  Serial.println("start");
 
  Serial.print("Steps/sec: ");
  Serial.println(StepsPerSecond, DEC);
 
  Serial.print("StepDelay: ");
  Serial.print(StepDelay, DEC);
  Serial.println(" mS");
 
}

void loop()
{
  boolean heart = false;
  while (true)
  {
    for (int j=0; j<60; j++)
    {
      for (int i=0; i<StepsPerSecond; i++)
      {
        // step the motor
        //===============
        digitalWrite(STEP_PIN, HIGH);
        delayMicroseconds(10);
        digitalWrite(STEP_PIN, LOW);
       
        // delay until next step required
        //===============================
        delay(StepDelay);
      }
      // heartbeat
      //==========
      heart = !heart;
      digitalWrite(HEARTBEAT_PIN, heart);
    }
    // another minute gone by
    //=======================
    Serial.println("tick");
  }
}
there are only 10 types of people
them that understands binary
and them that doesn't

pingy

I look forward to trying it tonight!

I'll report back. Thanks.

pingy

#13
Feb 05, 2011, 06:06 am Last Edit: Feb 05, 2011, 06:10 am by pingy Reason: 1

I just posted some code elsewhere to drive a stepper @ 1rpm
I'll post it here - you can give that a try...
Code: [Select]

//============================
// slow speed stepping
// Mike McPherson 4th Feb 2011
// aka mmcp42
//============================

// we use serial for debugging/monitoring
//=======================================
#include <HardwareSerial.h>

// define some pins
//=================
#define DIR_PIN 3
#define STEP_PIN 12
#define MS1_PIN 11
#define MS2_PIN 10
#define SLEEP_PIN 9
#define ENABLE_PIN 8
#define HEARTBEAT_PIN 13

// define stepper
//===============
#define STEPS_PER_REV 200

// define speed required in rpm
//=============================
float Speed = 1.0;

// some globals
//=============
int StepsPerSecond;    // speed converted to steps/second
int StepDelay;         // = delay in mS per step

void setup()
{
 // set all the pins as outputs
 //============================
 pinMode(DIR_PIN, OUTPUT);
 pinMode(STEP_PIN, OUTPUT);
 pinMode(MS1_PIN, OUTPUT);
 pinMode(MS2_PIN, OUTPUT);
 pinMode(SLEEP_PIN, OUTPUT);
 pinMode(ENABLE_PIN, OUTPUT);
 pinMode(HEARTBEAT_PIN, OUTPUT);
 
 // calculate the required delay (we're using 1/8 stepping)
 //========================================================
 StepsPerSecond = Speed * STEPS_PER_REV * 8 / 60;
 StepDelay = 1000 / StepsPerSecond;
 
 // initialise the EasyDriver
 //==========================
 digitalWrite(ENABLE_PIN, HIGH);  // = enabled
 digitalWrite(SLEEP_PIN, HIGH);   // = not aslepp
 digitalWrite(MS1_PIN, HIGH);     //
 digitalWrite(MS2_PIN, HIGH);     // might as well use 1/8 stepping
 digitalWrite(DIR_PIN, HIGH);     // arbitrary direction, LOW to spin the other way
 
 // initialise serial port for monitoring/debugging
 //================================================
 Serial.begin(19200);
 Serial.println("start");
 
 Serial.print("Steps/sec: ");
 Serial.println(StepsPerSecond, DEC);
 
 Serial.print("StepDelay: ");
 Serial.print(StepDelay, DEC);
 Serial.println(" mS");
 
}

void loop()
{
 boolean heart = false;
 while (true)
 {
   for (int j=0; j<60; j++)
   {
     for (int i=0; i<StepsPerSecond; i++)
     {
       // step the motor
       //===============
       digitalWrite(STEP_PIN, HIGH);
       delayMicroseconds(10);
       digitalWrite(STEP_PIN, LOW);
     
       // delay until next step required
       //===============================
       delay(StepDelay);
     }
     // heartbeat
     //==========
     heart = !heart;
     digitalWrite(HEARTBEAT_PIN, heart);
   }
   // another minute gone by
   //=======================
   Serial.println("tick");
 }
}



NOPE!
I had a problem compiling your code so I had to comment out the serial lines to get it to compile quickly.
I wired everything up via your code.

The motor again just locks up. unless I had the Enable pin in; then i was able to turn the motor by hand.

This is really driving me nuts and time is a ticking on this project. Im a week in and I cant even get a single motor to spin.

Do you think I can assume at this point that something is wrong with my EasyDriver? because this driver has been anything but easy on me......


mmcp42

looking at the code
Enable should be LOW, sorry
and it's only gonna "spin" at 1 rpm
you need to change the Speed variable for it to go faster

"locked solid" is good - it means that EasyDriver is holding the stepper in position

try setting Speed to 10.0
should then spin @ 10 rpm

odd that serial doesn't work for you
which version of IDE are you using?
there are only 10 types of people
them that understands binary
and them that doesn't

Go Up