This is only a preview of the August 1997 issue of Silicon Chip. You can view 34 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:
Articles in this series:
Items relevant to "A 500 Watt Audio Power Amplifier Module":
Items relevant to "Build A TENS Unit For Pain Relief":
Items relevant to "PC Card For Stepper Motor Control":
Articles in this series:
|
By RICK WALTERS
Addressable card for
driving a stepper motor
This interface card allows you to drive
a stepper motor using software control.
It plugs into your PC’s parallel port
and you can connect up to eight units
in daisy-chain fashion.
The interface card featured here is
the first of two new cards that allow
you to control stepper motors via the
parallel port of a PC. It is capable of
driving one stepper motor, while the
second unit (to be described next
54 Silicon Chip
month) is capable of driving two
stepper motors.
In practice, you can connect up to
eight cards (in daisy-chain fashion) to
the printer port, so that you can control eight different motors. Each card
is set with a unique address from 1-8,
so that it can be individually selected.
In addition, two or more cards can
be coded with the same address in a
master-slave setup, so that even more
motors can be controlled.
Of course, those cards that have the
same address will identically control
their motors.
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 address matches
that selected by a jumper on the card,
the logic levels present on the port’s
normal data lines are latched (stored)
and fed to the motor drivers.
Fig.1 (right): the circuit is
based on address decoder
IC1 and 8-bit data latch
IC1. When the correct
address is fed to IC1, the
data on the Port A lines
is latched into IC1 and
transferred to the Q
outputs. These outputs
then drive transistors Q1Q12 to control the stepper
motor.
August 1997 55
Note that the card is capable of
driving the stepper motor in both the
forward and reverse directions. When
the motor is not stepping, the driver
transistors are turned off to prevent
the motor from overheating.
Circuit details
The circuit of the card is shown in
Fig.1. It uses IC1, a one-of-eight active
low decoder, as the address latch.
Basically, this IC looks at the binary
coded decimal (BCD) data on its A, B &
C inputs and pulls the corresponding
decimal output (Y0-Y7) low.
In greater detail, this only occurs
when the strobe line from inverter
stage IC3b goes to a logic high (+5V).
This momen
tarily pulls the latch
enable input (pin 4) of IC1 high via a
.001µF capacitor. The decoded output
then goes low (0V) to give a unique
address.
If this is the output selected by the
address link, the decoded logic low is
fed to pin 2 of IC3a. IC3d inverts the
strobe signal and so pin 3 of IC3a will
also be low. As a result, pin 1 of IC3a
goes high and momentarily pulls the
latch enable 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, the
data present on its Data inputs (D0D7), as fed in from Port A of the parallel port, is latched and transferred to
the Q outputs. The latch enable signal
then goes low 47ms later (as set by the
associated 47kΩ pull-down resistor),
so that the data remains latched until
the next strobe signal.
Resistors (0.25W, 1%)
1 10MΩ
4 2.2kΩ
1 47kΩ
1 470Ω
9 10kΩ
from the positive supply rail through
Q1, coil MA and Q4 to ground.
Conversely, when outputs Q1 & Q2
are high and Q0 & Q3 are low, transistors Q6, Q2 and Q3 are tuned on and
the current flows through the coil in
the opposite direction.
Therefore, depending on the logic
levels at the Q0-Q7 outputs of IC2,
we can control the direction of the
current through the two coils and thus
the stepping direction of the motor. If
all outputs are low, all the transistors
are off and no current flows through
either coil (ie, the motor is stopped).
To actually step the motor it is necessary to switch the current through
the coils in a logical sequence. Table
3 lists the different modes for driving
a stepper motor, along with the binary
code required at IC2’s output which,
of course, is identical to that at CON1.
The decimal value can be used in a
Basic program to apply the correct bit
pattern to the parallel port.
Almost all motors can be powered
from the 12V supply, including centre-tapped 5V motors (because we
don’t use the CT). If you want more
torque and a faster stepping speed,
you can run the motor from a higher voltage, in which case a resistor
must be added in series with each
coil to keep the motor current within
specification. It is the inductance of
the motor windings which limits the
current and hence the torque, so by
applying a higher voltage we get a
higher initial current.
Miscellaneous
Tinned copper wire for links
Card selected indicator
Parts List
1 PC board, code 07108971,
120 x 112mm
1 DB25 PC-mount male rightangle connector
1 stepper motor, 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)
1 4-way terminal block (5.08mm
pitch)
Semiconductors
1 74HC137 decoder (IC1)
1 74HC573 8-bit latch (IC2)
1 74HC02 quad nor gate (IC3)
4 BD682 PNP Darlington
transistors (Q1,Q2,Q7,Q8)
4 BD679, BD681 NPN Darlington
transistors (Q3,Q4,Q9,Q10)
4 BC548 NPN transistors
(Q5,Q6,Q11,Q12)
1 1N914 small signal diode (D1)
1 5mm red LED (LED1)
Capacitors
2 100µF 25VW PC electrolytic
2 0.1µF monolithic ceramic
1 0.1µF MKT polycarbonate
2 .001µF MKT polycarbonate
The only circuit function yet to be
described is the card selected indicator. This is based on D1 and IC3c and
lights LED1 whenever a valid address
is received. This feature provides a
convenient way of checking which
card has been selected at any given
time in a multi-card system.
The way in which this works is
quite straightforward. As shown, pins
Motor drivers
Transistors Q1-Q6 and Q7-Q12
form two bridge circuits which drive
the stepper motor coils. One circuit
is controlled by the Q0-Q3 outputs
of IC2, while the other is controlled
by the Q4-Q7 outputs. Because these
two bridge circuits are identical, we
shall only describe the circuit based
on transistors Q1-Q6.
We’ll begin by considering what
happens when outputs Q0 & Q3 of
IC2 are high and Q1 & Q2 are low. In
this case, transistors Q5, Q1 & Q4 will
all be turned on and so current flows
Table 1: Resistor Colour Codes
❏
No.
❏ 1
❏ 1
❏ 9
❏ 4
❏ 1
56 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
TRANSFORMERS
• TOROIDAL
• CONVENTIONAL
• POWER • OUTPUT
• CURRENT • INVERTER
• PLUGPACKS
• CHOKES
STOCK RANGE TOROIDALS
BEST PRICES
APPROVED TO AS 3108-1994
SPECIALS DESIGNED & MADE
15VA to 7.5kVA
Tortech Pty Ltd
24/31 Wentworth St, Greenacre 2190
Phone (02) 642 6003 Fax (02) 642 6127
Fig.2: install the parts on the PC board as shown here. Don’t forget to fit a
jumper to the pin header to select the address of the card and take care when
mounting the power transistors as they don't all face in the same direction.
8 & 9 of IC3c are normally pulled high
via a 10MΩ resistor and so pin 10 is
low and LED1 is off. However, when a
valid address is received, the decoded
output from IC1 goes low and so pins
8 & 9 of IC3c are pulled low via D1.
This in turn switches pin 10 of IC3c
high and so LED1 lights to indicate
that the card has been selected.
Because a card can be selected
and deselected very quickly, a 0.1µF
timing capacitor is included between
the inputs of IC3c and ground. This
ensures that the LED stays lit for one
second after the card has been de
selected.
Building the card
The circuit is easy to build, with
all the parts mounted on a PC board
coded 07108971 (120 x 112mm). Fig.2
shows the parts layout on the board,
while Fig.3 shows the full-size etching
pattern.
Begin by checking your etched
board for defects by compar
ing it
with Fig.3. In particular, check for
undrilled holes and shorts between
tracks, especially around the IC pads.
This done, install the wire links (11),
followed by the resistors and diodes.
Table 1 shows the resistor colour codes
but it is also a good idea to check the
values using a digital multimeter, just
to make sure.
The capacitors can be installed next,
followed by LED1 and the transistors.
Be careful when fitting the transistors
as two different TO-220 types are
used. Note also that the metal faces
of Q3, Q4, Q9 & Q10 (all BD679) face
towards CON1 (the DB25 connector),
while the metal faces of Q1, Q2, Q7
& Q8 (all BD682) face towards CON3.
Take care to ensure that the LED is
correctly oriented. Its anode lead will
be the longer of the two, while the
cathode lead will be adjacent to a flat
section on the bevel at the bottom of
the plastic body.
Finally, complete the assembly by
fitting the 8-way pin header and the
P.C.B. Makers !
If you need:
• P.C.B. High Speed Drill
• P.C.B. Guillotine
• P.C.B. Material – Negative or
Positive acting
• Light Box – Single or Double
Sided – Large or Small
• Etch Tank – Bubble or Circulating
– Large or Small
• U.V. Sensitive film for Negatives
• Electronic Components and
•
•
Equipment for
TAFEs, Colleges and Schools
FREE ADVICE ON ANY OF
OUR PRODUCTS FROM
DEDICATED PEOPLE WITH
HANDS-ON EXPERIENCE
Prompt and Economical Delivery
KALEX
40 Wallis Ave E. Ivanhoe 3079
Ph (03) 9497 3422
FAX (03) 9499 2381
• ALL MAJOR CREDIT
CARDS ACCEPTED
August 1997 57
Listing 1
10 REM Step motor clockwise
20 PORTA = &H378 ‘This is for LPT1 Enter &H278 for LPT2
30 PORTC = PORTA + 2 ‘and card 1 selected
40 DATA 153, 150, 102, 105, 102, 150, 153, 105
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 anti-clock steps
70 OUT PORTA,105: 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 anti-clockwise
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
three connectors. Make sure that the
DB25 connector is sitting flat against
the board before soldering its pins.
Testing
To test the board you will need a
25-way “D” male-to-female cable (ie,
a printer cable) and a power supply
capable of supplying 5V at a few
milliamps and 12V at up to 1A. If
you are careful, you can pick up the
5V supply from the games port on
the computer. The connec
tions on
the 9-pin “D” connector are pin 5 for
the 5V line and pins 4, 5 and 12 for
ground. The 12V rail can come from
a suitable plugpack supply.
Alternatively, you can wait and
build the power supply to be described in next month’s issue.
Before applying power, connect
the card to your computer’s parallel
(printer) port LPT1 using the extender
cable. You will also have to install a
jumper on the pin header to set the
address of the card. If you only have
one controller card, you can choose
any address you like although it’s
probably best to fit the jumper 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. You can omit
the line numbers if you use Q-Basic.
You can also omit the remarks (after
the ‘) as they are only there to give you
an idea of what the software is doing.
When you run this program, the
motor should rotate clock
wise one
revolution, stop and then step anticlockwise to its original position. A
pencil mark on the gear will let you see
what is happening. Check that LED1
on the card lights to confirm that the
card has been addressed.
If you use LP2 as the parallel port,
you will have to change line 20 (ie,
Table 2
Fig.3: check your board against this full-size artwork before installing the parts.
58 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
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 motor you use is
different to that specified in the parts
list, your results may not be the same
as ours. If the motor runs in the wrong
direction, just swap the wires to pins
1 and 2 of CON3. The motor we used
has 7.5° steps and if the one you use is
different (eg, if it has 1.8° steps), you
will have to change the number 12 in
lines 80 & 160 to some other value to
get a complete revolution.
For example, you would have to
change 12 to 50 for a motor with 1.8°
steps.
A close examination of the program
shown in Listing 1 will reveal how
it all works and you can experiment
with your own values. The values we
have used are for a single full step
with both windings energised. You
Up to eight cards can be
connected to the printer
port, so that you can
control eight different
motors. Each card is
given a unique address
by fitting a jumper to an
8-way pin header.
may wish to load the “one winding
energised” values into the program
and compare the torque difference.
Fault finding
If it doesn’t work, the first thing
to do is to check that you have the
jumper or link set for card 1. If this is
OK, check that LED1 lights when you
run the program.
If LED1 doesn’t light, connect pins
4 & 16 of IC1 together and run the
program again. If the LED now lights,
then the problem probably involves
IC3b or the components connected to
pin 4 (LE) of IC1.
The same technique can be used
to test the circuitry that drives the
latch enable input (pin 11) of IC2 (ie,
connect pin 11 to pin 20).
SC
August 1997 59
|