Embedded System
Design Practice
Lab 4 – Stepper Motor Control with Systick Timer
Objective
This experiment deals with passing a
sequence of control signals with specific time
intervals to control the stepper motor using a
SysTick timer.
Stepper motor
A stepper motor is an electromechanical system which
is transducing an electrical signal into a mechanical.
It is designed to accomplish a discrete movement
(notion of step) and reach a precise position. The
movement is achieved through the use of a magnetic
field provided by coils and sensed by magnets.
Stepper Motor Introduction
A stepper motor is a brushless, synchronous electric
motor that converts digital pulses into mechanical
movement.
The stepper motor rotates a specific incremental
distance per step.
The number of steps that are executed controls the
degree of rotation of the motor’s shaft.
This characteristic makes stepper motors excellent
for positioning applications.
Stepper Motor Introduction
For example, a 1.8° stepper motor executing 100
steps will rotate exactly 180°.
The speed of step execution controls the rate of
motor rotation.
A 1.8° step motor executing steps at a speed of 200
steps per second will rotate at exactly 1 revolution
per second.
Stepper motor working principle
Stepper motors are widely used in
applications where angular position control is
needed.
This is accomplished by moving the motor
in incremental steps.
Step angle is the angle covered by the
motor shaft per step. The two methods to Types of Stepper Motors:
energize the stepper motor are the unipolar 1.Permanent Magnet Stepper Motors
and bipolar methods. 2.Variable Reluctance Stepper Motors
3.Hybrid Stepper Motors.
The experiment will use the bipolar method
to energize the stepper motor.
Stepper Motor Introduction
The stepper motor consists of a rotor that is
generally a permanent magnet and it is
surrounded by the windings of the stator.
As the current flows through the windings it
magnetizes the stator and forms
electromagnetic poles which cause propulsion to
the motor.
A sequence is changed for every 10
milliseconds. The sequence of the pulses
direction of rotation of motor. No. of sequences
determines the angular displacement.
Working of Permanent Magnet Stepper Motor: When the phase A
is energized with a positive with respect to the A', the windings
establish North and South poles. Due to the force of attraction, the
rotor poles align with stator poles such that the magnetic pole axis
of the rotor adjusts with that of the stator as shown in figure.
In the "2 phase on" method, two phases are always energized. Every
90° represents a 1.8° rotation.
If both phases A and B are energized as south poles, the north pole of
the rotor will be equally attracted to both poles and line up directly in
the middle.
In sequence as the phases are energized, the rotor will rotate to line
up between the two energized poles.
The "2 phase on" method has a four-step electrical sequence to rotate
the motor.
Oriental Motor's standard 2-phase and 2-phase M type motors use the
"2 phase on" method.
Every 90° represents a 1.8° rotation. If both phases A and B are energized
as south poles, the north pole of the rotor will be equally attracted to both
poles and line up directly in the middle. In sequence as the phases are
energized, the rotor will rotate to line up between the two energized poles.
A Abar B Bbar
0 1 0 1 5
0 1 1 0 6
1 0 1 0 A
1 0 0 1 9
Stepper Motor Working
S N
N S 1 N S 0
N S
0 1
5 6
0 1 0 1
S N
S N 1 S N 0
N S
0 1
9 A
1 0 1 0
Stepper Motor Working
Formula to calculate step angle :
° °
1 Step angle = = = . °
Nr=100 no. of teeth For 90° rotation total required steps
m = 1 Uni polar
S=m * Nr=2*100=200 Step = 50
m =2 Bi polar
Stepper Motor Interface
SysTick Timer Initialization
Clear the ENABLE bit in STCTRL register to turn off SysTick during initialization.
set the RELOAD register with the desired reload value calculated from
𝑫𝒆𝒔𝒊𝒓𝒆𝒅 𝒕𝒊𝒎𝒆𝒅𝒆𝒍𝒂𝒚
𝑹𝒆𝒍𝒐𝒂𝒅 𝒗𝒂𝒍𝒖𝒆 =
𝟏𝟐.𝟓 𝒏𝒔𝒆𝒄
write any value to the ST_CURRENT register to clear the counter
Finally configure the STCTRL register with necessary settings
set CLK_SRC=1, so the counter runs off the systemclock
clear INTEN so interrupts will not be requested
set the ENABLE bit so the counter willrun
CLK_SRC INTEN ENABLE
1 0 1
Steps for Initializing (PD0-3 output)
First activate the port clock in the SYSCTL_RCGC2_R register
0 0 0 0 1 0 0 0
Disable the analog functionality, by clearing bits in the AMSEL register
0 0 0 0 0 0 0 0
Select GPIO functionality, by clearing bits in the PCTL register
0 0 0 0 0 0 0 0
Specify whether the pin is an input or an output by clearing or setting bits in the DIR register
0 0 0 0 1 1 1 1
Clear the corresponding bits in the (alternate function) AFSEL register (as pins are digital)
0 0 0 0 0 0 0 0
Enable corresponding I/O pins by writing ones to DEN register
0 0 0 0 1 1 1 1
Example Exercise
Generate a control signal sequence at PD0-3 to rotate the stepper
motor from 900 in the clockwise direction.
(Note: time period considered 10 msec )
−𝟑
𝑫𝒆𝒔𝒊𝒓𝒆𝒅 𝒕𝒊𝒎𝒆 𝒅𝒆𝒍𝒂𝒚 𝟏𝟎∗𝟏𝟎
= = =
𝟏𝟐.𝟓 𝒏𝒔𝒆𝒄 𝟏𝟐.𝟓 ∗𝟏𝟎−𝟗
Expected output :
Practice Exercise
Generate a control sequence at PE0-3 to rotate the stepper motor
1800 in the clockwise direction, followed by a pause of 1 sec and anti-
clockwise by 1800.
(Note: consider any time period of your choice.)
Expected output :
Applications of Stepper Motors
3D printing equipment.
Textile machines.
Printing presses.
Gaming machines.
Medical imaging machinery.
Small robotics.
CNC milling machines.
Welding equipment.