Outline – Motion Control Position Sensors

Position Sensors
Outline – Motion Control
• Most motion control applications require
accurate position and velocity measurements.
provide velocity
y
• Position sensors,, which can p
estimates, are of major interest in industrial
automation:
• Sensors for Motion Control
– Position Encoders
• Incremental
• Absolute
– Encoder Interfacing
• Decoding
• Control of Electric Motors
– Optical Position Encoders (= Digital Sensors)
– DC Motors
• Rotary
• Linear (a.k.a. “Linear Scales”)
• H-bridge Drivers
• Relays
– Stepper Motors
– Resolvers (= Analog Sensors)
• Example
Chapter 11
• Rotary
• Linear (a.k.a. “Inductosyn™”)
ME 534
2
Chapter 11
Rotaryy Optical
p
Position Encoders
Opto-electro-mechanical devices for
measuring position:
– Robust and reliable
reliable,
– Provide digital outputs,
– Absolute/incremental and
rotary/linear versions are available
available,
– Decoder circuits are needed to
process encoder signals,
– Cost goes up with the increasing
resolution.
Coutesy of Heidenhain Corp.
Chapter 11
ME 534
3
Structure of Incremental Encoders
•
•
ME 534
4
•
•
•
Encoders consist of a stripped disk
in between a light source (LED)
and a photo-detector.
Depending on angular position of
the disk, the stripes on the disk
may either block or let the light
pass through
through.
Photo-detector emits a series of
electrical pulses as it gets to detect
light during the rotation of the disk.
Note the spatial relationship
between the disk’s
disk s position and the
pulse-stream being generated.
Chapter 11
ME 534
Courtesy of National Instruments
5
Structure (Cont’d)
(
)
•
•
•
Structure (Cont’d)
(Cont d)
An encoder producing one set of pulses would not be useful since it
could not indicate the direction of rotation.
Almost all incremental encoders generate a second set of pulses
that is 90o out of phase with the first one.
Most rotary encoders produce an index pulse per revolution using a
third detector (C) to indicate a reference position on the disk.
• Output of the photo-detector
photo detector is not exactly a square
wave (more like a sinusoidal pattern) since the intensity
g varies as a function of disk position.
of the light
• A circuitry shapes up the output (for each channel) to a
crisp square voltage-waveform.
Chapter 11
ME 534
6
Chapter 11
ME 534
7
4X Decoding
g
Decoders
ecode s
•
• An interface circuit is necessary to derive
position from incoming pulses.
Counting transitions in both
yields the angular
g
channels y
position of its shaft: θ = 90on/N.
– N is # of gratings on the disk.
– n is the count value of transitions
up to a particular time.
– 1X decoding (or interpolation):
• (H to L) or (L to H) transitions in one channel are counted.
•
– 2X decoding:
While counting transitions, one
p track of the direction:
must keep
– If forward, count up.
– If reverse, count down.
• (H to L) or (L to H) transitions in both channels are counted.
• 2 logic
g transitions per g
grid ((period)) are detected.
•
– 4X decoding (the best one!):
• (H to L) and (L to H) transitions in both channels are counted.
• 4 logic transitions per period are detected.
• Highest possible resolution is achieved in this case.
A Leads B (Forward Rotation)
+5V
Channel A
+5V
Channel B
+5V
Channel C
360o/N
B Leads A (Backward Rotation)
Direction can be detected:
– If A leads B ⇒ forward rotation.
– If B leads A ⇒ backward rotation.
+5V
Channel A
+5V
Channel B
+5V
Channel C
360o/N
Chapter 11
ME 534
8
Chapter 11
ME 534
9
Encoder/4X Decoder Model
4X Decoding (Cont’d)
Registered
Ang
gular Positio
on
90o/N)
Quadrature Decoder (4X)
A
dir
Channels
n+10
8
n+8
th
Sine Wave
n+6
n+4
A
A
B
B
Quadrature
Encoder
B
Direction
Monitor
th_cts
Quadrature
Decoder (4X)
-KGain
1
A
Position
Clk
Up Cnt
z-1
z
Difference
-u
1
th_cts
Unary Minus
Counter A
n+2
n
n-2
Switch
Quantizer
2
B
Clk
Up Cnt
U i D
Unit
Delay
l
Constant
Time
n
n+2
n+4
n+6
n+8
n+10
n+9
n+7
n+5
n+3
n+1
n-1
n-3
-KK
N
Channel A
n+1
n+3
n+5
n+7
n+9
n+8
n+6
n+4
n+2
n
n-2
Channel B
Time
System decelerates to a full-stop.
Chapter 11
System start to accelerate in reverse direction.
ME 534
10
Resolution is indicated by the
number of gratings on the disk.
Common resolutions are
•
Cost g
goes up
p with the increasing
g
resolution due to sophisticated
manufacturing process:
– Etching micro-gratings on a
glass disk covered with
chromium.
Courtesy
y of Heidenhain Corp.
p
Chapter 11
ME 534
Sample
and Hold
In S/H
Sample
and Hold1
NAND
5
cos
Trigonometric
Function1
AND
Logical
Operator
Constant2
Switch1
1
A
2
B
In S/H
Sample
and Hold2
0
2
B
Constant3
1
dir
Logical
Operator2
In S/H
Sample
and Hold3
ME 534
11
12
Major drawbacks of
i
incremental
l encoder
d are
– A decoder circuitry is needed.
– In case of a p
power failure,, the
decoder will lose information
on the current position.
•
– 200, 500, 1000, 2000, 5000,
10000 pulses/rev.
•
Direction
Monitor
Absolute Encoder (Cont’d)
(
)
– Number of pulses being
generated in one channel per
one revolution.
•
In S/H
Constant1
Chapter 11
Resolution of Incremental
Encoders
•
Switch
1
A
0
Q
Quadratur
re Encode
er
Time
sin
i
Trigonometric
Function
z
Counter B
5
1
th
1
•
Absolute encoders are
designed to tackle with these
problems.
O
Operating
ti principle
i i l iis similar
i il tto
that of the incremental one:
– has 8 to 16 photo-detectors
– uses a coded disk generating
a unique binary output per
g
segment.
Chapter 11
ME 534
13
Absolute Encoder (Cont’d)
(
)
Infinite Resolution Encoders
• Since each channel g
generates a p
particular digit
g
of a binary number, it is customary to specify the
resolution byy bits (N):
( )
– 8-bit, 10-bit, 12-bit, ..., 16-bit
– Angular
g
resolution is 360o/ 2N.
– Name is a bit misleading!
g
• One can interpolate the magnitudes of two
orthogonal sinusoidal waveforms (A and B) to
find the exact location of shaft within one (grate)
period.
• Absolute encoders are very expensive due to
the complexity involved in the manufacturing
process (photo-lithography).
– Price goes exponentially up with the resolution
resolution.
Chapter 11
ME 534
14
Terminal
e
a S
Signals
g as
ChA: channel A
~ChA: complement of channel A
ChB: channel B
~ChB: complement (negation) of channel B
IX: index
de (sometimes
(so e es ca
called
ed C
ChC)
C)
~IX: complement of index
Vdd: Supply
pp y voltage
g for the encoder ((+5V))
15
• Two types of encoder interfaces:
– Single-ended
– Differential
– Encoder and its interface are located in close
proximity (~a few meters or less).
• Noise
N i (pick-up)
( i k ) is
i nott a bi
big iissue.
– Vss is connected to the digital ground.
– ChA and ChB are directly employed as TTL inputs
to the interface circuitry.
• Vss: digital ground
ME 534
ME 534
• Single-ended encoders are quite common:
– Can be 3 to 24 Volts depending on the app.
Chapter 11
Chapter 11
Types
ypes o
of Encoder
code Interfaces
te aces
• Following signals are available in a generic
incremental encoder:
•
•
•
•
•
•
•
• Incremental encoders generating sinusoidal
waveforms (instead of pulses) are referred to as
infinite resolution encoders.
16
Chapter 11
ME 534
17
Encoder
code Interfaces
te aces (Co
(Cont’d)
t d)
•
Processing
ocess g Quad
Quadrature
atu e S
Signals
g as
Differential interfaces are used when the encoder
and
d its
it interface
i t f
mustt be
b located
l
t d far
f apartt (like
(lik ttens
of meters).
• Encoder “quadrature”
quadrature signals must be
processed to obtain position information in most
cases.
cases
– Noise pick-up and degradation of transmitted signal
become important issues.
issues
– “Balanced” digital data transmission is needed.
•
– Some DSPs and advanced microcontrollers have
built-in
built
in quadrature encoder interfaces
interfaces.
In such interfaces, the potential difference between
ChX and ~ChX
ChX (X: A or B) yields the desired logic
signal:
• There are various options to convert quadrature
signals into position “counts”:
counts :
– ChX (wrt. to Vss) ∈ {0, 2.5V}
– ~ChX
ChX ((wrt.
t T
To Vss) ∈ {0,
{0 -2.5V}
2 5V}
•
Differential line receivers (such as DS26C32) are
commonly used for this purpose:
– Custom digital circuits
– Quadrature decoder ICs
– Quadrature decoder / counter interface ICs
– Accept differential encoder inputs
– Yield corresponding TTL or CMOS logic outputs.
Courtesy of National Semiconductors.
Chapter 11
ME 534
18
Chapter 11
Custom So
Custo
Solutions
ut o s
ME 534
Encoder-to-Counter Interface ICs*
CLKOUT
• Produced by US Digital
(
(cost
~ a ffew USD iin
quantity)
• Drives standard counters
t
ChA
XOR
CLKOUT
Sign Error
DIR
t
D-F/F
D
ChA
t
DIR
– Mostly used as inputs to
“on-board” counters of
microcontrollers.
microcontrollers
Q
ChB
ChB
t
System decelerates to a full-stop.
•
•
System start to accelerate in reverse direction.
A custom interface with 2X decoding can be designed with an XOR
gate and a D flip/flop.
O t t off the
Outputs
th circuit
i it can b
be di
directly
tl connected
t d tto th
the PIC18F4520
PIC18F4520:
– CLKOUT to Timer1 (RC1/T1CK1) for counting
– DIR to (RB0/INT) for sign detection
Chapter 11
ME 534
19
20
LS7083
• Outputs are UpClk and DnClk
• Can be connected to 74193 or 40193
LS7084
• Outputs can Clock and UP/DN (direction)
• Can be connected to 74169 or 4516
Chapter 11
ME 534
• No external clock is
required.
q
• Features
– 1X or 4X interpolation
mode
d
– TTL/CMOS compatible I/O
– Low p
power
[*] Courtesy of US Digital.
21
Advanced
d a ced ICs:
Cs HCTL-2032*
C
03
Conventional
Co
e t o a DC
C Motor
oto
•
• Produced by Agilent
Technologies (cost ~7 USD)
• Interfaces between encoder and
microcontroller
Stator of a DC motor is composed of two
or more permanent magnet pole
l pieces.
i
Rotor is composed of windings which are
connected to a mechanical commutator.
In this case the rotor has three pole pairs.
Opposite polarities of the energized
winding and the stator magnet attract and
the rotor will rotate until it is aligned with
the stator.
Just as the rotor reaches alignment, the
brushes move across the commutator
g
the next winding.
g
contacts and energize
A spark shows when the brushes switch
to the next winding.
•
– Needs an external clock signal
•
• Has programmable interpolation
modes:
d
– 1X, 2X, or 4X
• Supports dual axis
• Features
•
– 32-bit binary up/down counter
– 8-bit
8 bit ttri-state
i t t iinterface
t f
– TTL/CMOS compatible I/O
Chapter 11
ME 534
[*] Courtesy of Agilent Technologies.
•
Courtesy of Motorola, Inc.
22
Chapter 11
ME 534
Operating
Ope
at g Modes
odes o
of DC
C Motor
oto
“Forward
o a d Motor”
oto Co
Control
to
Tm
Reverse Generator
Forward Motor
ia
_
+
M
Va
M
Va
_
+
ia
m
ia
_
+
M
Va
Va
M
_
+
• In motor mode
mode, the
machine drives the
“load” and needs
energy from the
supply.
• In generator mode,
the “load-side” drives
the machine and it
generates power.
ia
Reverse Motor
• Electronically-controlled
(unidirectional) switch is
turned on/off rapidly.
Electronically controlled
power switch
Va
+
+
– Pulse width modulation
VDC
Va
VDC
M
Td
_
Va
t
Tp
• Desired (average) voltage
at the terminals of DC
motor is obtained via
controlling switching times:
S1
Ra
+
VDC
La
Va = VDC
ia
+
Back e
a
E.M.F.
_
D1
ME 534
24
Chapter 11
Td
= VDC ⋅ d
Tp
where Tp is PWM period
(constant) and Td/Tp = d
is called duty cycle.
Forward Generator
DC Motor
Chapter 11
23
ME 534
25
Forward
o a d Motor
oto Co
Control
t o (Co
(Cont’d)
t d)
La
+
ia
D1 :off
VDC
ea
_
D2
• “clamp”
clamp diode allows
current flow in Mode 2:
+
ia
D1 :on
ea
_
Chapter 11
S4
+
VDC
– La drives a decaying
current
current.
La
Ra
S1 :off
S3
S1
D1
• If D1 isn’t in place, a very
g voltage
g will build up
p
large
across S1 and blow it up.
ME 534
S2
26
S4
D4
S2
D2
S4
D4
S3
D3
D1
S3
D3
To go forward,
forward
• To go reverse,
– S1 is fully turned on;
– PWM and ~PWM signals are applied to S4 and S3
respectively.
Unidirectional switch S1 can carry current only in the indicated
direction.
Chapter 11
27
Mode 2:
M
S1
– S3 is fully turned on;
– PWM and ~PWM (inverted PWM) signals are applied to S2 and S1
respectively.
ti l
•
ME 534
Mode 1:
VDC
•
– causes short-circuit.
– If one of the switches is
turned, the other must be
off.
ia
VDC
D1
• “H”
H bridge is used to
operate the motor in four
quadrants.
• Driver is composed of two
half-bridges.
• Switches in a half-bridge
cannot turned at the
same time.
ti
Reverse
e e se Motor
oto
ia
S1
Half-Bridge
Chapter 11
Mode 2:
D2
D3
Half-Bridge
Forward
o a d Motor
oto
Mode 1:
D4
S2
– It must flow somewhere!
Mode 2:
VDC
• When S1 is turned off, ia
flowing through the motor
cannot be cut off
immediately
immediately.
ME 534
M
Ra
S1 :on
M
Mode 1:
Four-Quadrant
ou Quad a t Motor
oto Co
Control
to
28
Chapter 11
ME 534
29
Building
u d g H-bridge
b dge
LMD 18200*
8 00
• Ideal for driving DC and
stepper motors,
p to 3A
• Delivers up
continuous output
• Commercial Motor Drivers
– Include all bells and whistles!
• Custom Solutions (high-power)
(high power)
– Switches: Power MOSFETs, IGBT
– Need gate drivers and signal isolation barriers.
– Peak current of 6A
• Operates at supply
voltages up to 55V,
• Accepts TTL and CMOS
compatible inputs,
• Bridge ICs (up to a few-hundred [W])
– LMD 18200
– L298
• For driving small DC motors,
– Internal
I t
l charge
h
pump
– L293D
– ULN 2003A
• Quite expensive: 20 USD.
Chapter 11
ME 534
30
L298:
98 Dual
ua H-bridge
b dge Driver*
e
Chapter 11
ME 534
[*] Courtesy of National Semiconductors.
31
L293D: Four Half-bridge
g Drivers*
• L293 includes 4 HalfHalf
bridge drivers.
– Can drive two bidirectional
DC motors.
motors
•
Constitutes two H
H-bridges
bridges
•
•
•
•
Supply voltage up to 46V
Maximum current is 4A
Over-temperature protection
Accepts TTL inputs
– Requires clamp diodes
Chapter 11
ME 534
[*] Courtesy of ST Microelectronics.
Half-Bridge
• L293D has clamp
((freewheeling)
g) diodes.
• Wide supply-voltage
range: 4.5 V to 36 V
• Output current for L293D
is 0.6A/channel
– 1.2A
1 2A peak
• Thermal shutdown
32
Chapter 11
ME 534
[*] Courtesy of Texas Instruments.
33
Electromagnetic
ect o ag et c Relays
e ays
Simple
S
peO
On/Off
/O Control
Co t o
• Relays are electromagnets connected
to mechanical switches
switches.
12V 24V
– When the electromagnets are energized,
the switches are pulled into contact.
– Hence,
H
th
the corresponding
di circuit
i it iis powered
d
up.
R l
Relay
ULN2003A
9
• Relays
y allow the control of high-power
g p
devices.
– Small power is sufficient to energize
electromagnets in relays
relays.
– Suitable for on/off control of slow devices:
• Pump (AC/DC) motors, solenoids
• Heaters,
H t
lamps,
l
etc.
t
– If compared to solid-state switches, relays
are more susceptible to malfunction.
Chapter 11
ME 534
34
Stepper Motors
Steppe
oto s
– Variable Reluctance (VR)
• Rotor saliency
y
– Permanent Magnet (PM)
• Magnets on rotor
– Hybrid Motors
• Relies on both rotor saliency and magnets
• Each pulse moves rotor by a discrete angle (i
(i.e.
e
“step angle”).
• Counting pulses tells how far motor has turned
without actually measuring (no feedback!).
ME 534
RX#
•
•
16
M
1N4004
Most microcontrollers cannot source/sink in sufficient current to
trigger relays.
General purpose BJTs (2N2222, 2N3904, BC337, etc) or
ULN2003A (Transistor Array) are utilized for this purpose.
Chapter 11
ME 534
35
Advantages
d a tages / Disadvantages
sad a tages
• Stepper Motors
Chapter 11
1
36
9 Low cost
9 Simple and rugged
9 Very reliable
9 Maintenance
M i t
ffree
9 No sensors needed
9 Widely accepted in
industryy
Chapter 11
8 Resonance effects
are
a
e do
dominant
a t
8 Rough performance
at low speed
8 Open-loop operation
8 Consume
C
power even
at no load
ME 534
37
((Simplified)
p
) Full-Step
p Operation
p
Coil A
Coil B
Coil D
Coil B
Coil D
S
S
N
•
N
Current
S
Current
Coil B
S
S
Coil D
N
Coil B
S
Current
Coil B
Coil D
N
S
S
Current
Coil C
Coil C
Current
Coil C
N
Current
Coil C
N
N
8
Current
S
N
7
6
Coil A
S
Coil D
5
Coil A
Coil A
Coil B
Coil B
Coil D
N
Coil B
Coil D
S
N
S
Current
S
Coil C
Coil D
N
Coil A
•
Coil B
N
Coil A
S
3
4
S
Coil D
S
4
Coil A
S
Coil C
Coil C
Just as the rotor aligns
with one of the stator
poles, the second
phase
h
iis energized.
i d
The two phases
alternate on and off to
create motion.
There are four steps.
Coil A
N
3
Coil A
N
Current
•
Current
Coil A
Current
Current
Coil C
S
Current
Coil C
Coil C
Coil B
Coil D
S
N
N
2
N
S
S
Current
– Stator has a number of
windings.
Coil B
Coil D
N
N
1
N
Coil B
Rotor of a PM stepper
motor consists of a
permanentt magnet:
t
S
Coil A
S
Coil D
•
2
Coil A
S
Current
N
N
1
(Simplified)
(S
p ed) Half-Step
a Step Ope
Operation
at o
S
Coil C
N
Current
Coil C
N
N
Chapter 11
ME 534
38
Chapter 11
ME 534
39
Winding
g Connections
Half-Step
a Step Ope
Operation
at o (Co
(Cont’d)
t d)
Bipolar (4-wire):
Unipolar (5-wire):
• Commutation sequence has eight steps instead of four.
• Main difference is that the second phase is turned on
b f
before
th
the fifirstt one is
i tturned
d off.
ff
• Sometimes, both phases are energized at the same
time.
time
• During the half-steps, the rotor is held in between the
two full-step positions
positions.
• A half-step motor has twice the resolution of a full-step
motor.
1
A
C
3
B
D
2
4
5
Unipolar (6-wire):
– Very popular due to this reason.
• Unipolar motor:
3
1
A
C
4
B
D
2
– Current flows through a coil
only in one direction.
• Bipolar motor:
– Current flowing through a
winding changes direction
during the operation.
5
6
Chapter 11
ME 534
40
Chapter 11
ME 534
41
Actual
ctua Steppe
Stepper Motor*
oto
Stepper-Motor
Steppe
oto Animations*
at o s
• Stator of a real motor
constitutes more coils
(typically 8).
• Individual coils are
interconnected to form only
two windings:
Full-step:
Half-step:
– one connects coils A, C, E,
and G:
• A and C have S-polarity
S polarity
• E and G have N-polarity
– one connects coils B, D, F,
and
dH
H:
• B and D have S-polarity
• F and H have N-polarity
p
y
Chapter 11
ME 534
[*] Courtesy of Microchip.
42
L297:
9 Steppe
Stepper Motor
oto Co
Controller*
to e
Chapter 11
ME 534
[*] Courtesy of ST Microelectronics.
44
[*] Courtesy of Motorola, Inc.
43
Stepper Motor
Steppe
oto Drive
e with
t L293*
93
• Half-bridge
Half bridge pair of L293 is
utilized to drive a phase
winding of a bipolar
stepper motor.
• Produced by
STMicroelectronics
• To be used in
conjunction with L298
• Half/full
f/f step modes
with direction control
input.
• Switch-mode load
current regulation
Chapter 11
ME 534
– Depending on control input
(Control A or B)
B), current
flows in one way or
another.
• No external (clamp)
diodes are needed if
L293D iis employed.
l
d
Chapter 11
ME 534
[*] Courtesy of ST Microelectronics.
45
20 k
(pot.)
d
e
RB3
f
g
RB5
RB4
RA2
•
– 5V → motor rotates CW direction at its
max. speed.
– 2.5V → motor is off.
– 0V → motor rotates CCW direction at
its max. speed.
K
470
Vcc = 12V
ULN2003A
9
RD7
RD6
RD5
RD4
1
16
2
15
3
14
4
13
Unipolar Stepper
Motor
•
•
•
Chapter 11
Full-step:
Half step:
Half-step:
LED indicates the direction of motion.
SSD shows speed as a hex
hex. number
(0: min; F: max)
Here, ULN2003A (transistor array)
serves as “electrically”
electrically controlled
switch.
– When 5V is applied by PICmicro, it
conducts current (up to 1A).
ME 534
46
Chapter 11
C Program:
g
Half-step
p
set_tris_b(0);
set_tris_d(3);
PORTB = 0; PORTD = 0;
/* Seven segment display routine */
/
/
byte const SSData[16] = {238,130,220,214,178,118,126,226,
254,246,250,62,28,158,124,120};
if(num < 16){
output_b(SSData[num]);
}
}
ME 534
47
void main() {
//
// Full step sequence (Uncomment!)
//
// byte const step[8] = {192,96,48,144,192,96,48,144};
byte const step[8] = {192,64,96,32,48,16,144,128}; /* Half-step sequence */
byte temp = 0;
long
g adval;
int i = 0;
#byte PORTB = 0xF81
#byte PORTD = 0xF83
#bit LED = PORTD.2
Chapter 11
ME 534
C Program
og a (Co
(Cont’d)
t d)
#include <18F4520.h>
#device ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
HS NOWDT NOPROTECT NOLVP
#use delay(clock=20000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
#use fast_io(B)
#use fast_io(D)
fast io(D)
#org 0x3F00,0x3FFF {}
#opt 9
void ss_disp(int
ss disp(int num) {
Coun
nter-CW
c
RB1
RB2
Let us develop a C program for a
g the ((unipolar)
p
)
PICmicro controlling
stepper motor shown.
20kΩ pot. is used to adjust the speed.
When the voltage on AN0 is
Counte
er-clockw
wise
RD2
b
RB7
•
Vdd = 5V
LS 5015-20
a
Clockw
wise Rotattion
470
RB6
Example
a p e - Drive
e Seque
Sequences
ces
Cllockwise
Example
p – Unipolar
p
Stepper
pp Motor
/* Set up digital I/O pins */
setup_adc_ports(AN0_TO_AN3);
setup_adc(ADC_CLOCK_INTERNAL);
_
_
_
set_adc_channel(2);
48
Chapter 11
/* Set ADC */
ME 534
49
C Program
og a (Co
(Cont’d)
t d)
while(TRUE) {
delay_us(200);
adval = read_ADC()>>3;
if (adval>60 && adval<68) {
ss_disp(0); PORTD = 0;
}
else if(adval>=68) {
ss_disp((adval>>2)-16);
adval = 132 - adval;
if (++i>7) i = 0; temp = (PORTD&15)+step[i];
PORTD = temp; LED = 1; delay_ms(adval);
}
else {
ss_disp(16-(adval>>2));
adval += 4;
if (--i>7) i = 7; temp = (PORTD&15)+step[i];
PORTD = temp; delay_ms(adval);
}
}
/* Motor is off */
/* CW direction */
/* CCW Direction */
}
Chapter 11
ME 534
50