Let’s discuss different stepper motor drivers

In this video I talk about four different stepper motor drivers. The A4988, the DRV8825, the EasyDriver and the TB6600. They all can be controlled with the AccelStepper library using an Arduino. They are all controlled using the same principle. You just need to control the step and the direction pins and that is all. The main differences are for example the amount of current they can provide, their form factor and the microstepping capabilities. For more information on the stepper motor controller, please refer to the links below.

If you need more info on the EasyDriver, visit the following website: http://www.schmalzhaus.com/EasyDriver/

If you need more info on the A4988 and the DRV8825, visit the following website: https://www.pololu.com/product/2133

AccelStepper library: https://www.airspayce.com/mikem/arduino/AccelStepper/



Arduino source code

//If you found this code useful, please subsricbe to my channel: https://www.youtube.com/c/CuriousScientist?sub_confirmation=1
//It took several hours for me to prepare everything, but subscription is just a click for you. Thank you!

//This code is used to test 4 different stepper motor driver circuits with the accelstepper library.
//Stepper motor controllers:
//EasyDriver
//A4988
//DRV8825
//TB6600

#include <AccelStepper.h>
AccelStepper stepper(1, 8, 9);// direction Digital 9 (CCW), pulses (or step) Digital 8 (CLK)

bool pingpong_CW = false;
bool pingpong_CCW = false;

//Pins
const int MS1 = 7; //MS = microstepping
const int MS2 = 6;
//const int MS3 = 5; //A4988 or DRV8825 without breakout board
//-------------------------------------------------------------------------------

void setup()
{
	//Serial.begin(115200); //define a baud rate	
  //Pin modes  
	pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  //pinMode(MS3, OUTPUT); //A4988 or DRV8825 without breakout board
  
  //Microstepping setup
  digitalWrite(MS1, HIGH);
  digitalWrite(MS2, LOW);    
  //digitalWrite(MS3, LOW); //A4988 or DRV8825 without breakout board

  //Accelstepper parameters
	stepper.setMaxSpeed(400); //SPEED = Steps / second
	stepper.setAcceleration(800); //ACCELERATION = Steps /(second)^2
  stepper.enableOutputs(); //enable pins
}

void loop() 
{
  PingPong();
  stepper.run();
}


void PingPong()
{   
      if(pingpong_CW == false) //CW rotation is not yet done
      {  
        stepper.moveTo(1000); //set a target position, it should be an absolute. relative (move()) leads to "infinite loop"
        
        if(stepper.distanceToGo() == 0) //When the above number of steps are completed, we manipulate the variables
        {
            pingpong_CW = true; //CW rotation is now done
            pingpong_CCW = false; //CCW rotation is not yet done - this allows the code to enter the next ifs
        }      
      }
        
      if(pingpong_CW == true && pingpong_CCW == false) //CW is completed and CCW is not yet done
      {
        stepper.moveTo(0); //Absolute position 
        
        if(stepper.distanceToGo() == 0) //When the number of steps are completed
          {
            pingpong_CCW = true; //CCW is now done
            pingpong_CW = false; //CW is not yet done. This allows the code to enter the first if again!
          }     
      }
}


Wiring diagrams


Previous
Previous

Controlling the SZBK07 DC-DC converter

Next
Next

Building and testing a new water cooling system for Peltier coolers