Arduino UNO Control Stepper Motor using SD02C

INTRODUCTION

SD02C is designed to drive unipolar or bipolar stepper motor, up to 1.8 Amp peak. With SD02C, you just need a minimum interface, the board is ready to be plug and use. Simply add in power and a stepper motor, this driver is ready to drive the motor. The onboard test button will help to verify the connection. Besides accepting the stepper driver conventional control signal (EN, DIR and PULSE), there is an additional control option UART or serial. With the UART interface, it can be controlled from computer via USB to serial bridge such as UC00A.

A stepper motor is an electric motor that rotates in discrete step increments. The movement of each step is precise and repeatable. Therefore, the motor’s position can be controlled precisely without any feedback mechanism, as long as the motor is carefully sized to the application. This type of control eliminates the need for expensive sensing and feedback devices such as optical encodes. The position is to know simply by keeping track of the input step pulses. It is one of the most versatile forms of positioning systems. They are typically digitally as part of an open loop system and are simpler and more rugged than closed loop servo system.

In this tutorial,  will also use LCD Keypad Shield. It’s come with a 2×16 LCD display and 6  momentary push button. Pins 4,5,6,7,8,9 and 10 are used to interface with the LCD. Just one Analog Pin 0 is used to read the five push button and the other button which is reset is direct connect to Arduino’s reset pin. The used of LCD is to display the Direction, Run, Enable and Pulse while for the buttons is used to configure the stepper motor.

HARDWARE LIST

This tutorial use :

  1. Stepper Driver 2 Ampere (SD02C)
  2. Stepper Motor NEMA 17HS4401
  3. Arduino Uno / CT- Uno
  4. LCD Keypad Shield
  5. USB Cable Micro B
  6. Jumper wire male to male
  7. Jumper wire female to male
  8. 32 in 1 Precision Screwdriver Set
  9. Adapter 12V 2A (UK plug)
  10. DC Jack Female
  11. Screw terminal shield

CHECK ANALOG VALUE FOR EACH BUTTON AT SERIAL MONITOR

Note:

Analogue value changes according to the button that is being pressed. So this step is very important. Otherwise, Arduino can’t recognize the button when pressed. We do need to check the analogue value of each button. Once you get the analogue value, insert the value in the sketch.

LCD keypad shield comes with 6 different keys (buttons), which is Up key, Down key, Right key, Left key, Select key and Reset key. Reset key is directly connected to Arduino’s reset pin. Each key generates different analog value for Arduino to detect different button from a single analog pin. The analog value is generated through a 5 stage voltage divider. The disadvantage is, we can only push one button at one time

  1. Stack LCD keypad shield on top the Arduino UNO / CT-UNO.
  2. Plug in USB cable at Arduino UNO / CT-UNO to laptop
  3. Choose board Arduino  / Genuino UNO and port
  4. Compile and upload the code below.
  5. Open the serial monitor, press any button on LCD keypad Shield and see the value at the serial monitor.

6.    Once you get the analog value,  insert the value to the sketch. But not to forget, the range must be bigger than the actual value. Here is some example.

METHOD 1: ARDUINO UNO CONNECT TO SD02C VIA CONNECTOR (SIGNAL)

Before we start with the tutorial, let me give some information about the new SD02C. The typical method to control stepper motor is Direction, Enable and Pulse, but with SD02C user also can control your stepper motor via UART interface. On this tutorial, we will be able to control the rotation of the motor according to the desired degree.

HARDWARE PREPARATION

  • Connect CT- Uno to the laptop using USB cable micro B
  • Stack CT-Uno / Arduino Uno with Terminal shield.
  • On top Terminal shield stack LCD Keypad Shield.
  • Connect the terminal shield to SD02C
Terminal ShieldSD02C
Pin 11PULSE
Pin 12DIR (Direction)
Pin 13EN (Enable)
GNDGND
  • After that, connect the stepper motor to SD02C
Stepper MotorSD02C
YellowX!
BlueX
GreenY!
RedY

Sample Code

In this sample code, you can control rotation for a stepper motor according to the given angle. For this type of Stepper Motor, a single move will be 1.8°. But users need to use micro stepping mode 1 to get the right angle. Because to complete a 360 ° rotation, each pulse will move by 1.8 ° degrees. Therefore, the pulse value should be 200 pulses to complete a 360 ° rotation. In other cases, if you use micro stepping mode 2. The value of the angle will be 0.9 ° degrees because the original degree value will be divided by 2. Therefore, to complete a 360 ° rotation need 400 pulse.

After uploading the code you should see something like this.

To operate please use the button on the LCD Keypad Shield. These are the function of each button:

Up key: Increase degree (DEGREE)

Down Key: Decrease degree  (DEGREE)

Select Key: Enable (En)

Left Key: Run (Run)

Right Key: Direction (Dir)

METHOD 2 : ARDUINO UNO CONNECT TO SD02C VIA UART INTERFACE

Let’s try another method, this time we will be using UART communication. But first, user needs to connect the RX and TX pin to the microcontroller. These two pins should be cross-connected to the microcontroller. In other words, RX on SD02C should be connected to microcontroller’s transmitter pin (TX), while TX on SD02C should be connected to microcontroller’s received pin (RX). By using the UART control, user can on/off, run/brake and change motor rotation direction in simple commands.

Hardware Preparation

Terminal ShieldSD02C
Pin 2Tx
Pin 3Rx
GNDGND

Sample Code

In this sample code, you will be able to control the pulse of the Stepper Motor. When the pulse increases the motor will rotate faster and vice versa. The micro stepping should be in default which is micro stepping mode 1.

After the uploading proses are done, you should see something like this on your LCD Keypad Shield.

To operate the Stepper Motor, please use the button on the LCD Keypad Shield. These are the function of each button:

Select Key: En (Enable)

Left Key: Run

Right Key: Dir (Direction)

Up Key: Increase the pulse value.

Down Key: Decrease the pulse value.

BUY

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Control Stepper Motor 28BYJ-48 Using TTGO T-Display ESP32
Smart Dustbin
Interface LSM9DS1 9DOF IMU With TTGO T-Display ESP32
Send and Receive SMS Using TTGO ESP32 SIM800L
Getting Started With ProjekIoT.com Using Raspberry Pi
Scroll to Top