0% found this document useful (0 votes)
444 views

Controlling NEMA 17 Stepper Motor With Arduino and A4988 Stepper Driver Module

Stepper motor control

Uploaded by

sanjib rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
444 views

Controlling NEMA 17 Stepper Motor With Arduino and A4988 Stepper Driver Module

Stepper motor control

Uploaded by

sanjib rai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

ARDUINO (HTTPS://CIRCUITDIGEST.

COM/ARDUINO-PROJECTS)
"
Controlling NEMA 17 Stepper Motor with Arduino and A4988
Stepper Driver Module (/microcontroller-projects/controlling-
nema-17-stepper-motor-with-arduino-and-a4988-stepper-driver-
module)
By (page_author.html)Ashish Choudhary (/users/ashish-choudhary) ! Sep 10, 2019 0
Controlling NEMA 17 Stepper Motor with Arduino and Potentiometer

A stepper motor (https://circuitdigest.com/tutorial/what-is-stepper-motor-and-how-it-works) is a type of DC motor that works in discrete steps


and used everywhere from a surveillance camera to sophisticated robots and machines. Stepper motors provide accurate controlling, and can
be differentiated on the basis of torque, steps per revolution, and input voltage. In our previous project, we controlled 28-BYJ48 stepper motor
using Arduino (https://circuitdigest.com/microcontroller-projects/stepper-motor-control-with-potentiometer-arduino). 28-BYJ48 has relatively
lower torque than the other stepper motors like NEMA 14, NEMA17.

In this tutorial, we are going to control NEMA17 stepper motor using Arduino Uno and A4988 stepper driver module. Nema17 stepper motor
has higher torque and higher operating voltage than 28-BYJ48. Here a potentiometer will also be attached to control the direction of stepper
motor.

Component Required

Arduino UNO
NEMA17 Stepper Motor
A4988 Stepper Driver Module
47 µf Capacitor
Potentiometer

NEMA17 Stepper Motor


Operation of Nema17 is similar to normal Stepper Motors (https://circuitdigest.com/tutorial/what-is-stepper-motor-and-how-it-works). NEMA 17
stepper motor has a 1.7 x 1.7-inch faceplate, and it usually has more torque than the smaller variants, such as NEMA 14. This motor has six lead
wires, and the rated voltage is 12 volt. It can be operated at a lower voltage, but torque will drop. Stepper motors do not rotate they step, and
NEMA17 motor has a step angle of 1.8 deg. means it covers 1.8 degrees in every step. Wiring diagram for NEMA17 is given below.

LED driver 12V to 48V LED LED Driver


Power Supply

Inquire Now Inquire Now Inquire Now

* Disclaimer
As you can see that this motor has a Unipolar six-wire arrangement. These wire are connected in two split windings. Black, Yellow, Green wires
are part of ^rst winding where Black is center tap, and Yellow and Green are coil end while Red, White, and Blue is part of a second winding, in
which White is center tap and Red and Blue are coil end wires. Normally center tap wires left disconnected.

Steps Per Revolution for NEMA17

Steps Per Revolution for a particular stepper motor is calculated using the step angle of that stepper motor. So in the case, NEMA 17 step angle
is 1.8 deg.

Steps per Revolution = 360/ step angle


360/1.8 = 200 Steps Per Revolution

SpeciDcations of NEMA17

Rated Voltage: 12V DC


Step Angle: 1.8 deg.
No. of Phases: 4
Motor Length: 1.54 inches
4-wire, 8-inch lead
200 steps per revolution, 1.8 degrees
Operating Temperature: -10 to 40 °C
Unipolar Holding Torque: 22.2 oz-in

Also check various stepper motor related projects (https://circuitdigest.com/tags/stepper-motor) here, which not only incudes basic interfacing
with various microcontrollers but also have robotics projects (https://circuitdigest.com/robotics-projects) which involves stepper motor.

A4988 Stepper Driver Module

A stepper driver module controls the working of a stepper motor. Stepper drivers send the current to stepper motor through various phases.

The A4988 Nema 17 stepper driver is a microstepping driver module that is used to control bipolar stepper motors. This driver module has a
built-in translator that means that we can control the stepper motor using very few pins from our controller.

Using this Nema 17 motor driver module, we can control stepper motor by using only two pins, i.e., STEP and DIRECTION. STEP pin is used to
control the steps while DIRECTION pin is used to control the direction of the motor. A4988 driver module provides Dve different step
resolutions: full-step, haft-step, quarter-step, eight-step, and sixteenth-step. You can select the different step resolutions using the resolution
selector pins ((MS1, MS2, and MS3). The truth table for these pins is given below:
MS1 MS2 MS3 Microstep Resolution

Low Low Low Full Step

High Low Low ½ Step (Half Step)

Low High Low ¼ Step (Quarter Step)

High High Low 1/8 Step (Eighth Step)

High High High 1/16 Step (Sixteenth Step)

SpeciDcations of A4988

Max. Operating Voltage: 35V

Min. Operating Voltage: 8V

Max. Current Per Phase: 2A

Microstep resolution: Full step, ½ step, ¼ step, 1/8 and 1/16 step

Reverse voltage protection: No

Dimensions: 15.5 × 20.5 mm (0.6″ × 0.8″)

Circuit Diagram

(/fullimage?

i=circuitdiagram_mic/Circuit-Diagram-for-Controlling-NEMA17-Stepper-Motor-with-Arduino.png)

SPONSORED SEARCHES
A4988 Arduino Code

NEMA 17 Stepper Motor


Circuit diagram to control Nema 17 stepper motor with Arduino is given in the above image. As A4988 module has a built-in translator that
means we only need to connect the Step and Direction pins to Arduino. Step pin is used for controlling the steps while the direction pin is used
to control the direction. Stepper motor is powered using a 12V power source, and the A4988 module is powered via Arduino. Potentiometer is
used to control the direction of the motor.

If you turn the potentiometer clockwise, then stepper will rotate clockwise, and if you turn potentiometer anticlockwise, then it will rotate
anticlockwise. A 47 µf capacitor is used to protect the board from voltage spikes. MS1, MS2, and MS3 pins left disconnected, that means the
driver will operate in full-step mode.

Complete connections for Arduino Nema 17 A4988 given in below table.

S.NO. A4988 Pin Connection

1 VMOT +ve Of Battery

2 GND -ve of Battery

3 VDD 5V of Arduino

4 GND GND of Arduino

5 STP Pin 3 of Arduino

6 DIR Pin 2 of Arduino

7 1A, 1B, 2A, 2B Stepper Motor

Code Explanation

Complete code with working video control Nema 17 with Arduino is given at the end of this tutorial, here we are explaining the complete
program to understand the working of the project.

First of all, add the stepper motor library to your Arduino IDE. You can download the stepper motor library from here
(https://github.com/arduino-libraries/Stepper).
After that de^ne the no of steps for the NEMA 17. As we calculated, the no. of steps per revolution for NEMA 17 is 200.

#include <Stepper.h>
#define STEPS 200

After that, specify the pins to which driver module is connected and de^ne the motor interface type as Type1 because the motor is connected
through the driver module.

Stepper stepper(STEPS, 2, 3);


#define motorInterfaceType 1

Next set the speed for stepper motor using stepper.setSpeed function. Maximum motor speed for NEMA 17 is 4688 RPM but if we run it faster
than 1000 RPM torque falls of quickly.

void setup() {
stepper.setSpeed(1000);

Now in the main loop, we will read the potentiometer value from A0 pin. In this loop, there are two functions one is potVal, and the other is Pval.
If the current value, i.e., potVal is higher than the previous value, i.e., Pval than it will move ten steps in the clockwise direction and if the current
value is less than previous value than it will move ten steps in the counter-clockwise direction.

potVal = map(analogRead(A0),0,1024,0,500);
if (potVal>Pval)
stepper.step(10);
if (potVal<Pval)
stepper.step(-10);

Pval = potVal;

Now connect the Arduino with your laptop and upload the code into your Arduino UNO board using Arduino IDE, select the Board and port no
and then click on the upload button.

Now you can control the direction of Nema17 stepper motor using the potentiometer. The complete working of the project is shown in the
video below. If you have any doubts regarding this project, post them in the comment section below.

Code
#include <Stepper.h>

#de^ne STEPS 200

// De^ne stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver

Stepper stepper(STEPS, 2, 3); // Pin 2 connected to DIRECTION & Pin 3 connected to STEP Pin of Driver

#de^ne motorInterfaceType 1

int Pval = 0;

int potVal = 0;

void setup() {

// Set the maximum speed in steps per second:

stepper.setSpeed(1000);

void loop() {

potVal = map(analogRead(A0),0,1024,0,500);

if (potVal>Pval)
stepper.step(10);

if (potVal<Pval)

stepper.step(-10);

Pval = potVal;

Video

Controlling NEMA 17 Stepper Motor with Arduino and Potentiometer

TAGS ARDUINO (/TAGS/ARDUINO) ARDUINO UNO (/TAGS/ARDUINO-UNO) STEPPER MOTOR (/TAGS/STEPPER-MOTOR)

INTERFACING (/TAGS/INTERFACING) POTENTIOMETER (/TAGS/POTENTIOMETER) NEMA17 (/TAGS/NEMA17)

RECOMMENDED POSTS

(http://bit.ly/2qhkOds )

IoT Device Security Conference 2020 (http://bit.ly/2qhkOds )

(http://bit.ly/2NLAL4l )

Proactive Ecosystem Collaboration for Autonomous Driving Systems (http://bit.ly/2NLAL4l )

(http://bit.ly/37efx6G )

The Current State of Machine Vision Technology (http://bit.ly/37efx6G )


(http://bit.ly/3arbcz6 )

The Buffer/Driver: What Is It, and Do I Need One? (http://bit.ly/3arbcz6 )

(http://bit.ly/2THbcFm )

Embedded Insiders: Recapping the 2020 Consumer Electronics Show (http://bit.ly/2THbcFm )

(http://bit.ly/30G58OA )

Dealing with Legacy in Industrial IoT (http://bit.ly/30G58OA )

(http://bit.ly/36iL2vl )

Introduction to the SPI Interface (http://bit.ly/36iL2vl )

(http://bit.ly/3aIFQEt )

Dev Kit Weekly: Renesas EK-RA6M3G Graphics Evaluation Kit (http://bit.ly/3aIFQEt )

Get Our Weekly Newsletter!


Subscribe below to receive most popular news, articles and DIY projects from Circuit Digest

Email Address *

Name

Country
United States of America
Subscribe

RELATED CONTENT

(/microcontroller-projects/adustable-electronic-dc-load-using-arduino)

Build your own Adjustable Electronic DC Load using Arduino (/microcontroller-projects/adustable-electronic-dc-load-using-arduino)

(/microcontroller-projects/arduino-smart-restaurant-menu-ordering-menu-ordering-system)

Smart Restaurant Menu Ordering System using Arduino (/microcontroller-projects/arduino-smart-restaurant-menu-ordering-menu-ordering-


system)

(/microcontroller-proejcts/arduino-buzz-wire-game)

Make a Buzz Wire Game with an Arduino (/microcontroller-proejcts/arduino-buzz-wire-game)

(/microcontroller-projects/ac-fan-speed-control-using-arduino-and-triac)

AC Fan Speed Control using Arduino and TRIAC (/microcontroller-projects/ac-fan-speed-control-using-arduino-and-triac)

(/microcontroller-projects/arduino-walkie-talkie-using-nrf24l01)

Long Range Arduino Based Walkie Talkie using nRF24L01 (/microcontroller-projects/arduino-walkie-talkie-using-nrf24l01)

(/microcontroller-projects/arduino-rc-car-using-bldc-motors-and-nrf24l01-rf-module)

Fastest Arduino RC Car using Coreless DC Motors and nRF24L01 RF module (/microcontroller-projects/arduino-rc-car-using-bldc-motors-
and-nrf24l01-rf-module)
(/news/arduino-releases-new-ide-1811-with-improved-mac-os-support-and-reduced-build-time)

Arduino Releases new IDE 1.8.11 with Improved MAC OS Support and Reduced Build Time (/news/arduino-releases-new-ide-1811-with-
improved-mac-os-support-and-reduced-build-time)

(/microcontroller-projects/arduino-based-water-wow-sensor)

Measuring water Flow Rate and Volume using Arduino and Flow Sensor (/microcontroller-projects/arduino-based-water-wow-sensor)

# PREVIOUS POST
DIY Pick and Place Robotic Arm using ARM7-LPC2148 ARM Microcontroller (https://circuitdigest.com/microcontroller-projects/diy-
robotic-arm-using-lpc2148-microcontroller)

NEXT POST $
Arduino Sleep Modes and How to use them to Save the Power (https://circuitdigest.com/microcontroller-projects/arduino-sleep-
modes-and-how-to-use-them-to-reduce-power-consumption)

COMMENTS

LOG IN (/USER/LOGIN?DESTINATION=NODE/4121%23COMMENT-FORM) OR REGISTER (/USER/REGISTER?


DESTINATION=NODE/4121%23COMMENT-FORM) TO POST COMMENT

TI INA293 High-Precision Current Sense Ampli^ers (http://bit.ly/2PuO9KS )


Measure voltage drops across shunt resistors from -4V to 110V.

(http://bit.ly/2PuO9KS
)
TI TPS7A24 Low-Dropout Linear Voltage Regulator (http://bit.ly/3aeOQ2K )
Supports a 2.4V to 18V input voltage range with ultra-low quiescent current (IQ).

(http://bit.ly/3aeOQ2K
)
Panasonic SVPT Conductive Polymer Aluminum Solid Capacitors (http://bit.ly/2T78x7e )
Feature low ESR range from 15–24mΩ and cover a capacitance range of 100µF to 5600µF.
(http://bit.ly/2T78x7e
)
ON Semiconductor NxHL080N120SC1 N-Ch SiC MOSFETs (http://bit.ly/2Tg70dC )
1200V, 80mΩ MOSFETs that provide superior switching performance and high reliability.

(http://bit.ly/2Tg70dC
)
Microchip VC-801 CMOS Crystal Oscillators (XO) (http://bit.ly/3acX9MA )
Quartz stabilized square wave generator with a CMOS output.

(http://bit.ly/3acX9MA
)
MAX17634x Synchronous Step-Down DC-DC Converter (http://bit.ly/2wUVgpE )
Comes with integrated MOSFETs and operates over an input-voltage range of 4.5V to 36V.

(http://bit.ly/2wUVgpE
)
Coilcraft 1812CAN Common Mode Choke Inductors (http://bit.ly/32xaTiC )
Designed for CAN or CAN FD in automotive or general industrial automation applications.

(http://bit.ly/32xaTiC
)
Analog Devices ADPD188BI Integrated Optical Module (http://bit.ly/2PxuOJ5 )
Complete photometric systems for smoke detection using optical dual-wavelength technology.

(http://bit.ly/2PxuOJ5
)
NEWS ARTICLES PROJECTS

New Ultra-compact 5 to 15W AC/DC Converters from MORNSUN (/news/new-ultra-compact-5-15w-ac-dc-converters-from-mornsun)

(/news/new-
ultra-
compact-5-
15w-ac-dc-
converters-
from-
mornsun)

Low Power Dual Channel Digital Isolators to Protect Electronic Subsystems from Noise and High Voltages (/news/low-power-dual-
channel-digital-isolators-to-protect-electronic-subsystems-from-noise-and-high-voltages)

(/news/low-
power-dual-
channel-
digital-
isolators-to-
protect-
electronic-
subsystems-
from-noise-
and-high-
voltages)

Low Pro^le, 4.3V to 65V non-isolated SMD DC/DC Converter with 0.5A Output Current (/news/low-pro^le-43v-65v-non-isolated-smd-
dcdc-converter-with-05a-output-current)

(/news/low-
pro^le-43v-
65v-non-
isolated-smd-
dcdc-
converter-
with-05a-
output-
current)

High Ezciency 18V, 6A Synchronous DC-DC Buck Converter with integrated MOSFET (/news/high-ezciency-18v-6a-synchronous-dc-dc-
buck-converter-with-integrated-mosfet)

(/news/high-
ezciency-
18v-6a-
synchronous-
dc-dc-buck-
converter-
with-
integrated-
mosfet)

LiDAR ICs by Maxim Offer More Than 2x Higher Bandwidth for Faster Self-Driving Cars (/news/lidar-ics-by-maxim-offer-more-than-2x-
higher-bandwidth-for-faster-self-driving-cars)

(/news/lidar-
ics-by-maxim-
offer-more-
than-2x-
higher-
bandwidth-
for-faster-self-
driving-cars)

FEATURED
PRODUCTS

Start your automotive design today with TI mmWave sensors (http://bit.ly/32Ep05L )


From long-range radar and lane-change assist to vital sign monitoring and child detection, TI mmWave sensors can be the primary sensing product in...

(http://bit.ly/32Ep05L
)
Kick-start your Wi-Fi development (http://bit.ly/38bOubZ )
Ramp to production in as little as 6 months with the newest SimpleLink™ Wi-Fi® LaunchPad™ development kits.

(http://bit.ly/38bOubZ
)
The CLB can customize what you need within your design. (http://bit.ly/2I4knbM )
Integrate custom logic and augment peripheral capability with C2000™ MCUs con^gurable logic block (CLB) peripheral.

(http://bit.ly/2I4knbM
)
The next-generation TI mmWave sensor for ADAS (http://bit.ly/2vw0Wpw )
Solve long-range ADAS challenges with the second-generation AWR2243.

(http://bit.ly/2vw0Wpw
)

Connect with us on social media and stay updated with latest news, articles and projects!

% & ' ( ) (https://www.linkedin.com/company/circuit-

(https://www.facebook.com/circuitdigest/)
(https://twitter.com/CircuitDigest)
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IPdLmw)
(https://www.instagram.com/circuit_digest/)
(https://www.pinterest.com/circuitdigest/)
digest/)

CATEGORIES

Embedded Electronics (https://circuitdigest.com/embedded)

Power Electronics (https://circuitdigest.com/power-electronics)

Analog Electronics (https://circuitdigest.com/analog-electronics)

Internet of Things (https://circuitdigest.com/internet-of-things)

Audio Electronics (https://circuitdigest.com/audio-electronics)

Electric Vehicles (https://circuitdigest.com/electric-vehicles)


Events (https://circuitdigest.com/events)

POPULAR

ROBOTICS (/ROBOTICS-PROJECTS) 555 CIRCUITS (/555-TIMER-CIRCUITS) ARDUINO PROJECTS (/ARDUINO-PROJECTS)

RASPBERRY PI PROJECTS (/SIMPLE-RASPBERRY-PI-PROJECTS-FOR-BEGINNERS) ELECTRONICS NEWS (HTTPS://CIRCUITDIGEST.COM/NEWS)

ELECTRONICS FORUM (HTTPS://CIRCUITDIGEST.COM/FORUMS) CALCULATORS (HTTPS://CIRCUITDIGEST.COM/CALCULATORS)

NEWSLETTER

Sign Up for Latest News

Enter your email

Subscribe

Copyright © 2020 Circuit Digest (http://circuitdigest.com/). All rights reserved.

Privacy Policy (http://circuitdigest.com/privacy-policy) | Cookie Policy (https://circuitdigest.com/cookie-policy) | Terms of Use (https://circuitdigest.com/terms-of-use) | Contact Us
(http://circuitdigest.com/contact) | Advertise (http://circuitdigest.com/advertise)

You might also like