PIC Output For 12VDC Circuits PDF
PIC Output For 12VDC Circuits PDF
25mA
The current taken by a device is called the LOAD CURRENT. Twenty-fivemilli-amps is not very
much in electrical terms but in electronic terms,it is amazing what can be driven. 25mA is 0.025Amp
and this is not sufficient to drive a motor or globebut there are a number of devices that can be
driven:
1. LEDs (Light Emitting Diodes) require up to about 25mA for fullillumination.
2. Piezo diaphragms require very little current and can be drivendirectly from an output line.
3. Low-current relays can be driven directly provided they operateon 25mA @ 5v. If more than
25mA is required, a driver transistor (also called a buffer transistor or buffer stage) will be needed.
The specification for a PIC microcontroller output line is 25mA @ 5v. In other wordsthe output line
has an output voltage of 5v and the maximum currentthat can be delivered by it is 25mA. The
output line will, in theory, deliver more than 25mA but the transistorin the chip may be damaged
(overheated) ifa higher current flows.The current delivered by the output line is determined by the
resistanceof the device (or devices), connected to the line. The simplest device is a resistor as
shown in fig: 1.
If the value of the resistor is too low, more than 25mA willflow. If the resistance is high, less than
25mA will flow. The currentflow is not determined by the chip but by the value of the resistor.The
resistor is called the LOAD RESISTOR or simply the LOAD.
THE VALUE OF THELOAD RESISTOR
The resistance of the load resistor is worked out using Ohm's Law. We know the voltage on the line
is 5v. This is V in the formula. Themax current available is 0.025A = I in the formula. Ohms Law
states: I = V/R (Current equals volts divided by resistance). This equation can be re-arranged as:
R = V/I
Putting the two values into the equation produces:
R = 5/.025
= 200
= 200ohms.
A 200 ohm resistor connected to an output line will allow 25mA toflow when the output is
HIGH.This is only a theoretical explanation as a resistor on an outputline will not perform any
function! It won't do anything by itselfexcept get slightly warm. But a resistor will perform more than
20different functions, depending on where it is placed in a circuitand the value of the components
around it.In our first example below, a resistor is added in series with a LEDso that the LED will
take a maximum of 25mA.The purpose of the resistor is two-fold. Firstly it allows the LEDto create
a characteristic voltage across it of 1.7v (for a red LED)and secondly it has a value so that 25mA
flows through the LED. The resistor will have 5v on one end and 1.7v on the other. Thesevoltages
are provided by the chip and the LED and the resistor hasnothing to do with creating them. The
resistor simply allows a certainamount of current to flow, depending on its value, and that'sthe
value is worked out above.
A point to note: The '508A has 5 output lines and if all the outputsare delivering 25mA, the total
output for the chip will be 125mA.This is slightly above the allowable maximum current of 100mA
forthe chip but will not be a problem.
The PIC16F84 has a maximum of 150mA for the chip and thus only 6 lines can be delivering current
at any one time.
Let's go to a practical situation:
CONNECTING A LED
If a LED is connected to one of the outputs as shown in fig: 2,
avoltage is dropped across it according to the colour of the LED. Thisis called the
CHARACTERISTIC voltage or the characteristic voltagedrop of the LED. This voltage is content, no
matter how bright theLED is illuminated. This is completely different to the characteristicsof a globe
and that's why LEDs and globes must be treated differentlywhen working out their operating
requirements.
For a red LED the "characteristic voltage" is 1.7v.For an orange LED the "characteristic voltage" is
1.9v.For a green LED the "characteristic voltage" is 2.1v.LEDs cannot be connected directly to the
output of a drive-line withouta voltage-dropping resistor. The reason is very technical but basicallya
red LED, for example, does not turn on at all until exactly 1.7v is placed across it and if the voltage
tries to rise above 1.7v, theLED will glow brighter, allow a very high current to flow and willbe
damaged when the current flow is greater than 40mA.
It is virtually impossible to provide a constant 1.7v and the simplestway to prevent damaging the
LED is to connect a resistor in series.If the value of the resistor is worked out via a formula, an
accurate current can be delivered to the LEDand everything will be ok. The LED will last 100 years
or more!
Suppose we want to deliver 25mA to a LED.
If we take a red LED, the value of resistance can be worked out byOhms law. The voltage across
the resistor is determined by:
5v - 1.7v = 3.3v (The voltage across the LED is the 5v supply voltageminus the 1.7v dropped
across the LED due to the characteristic voltagedrop mentioned above). This is the value for V.
I = V/R
0.025 = 3.3/R
R = 132 Use 130 ohm resistor.
An orange LED has a higher characteristic voltage of 1.9v and thusa lower value dropper-resistor
will be required for 25mA. Use 120R.
For a green LED, use 100R.High-bright LEDs are available in all colours and although they
arerated at 25mA, they will produce very good brightness at 5mA to 15mA.
For battery operated projects, LED current can be reduced to as lowas 1mA, and this will increase
the life of the battery enormously.
Table 1 gives the value for the dropper resistor for a red LED atdifferent currents.
The easiest way to determine the value of resistance for a dropper resistor is to put a LED in series
with a 1k resistor on a 5v supply. Gradually reduce the resistance until a satisfactory brightness is
obtained.
The illumination of a LED is given in milli-candella (mcd) and as manufacturing has improved over
the past few years, the output brightness has risen considerably. Thats why its best to experiment
with different value resistors and come up with a value for your particular LED(s).
130 ohms
15mA
220 ohms
10mA
330 ohms
5mA
680 ohms
1mA
3k3
flow into the transistor. In this way you are guaranteeing the transistor will be saturated, just in case
the gain is not 100. It's nice to add a margin of guarantee and thus a resistor as low as 470R can be
used.
A resistor as low as 470 ohm will not damage the transistor and will not make the globe glow "too
bright." It's simply a value to make sure the transistor turns on fully under the worst conditions. If the
transistor does not turn on fully, it will get hotter than normal and the globe will be dull. This can
overheat the transistor and cause damage - that's why it's important to FULLY turn it on.
A high start-up current is one of the hidden problems with driving globes and is generally not
encountered until a high current globe is employed or a number of globes are driven at the same
time. As you can see, current is required from the output of the microcontroller to drive the transistor
and if high current loads are driven, very soon the 25mA from the micro will be used up!
Suppose you require to drive a 12v 1amp car lamp. A high-power driver transistor will be required as
the start-up current will be about 6 amps.
High-current transistors have a current-gain of only about 20 to 50 and if you use the worst-case
scenario, the current required by the base to fully saturate (turn-on) the transistor will be 5,000/20
=250mA.
Obviously this is above the output capability of the microcontroller. So you have to carry out some
calculations before connecting high-current devices.
The answer is to add an extra amplifying transistor between the chip and the power transistor as
shown in fig: 3. This transistor is called a buffer transistor and effectively amplifies the capability of
the chip by a factor of about 100. If the output transistor (the power transistor) requires a current of
250mA into its base, the buffer transistor will deliver this current and require 250/100 = 2.5mA from
the microprocessor. The 2.5mA can easily be supplied by the micro and we are back in business.
The driver and output transistor can come in two different arrangements. Fig: 3 shows two individual
transistors or a single Darlington transistor as shown in fig: 4.
The end-result is exactly the same. The only difference is the number of components required and
board space needed.
In fig: 3, when the output of the micro is LOW, the PNP buffer transistor is turned on. This delivers
current to the base of the output transistor via a 18R resistor. We have determined the base current
must be 250mA to reliably turn on the 12v 1amp lamp. This current must flow through the 18R
resistor and the wattage dissipated by this resistor will be surprising! It needs to be 1watt! This is
wasted current as it does not perform any function and the 250mA will put a heavy load on the 5v
supply. The solution is to put a Darlington transistor in the output as shown in fig: 4.
A Darlington transistor is two transistors in the one case and it looks like a normal transistor with
three leads. A typical Darlington transistor can have a gain of 2,500 and if the lamp requires 6 amp
at turn-on, the current required into the base will be 2.5mA. The 1k separating resistor will deliver
about 3.5mA, remembering there is a 1.2v volt drop between base and negative rail for the
Darlington transistor.
But the biggest advantage of the Darlington design is the absence of the 18 ohm resistor. This will
remove the heavy demand on the 5v supply. A suitable Darlington transistor for up to 4 Amp load is
BD 679. The pin-out for a BD 679 is shown in fig: 5.
DRIVING TRIACS
If heavy AC loads are required to be driven, a TRIAC can be used as shown in fig: 6.
A TRIAC is especially suited to driving AC loads as it will conduct in either direction and can be
turned on part-way through a cycle (each half-cycle) to provide dimming for lamps or speed control
for motors. TRIACs are available in "sensitive gate" versions requiring low current on the gate. This
is ideal for the '508A micro. TRIACs require the least GATE TRIGGER CURRENT when the gate
current is negative.
To Top