This is only a preview of the September 1997 issue of Silicon Chip. You can view 29 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. Items relevant to "Multi-Spark Capacitor Discharge Ignition System":
Items relevant to "Building The 500W Audio Power Amplifier; Pt.2":
Articles in this series:
Items relevant to "PC Card For Controlling Two Stepper Motors":
|
Addressable card
for controlling two
stepper motors
Based closely on the design published last
month, this new interface card allows you to
control two stepper motors via your PC. It plugs
into the PC’s parallel port and you can connect
up to eight units in daisy-chain fashion.
By RICK WALTERS
We envisage that this new design
will be suitable for those who wish
two drive two stepper motors to
achieve 2-axis control. The new card
is capable of independently driving
each stepper motor in either forward
or reverse direction, or it can drive
just one stepper motor at a time.
When a motor is not stepping, its
driver transistors can be turned off to
prevent the motor from overheating.
80 Silicon Chip
As with last month’s design, the
card is set with a unique address
from 1-8 so that it can be individually
selected and two or more cards can
be coded with the same address in a
master-slave setup.
In operation, an address from 0-7
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 a jumper on the card, the logic
level present on the port’s normal
data lines is latched (stored) and fed
to the motor drivers.
Circuit details
Refer now to Fig.1 for the circuit
details. The decoding and latching
circuitry is identical to that published
last month but, for those who missed
that article, we’ll recap the details.
IC1, a 74HC137 one-of-eight active
low decoder, is used as the address
latch. This IC looks at the BCD address
Fig.1 (right): when the correct address
is fed into IC1, the data on the Port A
lines is latched into IC2 and appears
at its Q outputs. These outputs then
drive transistors Q1-Q24 to control
the stepper motors.
September 1997 81
8 & 9 of IC3c are pulled high via a
10MΩ resistor and so pin 10 is low
and LED1 is off.
When a valid address is received,
pins 8 & 9 of IC3c are pulled low via
D1 (since the decoded output from
IC1 goes low). As a result, pin 10 of
IC3c switches high and LED1 lights to
show that the card has been selected.
The 0.1µF capacitor connected
from pins 8 & 9 of IC3c to ground
ensures that the LED remains on for
at least one second.
Motor drivers
Transistors Q1-Q24 make up four
H-bridge circuits which drive the
stepper motor coils. These circuits are
identical, so we will only describe the
circuit based on transistors Q1-Q6.
This top circuit is driven from the
Q0 & Q1 outputs of IC2. Let’s first consider the situation when Q0 is high
and Q1 is low. In that case, transistor
Q5 will turn on and this will also turn
on transistors Q1 and Q4. As a result,
current now flows from the positive
supply rail and through transistor Q1,
coil M1A and transistor Q4 to ground.
Conversely, when output Q1 is
high and Q0 is low, transistors Q6,
Q2 and Q3 turn on and the current
flows through coil M1A in the opposite direction. If both the Q0 and Q1
outputs are low, all transistors are off
and no current flows.
Therefore, depending on the logic
levels on the Q0-Q7 outputs, we can
control the direction of the current
pulses through the coils and thus
the stepping direction of each motor.
To actually step a motor, it is necessary to switch the current through
its coils in a logical sequence. Table 3
lists the different driving modes and
shows the binary code required at
IC2’s output. This code is, of course,
identical to that required at D0-D7
(Port A) of CON1. The decimal value
is also shown in Table 3 and this can
be used in a Basic program to apply
Fig.2: exercise care when installing the power transistors on the PC board. You
must use the correct type at each location and it must be correctly oriented.
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 stage IC3b goes high and
momentarily pulls the latch enable
(LE) input of IC1 high via the series
.001µF capacitor.
As a result, the card will be addressed if the decoded output is
selected by the address link. In that
case, the decoded low will be fed to
pin 2 of IC3a and to the cathode of
D1. At the same time, the high strobe
signal is inverted by IC3d and so pin
1 of IC3a goes high and momentarily
pulls the LE input (pin 11) of IC2 high
via a second .001µF capacitor.
IC2 is a 74HC573 8-bit data latch.
When its LE input is taken high, it
latches the data present on its D0D7 inputs as fed in via Port A of the
parallel port. This data is transferred
through to IC2’s Q outputs and is used
to control the stepper motors via transistor H-bridge driver circuits. The LE
signal then goes low 47ms later (as
set by the 47kΩ pull-down resistor),
so that the data remains latched until
the arrival of the next strobe signal.
D1, IC3c and LED1 form the card
selected indicator. Normally, pins
Table 1: Resistor Colour Codes
❏
No.
❏ 1
❏ 1
❏ 9
❏ 8
❏ 1
82 Silicon Chip
Value
10MΩ
47kΩ
10kΩ
2.2kΩ
470Ω
4-Band Code (1%)
brown black blue brown
yellow violet orange brown
brown black orange brown
red red red brown
yellow violet brown brown
5-Band Code (1%)
brown black black green brown
yellow violet black red brown
brown black black red brown
red red black brown brown
yellow violet black black brown
Parts List
1 PC board, code 07208971,
120 x 112mm
1 D25 PC-mount male rightangle connector
2 stepper motors, Oatley
Electronics M35 or equivalent
1 8-way x 2-pin header strip
(2.54mm pitch)
1 jumper for header strip
1 3 way terminal block (5.08mm
pitch)
8 PC stakes
This view clearly shows how the power transistors are fitted to the heatsink.
Note that each transistor must be isolated from the heatsink using a TO-220
insulating washer.
Semiconductors
1 74HC137 decoder (IC1)
1 74HC573 8-bit latch (IC2)
1 74HC02 quad NOR gate (IC3)
8 BD682 PNP Darlington
transistors (Q1,Q2,Q11Q14,Q23,Q24)
8 BD679, BD681 NPN
Darlington transistors (Q3,Q4,
Q9,Q10,Q15,Q16,Q21,Q22)
8 BC548 NPN transistors
(Q5,Q6,Q7,Q8,Q17-Q20)
1 5mm red LED (LED1)
1 1N914 small signal diode (D1)
Capacitors
2 100µF 25WV PC electrolytic
2 0.1µF monolithic ceramic
1 0.1µF MKT
2 .001µF MKT
Resistors (0.25W, 1%)
1 10MΩ
8 2.2kΩ
1 47kΩ
1 470Ω
9 10kΩ
Heatsink parts (optional)
1 aluminium bar, 110 x 6 x 3mm
16 TO-220 insulating washers
8 3mm x 15mm bolts
8 3mm nuts
16 3mm flat washers
Fig.3: this diagram shows the drilling details for the aluminium heatsink.
the correct bit pattern to the parallel
port.
Almost all motors can be powered
from the 12V supply, including centre-tapped 5V motors (as we don’t use
the CT). If you want more torque and a
faster stepping speed, you can run the
motors from a higher voltage but you
should add a resistor in series with
each coil to keep the motor current
within specification.
PC board assembly
Fig.2 shows the parts layout on the
PC board (code 07208971). As usual,
check your etched PC board against
the full-size pattern shown in Fig.4
before installing any of the parts.
Once this has been done, begin the
assembly be installing PC stakes at
the eight external wiring pints, then
install the wire links (11), the resistors
and the diode (D1).
The ICs (or IC sockets if you use
them) can go in next, followed by the
capacitors, address jumper, the LED
and the D connector. Take care with
the LED polarity – its anode lead will
Miscellaneous
Tinned copper wire for links
be the longer of the two. In addition,
the cathode lead is adjacent to a flat
section on the bevel at the bottom of
the plastic body.
The eight BC548 transistors can
now be installed, followed by the
16 power transistors. Note that it
is advisable to bolt the power transistors to a common heatsink if you
intend driving high-current stepper
motors for long periods. The heatsink
September 1997 83
Listing 1
10 REM Step both motors clockwise
20 PORTA = &H378 ‘This is for LPT1 Use &H278 for LPT2
30 PORTC = PORTA + 2 ‘and card 1 selected
40 DATA 85, 102, 170, 153, 170, 102, 85, 153
50 FOR A = 1 TO 4: READ ROTCW(A): NEXT ‘Read data for clockwise steps
60 FOR A = 1 TO 4: READ ROTCCW(A): NEXT ‘Read data for anticlock steps
70 OUT PORTA,85: OUT PORTC,11 ‘Set motor to known position
80 FOR A = 1 TO 12 ‘Go forward 12 steps of 30 degrees
90 FOR B = 1 TO 4: OUT PORTA,ROTCW(B) ‘Four steps of 7.5 degrees
100 OUT PORTC,11: OUT PORTC,10 ‘Select card one, then take strobe low
110 FOR C = 1 TO 350: NEXT ‘Delay to allow motor to step
120 NEXT B: NEXT A
130 OUT PORTA,0: OUT PORTC,11: OUT PORTC,10 ‘De-energise motor coils
140 FOR A = 1 TO 20000: NEXT ‘Pause for a while
150 REM Now step motor anticlockwise
160 FOR A = 1 TO 12 ‘Go backwards 12 steps of 30 degrees
170 FOR B = 1 TO 4: OUT PORTA,ROTCCW(B) ‘Four steps of 7.5 degrees
180 OUT PORTC,11: OUT PORTC,10 ‘Select card one, then take strobe low
190 FOR C = 1 TO 350: NEXT ‘Delay to allow motor to step
200 NEXT B: NEXT A
210 OUT PORTA,0: OUT PORTC,11: OUT PORTC,10 ‘De-energise motor coils
fitted to the prototype was cut from
square-section (6 x 12mm) aluminium
rod and is 110mm long.
Fig.3 shows the drilling details for
the heatsink. The best procedure is
to first loosely attach the transistors
to the heatsink 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 are all mounted on the
opposite side.
Once the assembly is in position,
solder one lead at either end, then
tighten all the mounting bolts. The
assembly can then be adjusted so that
it sits parallel to the PC board and the
remaining leads soldered.
Finally, complete the assembly by
fitting the 8-way pin header, the DB25 connector and the 3-way terminal
block.
Testing the board
To test the board, first connect it to
the computer via a standard printer
cable. You will also need a power supply capable of supplying 5V at a few
milliamps plus a 12V supply capable
of powering the two stepper motors
(probably around 2A capacity).
If necessary, you can obtain the 5V
supply from the games port on the
computer (provided it has one). Pin 5
on the 9-pin “D” connector is the +5V
rail, while pins 4, 5 & 12 are ground.
If you only have one card, the address jumper should be fitted to the
C1 position. That way, you won’t have
to alter the program shown in Listing
1 in order to address the card.
Now load Basic and enter the program shown in Listing 1. The line
numbers can be omitted if you are
using Qbasic. You can also omit the
remarks (after the ‘), as they are only
Table 2
Fig.4: here is the full-size etching pattern for the PC board.
84 Silicon Chip
Card No.
Address
Card 1
11
Card 2 9
Card 3
15
Card 4
13
Card 5 3
Card 6 1
Card 7 7
Card 8 5
Table 3: Stepper Motor Sequences
Full Step - One Winding Energised
Step No. Polarity
Q0
Q1
Polarity
Q2
Q3
Polarity
Q4
Q5
Polarity
Q6
Q7
Step 1
M1A+
1
0
M1B0
0
0
M2A+
1
0
M2B0
0
0
Decimal
17
Step 2
M1A0
0
0
M1B+
1
0
M2A0
0
0
M2B+
1
0
68
Step 3
M1A-
0
1
M1B0
0
0
M2A-
0
1
M2B0
0
0
34
Step 4
M1A0
0
0
M1B-
0
1
M2A0
0
0
M2B-
0
1
136
Q0
Q1
Polarity
Decimal
Full Step - Both Windings Energised
Step No. Polarity
Q2
Q3
Polarity
Q4
Q5
Polarity
Q6
Q7
Step 1
M1A+
1
0
M1B+
1
0
M2A+
1
0
M2B+
1
0
85
Step 2
M1A-
0
1
M1B+
1
0
M2A-
0
1
M2B+
1
0
102
Step 3
M1A-
0
1
M1B-
0
1
M2A-
0
1
M2B-
0
1
170
Step 4
M1A+
1
0
M1B-
0
1
M2A+
1
0
M2B-
0
1
153
Q0
1
Q1
0
Polarity
M1B0
Q2
0
Q3
0
Polarity
M2A+
Q4
1
Q5
0
Polarity
M2B0
Q6
0
Q7
0
Decimal
17
1
0
M1B+
1
0
M2A+
1
0
M2B+
1
0
85
Half Step - Windings Turned On & Off
Step No. Polarity
Step 1
M1A+
Step 2
M1A+
Step 3
M1A0
0
0
M1B+
1
0
M2A0
0
0
M2B+
1
0
68
Step 4
M1A-
0
1
M1B+
1
0
M2A-
0
1
M2B+
1
0
102
Step 5
M1A-
0
1
M1B0
0
0
M2A-
0
1
M2B0
0
0
34
Step 6
M1A-
0
1
M1B-
0
1
M2A-
0
1
M2B-
0
1
170
Step 7
M1A0
0
0
M1B-
0
1
M2A0
0
0
M2B-
0
1
136
Step 8
M1A+
1
0
M1B-
0
1
M2A+
1
0
M2B-
0
1
153
there to give you an idea of what the
software is doing and play no part in
the program operation.
When you run this program, the
motors should both rotate clockwise
one revolution, stop briefly and then
step anticlockwise to their original
positions. In addition, the “selected”
LED should light to confirm that the
card has been addressed.
Note that the values shown in Listing 1 are for a single full step with
both stepper windings energised.
As an experiment, try loading the
“one winding energised” values into
the program and check the torque
difference.
If you use LPT2 as the parallel port
(instead of LPT1), you will have to
change line 20 (ie, change &H378 to
&H278). The address value for each
card from 1-8 is given in Table 2. The
illogical sequence of the numbers is
due to the fact that both C1 and C3
on PortC are inverted logic; ie, if they
are programmed high in Basic (or any
other language), they will actually
go low.
If the stepper motors you use are
different to those specified in the parts
list, your results may not be the same
as ours. If the motor runs in the wrong
direction, just swap one pair of motor
leads on the PC stakes. The stepper
motors we used have 7.5° steps and
if yours are different (eg, if they have
1.8° steps), you will have to change
the number 12 in lines 80 and 160 to
get a complete revolution.
For example, if the motor has 1.8°
steps, you would have to change the
number 12 to 50.
Fault finding
The stepper motors used with
the prototype card were M35s
from Oatley Electronics.
If you strike problems, first check
that the address jumper is set for card
1 (C1). If so, check that LED1 lights
when you run the program. If the LED
doesn’t light, connects pins 4 & 16 of
IC1 together and rerun the program. If
the LED now lights, check IC3b and
the components between IC3b and pin
4 of IC1. The same technique can be
used to test the circuitry that drives
the LE input of IC2 (ie, connect pin
SC
11 to pin 20).
September 1997 85
|