So far, I have not really delved into motors, especially stepper motors. Recently, I have been planning a project that requires relatively precise motor control, so I might use a stepper motor, but I quickly realized that I should first learn more about them. This article mainly introduces what I have learned so far.
What is a Stepper Motor?
A stepper motor is an electromagnetic device that moves in discrete steps. It has several coils that make up “phases” and drives the motor when each phase is energized in sequence. One of the huge benefits of this method is that stepper motors can achieve very precise positioning and/or speed control, which is why they are widely used in high-precision applications like printers.
Unipolar and Bipolar
There are two different types of stepper motors: unipolar and bipolar. The main difference between them is their winding arrangement, which affects how each is controlled.
Unipolar
This type of stepper motor consists of a single winding with a center tap. Depending on the direction of the desired magnetic field, each part of the winding is energized, allowing the magnetic poles to reverse without switching the direction of current. Center taps are more common, although a two-phase unipolar stepper motor typically has 6 leads (3 for each phase), and the two common terminals can be internally connected, meaning there are only five leads.
Bipolar
Unlike unipolar stepper motors, bipolar stepper motors have only a single winding per phase, without a tap. To reverse the magnetic poles, the current in the winding needs to be reversed, which means that driving a bipolar stepper motor is usually more complex and typically requires an H-bridge arrangement. Since there is no common terminal, each phase has two leads, and a typical two-phase motor will have four leads. Although bipolar motors are generally more complex to drive, they do have their advantages; due to better use of the windings, bipolar motors are more powerful than unipolar motors of the same weight. This is because unipolar stepper motors have twice the amount of wire in the same space and can only use half of it at any one time, meaning they only have about 50% efficiency.
Unipolar and bipolar stepper motors have several different winding arrangements, as shown below.
Arduino Motor Shield
The Arduino motor shield uses the L298 dual H-bridge driver, allowing the control of one stepper motor or two DC motors. With this shield, you can individually control speed and direction. The motors can be directly connected to the Arduino development board without the need for a breadboard or any other circuit board that is usually required when using Arduino.
Motor Used
The motor I decided to use for this project is a unipolar bipolar, unipolar stepper motor from Cliff Electronics, which is a five-lead unipolar stepper motor, but can be considered a bipolar stepper motor if you ignore the common lead.
Since this motor requires a 12V power supply, I had to separate the power lines for the shield and the Arduino Uno board to avoid any possible damage, as suggested on the Arduino motor shield webpage. Because the power lines must be separate, I could no longer use a 12V power supply directly plugged into the Arduino, so this also had to be modified. It must be separated so that it can power the six screw terminals on the Arduino and the Arduino motor shield. To do this, I cut about four inches off the socket, then used the same length of tinned wire to solder them together connecting to the rest of the cable to the plug.
Identifying the Motor’s Coils
The manufacturer’s datasheet for the motor I chose actually told me which wire was which. From the datasheet, I know that the blue and yellow wires form one coil, the pink and orange wires form another coil, and the red wire is the common terminal for both coils. I connected one coil to channel A on the motor shield and the other coil to channel B on the motor shield while leaving the common terminal unconnected. I can ignore the red wire since it is the tap point for both coils. If I were to use the motor as a unipolar stepper motor, I would connect it this way.
If the datasheet does not specify which wire belongs to which coil, it is easy to determine using a multimeter set to ohms. A part of the coil will show resistance, and the tap wire of the coil will be half of the total resistance, so make sure to check other wires to ensure the center tap is not confused with a terminal. If there is zero resistance, it indicates that these are two separate coils.
Driving the Motor
Since I have connected the motor as needed, the next step is to find code that works with the motor shield, so I have a rough idea of where to start. I found some code in the Instructables Arduino Motor Shield tutorial that allows me to rotate my motor. The code works well, but what I really want to do is include the Stepper.h library in the framework used, which this example does not use. Using the official library is the best way to drive the motor, so I looked for another example and found one in an Arduino forum. In that framework, the motor rotates 360 degrees in one direction and then 360 degrees in the opposite direction.
In this framework, I need to specify the number of steps per revolution for the motor used – but first, I must determine this. The manufacturer’s datasheet specifies the motor’s increments as 5.625 and 11.25 degrees, so I used this to determine the steps per revolution – for this, we need to divide 360 by the angle. Since this motor is also gear-driven with a gear ratio of 1:64, we need to multiply the steps by the gear ratio. Like this:
360 / 11.25 × 64 = 2048
360 / 5.625 × 64 = 4096
Initially, I used 4098 steps per revolution in the code, assuming the motor’s angle was 5.625 degrees, but when I did this, it completed two full rotations counterclockwise, then rotated two weeks clockwise. It was clear that I had assumed the wrong angle; because it made two rotations, since 5.625 is half of 11, using it in the numerator would provide a result twice as large, resulting in two full rotations. I changed the steps per revolution to 2048, at which point the motor rotated one turn clockwise and one turn counterclockwise. I also changed the motor speed from two to five, as it seemed too slow when set to two.
Then I looked at the source code of the Stepper library and saw that there was no code to control the brake pin. The example includes code to control the brake pin, defining it as an output and setting it to logic low as a precaution to prevent it from floating.
I feel like I have learned a lot about stepper motors; it is very interesting to understand how they work and how various winding arrangements affect their operation. I am really excited to be able to use them in future projects.
Thank you very much for following the Electronics Technology Forum. For more exciting tutorials on Arduino development boards, please click “Read Original“.
Leave a Comment
Your email address will not be published. Required fields are marked *