Lesson 24 – Working with a Stepper Motor

Setup

  1. Before you start working with any of the tutorials in this series please make sure you have completed the following tasks –
    1. Downloaded and installed the Arduino IDE.
    2. Are able to connect to the Arduino IDE from your computer
    3. Have been successful in uploading a simple (e.g. Blink LED’s) example programs (that comes with the Arduino IDE) onto your Arduino UNO board
  2. If you haven’t installed the Arduino IDE please head back to the first tutorial and make sure you’ve gone through each of the steps involved.
  3. Once you’ve sorted all of the above you are ready to move onto the next tutorial.

Tutorial

A stepper motor is an electro-mechanical device which converts electrical pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied.One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open loop system. Open loop control means no feedback information about position is needed. This type of control eliminates the need for expensive sensing and feedback devices such as optical encoders. Your position is known simply by keeping track of the input step pulses.

Features:

  1. The rotation angle of the motor is proportional to the input pulse.
  2. The motor has full torque at standstill(if the windings are energized)
  3. Precise positioning and repeatability of movement since good stepper motors have an accuracy of – 5% of a step and this error is non cumulative from one step to the next.
  4. Excellent response to starting/stopping/reversing.
  5. Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply dependant on the life of the bearing.
  6. The motors response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.
  7. It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the shaft.
  8. A wide range of rotational speeds can be realized as the speed is proportional to the frequency of the input pulses.

Parameters of Stepper Motor 28BYJ-48:

  1. Model: 28BYJ-48
  2. Rated voltage: 5VDC
  3. Number of Phase: 4
  4. Speed Variation Ratio: 1/64
  5. Stride Angle: 5.625° /64
  6. Frequency: 100Hz
  7. DC resistance: 50Ω±7%(25℃)
  8. Idle In-traction Frequency: > 600Hz
  9. Idle Out-traction Frequency: > 1000Hz
  10. In-traction Torque >34.3mN.m(120Hz)
  11. Self-positioning Torque >34.3mN.m
  12. Friction torque: 600-1200 gf.cm
  13. Pull in torque: 300 gf.cm
  14. Insulated resistance >10MΩ(500V)
  15. Insulated electricity power: 600VAC/1mA/1s
  16. Insulation grade: A
  17. Rise in Temperature <40K(120Hz)
  18. Noise <35dB(120Hz,No load,10cm)

Here’s the hardware you will need for the tutorials –

  1. Arduino Board x1
  2. Breadboard jumper wire x 10
  3. 1 x Stepper motor

You will find fritzing diagrams below outlining circuit connections for both the Arduino Uno and the Arduino Mega 2560.

Let’s have a look at the code for the tutorial.

Please note – The line of code with #include is incomplete. It should read –

#include <Stepper.h>

#include    
#define STEPS 100  
Stepper stepper(STEPS, 8, 9, 10, 11);  
int previous = 0;  
void setup()
{
  stepper.setSpeed(90);
 }   
 void loop()
 {    
   int val = analogRead(0);      
   stepper.step(val - previous);     
   previous = val;
 }

Download the above code to the controller board and see the result.


Prerequisites

This development track requires an investment a bit of hardware. See below for details –

  1. Arduino IDE –
    1. You will need to download and install the Arduino development IDE.
    2. The approach to installation, configuration, setup of the Arduino IDE is covered in our tutorials.
  2. Arduino Uno, Sensors, etc. –
    1. You will need to purchase the Super Learning Kit for Arduino from OzToyLib.
    2. The Arduino Advent kit has all the sensors you need to perform the tutorials covered in this development track.
    3. If you do not have an Arduino Uno or Arduino Mega 2560 you might want to head over to Arduino boards and pick one up now.

The Super Learning Kit for the Arduino kit has all the sensors you need to perform the tutorials covered in this development track.


About the Super Learning Kit for Arduino

The Super Learning Starter Kit for Arduino comes packed with ~35+ different electronic bits (Sensors, LEDs, switches, LCD, servo, etc.) and can be purchased with either the Keyestudio UNO R3 or the Keyestudio Mega 2560 board. The Keyestudio Arduino boards can be used to interface with the different electronic bits i.e. sensors, LED’s, switches, servos, etc. included in the starter kit. The starter kit for the Keyestudio Uno R3 offers a great opportunity to explore the world of electronics using the Arduino Development Platform. Interact with the real world through the various sensors, create innovative projects, learn how to program the micro:bit to read data from the sensors and perform certain actions. The starter kit for the Arduino is a great way to dive into the awesome world of electronics and get started with your own STEM (Science, Technology, Engineering, Math) learning journey.

The Arduino advanced study kit walks you through the basics of using the Arduino in a hands-on way. You’ll learn the fundamentals of electronics and working on the Arduino through building several creative projects. The kit includes a selection of the most common and useful electronic components with a book of 32 projects. Starting the basics of electronics, to more complex projects, the kit will get you interacting with the physical world using sensor and actuators. Along with the kit you get access to detailed tutorials and wiring diagrams.

You can purchase the Super Learning Kit for Arduino from OzToyLib.


About the Arduino UNO

The Arduino UNO is the most used and documented board of the whole Arduino family and very easy to setup, play with. The Arduino UNO is a microcontroller board based on the ATmega328 . The Arduino UNO has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. Here’s a listing of the some of the features of the Arduino UNO –

  1. Microcontroller: ATmega328
  2. Operating Voltage: 5V
  3. Input Voltage (recommended): 7-12V
  4. Input Voltage (limits): 6-20V
  5. Digital I/O Pins: 14 (of which 6 provide PWM output)
  6. Analog Input Pins: 6
  7. DC Current per I/O Pin: 40 mA
  8. DC Current for 3.3V Pin: 50 mA
  9. Flash Memory: 32 KB of which 0.5 KB used by bootloader
  10. SRAM: 2 KB (ATmega328)
  11. EEPROM: 1 KB (ATmega328)
  12. Clock Speed: 16 MHz

Arduino is an open-source, prototyping platform and its simplicity makes it ideal for hobbyists to use as well as professionals. The Arduino UNO contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The Arduino UNO differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega8U2 microcontroller chip programmed as a USB-to-serial converter. “Uno” means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Arduino Uno and version 1.0 will be the reference versions of Arduno, moving forward. The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform.

You can read more about the Arduino here – www.arduino.cc.

Questions