Download ucn5804b

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Commutator (electric) wikipedia , lookup

Power engineering wikipedia , lookup

Control system wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Three-phase electric power wikipedia , lookup

Electrical substation wikipedia , lookup

Stray voltage wikipedia , lookup

Electrification wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

History of electric power transmission wikipedia , lookup

Power inverter wikipedia , lookup

Transistor wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Coilgun wikipedia , lookup

Current source wikipedia , lookup

Rectifier wikipedia , lookup

Electric machine wikipedia , lookup

Voltage regulator wikipedia , lookup

Mains electricity wikipedia , lookup

Power MOSFET wikipedia , lookup

Two-port network wikipedia , lookup

Schmitt trigger wikipedia , lookup

Voltage optimisation wikipedia , lookup

Power electronics wikipedia , lookup

Alternating current wikipedia , lookup

Electric motor wikipedia , lookup

Buck converter wikipedia , lookup

AC motor wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Brushless DC electric motor wikipedia , lookup

Opto-isolator wikipedia , lookup

Induction motor wikipedia , lookup

Current mirror wikipedia , lookup

Brushed DC electric motor wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Stepper motor wikipedia , lookup

Transcript
Stepper Motor Musings
November 15, 2001 – Page 1
Introduction
I wanted to put down my latest thoughts on the stepper motor information that I’ve
gathered up. Obviously there is a bunch of stuff attached, but I think it should help move
us forward.
General Stepper Motor Info
There is a tutorial available on the we called, “Control of Stepping Motors, a tutorial”
which is available athttp://www.cs.uiowa.edu/~jones/step/index.html. It seems to deal
with the physics of the device in great detail. Also there’s a good reference at Wirz
(http://www.wirz.com/stepper/index.html) that has a good discussion about positioning.
I’ve attached some other relevant info as follows:
Attachment 1 – A description of 5, 6 and 8 lead stepper motors
Attachment 2 – StampWorks Project 26
Attachment 3 – 5804 Schematic
Attachment 4 - Basic Stamp I Stepper Controller
Attachment 5 – UNL2003 info
What We Have
So far we’ve received:
==============================================================
?? The Little Step-U and a 5-lead 12 Volt / 75 Ohm Unipolar Stepper Motor and a
ULN2803A Darlington Array.
Motor specs are at: http://dropball.cs.emporia.edu/stepper/index.html.
The full Little Step-U doc is at: http://dropball.cs.emporia.edu/stepper/5804.pdf.
The schematic for using this guy is:
Stepper Motor Musings
November 15, 2001 – Page 2
With details of the implementation and the Step-U at:
http://dropball.cs.emporia.edu/stepper/LittleStep.PDF.
I’ve order the addit ional components shown in the schematic from DigiKey and they
should arrive next week.
?? A generic stepper motor control using the basic stamp II. Schematic included as
Attachment 2.
Stepper Motor Musings
November 15, 2001 – Page 3
I’ve order the additional components shown in the schematic from DigiKey and they
should arrive next week.
==============================================================
?? From Alltronics (http://www.alltronics.com/stepper_motors.htm) I’ve received:
UNIPOLAR STEPPER MOTOR DRIVER IC UCN5804
NEMA size 23 (2.25" sq. x 2.25" L). 0.25" shaft both ends (front 0.375"L, rear 0.625"L).
Unipolar, six wires. 1.7 Volts, 3.4 Amps, 1.8°/step. Coil resistance 0.7 Ohm. Japan Servo
Co. #KP6M2-020 or equivalent.
SIX-WIRE UNIPOLAR STEPPER MOTOR 5VDC, 15°/step, 2" dia. x 1" thick. brass
gear. Nippon Pulse #PF55-48C5.
The schematic for using the 5804 is included as attachment 3.
I’ve order the additional components shown in the schematic from DigiKey and they
should arrive next week.
==============================================================
Basic Stamp I Circuit
Circuit is shown in Attachment 4. The circuit utilizes a ULN2003 Darlington array. Specs
for the ULN2003 are included in attachment 5,
I’ve order the additional components shown in the schematic from DigiKey and they
should arrive next week.
Attachment 1
Stepper Motor 5,6 and 8 Lead Descriptions
DIY KIT 109 STEPPER MOTOR DRIVER
Stepper motors can be used in a wide variety of hobby
applications: searchlights on small boats & cars, video
camera positioning, radio antenna control, controls
operating through waterproof housing, telescope control
where the azimuth, elevation & focus must be varied
independently, moving table positioning. In these
applications what is required is one or both of a
continuous stepping at varying speeds and a single
stepping, fine control to get the final position.
This kit is a stepper motor driver for 5, 6 & 8 lead
unipolar stepper motors. These are the most common
types today on the surplus market. The older four lead
bipolar stepper motors are not supported by this kit.
Visual indication that a pulse has gone to the stepper
motor is provided by 4 LED’s, one connected to each of
the four coils in the motor. (This may be very useful if
you cannot see the motor and want to be sure that it has
stepped.) The direction of stepping can be changed by a
switch. Three stepping modes are possible.
The kit uses an IC especially designed to drive 6 lead
unipolar stepper motors, the UCN5804B. As will be
shown the 5 and 8 lead steppers can be configured into a
6 lead pattern. The data sheet for this IC is included. The
various features of this IC are brought out to 5 SPDT
switches on the PCB. This kit was designed using Protel
for DOS.
ASSEMBLY
Check the components against the Component listing.
Make sure you identify C1, the 474 monoblok. It looks
just the same as C2 C4 & C6 which are 104 monobloks
with the same pitch. Note there are four links to go on the
board. One of the links goes under an IC socket. Make
sure the flat on the four LED’s corresponds to the bar
shown on the overlay. They all face right. It is generally
best to solder the lowest height components into the board
first. We have included a 6-pin header to make the
connection of the stepper motor to the PCB easier.
Motor Identification.
This is straight forward because the number of wires
coming out of the motor identifies it. Bipolar motors
have 4 leads coming out of them. One winding is on each
stator pole. These motors are not supported by this kit.
They were common in the late 1980’s and many kits using
discrete components were built to support them.
Unipolar motors may have 5 leads but generally have 6
or 8 wires. In all the motors we have seen, the wires for
the 6 & 8 types come out in two bundles of 3 or 4 wires
resp. Unipole steppers have two coils per stator pole. In
the 8 lead motors the 2 leads from the 2 coils from both
stators emerge from the motor. In the 6 lead motors the
two coils on each stator pole are joined (opposite sense)
together before they emerge from the motor. In the 5 lead
motors each of the two joined wires are themselves joined
before they leave the motor.
In the 6 wire version a multimeter (set it to 200ohm
resistance range) will show which is the centre lead within
each group of 3 leads. Typically the resistance between
the centre lead to the other two will be about 40 ohms
while the resistance between the outer two leads will be
twice that. Call the outer two leads in each of the two
bunches of wires A & B,
C & D. Solder them into
those positions on the
PCB. The centre lead in
each bunch is the power
lead & goes into the pad
marked +. Note that it
does not matter which
way around the A/B, C/D
leads go onto the pads.
5 wire version. Note that both + pads on the PCB are
connected together. In the 5 wire motor these centre leads
are connected internally.
So to power a 5 lead
stepper just connect the
common centre tap lead
from both phases to one of
the + pads. The A/B, C/D
leads are connected just as
in the 6 lead motors.
8 wire version. In each
bunch of 4 leads find the 2 pairs of wires connected to
each phase of the motor. Take one of each and join them
together. This is now the common lead to connect to the +
pad just as in the 6 lead case. The remaining leads are A
& B and C & D to the PCB..
Now there are 1, possibly
2, complications. First the
common connection must
join the coils in the
opposite sense. This refers
to the way in which they
are wound. This means
that the dot on one coil is
joined to the no-dot end
on the other coil in the
diagram. There is no way to tell the sense of the coils
unless you have the motor winding colour specification
which for surplus motors is generally missing. So you just
have to try it. Now if the wires are colour coded the same
in both bundles this is just a matter of two possibilities to
try. If the wires are not colour coded then there are four
possibilities. You will not damage the motor during this
testing if connections are wrong. The motor will either not
work or oscillate to and fro when the power is connected.
CIRCUIT DESCRIPTION
We have designed the kit so that the stepper motor can be
run continuously at a fast or low stepping rate then, when
it nears the desired position, it can be switched to
DIY KIT 109 STEPPER MOTOR DRIVER
PARTS LIST - K109
Resistors 1/4W, 5%:
180R brown grey brown ..... R1 ................................. 1
1K brown black red ............ R2 R3 ........................... 2
1M brown black green ........ R4 ................................. 1
1M potentiometer ............... POT .............................. 1
1000uF/35V electrolytic capacitor C3...................... 1
0.47uF 474 monoblok capacitor C1.......................... 1
0.1uF 104 monoblok capacitor C2 C4 C5 C6........... 4
UCN5804B ........................ IC2................................ 1
LM/NE555 nmos ................ IC1................................ 1
7805 voltage regulator ........ IC3................................ 1
2 pole terminal block .......... ...................................... 1
8 pin IC socket.................... ...................................... 1
16 pin IC socket.................. ...................................... 1
SPDT PCB-mounted switch ...................................... 5
6 pin header ........................ ...................................... 1
3mm red LED ..................... ...................................... 4
4 leg tact switch .................. ...................................... 1
K109 PCB .......................... ...................................... 1
single step mode and manually pulsed into final position.
Another switch controls the direction. A third switch can
turn the IC off and any power to the motor is removed.
Two other switches bring out halfstep and one phase
control modes supported by the IC.
A 555 IC is configured to deliver a continuous stream of
pulses to pin 11 of the 5804. The frequency is determined
by the values of the potentiometer and C1. Alternatively,
the single step switch allows individual pulses to be
delivered manually to the 5804 using a tact switch. A
switch debounce circuit is present using R4 & C5. LED’s
are included on the output of the 5804 to show which
phases of the motor are powered.
The Driver. The 5804 stepper driver is one of those
marvellous devices that replaces a handful of discrete
components. The driver will operate motors at up to 35V
and 1.25A. The step input is to pin 11 and direction goes
to pin 14. Pins 9 and 10 control one phase and half step
operation, respectively. Ref. 6 shows how to drive the IC
direct from a computer.
Motor Movement.
To make the motor step, power is applied to each coil in
turn. The 4 windings have to be energised in the right
sequence. Steppers have three different stepping methods:
wave, two phase & half-step. This is because there are
three basic patterns of energising the coils to make them
move. The last two are the most efficient. These patterns
are given in the data sheet on the 5804. No more than 2
coils are on at any one time.
In wave drive (or one phase operation) only one coil is
on at any time. In two phase drive two coils are always
on. In halfstep drive the number of coils energised cycles
between 1 & 2. We will not go into the details here since
they are given every year or so in the hobby electronics
magazines and in text books. Two of the best write-ups
starting from basics are references 2, 4 and 5 below. You
can see the pattern of coils being turned on/off by looking
at the LED’s as the motor steps.
As the motor is spinning, try varying the supply voltage.
This will make the motor run more roughly or smoothly.
Stepping motors are very sensitive to supply voltage
variations.
If you want the RUN stepping rate to be slower then
replace the 1M potentiometer by a 5M or even 10M pot.
What to do if it does not work
If there are more than 2 LED’s on then there is a short
circuit on the output of the 5804. Check that all the 4 links
are added to the board. Check the 555 IC is in the correct
way.
Ballast or Forcing Resistor
For two reasons a low value (typically 20 to 60 ohm), 5W
or 10W cement resistor is sometimes included in both the
+ lines between the 5804 and the stepper motor.
Lenz’s Law. Voltage driving gets into a time constant
problem (L/R) which limits speed & power. If R is
increased then the time constant is reduced. However, for
hobby applications it does not matter if the time constant
is 50msec or 10 msec.
Current Limiting. The resistor helps to limit current to
the motor. This is to help reduce overheating when it is
stopped (not stepping) but the power is still connected to
it to maintain its position.
External Diodes. These are mentioned in the data sheet
on the 5804 as possibly being necessary. However, for the
hobby stepper motors we are discussing here they are not
required.
Data Sheet. Download the data sheet for the UCN5804
from the Allegro website at:
www.allegromicro.com/control/pn1frame.htm
REFERENCES.
1. Control Stepper Motors with your PC, by Marque
Crozman. Silicon Chip, january, 1994, p80.
2. Stepper Motors and how they work, by Peter Phillips.
Electronics Australia, October & November, 1994.
3. A PC-Based Stepper-Motor Controller, by Larry
Antonuk. Popular Electronics, June 1992, p41.
4. Computer Controlled Stepper Motors, by Jim Spence.
ETI, august, 1994, p18.
5. Stepping Motor Driver/Interface, by Mark Stuart.
Everyday Electronics, january, 1992, p34.
6. Linear Motion Table, by John Iovine. Nut’s ‘n Volts,
august, 1995, p76.
------------------
DIY KIT 109 STEPPER MOTOR DRIVER
Attachment 2
StampWorks Project 26
Experiment #26: Stepper Motor Control
Experiment #26:
Stepper Motor Control
This experiment demonstrates the control of a small 12-volt unipolar stepper motor. Stepper motors
are used as precision positioning devices in robotics and industrial control applications.
New PBASIC elements/commands to know:
•
ABS
Building The Circuit
StampWorks Manual Version 1.1a • Page 125
Experiment #26: Stepper Motor Control
'
'
'
'
'
'
'
=========================================================================
File: STEPPER.BS2
Unipolar stepper motor control
{$STAMP BS2}
=========================================================================
PotCW
PotCCW
Coils
CON
CON
VAR
0
1
OutB
' clockwise pot input
' counter-clockwise pot input
' output to stepper coils
speed
x
sAddr
rcRt
rcLf
diff
VAR
VAR
VAR
VAR
VAR
VAR
Word
Byte
Byte
Word
Word
Word
'
'
'
'
'
'
delay between steps
loop counter
EE address of step data
rc reading - right
rc reading - left
difference between readings
' ------------------------------------------------------------------------'
__
'
ABAB
'
----Step1
DATA %1100
' A on
B on
A\ off B\ off
Step2
DATA %0110
' A off B on
A\ on
B\ off
Step3
DATA %0011
' A off B off A\ on
B\ on
Step4
DATA %1001
' A on
B off A\ off B\ on
' ------------------------------------------------------------------------Initialize:
DirB = %1111
speed = 5
' make stepper pins outputs
' set starting speed
' ------------------------------------------------------------------------Main:
FOR x = 1 TO 100
GOSUB StepFwd
NEXT
PAUSE 200
FOR x = 1 TO 100
GOSUB StepRev
Page 126 • StampWorks Manual Version 1.1a
' 1 rev forward
' 1 rev back
Experiment #26: Stepper Motor Control
NEXT
PAUSE 200
StepDemo:
HIGH PotCW
HIGH PotCCW
PAUSE 1
RCTIME PotCW,1,rcRt
RCTIME PotCCW,1,rcLf
' discharge caps
' read clockwise
' read counter-clockwise
rcRt = rcRt MAX 600
rcLf = rcLf MAX 600
' set speed limits
diff = ABS(rcRt - rcLf)
IF (diff < 25) THEN StepDemo
' get difference between readings
' allow deadband
IF (rcLf > rcRt) THEN StepCCW
StepCW:
speed = 60 - (rcRt / 10)
GOSUB StepFwd
GOTO StepDemo
' calculate speed
' do a step
StepCCW:
speed = 60 - (rcLf / 10)
GOSUB StepRev
GOTO StepDemo
' ------------------------------------------------------------------------StepFwd:
sAddr = sAddr + 1 // 4
READ (Step1 + sAddr),Coils
PAUSE speed
RETURN
StepRev:
sAddr = sAddr + 3 // 4
READ (Step1 + sAddr),Coils
PAUSE speed
RETURN
' point to next step
' output step data
' pause between steps
' point to previous step
StampWorks Manual Version 1.1a • Page 127
Experiment #26: Stepper Motor Control
Behind The Scenes
Stepper motors differ from standard DC motors in that they do not spin freely when power is applied.
For a stepper motor to rotate, the power source must be continuously pulsed in specific patterns.
The step sequence (pattern) determines the direction of the stepper’s rotation. The time between
sequence steps determines the rotational speed. Each step causes the stepper motor to rotate a fixed
angular increment. The stepper motor supplied with the StampWorks kit rotates 3.6 degrees per
step. This means that one full rotation (360 degrees) of the stepper requires 100 steps.
The step sequences for the motor are stored in DATA statements. The StepFwd subroutine will read
the next sequence from the table to be applied to the coils. The StepRev subroutine is identical
except that it will read the previous step. Note the trick with the modulus (//) operator used in
StepRev. By adding the maximum value of the sequence to the current value and then applying the
modulus operator, the sequence goes in reverse. Here’s the math:
0
3
2
1
+
+
+
+
3
3
3
3
//
//
//
//
4
4
4
4
=
=
=
=
3
2
1
0
This experiment reads both sides of the 10K potentiometer to determine its relative position. The
differential value between the two readings is kept positive by using the ABS function. The position is
used to determine the rotational direction and the strength of the position is used to determine the
rotational speed. Remember, the shorter the delay between steps, the faster the stepper will rotate.
A dead-band check is used to cause the motor to stop rotating when the RCTIME readings are nearly
equal.
Challenge
Rewrite the program to run the motor in 200 half steps. Here’s the step sequence:
Step1
Step2
Step3
Step4
Step5
Step6
Step7
Step8
=
=
=
=
=
=
=
=
%1000
%1100
%0100
%0110
%0010
%0011
%0001
%1001
Page 128 • StampWorks Manual Version 1.1a
Attachment 3
5804 Chip Schematic
5804
BiMOS II UNIPOLAR
STEPPER-MOTOR
TRANSLATOR/DRIVER
TYPICAL APPLICATION
L/R Stepper-Motor Drive
5V
28V
1
VDD
16
2
OE
15
14
3
4
DIRECTION
CONTROL
13
LOGIC
5
12
6
11
7
10
8
9
STEP INPUT
1
VDD
16
2
OE
15
14
3
OR
4
13
LOGIC
5
12
6
11
7
10
8
9
Dwg. EP-029A
Attachment 4
Basic Stamp I Stepper Controller
BASIC Stamp I Application Notes
6: A Serial Stepper Controller
Introduction. This application note demonstrates simple hardware
and software techniques for driving and controlling common four-coil
stepper motors.
Background. Stepper motors translate digital switching sequences
into motion. They are used in printers, automated machine tools, disk
drives, and a variety of other applications requiring precise motions
under computer control.
Unlike ordinary dc motors, which spin freely when power is applied,
steppers require that their power source be continuously pulsed in
specific patterns. These patterns, or step sequences, determine the
speed and direction of a stepper’s motion. For each pulse or step input,
the stepper motor rotates a fixed angular increment; typically 1.8 or 7.5
degrees.
The fixed stepping angle gives steppers their precision. As long as the
motor’s maximum limits of speed or torque are not exceeded, the
controlling program knows a stepper’s precise position at any given
time.
Steppers are driven by the interaction (attraction and repulsion) of
magnetic fields. The driving magnetic field “rotates” as strategically
placed coils are switched on and off. This pushes and pulls at permanent magnets arranged around the edge of a rotor that drives the output
TO PIN 11 1
(C) 1992 Parallax, Inc.
EEPROM
PIC16C56
PC
BASIC STAMP
+5V
Vin
0
1
2
3
4
5
6
7
BLK
16
IN 1
OUT 1
IN 2
OUT 2
IN 3
OUT 3
IN 4
OUT 4
IN 5
OUT 5
IN 6
OUT 6
IN 7
OUT 7
RED
BRN
ULN 2003
+5
+12
GRN
YEL
Stepper Motor
ORG
AIRPAX COLOR CODE:
RED & GREEN = COMMON
+5
TO PIN 10
1k
NC
1k
GND
1k
1k
TO PIN 1
22k
8
Serial Input
NC
9
GND
TEST
TO PIN 4
NC
Serial Output
Figure 1. Schematic for the serial stepper controller.
Parallax, Inc. • BASIC Stamp Programming Manual 1.9 • Page 99
1
BASIC Stamp I Application Notes
6: A Serial Stepper Controller
shaft. When the on-off pattern of the magnetic fields is in the proper
sequence, the stepper turns (when it’s not, the stepper sits and quivers).
The most common stepper is the four-coil unipolar variety. These are
called unipolar because they require only that their coils be driven on
and off. Bipolar steppers require that the polarity of power to the coils
be reversed.
The normal stepping sequence for four-coil unipolar steppers appears
in figure 2. There are other, special-purpose stepping sequences, such
as half-step and wave drive, and ways to drive steppers with multiphase analog waveforms, but this application concentrates on the
normal sequence. After all, it’s the sequence for which all of the
manufacturer’s specifications for torque, step angle, and speed apply.
Step Sequence
coil 1
coil 2
coil 3
coil 4
1
2
3
4
1
1
0
1
0
1
0
0
1
0
1
0
1
0
1
1
0
1
0
1
0
Figure 2. Normal stepping sequence.
If you run the stepping sequence in figure 2 forward, the stepper rotates
clockwise; run it backward, and the stepper rotates counterclockwise.
The motor’s speed depends on how fast the controller runs through the
step sequence. At any time the controller can stop in mid sequence. If it
leaves power to any pair of energized coils on, the motor is locked in
place by their magnetic fields. This points out another stepper motor
benefit: built-in brakes.
Many microprocessor stepper drivers use four output bits to generate
the stepping sequence. Each bit drives a power transistor that switches
on the appropriate stepper coil. The stepping sequence is stored in a
lookup table and read out to the bits as required.
This design takes a slightly different approach. First, it uses only two
output bits, exploiting the fact that the states of coils 1 and 4 are always
Page 100 • BASIC Stamp Programming Manual 1.9 • Parallax, Inc.
6: A Serial Stepper Controller
BASIC Stamp I Application Notes
the inverse of coils 2 and 3. Look at figure 2 again. Whenever coil 2 gets
a 1, coil 1 gets a 0, and the same holds for coils 3 and 4. In Stamp designs,
output bits are too precious to waste as simple inverters, so we give that
job to two sections of the ULN2003 inverter/driver.
The second difference between this and other stepper driver designs is
that it calculates the stepping sequence, rather than reading it out of a
table. While it’s very easy to create tables with the Stamp, the calculations required to create the two-bit sequence required are very simple.
And reversing the motor is easier, since it requires only a single
additional program step. See the listing.
How it works. The stepper controller accepts commands from a terminal or PC via a 2400-baud serial connection. When power is first applied
to the Stamp, it sends a prompt to be displayed on the terminal screen.
The user types a string representing the direction (+ for forward, – for
backward), number of steps, and step delay (in milliseconds), like this:
step>+500 20
As soon as the user presses enter, return, or any non-numerical character at the end of the line, the Stamp starts the motor running. When the
stepping sequence is over, the Stamp sends a new step> prompt to the
terminal. The sample command above would take about 10 seconds
(500 x 20 milliseconds). Commands entered before the prompt reappears are ignored.
YELLOW
BROWN
RED
GREEN
ORANGE
BLACK
Figure 3. Color code for Airpax steppers.
On the hardware side, the application accepts any stepper that draws
500 mA or less per coil. The schematic shows the color code for an
Airpax-brand stepper, but there is no standardization among different
Parallax, Inc. • BASIC Stamp Programming Manual 1.9 • Page 101
1
BASIC Stamp I Application Notes
6: A Serial Stepper Controller
brands. If you use another stepper, use figure 3 and an ohmmeter to
translate the color code. Connect the stepper and give it a try. If it
vibrates instead of turning, you have one or more coils connected
incorrectly. Patience and a little experimentation will prevail.
' Program STEP.BAS
' The Stamp accepts simply formatted commands and drives a four-coil stepper.
Commands
' are formatted as follows: +500 20<return> means rotate forward 500 steps with 20
' milliseconds between steps. To run the stepper backward, substitute - for +.
Symbol
Symbol
Symbol
Symbol
Symbol
Directn = b0
Steps = w1
i = w2
Delay = b6
Dir_cmd = b7
dirs = %01000011 : pins = %00000001 ' Initialize output.
b1 = %00000001 : Directn = "+"
goto Prompt
' Display prompt.
'
'
'
'
Accept a command string consisting of direction (+/-), a 16-bit number
of steps, and an 8-bit delay (milliseconds) between steps. If longer
step delays are required, just command 1 step at a time with long
delays between commands.
Cmd:
serin 7,N2400,Dir_cmd,#Steps,#Delay ' Get orders from terminal.
if Dir_cmd = Directn then Stepit
' Same direction? Begin.
b1 = b1^%00000011
' Else reverse (invert b1).
Stepit:
for i = 1 to Steps
' Number of steps.
pins = pins^b1
' XOR output with b1, then invert b1
b1 = b1^%00000011
' to calculate the stepping sequence.
pause Delay
' Wait commanded delay between
' steps.
next
Directn = Dir_cmd
' Direction = new direction.
Prompt: serout 6,N2400,(10,13,"step> ")
goto Cmd
' Show prompt, send return
' and linefeed to terminal.
Page 102 • BASIC Stamp Programming Manual 1.9 • Parallax, Inc.
Program listing: As with the other application notes, this program may be downloaded from our Internet ftp site at
ftp.parallaxinc.com. The ftp site may be
reached directly or through our web site
at http://www.parallaxinc.com.
Attachment 5
ULN2003 Specs
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
HIGH-VOLTAGE HIGH-CURRENT DARLINGTON TRANSISTOR ARRAYS
D
D
D
D
D
D
500-mA Rated Collector Current
(Single Output)
High-Voltage Outputs . . . 50 V
Output Clamp Diodes
Inputs Compatible With Various Types of
Logic
Relay Driver Applications
Designed to Be Interchangeable With
Sprague ULN2001A Series
D OR N PACKAGE
(TOP VIEW)
1B
2B
3B
4B
5B
6B
7B
E
description
1
16
2
15
3
14
4
13
5
12
6
11
7
10
8
9
1C
2C
3C
4C
5C
6C
7C
COM
The ULN2001A, ULN2002A, ULN2003A, ULN2004A, ULQ2003A, and ULQ2004A are monolithic high-voltage,
high-current Darlington transistor arrays. Each consists of seven npn Darlington pairs that feature high-voltage
outputs with common-cathode clamp diodes for switching inductive loads. The collector-current rating of a
single Darlington pair is 500 mA. The Darlington pairs may be paralleled for higher current capability.
Applications include relay drivers, hammer drivers, lamp drivers, display drivers (LED and gas discharge), line
drivers, and logic buffers. For 100-V (otherwise interchangeable) versions, see the SN75465 through SN75469.
The ULN2001A is a general-purpose array and can be used with TTL and CMOS technologies. The ULN2002A
is specifically designed for use with 14- to 25-V PMOS devices. Each input of this device has a zener diode and
resistor in series to control the input current to a safe limit. The ULN2003A and ULQ2003A have a 2.7-kΩ series
base resistor for each Darlington pair for operation directly with TTL or 5-V CMOS devices. The ULN2004A and
ULQ2004A have a 10.5-kΩ series base resistor to allow operation directly from CMOS devices that use supply
voltages of 6 to 15 V. The required input current of the ULN/ULQ2004A is below that of the ULN/ULQ2003A,
and the required voltage is less than that required by the ULN2002A.
logic symbol†
logic diagram
9
CLAMP
1B
2B
3B
4B
5B
6B
7B
1
16
2
15
3
14
4
13
5
12
6
11
7
10
9
COM
1B
1C
2C
2B
3C
4C
3B
5C
6C
4B
7C
† This symbol is in accordance with ANSI/IEEE Std 91-1984
and IEC Publication 617-12.
5B
6B
7B
1
16
2
15
3
14
4
13
5
12
6
11
7
10
COM
1C
2C
3C
4C
5C
6C
7C
Copyright  2001, Texas Instruments Incorporated
PRODUCTION DATA information is current as of publication date.
Products conform to specifications per the terms of Texas Instruments
standard warranty. Production processing does not necessarily include
testing of all parameters.
POST OFFICE BOX 655303
• DALLAS, TEXAS 75265
1
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
schematics (each Darlington pair)
COM
COM
7V
Output C
Output C
Input B
Input B
10.5 kΩ
7.2 kΩ
E
7.2 kΩ
3 kΩ
3 kΩ
E
ULN2002A
ULN2001A
COM
RB
Output C
Input B
ULN/ULQ2003A: RB = 2.7 kΩ
ULN/ULQ2004A: RB = 10.5 kΩ
7.2 kΩ
3 kΩ
E
ULN2003A, ULN2004A, ULQ2003A, ULQ2004A
All resistor values shown are nominal.
absolute maximum ratings at 25°C free-air temperature (unless otherwise noted)
Collector-emitter voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 V
Clamp diode reverse voltage (see Note 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 V
Input voltage, VI (see Note 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 V
Peak collector current (see Figures 14 and 15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 mA
Output clamp current, IOK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 mA
Total emitter-terminal current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . – 2.5 A
Continuous total power dissipation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . See Dissipation Rating Table
Operating free-air temperature range, TA, ULN200xA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . – 20°C to 85°C
ULQ2003A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . – 40°C to 85°C
ULQ2004A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . – 40°C to 70°C
Operating junction temperature range, TJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . – 40°C to 105°C
Storage temperature range, Tstg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . – 65°C to 150°C
Lead temperature 1,6 mm (1/16 inch) from case for 10 seconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260°C
NOTE 1: All voltage values are with respect to the emitter/substrate terminal E, unless otherwise noted.
DISSIPATION RATING TABLE
TA = 25°C
POWER RATING
DERATING FACTOR
ABOVE TA = 25°C
TA = 85°C
POWER RATING
D
950 mW
7.6 mW/°C
494 mW
N
1150 mW
9.2 mW/°C
598 mW
PACKAGE
2
POST OFFICE BOX 655303
• DALLAS, TEXAS 75265
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
electrical characteristics, TA = 25°C (unless otherwise noted)
PARAMETER
VI(on)
VCE(sat)
( )
On-state input voltage
Collector-emitter
C
ll t
itt
saturation voltage
VF
Clamp forward voltage
ICEX
Collector cutoff current
TEST
FIGURE
6
5
8
TEST CONDITIONS
II
Input current
4
IR
Clamp reverse current
7
hFE
Static forward current
transfer ratio
5
Ci
Input capacitance
TYP
MAX
0.9
1.1
1.1
II = 350 µA,
II = 500 µA,
IC = 200 mA
IC = 350 mA
1
1.3
1
1.3
1.2
1.6
1.2
1.6
1.7
2
1.7
2
VCE = 50 V,,
TA = 70°C
3
MIN
0.9
2
Off state input current
Off-state
MAX
IC = 300 mA
IC = 100 mA
VCE = 50 V,,
TA = 70°C
II(off)
I( ff)
ULN2002A
TYP
VCE = 2 V,
II = 250 µA,
IF = 350 mA
VCE = 50 V,
1
ULN2001A
MIN
VI = 17 V
VR = 50 V,
13
II = 0
II = 0
VI = 6 V
IC = 500 µ
µA,
50
50
100
100
50
65
50
VR = 50 V
VI = 0,
f = 1 MHz
V
V
µA
µA
65
0.82
IC = 350 mA
V
500
TA = 70°C
VCE = 2 V,
UNIT
1.25
100
100
50
50
mA
µA
1000
15
25
15
25
pF
electrical characteristics, TA = 25°C (unless otherwise noted)
PARAMETER
TEST
FIGURE
TEST CONDITIONS
ULN2003A
MIN
TYP
IC = 125 mA
IC = 200 mA
VI(
I(on))
VCE(sat)
( )
ICEX
On state input voltage
On-state
Collector-emitter
C
ll t
itt
saturation voltage
Collector cutoff current
6
VCE = 2 V
MAX
IC = 250 mA
IC = 275 mA
2.7
IC = 300 mA
IC = 350 mA
3
6
7
1.1
5
1
1.3
1
1.3
II = 500 µA,
VCE = 50 V,
IC = 350 mA
II = 0
1.2
1.6
1.2
1.6
1
2
VCE = 50 V,,
TA = 70°C
II = 0
VI = 1 V
Off state input current
Off-state
3
VCE = 50 V,,
TA = 70°C
II
Input current
4
7
50
VI = 3.85 V
VI = 5 V
0.93
TA = 70°C
f = 1 MHz
POST OFFICE BOX 655303
50
100
100
• DALLAS, TEXAS 75265
2
65
VI = 12 V
VR = 50 V
VR = 50 V,
VI = 0,
50
V
µA
500
1.7
IC = 500 µ
µA,,
V
8
0.9
II(off)
I( ff)
UNIT
5
2.4
1.1
IF = 350 mA
Input capacitance
TYP
0.9
8
Ci
MIN
IC = 100 mA
IC = 200 mA
Clamp forward voltage
Clamp reverse current
MAX
II = 250 µA,
II = 350 µA,
VF
IR
ULN2004A
15
1.7
50
2
V
µA
65
1.35
0.35
0.5
1
1.45
50
50
100
100
25
15
25
mA
µA
pF
3
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
electrical characteristics, TJ = –40°C to 105°C (unless otherwise noted)
TEST
FIGURE
PARAMETER
TEST CONDITIONS
ULQ2003A
MIN
TYP
ULQ2004A
MAX
IC = 125 mA
IC = 200 mA
VI(
I(on))
On state input voltage
On-state
VCE(sat)
( )
Collector-emitter
C
ll t
itt
saturation voltage
6
VCE = 2 V
2.9
IC = 300 mA
IC = 350 mA
3
6
7
1.1
5
1
1.4
1
1.3
II = 500 µA,
VCE = 50 V,
IC = 350 mA
II = 0
1.2
1.7
1.2
1.6
1
2
VCE = 50 V,,
TA = 70°C
II = 0
VI = 1 V
IF = 350 mA
II(off)
I( ff)
Off state input current
Off-state
3
VCE = 50 V,,
TA = 70°C
II
Input current
4
100
µA
500
1.7
IC = 500 µ
µA,,
30
0.93
TA = 70°C
f = 1 MHz
2.2
65
VI = 12 V
VR = 50 V
VR = 50 V,
VI = 0,
V
50
100
VI = 3.85 V
VI = 5 V
7
V
8
0.9
8
Input capacitance
IC = 250 mA
IC = 275 mA
1.2
Clamp forward voltage
UNIT
5
2.7
0.9
VF
Ci
MAX
IC = 100 mA
IC = 200 mA
Collector cutoff current
Clamp reverse current
TYP
II = 250 µA,
II = 350 µA,
ICEX
IR
MIN
15
1.7
50
2
V
µA
65
1.35
0.35
0.5
1
1.45
100
50
100
100
25
15
25
mA
µA
pF
switching characteristics, TA = 25°C
PARAMETER
TEST CONDITIONS
ULN2001A, ULN2002A,
ULN2003A, ULN2004A
MIN
tPLH
tPHL
Propagation delay time, low-to-high-level output
VOH
High-level output voltage after switching
Propagation delay time, high-to-low-level output
See Figure 9
VS = 50 V,
See Figure 10
IO ≈ 300 mA,
UNIT
TYP
MAX
0.25
1
µs
0.25
1
µs
VS – 20
mV
switching characteristics, TJ = –40°C to 105°C
PARAMETER
tPLH
tPHL
VOH
4
TEST CONDITIONS
Propagation delay time, low-to-high-level output
Propagation delay time, high-to-low-level output
High-level output voltage after switching
POST OFFICE BOX 655303
ULQ2003A, ULQ2004A
MIN
See Figure 9
VS = 50 V,
See Figure 10
IO ≈ 300 mA,
• DALLAS, TEXAS 75265
VS – 500
UNIT
TYP
MAX
1
10
µs
1
10
µs
mV
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
PARAMETER MEASUREMENT INFORMATION
Open
Open
VCE
ICEX
VCE
ICEX
Open
VI
Figure 1. ICEX Test Circuit
Open
Figure 2. ICEX Test Circuit
VCE
Open
II(off)
IC
II(on)
Open
VI
Figure 3. II(off) Test Circuit
Figure 4. II Test Circuit
Open
Open
IC
hFE =
II
VCE
II
IC
VI(on)
VCE
IC
NOTE: II is fixed for measuring VCE(sat), variable for
measuring hFE.
Figure 5. hFE, VCE(sat) Test Circuit
Figure 6. VI(on) Test Circuit
VR
IR
VF
Open
IF
Open
Figure 7. IR Test Circuit
POST OFFICE BOX 655303
Figure 8. VF Test Circuit
• DALLAS, TEXAS 75265
5
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
PARAMETER MEASUREMENT INFORMATION
50%
Input
50%
t PHL
t PLH
50%
Output
50%
VOLTAGE WAVEFORMS
Figure 9. Propagation Delay Time Waveforms
VS
Input
Open
Pulse
Generator
(see Note A)
2 mH
1N3064
ULN2001A only
2.7 kΩ
200 Ω
Output
ULN2002A
ULN/ULQ2003A
ULN/ULQ2004A
CL = 15 pF
(see Note B)
TEST CIRCUIT
≤ 5 ns
≤ 10 ns
90%
1.5 V
Input
10%
VIH
(see Note C)
90%
1.5 V
10%
40 µs
0V
VOH
Output
VOL
VOLTAGE WAVEFORMS
NOTES: A. The pulse generator has the following characteristics: PRR = 12.5 kHz, ZO = 50 Ω.
B. CL includes probe and jig capacitance.
C. For testing the ULN2001A, the ULN2003A, and the ULQ2003A, VIH = 3 V; for the ULN2002A, VIH = 13 V;
for the ULN2004A and the ULQ2004A, VIH = 8 V.
Figure 10. Latch-Up Test Circuit and Voltage Waveforms
6
POST OFFICE BOX 655303
• DALLAS, TEXAS 75265
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
TYPICAL CHARACTERISTICS
COLLECTOR-EMITTER
SATURATION VOLTAGE
vs
TOTAL COLLECTOR CURRENT
(TWO DARLINGTONS PARALLELED)
COLLECTOR-EMITTER
SATURATION VOLTAGE
vs
COLLECTOR CURRENT
(ONE DARLINGTON)
VCE(sat)
VCE(sat) – Collector-Emitter Saturation Voltage – V
TA = 25°C
2
II = 250 µA
II = 350 µA
II = 500 µA
1.5
1
0.5
0
0
100
200
300
400
500
600
700
800
2.5
TA = 25°C
II = 250 µA
2
II = 350 µA
1.5
II = 500 µA
1
0.5
0
0
100
200
300
400
500
600
700
800
IC(tot) – Total Collector Current – mA
IC – Collector Current – mA
Figure 11
Figure 12
COLLECTOR CURRENT
vs
INPUT CURRENT
500
RL = 10 Ω
TA = 25°C
450
IIC
C – Collector Current – mA
VCE(sat)
VCE(sat) – Collector-Emitter Saturation Voltage – V
2.5
400
VS = 10 V
350
VS = 8 V
300
250
200
150
100
50
0
0
25
50
75
100
125
150
175
200
II – Input Current – µA
Figure 13
POST OFFICE BOX 655303
• DALLAS, TEXAS 75265
7
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
THERMAL INFORMATION
N PACKAGE
MAXIMUM COLLECTOR CURRENT
vs
DUTY CYCLE
D PACKAGE
MAXIMUM COLLECTOR CURRENT
vs
DUTY CYCLE
600
IIC
C – Maximum Collector Current – mA
IIC
C – Maximum Collector Current – mA
600
500
N=1
N=4
400
N=3
300
N=2
N=6
N=7
N=5
200
100
TA = 70°C
N = Number of Outputs
Conducting Simultaneously
500
400
N=4
300
N=5
N=6
N=7
200
100
TA = 85°C
N = Number of Outputs
Conducting Simultaneously
0
0
0
10
20
30
40
50
60
70
80
90 100
0
10
20
30
40
50
60
70
Duty Cycle – %
Duty Cycle – %
Figure 14
8
N=1
N=3
N=2
Figure 15
POST OFFICE BOX 655303
• DALLAS, TEXAS 75265
80
90 100
ULN2001A, ULN2002A, ULN2003A, ULN2004A,
ULQ2003A, ULQ2004A
DARLINGTON TRANSISTOR ARRAY
SLRS027A – DECEMBER 1976 – REVISED MAY 2001
APPLICATION INFORMATION
ULN2002A
VSS
P-MOS
Output
V
ULN2003A
ULQ2003A
VCC
V
1
16
1
16
2
15
2
15
3
14
3
14
4
13
4
13
5
12
5
12
6
11
6
11
7
10
7
10
8
9
8
9
Lamp
Test
TTL
Output
Figure 16. P-MOS to Load
ULN2004A
ULQ2004A
VDD
Figure 17. TTL to Load
ULN2003A
ULQ2003A
VCC
V
V
1
16
1
16
2
15
2
15
3
14
RP 3
14
4
13
4
13
5
12
5
12
6
11
6
11
7
10
7
10
8
9
8
9
CMOS
Output
TTL
Output
Figure 18. Buffer for Higher Current Loads
POST OFFICE BOX 655303
Figure 19. Use of Pullup Resistors to
Increase Drive Current
• DALLAS, TEXAS 75265
9
IMPORTANT NOTICE
Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue
any product or service without notice, and advise customers to obtain the latest version of relevant information
to verify, before placing orders, that information being relied on is current and complete. All products are sold
subject to the terms and conditions of sale supplied at the time of order acknowledgment, including those
pertaining to warranty, patent infringement, and limitation of liability.
TI warrants performance of its products to the specifications applicable at the time of sale in accordance with
TI’s standard warranty. Testing and other quality control techniques are utilized to the extent TI deems necessary
to support this warranty. Specific testing of all parameters of each device is not necessarily performed, except
those mandated by government requirements.
Customers are responsible for their applications using TI components.
In order to minimize risks associated with the customer’s applications, adequate design and operating
safeguards must be provided by the customer to minimize inherent or procedural hazards.
TI assumes no liability for applications assistance or customer product design. TI does not warrant or represent
that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other
intellectual property right of TI covering or relating to any combination, machine, or process in which such
products or services might be or are used. TI’s publication of information regarding any third party’s products
or services does not constitute TI’s approval, license, warranty or endorsement thereof.
Reproduction of information in TI data books or data sheets is permissible only if reproduction is without
alteration and is accompanied by all associated warranties, conditions, limitations and notices. Representation
or reproduction of this information with alteration voids all warranties provided for an associated TI product or
service, is an unfair and deceptive business practice, and TI is not responsible nor liable for any such use.
Resale of TI’s products or services with statements different from or beyond the parameters stated by TI for
that product or service voids all express and any implied warranties for the associated TI product or service,
is an unfair and deceptive business practice, and TI is not responsible nor liable for any such use.
Also see: Standard Terms and Conditions of Sale for Semiconductor Products. www.ti.com/sc/docs/stdterms.htm
Mailing Address:
Texas Instruments
Post Office Box 655303
Dallas, Texas 75265
Copyright  2001, Texas Instruments Incorporated