The 28BYJ-48 stepper motor is a cheap and robust stepper motor, suitable for use on robotics and other slow-speed applications. In this tutorial, I will guide you on how to use this stepper motor with Arduino.
A unipolar stepper motor follows this diagram: Since the two electromagnets have a common wire, only one power source is necessary for a unipolar stepper motor. The common wire is usually connected to ground. The 28BYJ-48 is a unipolar stepper motor, with five pins as shown: For a unipolar motor, the number of coils is equal to its phase. One of the easiest and inexpensive way to control stepper motors is to interface L293D Motor Driver IC with Arduino. It can control both speed and spinning direction of any Unipolar stepper motor like 28BYJ-48 or Bipolar stepper motor like NEMA 17. If you want to learn the basics of L293D IC, below tutorial is invaluable.
Contents
How Do Stepper Motors Work?
Before I continue, I find it necessary to review the basics of stepper motors.
The 28BYJ-48 motor is a permanent magnet (PM) type stepper and thus share similar characteristics with other PM steppers.
A PM stepper motor has a rotating part (rotor) made out of permanent magnet and a stationary part (stator) of electromagnets. A single motor rotation is divided into steps, hence the name. The number of steps per revolution depends on the number of teeth of the rotor.
To rotate a stepper motor, the electromagnets must be energized in a circular pattern. The rotor, attracted to an energized electromagnet, follows that rotation. Thus, the speed of the stepper motor depends on the speed of the switching of the electromagnets.
Stepper Motor Polarity
There are bipolar and unipolar stepper motors. In a bipolar stepper motor, the electromagnets are alternately energized:
Note that while only two coils (electromagnets) are shown, there could be four coils with the vertical (up and down) and horizontal (left and right) coils each connected in series.
A bipolar stepper motor requires two separate power sources, one for each electromagnet. Because of this, bipolar steppers are not popular with Arduino users. Most high speed stepper motors are bipolar, however.
A unipolar stepper motor follows this diagram:
Since the two electromagnets have a common wire, only one power source is necessary for a unipolar stepper motor. The common wire is usually connected to ground.
The 28BYJ-48 is a unipolar stepper motor, with five pins as shown:
For a unipolar motor, the number of coils is equal to its phase. The 28BYJ-48 has four coils hence, it is a four-phase stepper motor.
More information about this motor is found on its datasheet:
28BYJ-48 Datasheet1 file(s) 192.72 KBMaking a Stepper Motor Rotate
Rotating a stepper motor is often called driving and can be a wave drive, full-step drive, half-step drive or microstep. The last one is complicated and less common so it will not be discussed here.
In a wave drive, one electromagnet or coil is excited at a time:
In a full-step drive, two coils are excited at a time:
Since the full-step drive energizes two coils at a time, it requires more current than a wave step. In exchange of the higher current is higher torque.
A half-step combines a wave and a full-step:
Half-step increases the number of steps per revolution. As you can see in the wave and full-step drives, one revolution takes four steps. In a half-step drive, one revolution takes eight steps. Thus, a half-step drive is recommended for a more precise movements.
Note that the animations shown are somewhat simplified. While the 28BYJ-48 is a four-phase stepper, it doesnât take 8 steps in one revolution for half-step driving. It actually takes 64 steps, according to its datasheet. This is because the rotor of this stepper is not just one magnet.
Using a Driver Board for the 28BYJ-48
In this tutorial, we will be using the ULN2003 driver board with the 28BYJ-48.
The board has 7 input pins IN1 to IN7 but only IN1 to IN4 are usable.
It also has pins for power and switching. This allows you to use a separate power supply with a rating of 5 V to 12 V for the motor.
Upon testing, we found out that the 28BYJ-48 still works at 12 V although the stepper motor is labeled 5 V. It seems higher rotation speeds need higher voltages.
Programming the Arduino
The Arduino platform contains a built-in stepper library which actually works for the 28BYJ-48. Here is a simple sketch that rotates the stepper in one direction then to the other direction:
![]()
To use the sketch, connect the stepper motor to the ULN2003 board, then follow this connection to Arduino.
I suggest you use a separate power supply for the motor since it may draw current beyond the power pins of the Arduino can provide. (I actually did use the Arduino power pins to power the stepper and got one damaged Arduino as a result).
Using a Better Stepper Motor Library
The disadvantage of using the built-in stepper library is that thereâs no option to change the stepping mode as it defaults to wave drive only. Also, the built-in library is limited to one stepper motor.
A better library for controlling stepper motors is the AccelStepper library by AirSpayce.
Besides support for half-step driving and multiple motors, the library also offers acceleration and decceleration functions, among other things.
The following sketch rotates the 28BYJ-48 in one direction with a predetermined number of steps:
An Example Project
I created another sketch where I display the speed and the steps of the stepper motor in a 16x2 LCD:
The following video shows the result of the above sketch:
Unipolar Stepper Drive
Unfortunately, this stepper motor will not produce speeds higher than 15 RPM. NEMA17 stepper motors will produce higher RPMs and those will be the subject of my next tutorial.
Unipolar Stepper Motor Driver Circuit Arduino
Was this post useful? Kindly drop a comment below.
Arduino Stepper Motor Driver Code
Active5 years, 6 months ago
I hope this question is specific enough. Basically I want to know if it matters a great deal what kind of Motor Driver IC(s) or pre-assembled kits you use to drive a Unipolar Stepper Motor.
For example: Can the following Driver be used to control this Stepper Motor?
Driver: https://www.sparkfun.com/products/9670
Motor: http://www.jaycar.com.au/productView.asp?ID=YM2754
Thanks!
Unipolar Stepper Motor Control Arduino
James MillsJames Mills
1 Answer
It does matter. There are pros and cons to each different driver setup.
If you wire the motor as a bipolar, which I'm not sure that you can, you can use the driver that you linked, but it is not very good for driving stepper motors. https://www.sparkfun.com/products/11876 is a better driver for steppers for half the price. (still have to wire it bipolar)
If you need to stick with unipolar wiring, PCBheaven.com shows an example using a CD4017, MOSFETs, and diodes to run a unipolar motor. It will only turn one direction. Instead you could use a micro-controller, such as an Arduino, in place of the CD4017 along with logic-level MOSFETs to go both directions.
A tutorial on the Arduino site uses a ULN2003A, which is not powerful enough to drive your motor to its full potential (does it need to turn, or turn well?) and doesn't have the diodes (important to protect your IC!), but the Arduino sketches would still work using the schematic from PCBheaven.
A couple of complete driver boards:
JerryJJJerryJJ
Driving Stepper Motors With ArduinoNot the answer you're looking for? Browse other questions tagged motor or ask your own question.Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |