The Classroom

The ULN2003 Darlington Array

Daniel Koch

Issue 37, August 2020

This article includes additional downloadable resources.
Please log in to access.

Log in

This specialised IC provides a neat and effective interface between a stepper motor and an Arduino or Raspberry Pi.

The ULN2003 has been around longer than Arduino or Raspberry Pi, and even predates the now almost unheard of Picaxe. The reason for this is that it has uses far beyond driving stepper motors with microcontrollers. The integrated circuit (IC) is an array of seven Darlington transistors, with flyback diodes common-cathode connected inside, specifically for driving inductive loads. It does have the ability to control seven separate single-channel loads, or for outputs to be paralleled to increase current capacity.

WHAT IS A DARLINGTON?

A Darlington pair is the name for two transistors connected as a current amplifier in such a way that the Darlington gain is the product of the individual gain of each transistor of the pair. i.e. Gain Total = gain Q1 x gain Q2. It is quite possible to construct your own Darlington pairs, or even arrays, but there is a challenge when more than one Darlington pair is used. The gains of the individual devices are always stated as within a range, often quite broad.

The effect is compounded when the second device is considered. This means that, in building your own arrays, one channel may end up with a significantly higher gain even if constructed from the same devices. One channel may have devices at the lower end of their gain range, while another channel may have devices at the higher end of their gain range. It’s unlikely that you will have this case, but there will still be appreciable and problematic differences between your channels.

Commercially produced Darlingtons are manufactured in such a way that their gains are within the published range for the device, a much lower range than would be if two discrete devices were used. The ULN2003A takes that a step further by having all the transistors made from the same wafer of semiconductor material. While nowhere in the datasheets are the devices referred to as ‘matched’, this practice ensures far less difference between channels.

It is worth noting that if you are using individual commercial Darlington transistors for a project, they are available in both NPN and PNP configurations and a variety of input arrangements to suit TTL, CMOS, and other input voltages. The ULN2003A is specifically designed for 5V TTL logic input, driving up to 50VDC loads. The ULN200x family includes options for being driven by other sources.

PHYSICAL LAYOUT

The ULN2003A is a 16-pin device designed so that its connections are intuitive, and logical for PCB design. When viewed with pin 1 at the top left, the input for channel 1 is on the left, directly opposite the output pin for channel one, and so on down the chip. There is no single power supply pin as power is supplied to each output via the individual loads. Pin 8 is the Ground Pin connected to all 7 Darlington Emittors. Should all 7 Darlingtons take their maximum 500mA, this ground pin would take 3.5A, requiring good PCB design to manage. Thermal restrictions of the IC would not allow this current to continue for very long. Pin 9 is the common of the flyback diodes which should be connected to the positive of the load power supply.

Internally, the input connects to a 2.7kΩ resistor, as shown in the following diagram. The input pin is connected to the base of the first transistor via a 2.7kΩ resistor. The bias stabilisation is controlled by the resistors, 2k7, 7k2 and 3k. Electrostatic protection diodes are also added between inputs and ground, and outputs and ground. All of this means there is far less assembling and connecting to be done by the maker. As all of this is done on one wafer of material, a consistent and repeatable result is achieved.

ELECTRICAL CHARACTERISTICS

The ULN2003 is designed for use with 5V TTL, but can handle input voltages of up to 30V. The Darlington gates should all be driven by the same supply voltage of up to 50VDC. The gates should not be driven from different supplies due to the common flyback diodes which should be connected to the common supply.

The gates are configured as something known as "Open Collector" meaning the gate outputs are the collectors of the output transistors.

Each collector can switch up to 500mA but should not exceed 300mA for continuous current. As the 500mA causes 1.2V drop across the output to ground, there will be 600mW of heat generated inside the device.

The device can only sink 2.5A total so only 5 outputs could be used at that current, and the device would be sinking 3W, so temperature failure would soon follow.

Although rated for 5V TTL input, the gates work perfectly well on 3.3V TTL due to both using the same switching voltages.

USING THE DEVICE

Put simply, you can use the ULN2003A to drive an inductive load, within its maximum voltage and current parameters, from TTL logic. This means that there is no external circuitry required to use the ULN2003A. When it is purchased as a stepper motor driver module, there are usually some extra components. These are ‘nice to have’, not ‘need to have’ components.

Our hands-on circuit this month uses four LEDs with ballast resistors used to illustrate the state of the outputs of the ULN2003A. The module we use in this build has four LEDs and dropping resistors for each. These just provide a visual indicator of what is going on with the outputs, and do not affect the circuit. Likewise, it has a header for power supply. This is for the motor connected, not the ULN2003A, and the same applies to the small capacitor across the supply line.

If you are working from scratch, you may be driving signal channels such as relays. In this case, the power is supplied to the relay coil, and its ground side is connected to the output pin of the desired channel. When that channel is active, the relay is grounded and so turns on. The same would apply to solenoids and simple DC motors.

When working with stepper motors, things get a bit interesting. Different motors are wired in different ways, and work in different ways. The most common stepper motors used by makers have five wires: a common power supply wire for all coils, and four grounds, one for each coil. There are other configurations and other ways to use the ULN2003A to drive them, but we’ll stay with the most commonly-available motor configuration.

In this arrangement, power is always applied to the coil, and the switch to activate it grounds the relevant coil. In our case, the switch is the ULN2003A’s outputs, which of course are the collectors of the Darlington arrays because the emitters are connected to ground. Standard NPN switching there.

From here, because the ULN2003A has everything in it that is needed, all that remains is to connect four outputs from the microcontroller to the inputs of the ULN2003A, and the rest is done in code.

In terms of code, what you write depends on what you want the motor to do. Driving stepper motors is an article on its own, quite an extensive one. We’ll leave that for another day, but information abounds if you want to read about it sooner. In short, however, one pole of the motor needs to be activated at a time, and then another is used to make the motor ‘step’ again. Different configurations of coils on and off at different times can rotate the motor, and brake it.

Hands on:

Parts Required:JaycarAltronicsCore Electronics
Solderless BreadboardPB8820P1002CE05102
Wire LinksPB8850P1014ACE05631
Plug to Plug Jumper LeadsWC6024P1022PRT-12795
4 x 150Ω Resistors*RR0552R7538CE05092
1 x 10kΩ Resistor*RR0596R7582CE05092
4 x LEDsZD0152Z0980COM-09856
1 x 5-pin Length of Header StripHM3211P5430PRT-12693
1 x Pushbutton SwitchSP0710S1060BCOM-11997
1 x ULN2003AZK8855#Z3000#CE07193
1 x Arduino Uno or Compatible BoardXC4410Z6240CE05629
1 x Stepper MotorXC4458#Z6330#ADA858

Parts Required:

Materials Required:
Shoe Box or Gift Box
Paper, Drawing Compass and Markers OR
Printed Template and Markers
Stick Glue
Hot Melt Glue

Materials Required:

* Quantity shown, may be sold in packs. You’ll also need a breadboard and prototyping hardware.

† The mounting hole for this switch may be smaller than the specified 20mm.

Our build is fairly simple because the ULN2003A takes care of most of it for us. We are driving our ULN2003A with an Arduino Uno. Be careful that the power supply chosen has enough current to run the motor. Rather than rely on the USB connection for power, we chose to use a breadboard power supply to run both the motor and the Uno. We have added four status indicator LEDs to our project. These tell us what the outputs of the Darlingtons are doing, so that if something is not working, we have a visual aid in finding what is wrong.

All of this won’t matter, however, because we are housing it in a shoebox so that the stepper motor can mount a spinner. This will form a 1-10 ‘dice’, but of course it is not a dice at all. With one push of a trigger button, the spinner will display a number from 1 to 10, based on a random timer. We have structured the code to spin the motor quite slowly, as sudden starts and stops will make connecting the spinner to the motor shaft very challenging.

There is so little in the build, we don’t even need steps for the circuit. Just follow the schematic, Fritzing, and photos to make the few connections needed.

Take an old shoebox, or a gift box of the right size, and make a mark in the centre by drawing lines between the diagonals. Use a drawing compass to make a circle that nearly fills the smaller axis of the box. Lastly, use a protractor to mark 36° increments to divide the circle into ten equal segments.

Now you can use a pencil to make a hole in the centre of the box. On the base of the box, draw the shape of a spinner and cut it out. Find the centre and make a slot to fit over the motor shaft. Use hot-melt glue to mount the motor to the underside of the box, and the spinner to the motor shaft. Number the segments of the circle from 1 to 10, and make a hole at the side away from the path of the spinner to mount the pushbutton. This should also mount with hot melt glue.

Alternatively, you can download and print our template and glue these to the box. Cut off the spinner section and glue this to the base of the box so that you don’t end up with a hole on the top.

You may also like to make a hole in the side of the box for a power cord to pass through, or you can drape the cord over the side and just close the lid on it. You may also like to battery power your creation.

WHY A MODULE?

We were originally going to use the module that came with our stepper motor. It has headers for both the motor and inputs from the controller, as well as LEDs already mounted, and pins for input power. This makes life easier but also guarantees that the wiring of the supplied motor is accommodated. Our stepper appeared to be a standard 28BYJ-48 but had no label. It turned out to be, but other motors may have a different wire order or colour scheme. If you are buying a motor on its own, make sure you can get hold of its datasheet. In the end, we chose not to use the module so that we could show you how to wire from scratch.

THE CODE

We have the code for this project on our website. Rather than describe it here, we have instead used comments within the code. This makes for a lot of grey text in the code, but it means that we can update the code as often as we find bugs, issues, or improvements, without rendering this article outdated.

WHERE TO FROM HERE?

Where you go from here is really open to what applications you can find for a stepper motor. Of course, you could use the ULN2003A as a relay or solenoid driver. If you are modifying the spinner, we would love to see someone make the spinner speed up and then slow down as it reaches its target. LEDs that flash in time with the movement of the spinner would be fun as well.

The ULN2003A is a versatile device despite being quite specialised. While we have concentrated on stepper motors here, as have highlighted some of the other uses as well. We think you’ll get plenty of use out of this IC whenever you have the need to drive inductive loads below 500mA, which is perfectly adequate for many maker projects.