Arduino - connection of a stepper motor according to the diagram
Connecting stepper motors is a real challenge for many people.
The easiest way to connect the motors is to use ready-made, proven solutions such as the CNC BlackBox OpenBuilds controller, which will allow us to start the stepper motors in a few minutes.
Dedicated drivers are a very good solution when we plan to build a device, a CNC milling machine, a plotter with a laser and other similar devices.
It happens, however, that the purchase of a driver for a given project may turn out to be too expensive or we are simply looking for another solution
Arduino and stepper motor
Many hobby and semi-professional projects can be created using, for example, Arduino. These “microcomputers” allow us to create many unique solutions and they are widely used in many industries.
Many people ask us the question - "How to connect a stepper motor to Arduino?", So we have prepared a short guide for you in which we will show you in a few steps how to use Arduino to control a NEMA stepper motor.
So let's get down to business!
What will we need to run a stepper motor with Arduino?
-
Arduino UNO copy or original
-
Power Supply 5V
-
Power Supply 24V
https://www.v-slot.pl/pl/p/Zasilacz-MEAN-WELL-LRS-100-24-24V4.5A/1107
-
Stepper motor NEMA 23
https://www.v-slot.pl/pl/p/Silnik-krokowy-NEMA-23-HTS-OpenBuilds/1827
-
Driver DM542T https://www.v-slot.pl/pl/p/Cyfrowy-sterownik-krokowy-1.0-4.2A-20-50VDC-dla-silnika-krokowego-Nema-17%2C-23%2C-24/2645
-
A computer with Arduino IDE installed
Downloa here
-
Cables (here you have to choose cables of appropriate length and cross-section, below the cable for example cables)
It is worth noting here that this is an example of the elements needed to start the engine. It should be remembered that the listed items 3-5 may be completely different. Depending on what stepper motor you choose, you should select the appropriate driver and the power supply for it.
How to connect an arduino with a stepper motor? - diagram
So let's assume that you have selected all the necessary elements and we can proceed to the connection.
Below you will find a diagram where it is shown exactly how to connect the wires from the stepper motor to the driver, how to power the driver and which pins should be used to connect the wires between the driver and the Arduino.
-
Connect the DIR + and PUL + connectors from the DM542T driver to the pins on the Arduino using wires. For example :
-
DIR+ to PIN8
-
PUL+ to PIN9
-
Connect the DIR-, PUL- and GND connectors to the GND connector on the Arduino
-
Connect the power cord to the 24V power supply
-
Connect V + from the power supply to the V + connector on the DM542T driver
-
Connect V- from the power supply to the GND connector on the driver
-
Connect a pair of wires from the motor to the A + and A- connectors (remember to check which wires of the stepper motor form a party.How to find pairs of wires in the stepper motor - see the video below)
-
similarly to step 6, connect another pair of wires from the stepper motor to the B + and B- connectors
-
Write a control program on your computer and upload using the Arduino environment (an example of the code can be found below)
-
Upload the program to Arduino and power the arduino using the 5V power supply
-
Connect the power (230V) to the 24V power supply
THE MOVIE “CHOOSING PAIRS OF CABLES FOR STEPPING MOTORS
EXAMPLE CODE :
int x;
void setup() {
pinMode(9,OUTPUT); // ustaw Pin9 jako PUL
pinMode(8,OUTPUT); // ustaw Pin8 jako DIR
}
void loop() {
digitalWrite(8,HIGH); // ustaw stan wysoki dla określenia kierunku
for(x = 0; x < 400; x++) //
{
digitalWrite(9,HIGH);
delayMicroseconds(500);
digitalWrite(9,LOW);
delayMicroseconds(500);
}
delay(1000);
digitalWrite(8,LOW);
for(x = 0; x < 400; x++)
{
digitalWrite(9,HIGH);
delayMicroseconds(500);
digitalWrite(9,LOW);
delayMicroseconds(500);
}
delay(1000);
}
READY!
If you connected everything correctly, your engine should be running. If the engine did not work, check the correct connection of the wires. If you have any questions, you can contact us by e-mail or by commenting on the video, where we show you the entire process described above step by step.
VIDEO: HOW TO CONNECT A STEP MOTOR TO ARDUINO?