Each of the output lines of a β508A microcontroller can deliver a maximum of 25mA.
What does this mean?
It means any device connected to the line must take 25mA or less.
If it takes more than 25mA a buffer transistor (also called an amplifyingΒ transistor) must be used and this will be discussed in a moment.
However, if it operates on less than 5v, and requires less than 25mA,Β a current-limiting resistor must be included.
A typical device that requires less than 5v and draws less than 25mAΒ is an LED.
A LED must be supplied with an exact voltage for it to operate correctly. Because it requires LESS than 5v, a dropper resistor (current limitingΒ resistor) must be included in series to βtake-upβ or βabsorbβ or βinterfaceβΒ the LED to the output line.Β Working out the value of the current-limitingΒ resistor requires some mathematics but this is very easy when youΒ know how.Β
25mA
The current taken by a device is called the LOAD CURRENT. Twenty-fiveΒ milli-amp 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 globeΒ but there are a number of devices that can be driven.Β Β
1. LEDs (Light Emitting Diodes) require up to about 25mA for fullΒ illumination.
2. Piezo diaphragms require very little current and can be drivenΒ directly from an output line.
3. Low-current relays can be driven directly provided they operateΒ at 25mA and 5v. If more than 25mA is required, a driver transistorΒ (also called a buffer transistor or buffer stage) will be needed. The specification for an output line is 25mA @ 5v. In other wordsΒ the output line has an output voltage of 5v and the maximum currentΒ that can be delivered by it is 25mA.The output line will, in theory, deliver more than 25mA but the transistorΒ (in the chip) delivering the current may be damaged (overheated) ifΒ a higher current flows.Β The current delivered by the output line is determined by the resistanceΒ of the device (or devices), connected to the line.
The simplest device is a resistor as shown in fig: 1.Β
If the resistance of the resistor is too low, more than 25mA willΒ flow. If the resistance is high, less than 25mA will flow. The currentΒ flow 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 THEΒ Β LOAD RESISTOR
The resistance of the load resistor is worked out using Ohmβs Law. We know the voltage on the output line is 5v.Β Β This is V in the formula.Β Β Β TheΒ max 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 toΒ flow when the output is HIGH.Β This is only a theoretical explanation as a resistor on an outputΒ line will not perform any function! It wonβt do anything by itselfΒ except get slightly hot. But a resistor will perform more than 20Β different functions, depending on where it is placed in a circuitΒ and the value of the components around it.Β In our first example below, a resistor is added in series with a LEDΒ so that the LED will take a maximum of 25mA.Β The purpose of the resistor is two-fold. Firstly it allows the LEDΒ to 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. TheseΒ voltage are provided by the chip and the LED and the resistor hasΒ nothing to do with creating them. The resistor simply allows a certainΒ amount of current to flow, depending on its value, (25mA) and thatβsΒ the value worked out above.
A point to note: The β508 has 5 output lines and if all the outputsΒ are delivering 25mA, the total output for the chip will be 125mA.Β This is slightly above the allowable maximum current of 100mA forΒ the chip but will not be a problem.
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, aΒ voltage is dropped across it according to the colour of the LED. ThisΒ is called the CHARACTERISTIC voltage or the characteristic voltage
drop of the LED. This voltage is content, no matter how bright theΒ LED is illuminated.Β This is completely different to the characteristicsΒ of a globe and thatβs why LEDs and globes must be treated differentlyΒ when 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 withoutΒ a voltage-dropping resistor. The reason is very technical but basicallyΒ a 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, theΒ LED will glow brighter, allow a very high current to flow and willΒ be damaged when the current flow is greater than 40mA.Β
It is virtually impossible to provide a constant 1.7v and the simplestΒ way to prevent damaging the LED is to connect a resistor in series.Β If the value of the resistance is worked out via a formula (we will
give in a moment), an accurate current can be delivered to the LEDΒ and 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 byΒ Ohms law. The voltage across the resistor is determined by:
5v β 1.7v = 3.3vΒ (The voltage across the LED is the 5v supply voltageΒ minus the 1.7v dropped across the LED due to the characteristic voltageΒ drop mentioned above).<N>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 thusΒ a 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 areΒ rated at 25mA, they will produce very good brightness at 5mA to 15mA.
For battery operated projects, LED current can be reduced to as lowΒ as 1mA, and this will increase the life of the battery enormously.
Table 1 gives the value for the dropper resistor for a red LED atΒ different currents. Check the brightness of the LED you are usingΒ before selecting a dropper resistor as some LEDs are much better quality
than others and give a higher brightness at very low current.Β
CONNECTING A PIEZO DIAPHRAGM
A piezo diaphragm is essentially very similar to a capacitor (approx22n) as far as the micro is concerned. It requires very little current to operate the device.
A piezo diaphragm is a passive device. It does not contain any active components to create the tone.
Piezo buzzers, piezo sounders and piezo sirens have active components inside the housing (transistors, choke, etc) to create a very loud sound. These devices operate from a DC supply (6v to 12v).
A piezo diaphragm requires a sine wave or square wave β in other words a βpulsingβ waveform to cause the diaphragm to βdishβ (bend) and thus produce the characteristic annoying sound. The amplitude of the waveform determines the loudness of the sound and the frequency of the waveform determines the tone.
See β10 Tricks for the β508Aβ for more details on driving a piezo.
For more detail: A discussion on the drive-current for the outputs of a PIC12C508A microcontroller