This is only a preview of the December 1997 issue of Silicon Chip. You can view 30 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Build A Speed Alarm For Your Car":
Articles in this series:
Items relevant to "Loudness Control For Car Hifi Systems":
Items relevant to "Stepper Motor Driver With Onboard Buffer":
Articles in this series:
Items relevant to "Power Supply For Stepper Motor Cards":
Purchase a printed copy of this issue for $10.00. |
Stepper motor driver
with onboard buffer
This new buffered design stores the
instructions for up to 63 revolutions
and can be jumpered for forward or
bidirectional stepping.
Design by RICK WALTERS
While this new stepper board is
similar in function to the designs
featured in the August & September
issues, it has the advantage of an
on-board buffer to store data from
the computer. This means that the
computer could give an instruction
to step the motor by, say, 50 steps.
The computer can then move on to
other tasks, for example, monitoring
60 Silicon Chip
the I/O card (described in July 1997)
while the motor is stepping.
By contrast, the two previous designs required the computer to issue
continuous instructions while the
motors were being stepped; it could
not perform any other function while
a motor was stepping.
As with the previous designs, this
new buffered stepper driver can be
daisy-chained with seven others, either buffered or unbuffered. For example, if you wanted to produce an XY
plotter, you could have two of these
buffered stepper drivers connected to
the parallel port. The computer could
then control both steppers for the XY
plotter and still have time to perform
other tasks.
We have produced new BASIC
listings to go with the buffered card
and these are featured elsewhere in
this article.
The procedure for driving the buffered card is virtually the same as for
the unbuffered card: an address from
1-8 is placed on three pins of the PC
port connector then the strobe line is
toggled. This latches the address in a
decoder. If this is the address selected
by the jumper on the card, the logic
level present on the port’s normal data
lines is latched into the buffers. Once
that happens the card takes over and
the motor is stepped to the required
position.
Jumper options
This buffered card is capable of
driving the stepper motor in either
forward or reverse direction. A jumper
on the card selects forward only or
bidirectional stepping. In forward
only mode, using a 7.5 degree per
step motor, up to 63 revolutions can
be stored, in bidirectional mode the
maximum is 32.
The motor begins stepping at a
preset slow speed and accelerates to
the preset maximum speed for that
particular motor and supply voltage.
When the motor is not stepping all the
drivers are turned off, thus preventing
the motor from overheating.
Another jumper selects full step or
half step operation and provision is
made via additional jumpers for the
computer to interrogate the card(s) to
determine whether it is still stepping
or can accept another instruction.
Circuit details
Refer now to Fig.1 for the circuit
details. While the overall operation of
the circuit is quite complex it can be
broken down into a number of simple
blocks. The first of these is the card
select logic which is carried out by
IC1 and IC2.
IC1 is a 74HC137 three line to eight
line active low latched decoder. This
IC looks at the BCD address data on its
A, B & C inputs and pulls the corresponding decimal output (Y0-Y7) low.
However, this can only happen when
the strobe line from inverter IC2a goes
low and momentarily pulls the latch
enable (LE) input of IC1 low via the
series .001µF capacitor.
Step counter
Once the desired card has been
selected, the number of steps the motor has to make is taken care of. This
information will have been loaded
into PortA and is present on the preset
inputs (P0-P3) of step counters IC3
& IC4. The data is loaded into IC3
& IC4 by the action of pin 5 of IC2c
going high (+5V) which takes the PL
(parallel load) inputs of these two ICs
high. Once there is any data present in
the ICs, the TC pins (terminal count,
pin 7) which were low will go high.
Parts List
1 PC board, code 07109971,
176 x 123mm
1 stepper motor, Oatley
Electronics M25 or equivalent
1 25-pin PC mounting R/A “D”
male connector
1 200kΩ PC mount trimpot
(VR1)
1 500kΩ PC mount trimpot
(VR2)
Semiconductors
1 74HC137 octal latch (IC1)
1 4572 complex gate (IC2)
2 4029 presettable counters
(IC3,4)
1 74HC4046 phase locked loop
(IC5)
1 74HC4017 decade counter
(IC6)
1 74HC02 quad NOR gate (IC7)
1 74HC32 quad OR gate (IC8)
4 74HC4066 quad analog switch
(IC9,10,13,14)
1 74HC00 quad NAND gate
(IC11)
1 74HC112 dual JK flipflop
(IC12)
4 BD681 NPN power transistors
(Q3,Q4,Q9,Q10)
4 BD682 PNP power transistors
(Q1,Q2,Q7,Q8)
This has two outcomes: the output
of OR gate IC8b (pin 6) will go high
and via D4, it will rapidly turn on
the CMOS switches IC13 and IC14,
allowing pulses to reach the stepper
motor coils, MA & MB. We’ll come
back to describe how MA & MB are
driven later in this article.
This high level from pin 6 of IC8b
is inverted by IC2e and the inhibit pin
of IC5 (pin 5) which was held high
now goes low. This allows the VCO
(voltage controlled oscillator) in this
chip to start. The oscillator output at
pin 4 is a square wave which begins
clocking decade counter IC6.
Note that IC2 is an odd chip, as it
contains four inverters, one 2-input
NAND gate and one 2-input NOR gate.
Phase counter
Each time IC6 is clocked it will sequentially take each of its 10 outputs
high. Depending on the voltage at the
cathode of D2, it will be reset by IC8a
4 BC548 NPN transistors
(Q5,Q6,Q11,Q12)
1 2N7000 N channel IGFET
(Q13)
4 1N914 signal diodes
(D1,D2,D3,D4)
Capacitors
2 100µF 25VW electrolytic
2 0.1µF monolithic ceramic
4 0.1µF MKT polyester
2 .01µF MKT polyester
4 .001µF MKT polyester
Resistors (0.25W, 1%)
1 1MΩ
13 10kΩ
5 100kΩ
4 2.2kΩ
2 47kΩ
1 1kΩ
Miscellaneous
1 7-way terminal strip (5.08mm
spacing)
1 8 x 2 pin strip
1 5 x 2 pin strip
1 2 x 2 pin strip
2 2-pin strips
5 jumpers for above
1 58 x 6 x 12mm aluminium bar
4 3mm x 16mm bolts
4 3mm nut
8 3mm flat washer
4 3mm star washer
8 TO-220 insulating washers
when its output is stepped to pin 1
or pin 11. The resistor and capacitor
on pin 15 are necessary to widen the
reset pulse, as IC6 is able to be reset
with a pulse which is too narrow to
clock the step counters. (This is one of
the problems of mixing HC and 4000
series devices.)
The pulse which resets IC6 also
clocks the step counters, IC3 & IC4,
which are connected so that they
count down (ie, pin 10 tied low).
When they are empty (zero count)
both TC pins will go low and pin 6 of
IC8b will go low, inhibiting the oscillator in IC5 as pin 11 of IC2e will go
high. Diode D4 is now reverse biased
and the voltage at pin 13 of IC13a
and IC14a will slowly fall to ground
as the 100kΩ resistor discharges the
.01µF capacitor.
So to recap, the card is selected and
the number of steps loaded into the
down counters. After this number of
steps has been counted, the VCO will
December 1997 61
62 Silicon Chip
Fig.1: presettable up/
down counters IC3 &
IC4 form a buffer for
data from the
computer’s printer
port. This lets the
computer download
steps and it can then
perform other
functions while the
motor is stepping
through.
be inhibited and will stop driving the
phase counter. The logic signals to the
stepper motor transistors will also be
turned off, preventing any current
flow in phase windings MA and MB.
Full step - half step
If you have looked at the driver software for the previous stepper motor
cards you may have observed that for
a full step, four sub-steps are used, but
for half steps eight are needed. The
same situation applies in this case
(refer Table 3).
A jumper across J3 sets the full
step condition. This pulls pins 1 &
2 of IC11a low which results in the
cathode of diode D2 being pulled
high. This resets the phase counter
(IC6) and the step counters are now
clocked by IC8a when pin 1 of IC6
goes high; ie, after four steps.
For the half step mode, a jumper
across J2 pulls pins 1 & 2 of IC11 high,
which holds diode D2’s cathode low,
preventing pin 1 from resetting the
counter. IC6 will be reset and will also
clock IC3 and IC4 when it reaches a
count of nine; ie, when pin 11 goes
high, after eight steps.
Speed ramp up
Before we look at all the gates
connected to the outputs of IC6, we
should discuss the operation of the
VCO, in IC5. It starts the motor stepping at a slow speed, as set by VR2,
and gradually increases the stepper
rate to a value dictated by the fast
control VR1. This is done because a
stepper motor will ramp up to a higher
speed than it will start from, due to
the inertia of the rotor.
We achieve this speed increase by
December 1997 63
Fig.2: component overlay for the PC board. Note that the ICs are all oriented
differently so be careful to insert them in the right way. The same point applies
to the rest of the semiconductors and the electrolytic capacitors.
varying the VCO frequen
cy, which
depends on two factors, the voltage
on pin 9 and the resistance from pins
11 & 12 to ground. When pin 9 is low,
the output frequency is set by VR2
(set slow), and when pin 9 is taken to
+5V, the output frequency is dictated
by VR1.
By charging the 0.1µF capacitor
through the 1MΩ resistor, the voltage
on pin 9 slowly increases from zero to
5V and consequently the motor speed
increases from the slow control setting
mode is selected. As we explained
previously, the full step mode has four
increments, while the half step has
eight. By switching in the extra capacitor we hold the maximum motor speed
the same in both modes. This allows a
card to have its trimpots initially set
for a particular type of motor, allowing
it to run in either mode without any
readjustment to the presets.
to the fast control setting.
When the MSD counter, IC3, is
empty its TC output will swing low
and rapidly pull pin 9 of IC5 low,
by courtesy of diode D3. This will
immediately reduce the motor speed
to SLOW for any counts remaining
in IC4. The filter network on pin 7 of
IC4 is used, as one of the data books
claims that glitches can be present at
this output.
Mosfet Q13 switches an additional
capacitor in circuit when the full step
Decoder
The outputs of IC6 are fed to seven
gates which are used to decode and
direct the logic levels to the appropriate points. The explanation of how
this is done is too involved to go into
Table 1: Resistor Colour Codes
❏
No.
❏ 1
❏ 5
❏ 2
❏
13
❏ 4
❏ 1
64 Silicon Chip
Value
1MΩ
100kΩ
47kΩ
10kΩ
2.2kΩ
1kΩ
4-Band Code (1%)
brown black green brown
brown black yellow brown
yellow violet orange brown
brown black orange brown
red red red brown
brown black red brown
5-Band Code (1%)
brown black black yellow brown
brown black black orange brown
yellow violet black red brown
brown black black red brown
red red black brown brown
brown black black brown brown
Table 2: Capacitor Codes
❏
❏
❏
❏
Value
IEC Code EIA Code
0.1µF 100n 104
.01µF 10n 103
.001µF 1n0 102
in detail. Table 3 explains the logic
sequence used to drive the stepper
in each mode. By using this table you
will be able to trace out the logic paths
if you wish.
Step control
The quad analog switch package
IC9 is labelled as the step control. It
switches either IC7a & IC7c or IC7b &
IC7d to the inputs of IC10, the Direction switch. If the jumper is placed on
J3 (FULL) the signals MAF and MBF
from pins 4 & 13 of IC7 are fed to IC10.
If J2 is selected (HALF), then MAH
and MBH from pins 1 & 10 of IC7 are
the selected signals. Also IC11c and
IC11d, which are disabled in the FULL
mode, will be able to pass the MAINH
and MBINH signals from pins 8 & 11
of IC8 to IC13 and IC14. When these
ICs are turned off the zero current in
Table 3 is achieved.
The coil driver transistors (Q1-Q4 and Q7-Q10) are all bolted to a common
aluminium heatsink to aid heat dissipation. Note that the transistors must all
be isolated from the heatsink using insulating washers.
Fig.3 drilling details
for the aluminium
bar heatsink.
Motor direction
If F/R (forward-reverse) is selected
with jumper J1, then the logic level
on A7 of PortA (pin 9) will control
the direction. If it is high, IC10 will be
switched and the motor will step backwards. What this IC does is to swap
the pairs of gates (from IC7 which are
selected by IC9) to the inputs of IC12.
IC2d is used as a power-on reset to
ensure that both flipflops of IC12 are
reset at turn on. Each time an input
of IC12 (pins 1 & 13) goes low the
logic levels on the outputs change.
The outputs of IC12a are fed through
IC13 to drive motor coil MA and the
outputs of IC12b are fed through IC14
to drive coil MB.
Winding control
The path through IC13 (and IC14)
is actually two switches in series. As
we have explained previously, when
IC8b’s output is high one switch is
on and this will allow the coils to be
energised. The outputs of IC8d & IC8c
(MAINH and MBINH) will switch off
the drive signals through IC13 and
IC14 when a zero is needed in the half
step table. In the full step mode, IC11c
and IC11d will have one input low
(J3) and their outputs will always be
high, keeping that switch turned on.
Coil driver
Transistors Q1-Q12 make up two
H-bridge circuits which drive the
stepper motor coils, MA & MB. These
circuits are identical so we will only
describe the circuit based on Q1-Q6
which drives MA. This top circuit is
driven from the Q and Q-bar outputs
of IC12a, via switches IC13d and
IC13c.
Consider the situation when Q
is high and Q-bar (of IC12a) is low.
Q5 will turn on and this will also
turn on Q1 & Q4. As a result, current
flows through Q1, coil MA and Q4.
Conversely, when Q-bar of IC12a is
high, transistors Q6, Q2 & Q3 turn on,
causing current to flow through coil
MA in the opposite direction.
If IC13 is turned off, then both Q5
& Q6 will be off and no current will
flow through coil MA.
Almost all motors, including the
centre-tapped 5V types (as we don’t
use the CT) can be powered from the
12V supply. If you want more torque
and a faster stepping speed you can
run a motor from a higher voltage but
you should include a series resistor
in each coil to keep the motor current
December 1997 65
Fig.4 this is the full-size etching pattern for the PC board. Check your board
carefully before installing any of the parts.
within specification. It is the inductance of the motor windings which
limits the current and hence reduces
the torque, so by applying a higher
voltage we get a higher initial current.
Building the board
Before you begin the board assembly
it is worthwhile checking the copper
pattern against the artwork of Fig.4,
J4-J8
J1
Jumper header pair J1 is used to select
forward or forward/reverse (shown),
while jumpers J4-J8 provide the card
with a unique identification.
66 Silicon Chip
especially where there are three tracks
through the centre of an IC or where
there is a track between two IC pads.
The first task is to fit and solder
the 72 links, counting as you go, for a
couple are underneath ICs and may be
difficult to install later on. Next fit and
solder the resistors and diodes, then
the ICs. Continue with the trimpots,
jumper strips and capacitors.
It is advisable to bolt the eight power
transistors to a common heatsink if you
intend driving high current stepper
motors for long periods. The heatsink
fitted to the prototype was a piece of
aluminium bar 12 x 6 x 58mm long.
Fig.3 shows the drilling details for
the heatsink. The best procedure is
to loosely attach all the transistors to
the heatsink bar and then mount the
entire assembly on the PC board. Be
sure to use insulating washers to isolate the metal faces of the transistors
from the heatsink. The BD682 PNP
transistors are all mounted on one
side of the heatsink while the BD679
NPN types mount on the other side.
Table 3
Full Step (Both Windings Energised)
Step
1
2
3
4
Step
1
2
3
4
5
6
7
8
MA
L-R
R-L
R-L
L-R
Half Step
MA
L-R
0
R-L
R-L
R-L
0
L-R
L-R
MB
L-R
L-R
R-L
R-L
MB
L-R
L-R
L-R
0
R-L
R-L
R-L
0
Once the heatsink assembly is in
position, solder one lead at either
end and then tighten all the mounting bolts. The assembly can then be
adjusted to sit parallel to the PC board
and the remaining transistor leads
soldered.
After you have finished, check the
copper side of the PC board for any
Listing 1
10 PORTA = &H378 ‘this is LPT1 use &H278 for LPT2
20 PORTB = PORTA + 1: PORTC = PORTA + 2
30 OUT PORTA,20: OUT PORTC,11 ‘set 20 steps and card 1
40 OUT PORTC,10 ‘reset strobe
The answers! to
260,000 questions,
ALL in one book!
The following code will allow you to identify which cards are busy. You must
run it after the previous code or redefine the ports (lines 10 & 20)
100 OUT PORTC,11 ‘select ANY active card
110 OUT PORTB,120 ‘set PORT B lines high
120 B = 127 - INP(PORTB) ‘read PORT B lines
130 IF B AND -128 THEN J7$ = “J7 busy “
140 IF B AND 64 THEN J6$ = “J6 busy “
150 IF B AND 32 THEN J5$ = “J5 busy “
160 IF B AND 16 THEN J4$ = “J4 busy “
170 PRINT J7$ + J6$ + J5$ + J4$
180 WHILE B > 0 OR B < 0: B = 127 - INP(PORTB): WEND ‘wait for all cards
190 OUT PORTC,10 ‘reset strobe
200 PRINT “All motors stopped.”
210 END
Table 4
Jumper
J4
J5
J6
J7
Code
16
32
64
128
unsoldered pads which can mean
missing components or links.
Finally, complete the assembly by
fitting the 8-pin header, the DB25 connector and the 7-way terminal block.
Testing the board
Before you apply power to the card,
turn both trimpots anticlockwise, fit
the jumper to select card 1 (C1), fit J3
and fit the two F/R links so that they
are parallel to Con1. You will need
a 25-way D male to female cable to
connect the card to the computer’s
parallel printer port.
You will also need a power supply
capable of supplying 5V at a few milliamps and 12V at probably around 1A,
to supply the stepper motor.
The first four lines of Basic code
in Listing 1 will allow you to test
the card.
PortB jumpers
The major advantage of this card
is that the computer can send the
number of steps for the motor to make,
then do something else while the card
is driving the stepper. We now need
some way of letting the computer
know when the job is completed.
Two different methods are available
on this card. If one or several of them
are being used in a system, jumpers
J4-J7 can be used. The STOP line on
each card is low while the motor is
running and goes high when the motor stops. If each card uses a different
jumper the computer can read PortB
and determine the status of the cards
(see Table 4).
If only one card is in use, J8 can be
used but only if the card is left selected. In this case the line is high while
the motor is stepping and goes low
when the motor stops. As this input
line is inverted the program will see
SC
the inverse of this logic.
The largest range of replacement semiconductors in the industry! Call now
to get your new NTE cross reference
book for just $25.
Stewart Electronic Components P/L
P.O. Box 281 Oakleigh 3166
phone (03)9543-3733 fax (03)9543-7238
Silicon Chip
Binders
REAL
VALUE
AT
$11.95
PLUS P
&P
How To Get The Software
★ Heavy board covers with 2-tone
green vinyl covering
★ Each binder holds up to 14 issues
★ SILICON CHIP logo printed on
spine & cover
Price: $A11.95 plus $A3 p&p each
All the software for this series of stepper cards and the I/O card described
in the July 1997 issue is now available on a 3.5-inch floppy disc for $7 plus
$3 postage and packing. Payment may be made by cheque, postal money
order or credit card (Bankcard, Visa or Mastercard) to Silicon Chip, PO Box
139, Collaroy, NSW 2097 or via fax (02) 9979 6503.
Just fill in & mail the handy order form
in this issue; or fax (02) 9979 6503;
or ring (02) 9979 5644 & quote your
credit card number.
Note: prices rise next month
Aust. only. Not available elsewhere
December 1997 67
|