stepper motor
Design Project no. 1 - Linear Stage with Open-loop Controls
The goal of this project is to create an automated system capable of moving a carriage to a predefined location along a linear path. Specifically a 1lb rigid load will be applied to a 5"x5" platform without affecting the linear motion.
​
The learning objectives gained from this assignment include: 1) the principles of operating a stepper motor, 2) identify the relative advantages and disadvantages of using full-stepping vs half-stepping control sequences for a stepper motor, 3) utilize Arduino code to control the motion, 4) Use an open-loop control to program the linear position and speed of an object, and 5) implement a homing stage to allow for positioning of a linear stage with respect to a reference position.
Thought & Design Process
In order to control the stepper motor, an Arduino Uno and Shield are used to program its motion. The stepper motor used in this project has 2 coils. The principles of stepping can be programmed to create motion via an Arduino. Individual sketches were created to produce full stepping motion and half stepping motion. To further understand the motor, the displacement versus time of the motion and currents running through the coils were analyzed.
Fig,1: programming setup with stepper motor
Fig. 2: principles of full stepping with 2 coils A & B
Principles of Motor Stepping
For this project, a two phase bipolar stepper motor is used. In general, this is a brushless DC motor which moves in steps. The motor can be positioned without a feedback sensor, which creates an open-loop controller. A rotor resides in the middle with north and south polarities. Four windings surround the rotor, labeled A, B, A', and B'. When a current flows through a winding, an electric field is created that creates a polarity. As a result, the rotor will step to the next winding due to the opposite polarities present. Figure 1 depicts how a rotor would step due to changing polarities in the windings. Figure 2 depicts a half-stepping sequence. Half-stepping provides a more precise control of moving a rotor. The half step made between each full step is created by magnetizing both windings at the same time so the rotor will step between the windings.
Fig. 3: principles of half-stepping with coils A&B
full-stepping Arduino code with bi-directionality and displacement measurement
​
Coils A is defined by pins 12 (direction), 3 (on/off) and 9 (brake). Coil B is defined by pins 13 (direction), 11 (on/off) and 8 (brake). Following the principles of stepper motors, there are four defined sequences to move the rotor 360 degrees. Each sequence is a 90 degree displacement. The stepping sequence within the motor itself is defined as 200 steps for a full rotation while full stepping. In the code, a count is defined to move the four sequences a finite amount of times according to the count. In order to make a full rotation (200 steps), a count of 50 is used since 200 steps divided by 4 sequences results in 50 counts. Once the motor has been through 50 counts, the polarities of the coils are flipped to move the motor back in the opposite direction. The count then begins at 50 and ends at 0 to generate a full rotation in the opposite direction with respect to the original motion. A print statement is included at the end of each sequence to print out the amount of time that has elapsed and the amount of steps the motor has taken. Finally the motor is powered off.
full-stepping Arduino code with bi-directionality and current measurement
​
The initial setup is the same as the code above, however with the addition of iA and iB being defined. iA and iB represent the current values flowing through coils A and B respectively. The same stepping sequence is used as before. The current measurements are defined by reading the analog signal and converting into milliamps. The Arduino predefines 0V as a value of 0 and 5V as a value of 1023 based on bits. When reading in the analog signal from either ports 0 (iA) or 1 (iB), that value is divided by 1023 and multiplied by 5 resulting in a true voltage value. Then to convert the voltage to milliamps, the value is is divided by 1.65 (a predefined sensitivity value conversion from the Arduino) to get amps and then multiplied by 1000 to get milliamps. iA and iB are then printed so the current measurements can be plotted or recorded.
half-stepping Arduino code with bi-directionality and current measurement
​
The code initially follows the same setup as both of the previous ones mentioned, with the coils and current measurements being predefined the same way. This code is almost identical to the full-stepping code with current measurement, except with a half stepping sequence. In order to perform a half step, both coils are energized at the same time to cause rotor to only step 45 degrees. The sequence is described in Figure 3. Since half-stepping involves twice the amount of sequences as full-stepping, the count is doubled as well. In order to travel a full 360 degrees, 400 steps within the motor are required. In terms of counting, 8 different sequences are cycled through for one full rotation, resulting in the counter being 50 to make one full rotation.
Arduino Motor Code Tests
full-stepping motion in two directions
half-stepping motion in two directions
The motor takes 200 steps to make a full rotation while full stepping or 400 steps while half stepping. The steps can be converted into angular displacement from 0 - 360 degrees. The graph on the left showcases the angular displacement of a motor full stepping. As the shaft makes a full rotation in one direction and reverses afterwards, the overall displacement goes from 0 to 360 and back to 0 degrees. The greater the speed of the motor, the faster the angular displacement is with respect to time.
Fig. 4: Angular Displacement vs Time of the motor shaft with different speeds
For a full-stepping motion, the two coils are turned on and off one after the other with changing polarities to allow for a 90 degree step. The graph visualizes this effect by illustrating one coil having no current while the other coil is fully energized. The currents alternate when the motor moves in the opposite direction which can be seen at the midway point.
Fig. 5: Current vs Time for full-stepping motor
Half-stepping utilizes a more complex system of stepping. It begins the same with one coil off and one energized, but the half step is then produced by both coils being on at the same time. With both on, the currents are simultaneously shared until the next step, which would result in the repetition of the same pattern.
Fig. 6: Current vs Time for half-stepping motor
Mechanical Construction
The linear rail system is built with an 8mm lead screw and nut, a shaft coupling for the motor connection, linear ball bearings, guide rods, mounting blocks and carriage blocks. The system can be seen mounted together in Figure 7, with the lead screw and nut resting between the two guide rails. The carriages are placed around the lead screw nut to create a surface area to mount a platform. The carriage platform is created out of a 5"x5" piece of foam and fixed to the nut and blocks. All the physical connections made between all the separate parts were glued with a hot glue gun. The bearing stand and the mounting blocks were glued at their bases. The legs were then glued directly to a foam board as a base. The platform is glued directly onto the carriage blocks and lead nut.
Fig. 7: Linear Rail System Underside View
Fig. 8: Top View of Linear Rail System
Mechanical Winding of System
Principles of a Lead Screw
A lead screw translates rotary motion into linear motion. The threading on the screw is directly in contact with the nut's threading. The distance a lead nut travels in one rotation about the screw is called the lead, the axial advance. A lead screw can be connected to a coupling shaft, where it is driven by an external motor. In order to determine the displacement of the lead nut, a relationship between the input of a motor and the nut must be defined. Figure 10 describes the relationship, and defines displacement in terms of number of steps, the lead, and steps per revolution. The specific lead screw used in this project has a lead of 8mm. One full rotation of the lead nut moves 8mm. In a full stepping sequence, 1 rotation = 200 steps and in a half-stepping sequence, 1 rotation = 400 steps. To further simply, a full-stepping sequence: 25 steps/mm and for a half-stepping sequence: 50 steps/mm.
Fig. 9: Lead Screw & Nut
Fig. 10: Input to Output Relationships
Switch Mechanism
A push button switch is implemented in the final design to control the linear homing sequence of the motor. A switch generally disconnects or connects an electrical path within a circuit. The switch used in this circuit is utilized in a pull-up resistor. In a pull-up resistor circuit, the control is directly connected to a power source. The switch is bridged in between the power connection and the ground. Figure 12 shows a simple diagram of how the pull-up resistor works. The homing sequence starts with the button being pressed, sending a LOW signal to the control to begin movement. While the motor is rotating, the switch is sending a HIGH signal since it is directly connected to power. Once the switch is triggered again (inputting a LOW signal), a new motion sequence begins. A switch allows for easy control of the carriage motion. The switch is tested by running a counting code for when the signal is received via pressing the button. Once verified, the switch mechanism is easily integrated with the motion of the stepper-motor.
Fig. 11: Button Switch Setup
Fig. 12: Pull-down Resistor Circuit Diagram
Fig. 14: Counter Switch Test Results
Fig. 13: Counter Switch Test
Results
The end goal of the the project was successfully completed. As part of the requirements, a linear program must be able to move a minimum of a 1lb load. The video on the left shows a 22oz filled bottle being moved on the platform via a predefined sequence. The motion starts at an undefined spot and moves all the way back, via full-stepping, to touch the button switch. Once contact has been made with the switch, the carriage moves forward 5mm with full-stepping and then backwards 5mm with half-stepping. Afterwards, the carriage moves forward 30mm with half- stepping and comes to an end.
Final Product: Linear Movement With an Applied Force
The final sequencing code utilizes all the previous concepts discussed to create a fully functioning linear system. The coils have been defined and setup the same as before along with the switch being defined as a input-pullup. The first motion sequence begins when the switch has been triggered, followed by a motion sequence of the motor continuously running with no predefined counting. This allows a homing sequence to be possible since the platform could start at any carriage. However, once the switch has been reactivated a new motion sequence begins. The motor follows a full-stepping counter of 31, which is calculated by taking into consideration the lead and steps required to move the carriage 5mm. Once the counter has made its full cycle, the carriage will return back to the switch via a half-stepping sequence. The switch will then be triggered again, indicating the controls to start a new motion sequence. The final sequence involves half-stepping with a counter of of 188 to move the carriage approximately 30mm from the starting position. Once the motor has finished its cycle, the carriage comes to a halt and the system shuts down.
Final Sequence Arduino Code
Reproducing This Project
By following all the information discussed in this project, it is possible for another person to reproduce the same results. Figures 15 - 17 below show the electrical connections required to remake this linear stage system.
Figure 15: Arduino Base, Attached Directly Under the Shield
Figure 16 Arduino Shield Stepper Motor Connections
Figure 17: Button Switch to Shield Connections