Documente Academic
Documente Profesional
Documente Cultură
th ed
EET 2261 Unit 13
Controlling Stepper Motors and Servos
Read.
7lectromagnets are
constructed "y rapping ire
around an iron8alloy "ar.
(Illustration from Wikipedia.)
;nipolar
)ipolar
The e"site at
http:==homepage.cs.uioa.edu=>?ones=step=
contains an e$cellent online tutorial on
stepper motors, including this animation
shoing the operation of a unipolar motor.
#nline Tutorial
-s shon on its
specifications sheet,
it!s a unipolar motor
ith a 2.3 step
angle.
#ur Stepper Motor
T)33*'ECF datasheet.
Toshi"a T)33*'ECF
+oer (red)
Fround ("lack)
See ServoCity!s
e"page for detailed
specifications.
#ur Servo
Eigure from p. 3 of
te$t"ook or page '2 of
/evice ;ser Fuide).
+ulse Width Modulation (+WM)
)lock
)lock /iagram of +ulse Width
Modulation (+WM) )lock
.
The +WM "lock!s
eight channels let
us generate up to
eight different
+WM signals at
the same time.
.
See page *0 of the
+WMJ<)<C
)lock ;ser Fuide.
Special8Eunction 4egisters
-ssociated ith the +WM )lock
.
The 2@ special8function registers located at
addresses K((-( to K((C& let us control the
operation of the +WM "lock.
.
See page 21 of /evice ;ser Fuide.
Special8Eunction 4egisters That
We!ll ;se
.
The folloing registers are the most
important ones for using the +WM "lock:
.
+WM 7na"le 4egister (+WM7)
.
+WM +olarity 4egister (+WM+#A)
.
+WM +rescale Clock Select 4egister (+WM+4CAL)
.
+WM Scale - 4egister (+WMSCA-)
.
+WM Clock Select 4egister (+WMCAL)
.
+WM Channel +eriod 4egisters (+WM+74$):
one register for each of the eight channels
.
+WM Channel /uty 4egisters (+WM/TM$): one
register for each of the eight channels
+WM 7na"le 4egister (+WM7)
.
The "its in this register let us ena"le or
disa"le each of the eight +WM channels. If
e ena"le a particular channel, then its I=#
pin cannot also "e used for general8purpose
I=# as part of +ort +.
.
Eigure from p. *@ of +WMJ<)<C )lock ;ser Fuide.
+WM +olarity 4egister (+WM+#A)
.
Eor each +WM channel, e can choose
hether the +WM signal starts 9IF9 and
then goes A#W in each cycle, or vice versa.
.
Eigure from p. '( of +WMJ<)<C )lock ;ser Fuide.
+WM Clocks
.
The +WM "lock has four clocks that are
derived from the system!s "us clock:
.
Clock -
.
Clock )
.
Clock S- (Scaled -)
.
Clock S) (Scaled ))
.
+WM Channels (, *, 0, 1 can use either
Clock - or Clock S-
.
+WM Channels ', 2, 3, & can use either
Clock ) or Clock S).
.
The ne$t three slides discuss the registers
that control these clocks.
+WM +rescale Clock Select
4egister (+WM+4CAL)
.
The "its in this register set the fre,uencies
of Clock - and Clock ), as follos:
Eigures from p. '2 of
+WMJ<)<C )lock ;ser
Fuide.
+WM Scale - 4egister
(+WMSCA-)
.
The <8"it value in this register sets Clock
S-!s fre,uency, according to the formula:
.
Eigures from p. '< of +WMJ<)<C )lock ;ser Fuide.
+WM Clock Select 4egister
(+WMCAL)
.
7ach +WM channel has one "it in this
register to select hich clock it uses:
.
Eor +WM Channels (, *, 0, 1, e can choose
"eteen Clock - and Clock S-.
.
Eor +WMM Channels ', 2, 3, &, e can choose
"eteen Clock ) and Clock S).
.
Eigure from p. '' of +WMJ<)<C )lock ;ser Fuide.
+WM Channel +eriod 4egisters
(+WM+74$)
.
7ach +WM channel has one of these
registers.
.
The value in this register determines the
period (cycle time) of the signal generated
"y the +WM channel:
Signal period N +WM+74$ O +eriod of selected clock source
.
Eigure from p. 2* of +WMJ<)<C )lock ;ser Fuide.
+WM Channel /uty 4egisters
(+WM/TM$)
.
7ach +WM channel has one of these registers.
.
-ssuming +WM+#A has "een set so that the signal
starts 9IF9, the value in this register determines
the pulse width (time high) of the signal generated
"y the +WM channel:
+ulse idth N +WM/TM$ O +eriod of selected clock source
.
Eigure from p. 2' of +WMJ<)<C )lock ;ser Fuide.
Sample Code for Configuring
+WM Channel 0
.
Cote that code is incomplete: you must
decide hat values to load into +WM+740
and +WM/TM0.