Arduino Stepper Motor Control
- Stepper Motor Driver Board
- Arduino Board (UNO)
If you have purchased the Arduino Board from ZTW, we have already uploaded the g-code library for you. If you are using your own Arduino Board, you can doawnload grbl Arduino library online and load it to your board using xloader.
- Power Supply
The power supply is used to give the power to stepper motor driver board.
- USB Cable (A Male – B Male/Printer USB Cable)
A USB cable is need to connect the Arduino board to your computer. An A Male to B Male USB cable will be used, the one usually used for printer USB connection. If you really cannot find one, here is the link you can purchase.
This is the diagram we will be following in order to use the Arduino to control our stepper drivers. You will use an Arduino Board(UNO) as a controoler, 3 stepper motors and drivers, a DC power supply and a laptop computer.
First, attach a power cord to your power supply. Please check your outlet voltage, change the 110 – 220V setting on your PSU if necessary according to PSU you are using.
Now we need to connect the PSU’s DC output (12V) to stepper motor driver. To illustrate this better, we are using red wire for positive and black for negative connections.
We are going to wire positive terminals on all three stepper motor drivers together, and same for negative terminals. Here you can see the positive(red) wire from the PSU as well as another red wire(jumper) to our first stepper driver.
Here is how the power wires will be connected from PSU to all three stepper drivers when it is done.
Now we will start connecting the stepper singal lines to the Arduino. First we need to connect all “-Dir” and “-Pul” terminals together, these will be connected to the ground pin on the Arduino board.
Now we will connect the signal ground to the Arduino Board ground.
Here is a closer look at the Arduino board ground pin connection.
Now the “+Pul” for X axis will be connected to Arduino board pin 2.
And the “+Dir” for X axis will be connected to Arduino board pin 5.
Now let’s connect Y axis, “+Pul” will be connected to Arduino Pin3, and “+Dir” need to be connected to Pin6.
For Z Axis, connect “+Pul” to Pin4, and “+Dir” to Pin7.
All stepper sigal wires have been connected between the stepper drivers and Arduino Board.
Now we need to connect the stepper motors to the driver boards. Detailed information on our Shinano Stepper Motors can be found here: http://www.shinano.com/motors/stepper.html
First, we need to identify the two wires that belong to the same loop. A multimeter can be used here. If you have our Unipolar stepper motor(Shinano NEMA17), two center wires will not be used.(black & white)
The motors wires have been connected to stepper driver’s “A+”, “A-” and “B+” “B-“
Stepper Motors for all three axis have been connected to their driver boards.
If you already have installed the software (below), then you are ready to connect the Arduino board to the computer through USB cable.
In This tutorial, we will be walking you through one way to control your CNC machine with an Arduino.
The first thing you will want to do is to navigate to http://arduino.cc in your web browser.
Navigate or click on the download tab.
Choose the proper download for your machine. Note- the software we will be using to send
G-Code to the arduino is currently only available in Windows.
Choose where you would like to download the file.
Wait for the download to complete.
Once the download has completed, click open.
The arduino software downloads as a zip file, so we will need to extract the files.
Right click on the folder, and choose extract all.
Choose the destination where you would like to extract the arduino
folder and click extract.
Let the files extract, it will take a few moments.
Now that the folder has been extracted, open it.
Double click the arduino application.
Next we will have to navigate to our device manager, where you should see your arduino.
Right click on the arduino device, and choose “update driver software”.
Now we want to choose “Browse my computer” for driver software.
Navigate to your recently extracted Arduino folder and click OK.
Your driver will now be updated.
If windows gives you this security alert- choose “install this driver software anyway”.
The driver should continue installing.
You should get a window that says the driver was updated successfully. Click close.
The device should now be shown in your device manager with the correct COM port.
Now navigate to https://github.com/OttoHermansson/GcodeSender/downloads
in your web browser. Then click on the GCodeSender.exe download link.
Choose run when prompted.
Choose your save destination.
Once download has completed, select “open folder”.
Now double click the GCodeSender application.
If prompted with a security warning choose “run”.
Once in GCodeSender click the “Open” button.
Be sure the \r\n bubble is selected.
Type a “$” without the quotes into the command bar and hit enter.
You should get a list of settings that you can alter to fit your application. To change the “x” step/mm for example, type $0 = 400 or whatever your steps per mm needs to be, and then hit enter. The same can be done for any of the other settings.
Next you should test your settings by typing for example X10 then hit enter. Your machine should move 10mm in the positive “X” direction. You can similarly test the other axis the same way. Just replace X with the axis of choice.
Depending on the machine and configuration used, it may be necessary to set the axis motion direction opposite of its current setting. This is accomplished by setting the invert mask within the grbl controller. As of version .8c the command is $6=”X”, older versions used $7=”X”, where X is the value the direction(s) needing to be reversed from the following list (“None = 0, X=32, Y=64, X+Y=96, Z=128, X+Z=160, Y+Z=192, X+Y+Z=224”) if I needed to reverse the Y axis I would enter command $6=64
Another useful tool is Grbl controller 3.5 available at
GRBL controller is useful for workpiece setup and getting a graphical view of the toolpath. However, G-code sender has superior motion control for arcs.
Once motion control is verified it is recommended to upgrade the GRBL control software on the Arduino. A tutorial is located at
Source: Arduino Stepper Motor Control
This Post / Project can also be found using search terms:
- arduino based stepper motor control pdf
- stepper motor control arduino
- arduino stepper motor control
- arduino mega 2560 stepper projects