- Published: Saturday, 04 April 2009
- Written by Digital DIY
- Hits: 21005
Why use another chip to control outputs? Well the answer to that is that the PIC can only supply up to 25mA. This is fine for logic levels, and even small devices like LED's, but you can't drive a , motor, piezo siren etc with a PIC..
The ULN2003 is a very cost effective chip that acts like a . It simply switches an earth to/from an external circuit, and can withstand a continual 500mA current drain and a maximum 50V. All this for $0.47 AUD.
Internally the ULN2003looks like this;
The +Ve voltage must be connected to Pin 9 to protect Back EMF, and the common ground is connected to Pin 8. This is the ground supplied to the external circuits when switched on. As you can see there are 7 channels per chip, to control a , hook up a circuit like this, and be sure to connect Pin 8 of the ULN2003 to ground);
You don't need the ULN2003 to control a /load that the PIC can't drive on its own. You can use a transistor like the following example (note that there are now 3 external components instead of 1);
Now whenever the output of the PIC goes high, an earth is instantly supplied to the , the coil will energize. Note the diode, this is to negate back EMF (Built-in on the ULN2003), and is vital in inductive circuits like these.
The benefit of the diode is that it provides a low voltage-drop path for the current induced by the collapsing magnetic field to follow, thereby preventing the build-up of a destructively high voltage on the coil winding and/or the switch contacts. With the absence of the diode, the voltage will rapidly build up on the coil until something brakes down, allowing the energy to dissipate. That breakdown could be by damaging arcing across the switch contacts or by punching through the insulation on the coil wires, leading to eventual failure.