Arduino Stepper Motor Control

Hardware Preparation

  • Stepper Motor Driver Board
  • Arduino Board (UNO)

If you bought the Arduino Board from ZTW, we have already installed the g-code library for you. If you have your own Arduino Board, you have the option to download the grbl Arduino library from the internet and upload it onto 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.

Wiring Instruction

Wiring Instruction

This diagram is the one we will be using to guide us when controlling our stepper drivers with the Arduino. An Arduino Board (UNO) will serve as the controller, along with 3 stepper motors and drivers, a DC power supply, and a laptop computer.

640px-Arduino_Wire_001

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.

640px-Arduino_Wire_002

Next, we must link the power supply unit’s direct current output (12V) to the stepper motor driver. In order to make this clearer, red wire is used for positive connections and black for negative connections.

640px-Arduino_Wire_003

We will connect the positive terminals of all three stepper motor drivers and do the same for the negative terminals. This is where you can observe the positive (red) wire coming from the PSU along with another red wire (jumper) leading to our initial stepper driver.

640px-Arduino_Wire_004

Here is how the power wires will be connected from PSU to all three stepper drivers when it is done.

640px-Arduino_Wire_005

We will connect the positive terminals of all three stepper motor drivers and do the same for the negative terminals. This is where you can observe the positive (red) wire coming from the PSU along with another red wire (jumper) leading to our initial stepper driver.

640px-Arduino_Wire_006

Now we will connect the signal ground to the Arduino Board ground.

640px-Arduino_Wire_007

Here is a closer look at the Arduino board ground pin connection.

640px-Arduino_Wire_008

Now the “+Pul” for X axis will be connected to Arduino board pin 2.

640px-Arduino_Wire_009

And the “+Dir” for X axis will be connected to Arduino board pin 5.

640px-Arduino_Wire_010

640px-Arduino_Wire_011

Now let’s connect Y axis, “+Pul” will be connected to Arduino Pin3, and “+Dir” need to be connected to Pin6.

640px-Arduino_Wire_012

For Z Axis, connect “+Pul” to Pin4, and “+Dir” to Pin7.

640px-Arduino_Wire_013

All stepper sigal wires have been connected between the stepper drivers and Arduino Board.

640px-Arduino_Wire_014

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

640px-Arduino_Wire_015

Initially, it is necessary to pinpoint the two wires that are part of the same circuit. Here, a multimeter can be utilized. If you are using our Unipolar stepper motor (Shinano NEMA17), you will not need to use two central wires (black and white).

640px-Arduino_Wire_016

The motors wires have been connected to stepper driver’s “A+”, “A-” and “B+” “B-”

The motors wires have been connected to stepper driver

Stepper Motors for all three axis have been connected to their driver boards.

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.

Software Installation

Software Installation

ArduinoControl 001:
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.

ArduinoControl

ArduinoControl 002:
Navigate or click on the download tab.

Navigate or click on the download tab

ArduinoControl 003:
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.

640px-ArduinoControl_004

ArduinoControl 004:
Click open.

640px-ArduinoControl_005

ArduinoControl 005:
Choose where you would like to download the file.

Choose where you would like to download the file

ArduinoControl 006:
Wait for the download to complete.

Wait for the download to complete

ArduinoControl 007:
Once the download has completed, click open.

ArduinoControl 008:
The arduino software downloads as a zip file, so we will need to extract the files.

 

The arduino software downloads as a zip file, so we will need to extract the files

ArduinoControl 009:
Right click on the folder, and choose extract all.

Right click on the folder, and choose extract all

ArduinoControl 010:
Choose the destination where you would like to extract the arduino
folder and click extract.

640px-ArduinoControl_011

ArduinoControl 011:
Let the files extract, it will take a few moments.

Let the files extract, it will take a few moments

ArduinoControl 012:
Now that the folder has been extracted, open it.

Now that the folder has been extracted, open it

ArduinoControl 013:
Double click the arduino application.

Double click the arduino application

ArduinoControl 014:
Next we will have to navigate to our device manager, where you should see your arduino.

640px-ArduinoControl_015

ArduinoControl 015:
Right click on the arduino device, and choose “update driver software”.

Right click on the arduino device, and choose update driver software

ArduinoControl 016:
Now we want to choose “Browse my computer” for driver software.

640px-ArduinoControl_017

ArduinoControl 017:
Click browse.

Click browse

ArduinoControl 018:
Navigate to your recently extracted Arduino folder and click OK.

Navigate to your recently extracted Arduino folder and click OK

ArduinoControl 019:
Choose next.

Choose next

ArduinoControl 020:
Your driver will now be updated.

Your driver will now be updated.

ArduinoControl 021:
If windows gives you this security alert- choose “install this driver software anyway”.

If windows gives you this security alert- choose install this driver software anyway

ArduinoControl 022:
The driver should continue installing.

The driver should continue installing

ArduinoControl 023:
You should get a window that says the driver was updated successfully. Click close.

You should get a window that says the driver was updated successfully

ArduinoControl 024:
The device should now be shown in your device manager with the correct COM port.

The device should now be shown in your device manager with the correct COM port

ArduinoControl 025:
Now navigate to https://github.com/OttoHermansson/GcodeSender/downloads
in your web browser. Then click on the GCodeSender.exe download link.

640px-ArduinoControl_026

ArduinoControl 026:
Choose run when prompted.

Choose run when prompted

ArduinoControl 027:
Choose your save destination.

Choose your save destination

ArduinoControl 028:
Once download has completed, select “open folder”.

Once download has completed, select open folder

ArduinoControl 029:
Now double click the GCodeSender application.

Now double click the GCodeSender application

ArduinoControl 030:
If prompted with a security warning choose “run”.

If prompted with a security warning choose

ArduinoControl 031:
Once in GCodeSender click the “Open” button.

Once in GCodeSender click the Open button

ArduinoControl 032:
Be sure the \r\n bubble is selected.

Be sure the r n bubble is selected

ArduinoControl 033:
Type a “$” without the quotes into the command bar and hit enter.

without the quotes into the command bar and hit enter

ArduinoControl 035:

You need to obtain a set of configurations that can be adjusted to suit your specific application. To adjust the step/mm for “x”, enter $0 = 400 or the required steps per mm value, then press enter. The same process can be applied to any of the other configurations.

Afterwards, you need to verify your configurations by entering X10, then pressing enter. Your device needs to travel 10mm towards the positive “X” axis. You can test the other axis in a similar manner. Simply substitute X with the desired axis.

In some cases, the axis motion direction may need to be reversed based on the machine and configuration being used. Achieving this is done by adjusting the invert mask in the grbl controller. In version .8c, the command $6=”X” is now used instead of older versions using $7=”X”, with X representing the direction(s) to be reversed from a list of values (“None = 0, X=32, Y=64, X+Y=96, Z=128, X+Z=160, Y+Z=192, X+Y+Z=224”). To reverse the Y axis, enter command $6=64.

Another helpful resource is the Grbl controller 3.5 that can be accessed at

http://zapmaker.grblcontroller.s3-website-us-west-2.amazonaws.com/GrblController35Setup.exe – Download the GrblController35Setup.exe file from this website.

The GRBL controller is beneficial for setting up workpieces and visualizing the toolpath. Nonetheless, G-code sender offers better motion control when dealing with arcs.

Once motion control is verified it is recommended to upgrade the GRBL control software on the Arduino. A tutorial is located at
http://wiki.zentoolworks.com/index.php/How_to_upgrade_Arduino_GRBL_software

Source: Arduino Stepper Motor Control


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top