Go Down

Topic: Ardunio - EasyDriver 4.3 - Stepper Motor (Read 14110 times) previous topic - next topic

SniffTheGlove

Feb 20, 2011, 04:06 pm Last Edit: Feb 20, 2011, 04:08 pm by SniffTheGlove Reason: 1
I have used the great tutorial from Dan Thompson. http://danthompsonsblog.blogspot.com/2010/05/easydriver-42-tutorial.html

I have built the breadboard identically as per


however the only difference is the stepper motor that I am using and my external power supply to the EasyDriver board.

My stepper motor is...
4 Lead Bipolar Hybrid Stepper Motor ETS535
Step Angle: 0.9d full step
Rated Voltage 4.25Vdc
Rated Current 0.425A/phase
Winding Resistance 10ohms
Holding Torque 7.5N-cm
Step Accuracy 5%
Rotor Inertia 15g-cm2

The power supply is a 9v 0.6A 5.4W Max as supplied by oomlout.
http://www.oomlout.co.uk/wall-power-adapter-9v-600-ma-p-236.html

As my motor is a 400 step (360/0.9) and not the one in Dan's example 200(360/1.8) I am having a little difficulty understand how to control the stepper at different speeds.
I have played with changing
Quote
while(i<(modeType*200))
to replace 200 with 400

and also changing
Quote
delayMicroseconds(1600/modeType)
to replace 1600 with 3200

These changes do slow the motor down but no as much as I would like.

I am really looking to have a really slow speed of say 1 step(0.9deg) per second when Step Mode is Eighth, and then 2 steps when Step Mode is Quarter, 4 steps when Step Mode is Half and finally 8 steps when Step Mode is Full.

I have no idea of achieving this. Can someone help this poor little old newbie tweak the code.

PS, when running the code below the A3967 on the EasyDriver board gets very very hot, is this right or should it be cooler. The current adjuster pot on the EasyDriver board is set at the mid point between Min and Max

Code: [Select]
///////////////////////////////////////////////////////////
// Stepper Motor skecth for use with the EasyDriver v4.2 //
///////////////////////////////////////////////////////////

// Dan Thompson 2010
//
// Use this code at your own risk.
//
// For all the product details visit <a class="linkification-ext" href="http://www.schmalzhaus.com/EasyDriver/" title="Linkification: http://www.schmalzhaus.com/EasyDriver/">http://www.schmalzhaus.com/EasyDriver/</a>
// For the full tutorial visit <a class="linkification-ext" href="http://danthompsonsblog.blogspot.com/" title="Linkification: http://danthompsonsblog.blogspot.com/">http://danthompsonsblog.blogspot.com/</a>


////// ED_v4  Step Mode Chart //////
//                                //
//   MS1 MS2 Resolution           //
//   L   L   Full step (2 phase)  //
//   H   L   Half step            //
//   L   H   Quarter step         //
//   H   H   Eighth step          //
//                                //
////////////////////////////////////

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



CristobalGordo

On the sparkfun easydriver page there is a link to an arduino tutorial in Portuguese.  Don't worry about the Portuguese part, you just need to take a look at the code sample.  Here it is here- http://lusorobotica.com/index.php/topic,106.0.html
When they step, they go HIGH and then a delay and then go LOW and delay again.  From myexperience you need to play around with the delay times to see what works for your motor.  Find a value that works for full step and then go from there.  In the Portuguese example you can see what they use and go from there.  Also play with the potentiometer on the board to see what works for your motor.
I would start simple- forget about sleep and fine stepping and just try to get the motor to turn correctly both ways on full step.  Then start worrying about the other stuff.

jraskell

The value in the while() statement determines the total number of steps to take, and does one full revolution in each step mode for the 200 step motor.  Changing it to 400 with your stepper motor will have it turn one full revolution in each step mode as well.

The delaymicroseconds() inside the while() statement determines the time between steps.  Note that this is the microsecond delay.  1000 microseconds = 1 millisecond.  1000 milliseconds = 1 second.  So if you want to delay a full second between steps, you'd need to delay for 1 million microseconds.  If you use delay() instead, that value is in milliseconds, which makes it a slightly easier number to deal with.  delay(1000/modetype) should give you the delay times you want.  Just keep in mind that this is a very slow speed of rotation, giving you one full revolution every 6 minutes 40 seconds.

SniffTheGlove

Thanks both the code pointers.

I have done a very simple code along the line of the Portuguese sample and the code is stepping the motor around slowly. Great.


The other thing I was worried about in my first (the bit at the bottom in bold) is hot hot should the A3937 get when driving the motor around. Mine is too hot to touch after 5 mins of usage. Is this correct or am I doing something wrong? I don't want to burn it out after an hours worth of turning the motor.

PaulS

The way a stepper motor works, it draws full power all the time. All that current is running through the easydriver. So, it will get hot. If it gets too hot, you are probably trying to drive a stepper motor that draws more current than the easydriver was designed for.

Look at the motor controllers on a CNC machine. They are not that rinky-dink little easydriver. They have massive heat-sinks and fans.

jraskell

The AC3937 does have built in thermal shutdown protection.  You listed your stepper motor current rating at .425A/phase.  The AC3937 is rated for .75A, but I don't know if this is per phase, or total.  If it's total, your stepper motor is too big for the EasyDriver (but it will just go into thermal shutdown, you shouldn't burn anything out).  Your power supply is also only rated for .6A, so that's also inadequate for the stepper motor you're using.

SniffTheGlove


The AC3937 does have built in thermal shutdown protection.  You listed your stepper motor current rating at .425A/phase.  The AC3937 is rated for .75A, but I don't know if this is per phase, or total.  If it's total, your stepper motor is too big for the EasyDriver (but it will just go into thermal shutdown, you shouldn't burn anything out).  Your power supply is also only rated for .6A, so that's also inadequate for the stepper motor you're using.

Thanks,

The EasyDriver site from quotes

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


The current limiter pot is set half way between min/max on my EasyDriver, I thought that would be the best place for .425A draw.

I will look for a better power supply

tyousaf

Hi SniffTheGlove

I am looking to use a similar stepper motor for my project. Could you please let me know what the coils pinout for this motor is?

Thanks for your time.


Go Up