Skip to content

Step Motor with Arduino

In this tutorial we will learn how does bigger Step Motor drive with TB6600 micro-stepping driver and  Arduino. Next tutorial we will do the same things with STM32 microprocessor.

 We will use an Arduino library called MWC_STEPPER which is I wrote. Here is the Github link to download MWC_STEPPER library:

https://github.com/mertwhocodes/mwc_stepper

I will explain how the code works, so you should have no problems modifying it to suit your needs.

Hardware components


  • Arduino Uno
  • TB6600 Step motor Driver 
  • Nema23 Step Motor

Hardware connections


 

 

 

Stepper Motor Wiring


Nema23 Step motor type 57Hs22 which I used for this tutorial.As you can see under bellow there is two type connections, series and parallel connections.

Parallel connections basically provide more speed and serial connections provide more torque.

As you can see in the picture there are six switch from SW1 to SW2 to configure your driver.  Nema23 with a 1.8 degree that means (360°/1.8°)200 steps for every full revolution for the motor. This discrete motion means the motor’s rotation isn’t perfectly smooth. Step motor driver converts each full step into smaller steps to help smooth out the motor’s rotation. From 1 to 3 you can configure that I will configure it to 1600 which means set these switch respectively Off-On-Off. From 4 to 6 you can configure current limiting. Current limiting is important to prevent damage to step motor. 

Check your step motor information to configure correctly. My step motor is Nema23 3.0A that means  I have to set these switch  respectively Off-On-Off

Arduino codes


Before understanding code pls check the MWC_stepper Arduino library parameter and functions in my Github page. 

https://github.com/mertwhocodes/mwc_stepper 

Example Code for  MWC_stepper Library


/*
Name :step_drive.ino
Author:mertwhocodes
*/
#include<mwc_stepper.h>
 
#define EN_PIN 3
#define DIR_PIN 2
#define STEP_PIN 5
 
#define RPM 50
#define RPM1 100
 
#define PULSE 1600
 
#define ClOCKWISE 1
#define OTHERWISE 0
 
MWCSTEPPER nema23(EN_PIN, DIR_PIN, STEP_PIN);
 
void setup() {
nema23.init();
}
 
void loop() {
nema23.set(ClOCKWISE, RPM, PULSE);
 
for (size_t i = 0; i < 1600; i++)
{
nema23.run();
}
 
delay(1000);
 
nema23.set(OTHERWISE, RPM1, PULSE);
 
for (size_t i = 0; i < 1600; i++)
{
nema23.run();
}
}
Published inArduino examples

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *