How to control NEMA Stepper Motor with Arduino and MicroStep Driver

by Oct 24, 2022Arduino Uno, arduino uno projects

For precisely moving and positioning mechanical items, stepper motors are the best option. The position of the motor shaft can be precisely adjusted by using techniques like microstepping.

There are numerous sizes of stepper motors available. The steppers that DVD and Blu-Ray drives employ to position the laser head are at the low end of the scale. On the other end of the spectrum are big steppers that can regulate the positioning of CNC and 3D printers that are industrial in size.

The big stepper motors can be used with an Arduino in a manner similar to the smaller ones. The choice of a driver module is where the primary differences lie.

What is a Stepper Motor?

A stepper motor is a synchronous, brushless electric motor that transforms digital pulses into mechanical shaft rotations. A stepper motor’s rotation is broken down into a specified number of steps, often as many as 200 steps. For each step, a different pulse needs to be supplied to the stepper motor. Only one pulse can be received by the stepper motor at a time, and each step must be the same length. You can precisely control the position of the stepper motor without a feedback device since each pulse causes the motor to rotate at a precise angle, typically 1.8 degrees. The stepping movement transforms into a continuous rotation with a rotational speed that is directly proportional to the frequency of the control pulses as the digital pulses from the controller increase in frequency. Due to their incredible accuracy, stepper motors are utilized in devices like 3D printers, CNC machines, laser engravers, and others.

The printer is more capable of accuracy the smaller the available step. Because the stepper motor on certain machines has a full step of 0.04 mm, it is recommended that you select a layer height that is divisible by 0.04. But thanks to a feature known as microstepping, 3D printers have other options besides taking single, complete steps.

Microstepping

Microstepping is the splitting up of a large step into several smaller ones. These more minute steps, sometimes known as “microsteps,” are frequently expressed as fractions with a denominator that is a multiple of 2, including 1/16, 1/32, or 1/64. As we previously noted, microstepping enables the motor to spin over a smaller distance than a full step.

The stepper motor winding is energized by microstepping in a way that splits the number of positions between the poles even more. A full step (1.8 degrees) can be divided into 256 microsteps by some microstepping controllers. One rotation (.007 deg/step) would have 51,200 steps. Microstepping is typically used in situations where precise positioning and more fluid motion over a wide speed range are necessary. Microstepping, like half-step mode, reduces torque by around 30% in comparison to full-step mode.

In this tutorial, we will see how to program the NEMA stepper motor with Arduino.

Hardware Required

  1. NEMA Stepper Motor
  2. Microstep Driver
  3. Power Supply 12VDC
  4. Arduino Mega / Arduino Uno
  5. Jumper Wires

Software – Arduino IDE

Wiring Diagram

Follow the wiring diagram for your connection with Arduino and the stepper motor.

The micro step driver has differential inputs for their step and direction inputs, usually called “PUL+” and “PUL-” (for”pulse” or “step”) and “DIR+” and “DIR-” (for “direction”).

The DIR+ and PUL+ are connected to the digital pins 2 and 3 of the Arduino. The negatives are grounded.

The stepper motor is connected to the A and B pins.

The stepper motor is hooked up to a 12VDC power supply.

Code (1)

Open your Arduino IDE, and paste the following code. The great news is, you don’t require any external libraries to control the motors.

#define dirPin 2
#define stepPin 3
void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  // Set the spinning direction CW/CCW:
  digitalWrite(dirPin, HIGH);
}
void loop() {
  // These four lines result in 1 step:
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(500);
}
  1. You start the code by defining the pins for the DIR and the PUL – setting the direction and pulse of the motor.
  2. Then declare the output pins as the step pin and the dir pin.
  3. In the void loop, which is the main part of the code, set HIGH for the stepPin which is the pulse of the motor for a period of time, and then set them to LOW. Repeat this to make a number of rotations.
  4. Give some delay, the longer the delay, the lesser the speed of the motor.

Similar Article – Using Stepper motors with Arduino

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

How to use simulators to build Arduino Projects

How to use simulators to build Arduino Projects

Introduction In this tutorial, let's learn how to use simulators for building Arduino projects for beginners. In addition to it, We shall learn how to configure it and how to get started with simulation tools. Here, We shall take an example of blinking an led using...

Arduino and its various development boards

Arduino and its various development boards

1. What is Arduino? Arduino is an open-source software and software company, project, and user community that designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices....

MIT app inventor with Arduino

MIT app inventor with Arduino

MIT app inventor is a platform developed to help you expand your ideas into mobile applications that can be used throughout various devices. Arduino, as you most probably have heard of is mainly used to develop and implement many projects. When you put together the...

Arduino Compatible Temperature Sensors

Arduino Compatible Temperature Sensors

In this article, we will look at Arduino's popular temperature sensors which are the foundation for Arduino's entry level projects. Temperature Sensor Temperature sensors are designed to measure the temperature of an object or substance using the properties and...

ARDUINO MKR 1000

In this article, we are going to learn about Arduino MKR 1000. .Arduino MKR1000 is a powerful board that combines the functionality of the Zero and the Wi-Fi Shield. It is the ideal solution for makers wanting to design IoT projects with minimal previous...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....