A more thorough take on a simple polarity tester circuit for unknown power supplies and an introduction to constant current and power dissipation on the way.
While we generally know what polarity our batteries are by the physical construction of the case, and can use this to figure out which wire is positive and which is negative in a battery pack even if the wires are not coloured, the same is not true of plug pack mains power supplies. Many makers use whatever parts they have around, and while power supplies usually have their voltage and current displayed on the compliance label, the polarity is often not. Some plugpacks feature a symbol to indicate whether the centre of the connector is positive, but others do not. In addition, what if the plug has been changed by someone, or is one of those multi-plug types which can have either polarity and are sometimes very poorly marked? Even batteries are not immune, with some larger or specialised types being very hard to identify the terminals of.
With this in mind, we're presenting a very simple circuit this month, but one which will be invaluable on your workbench in the right situation. A tester for polarity demands a circuit that can show, with real clarity, which side of a power supply is positive and which is negative, and work from a wide variety of voltages. It should also have some protections built in, too, in case accidents happen or a fault causes flow-on problems. For this reason, our circuit is a bit more than the single resistor and two back-to-back LEDs often used for this kind of test.
SOME HELPFUL HINTS
We encourage you to read all the way to the end of the article before you build. Not only will you then have a better feel for the overall picture as you build, but we sometimes discuss options or alternatives that you will need to have decided on. You will need some basic hand tools for most builds. Small long-nosed pliers and flush-cut side cutters meant for electronics are the main ones. Materials like tape or glue are mentioned in the steps, too. We always produce a tools materials list if you have to go shopping, but anything that is lying around in most homes is just stated in the steps.
As always with Kids' Basics, we avoid soldering to make the build more accessible to more people, but having an adult around can still be helpful. You won't need any particular skills besides being able to identify components at a basic level, and even then, we help as you go along. If, for example, you don't already know what a resistor is, you'll probably be able to work it out from the photos and description in each step.
We do provide a schematic or circuit diagram but this is just helpful if you already know how to read one. Don’t stress if you have never learned, but take the chance to compare the digital drawing of the breadboard layout (which we call a 'Fritzing' after the company that makes the software) to the schematic and see if you can work some things out. You can make this project from the Fritzing and photos alone. You might also like to check out our Breadboarding Basics from Issue 15.
The Build:
Parts Required: | ID | Jaycar | |
---|---|---|---|
1 x Solderless Breadboard | - | PB8820 | |
1 x Packet Breadboard Wire Links | - | PB8850 | |
2 x Plug-to-plug Jumper Wires | - | WC6024 | |
2 x 2N2222 Transistors* | Q1, Q2 | ZT2298 | |
1 x Red 5mm LED* | - | ZD0150 | |
1 x Green 5mm LED* | - | ZD0170 | |
2 x 1N4004 Diodes* | D1, D2 | ZR1004 | |
2 x 1N4728 3.3V 1W Zener Diodes* | ZD1, ZD2 | ZD1398 | |
2 x 100Ω Resistors* | R2, R3 | RR0548 | |
2 x 2.4kΩ Resistors* | R1, R4 | RR0581 | |
1 x 2mm Black Probe | - | PP0425 | |
1 x 2mm Red Probe | - | PP0425 | |
1m x Twin Core Wire | - | WB1704 | |
1 x 9V Battery | - | SB2423 | |
1 x 9V Battery Snap | - | PH9232 |
* Quantity shown, may be sold in packs.
Step 1:
Place the breadboard in front of you, with the outer red (+) rail facing away from you and the outer blue (-) rail closest to you. Install two wire links, one joining the two red (+) rails and one joining the two blue (-) rails.
Step 2:
Insert a 2N2222 NPN transistor with its flat face toward you. Also, insert a 2.4kΩ resistor (RED YELLOW BLACK BROWN SPACE BROWN) from the middle (base) leg of the transistor to a spot to the left.
Step 3:
Install a green LED with its shorter cathode (-) leg to the left-hand (collector) leg of the transistor, and its longer anode (+) leg to the same row as the 2.4kΩ resistor. If you are shortening the LED legs, like we have, it helps to bend the legs with pliers to fit neatly. Add a 1N4004 general purpose diode with its striped (cathode) end in the resistor/LED row and the other end in the upper red (+) rail.
Step 4:
Place a 1N4728 Zener diode with its black striped cathode end to the middle (base) leg of the transistor, and its unmarked anode end to the upper blue (-) rail. Add a 100Ω resistor (BROWN BLACK BLACK BLACK SPACE BROWN) between the right-hand (emitter) leg of the transistor, and the upper blue (-) rail.
Step 5:
Insert another 2N2222 NPN transistor with its flat face toward you. Also, insert a 2.4kΩ resistor (RED YELLOW BLACK BROWN SPACE BROWN) from the middle (base) leg of the transistor to a spot to the left.
Step 6:
Install a red LED with its shorter cathode (-) leg to the left-hand (collector) leg of the transistor, and its longer anode (+) leg to the same row as the 2.4kΩ resistor. Add a 1N4004 general purpose diode with its striped (cathode) end in the resistor/LED row and the other end in the upper blue (-) rail.
Step 7:
Place a 1N4728 Zener diode with its black striped cathode end to the middle (base) leg of the transistor, and its unmarked anode end to the upper red (+) rail. Add a 100Ω resistor (BROWN BLACK BLACK BLACK SPACE BROWN) between the right-hand (emitter) leg of the transistor, and the upper red (+) rail.
Step 8:
Cut a plug-to-plug jumper wire in half, and bare the ends. Bare the ends of a length of twin-core hookup wire and twist the jumper wire halves to one end of the twin-core wire. Tape the joints to keep them secure and insulated, but we left one exposed so you can see how we did it.
Step 9:
Unscrew the black and red probes, and slide the other bared ends of the twin-core wire through them. Screw the retainer ring back on tightly to hold the ends of the wires in the probes. This may take a couple of attempts, as you often need to spread the wire strands out.
Step 10:
Plug the wire from the red probe into the upper red (+) rail, and the wire from the black probe into the lower blue (-) rail. Now, the circuit is ready for testing.
TESTING AND USING IT
To test the circuit, you will need a power source. For this purpose, a 9V battery is a good call because it has easily accessible terminals and clear markings. You can also Blu-Tack the thing down while you do the test. Double-check the labelling on the battery so that you know which terminal is positive (the small one) and which is negative (the big one).
Hold the red probe onto the positive terminal, and the black probe onto the negative terminal. The green LED should light up.
Swap them over so the red probe is on the negative terminal and the black probe is on the positive terminal. The red LED should light. If it does not, first check your battery in case you have a dead one, then check the circuit connections carefully, looking for loose connections or component legs which have ended up in the wrong row.
If you do not have a 9V battery, any safe DC power source will do. You could use a 4AA battery pack, and if yours has coloured fly leads then telling positive from negative is fairly easy. You could also use a plug pack but it's harder to tell whether the inside of the plug is positive or negative. Most are centre positive, but you cannot tell by looking at them. Some labels on the plugpacks themselves have a diagram to show whether they're centre negative or centre positive, but not all do. This is actually a perfect use for the tester once you know it works.
HOW IT WORKS
The circuit is composed of two identical halves, with one flipped around. So, we will describe how one half works, then explain what they do when paired together this way. However, before we explain the circuit, we should describe in detail two different types of diodes. D1 is a rectifier, or general purpose diode. ZD1 is a Zener diode, and works differently.
The diode allows current to flow only one way, and that is important later. If the probes are connected with probe 1 to the positive supply and probe 2 to the negative or ground, D1 is 'forward biased. The bias of a diode means which way the current is connected to the PN junction inside. In a diode, the P side of the junction is the positive terminal and the N side is the negative terminal.
More correctly, the P side is the anode (A), and the N side is the cathode (K). If you connect current so that the anode has a higher voltage than the cathode, current flows across the PN junction. The cathode does not have to be at 0V, just a lower voltage than the anode. In that case, the diode is 'forward biased'. To make that clear, in the diagram above, there is no 0V, just two different voltages with one higher than the other. If the cathode is at a higher voltage than the anode, then no current flows. This is 'reverse biased'.
All diodes have a 'forward voltage drop' and a 'reverse breakdown voltage'. The forward voltage drop is the voltage it takes to overcome the barrier inside the diode. For most general purpose diodes that we use as rectifiers or reverse-polarity protection devices, that is around 0.6V.
So, the voltage on D1, for example, will be 0.6V lower at the cathode, where R1 is, than at the anode, no matter what voltage is applied. Reverse breakdown voltage, on the other hand, is the voltage a diode can tolerate when reverse biased. This is the voltage at which the diode will break down, and current will flow from cathode to anode.
The problem is, this voltage destroys the diode and it will never be a diode again. By the way, there is also a forward voltage rating, which is the maximum forward biased voltage that can be applied before a diode is destroyed, too, but this is always much higher than the reverse voltage.
Zener diodes are a special type of diode, built differently than regular PN junction rectifier or signal diodes. A zener diode has a Zener voltage, rather than a reverse breakdown voltage. When the Zener voltage is reached, the diode breaks down and conducts in the reverse direction. However, unlike a regular diode, this does not destroy the device. What's more, the Zener voltage becomes like a bigger forward voltage drop, so the cathode side of the diode will always be the Zener voltage higher than the anode, no matter what the anode is connected to. Therefore, a Zener diode is a basic voltage regulator.
Any voltage above the Zener voltage goes straight through the Zener diode! All that extra voltage flowing through it generates heat, however. There is a maximum power of heat that a Zener diode can cope with, and that is what gives us its power rating. The diodes we are using can dissipate (or turn to heat without failing) 1W. That is why we need R1: To limit the current through the Zener diode at the highest voltage we expect to use this tester at. It also limits the amount of current that can flow through Q1'a base, too, which has its own maximum tolerated current.
Before we explain the circuit, let's refresh the operation of transistors. Transistors are current amplifiers. That means that the amount of current flowing through the collector to the emitter (for an NPN transistor) is a given number of times the current flowing from the base to the emitter. For a PNP transistor, the main current flows from emitter to collector and the base current from emitter out through the base, but the principle is the same. The number of times greater the main current is compared to the small base current is called the gain.
This number is represented by the Greek letter Beta (β) but in datasheets, it is often written as 'hFE'. It will always be a range, because no two transistors are exactly alike, even from the same batch. Some are worse than others. For example, the BC547 has a range of between 100 and 800 for hFE, meaning the β for a given BC547 could be any number between 100 and 800. In contrast, the 2N2222 has a range of 100 to 300, which means any two transistors will likely be more similar.
We exploit that property in this circuit to build something called a 'constant current sink'. The constant current source or sink is a circuit that allows us to provide a controlled amount of current through a circuit. It's a source if it is between the supply rail and load, and a sink if it is between the load and the ground rail. Besides that, they're the same. Technically, a resistor can be thought of as a current source but it is a bit too simple to really be called one.
With a transistor, however, we can make something truly controlled. Because the current through the collector to emitter (the load current) is the transistor gain times the current through the base to emitter, we can calculate it using the base to emitter current from the voltage at the base of the transistor and the resistor R2 between the emitter and ground. The load current is the name we give to the current through the collector, because the load is between the supply voltage and the collector and is the real reason we are even doing this in the first place.
Now, let's look at one of the mirrored sections of the circuit as a whole. Assume Probe 1 is connected to V+ and Probe 2 is connected to GND. Current flows from the supply rail through diode D1, Resistor R1, and Zener diode ZD1. Because of the Zener effect, there is now a fixed voltage at the base of Q1. If we had a known supply, say, 12V, then we could use a voltage divider made from two resistors to set the voltage at the base of Q1 (see Classroom Issue 051 for more details on voltage dividers and to do maths with chocolate). However, we do not have a constant supply voltage - our tester could be connected to anything from a 3.7V Li-Po battery to a 36V LED string. To understand why we need a fixed voltage, we need to share a formula for the single-transistor current sink.
We do not usually use formula in Kids' Basics but it's here to help you understand what's going on if you want to. Vb in the formula is the voltage at the base, while VBE is the voltage drop across the base.
The base to emitter path is a PN junction just like a diode, so it has a voltage drop. In the case of the 2N2222, it's about 0.6V. Because of the way transistor gain works, and because of Ohm's Law, the current from the base to the emitter is related to the voltage at the base, and the resistance between there and ground. So, to find the load current, we take the voltage at the base (which is the Zener voltage), subtract the base-emitter voltage drop, and finally divide what's left by the value of R2.
This formula is the end result of several other formulae, and if designing from scratch, you would need those. You can calculate the emitter current, and some other things, but we try to avoid too much maths in Kids' Basics anyway. The one formula here should help your understanding to a functional level.
So, current flowing through R1 and ZD1 sets a voltage at the base of Q1, with R1 stopping the Zener diode or Q1's base being overloaded. What about the other components? R2 sets the base-emitter current, as we briefly discussed. LED1 is our indicator, and is the load we are setting the current for. D1 ensures that the current can only flow through the circuit one way, no matter how we connect the probes. The value of R2 is chosen so that we have 20mA through the current sink to power the LED.
Normally, we use a resistor to limit the current through an LED. An LED has a forward voltage drop, just like any other diode, but it's generally higher. Red, orange, and yellow LEDs take 1.8V to 2V typically, while green, blue, and white generally have a forward voltage of 2.8V to 3.5V. We use the resistor to drop the remaining voltage at a chosen current. However, if we regulate the current as we are here, then there is no need for a resistor: The LED will drop the voltage it operates at, and that's it.
The circuit as a whole is just two identical halves, with one side flipped upside down. The other half has a red LED, while the first half has a green LED. Probe 1 is red and probe 2 is black. This way, if the red probe is connected to the positive, and the black to negative, the green LED lights. If red is to negative, and black is to positive, the red LED lights, telling you that the polarity of the power supply is backwards. If both light, you have an AC power supply. This changes polarity 50 times per second (unless you're in the United States or a former territory thereof, in which case it's 60 times per second). Each LED is only on for half the cycle but it's so fast our eyes see both on, just not as bright. We included D1 and D2 to make sure there is no cross-path for the current to flow through and to make sure that the fragile junctions of the LED or transistor are never the thing holding back current when that side of the circuit is reverse-biased. LEDs and transistor base-emitter junctions are not very rugged when reverse biased, despite being on paper a PN junction just like any other. It's the way they're built for their intended purpose that makes the difference.
IT'S NOT PERFECT
While we called this circuit a constant current sink, it isn't constant. However, it is close. If we did not design it for such a wide voltage range, it would be more constant. There is a compromise when choosing resistor values for R1 and R4. The Zener diode needs a certain minimum current to run, but also has a maximum. Because of Ohm's Law, if we increase the voltage across a resistor, we increase the current through it. The opposite is true, however.
The other problem is power dissipation. This phrase describes how much electrical energy a resistor (or any other component) can turn into heat without failing. The resistors we use are metal film 1% resistors, which can dissipate half a Watt (0.5W) of power as heat. Many people are using quarter-Watt (0.25W) carbon-film resistors at the hobby level, so they cope with even less heat.
R1 (and R4, but we will talk about one circuit half) is in series with a 3.3V Zener diode. That means that R1 drops the rest of the voltage for the branch. So, if the circuit is fed with 5V, the resistor drops 1.7V. At 2.4kΩ, Ohm's Law says that only 0.0007A, or 0.0007mA, is flowing through the R1/Q1base/ZD1 branch. That's not really enough to keep the Zener in regulation.
However, if we fed the circuit 36V, then we have 32.7V dropped across the 2.4kΩ resistor. Plugged into Ohm's Law, the current through the branch is now 0.013A or 13.6mA. 5mA is usually enough to keep most brands of Zener stable. Why don't we lower the value of R1 then, to allow more current?
This is where power dissipation comes in. Power dissipated is the voltage dropped across the component (so this works for the Zener too, and even the base-emitter and collector-emitter junctions of the transistor) multiplied by the current through it. At 36V supply, with ZD1's 3.3V drop taken away, R1 will dissipate 32.7V at 13.6mA, which, after converting milliAmperes to Amperes, gives a power dissipation of 0.45W.
That's very close to the 0.5W limit and even below the limit but close to it, the resistor gets hot enough to hurt when touched. If we reduce the value of R1 to give us the currents we really want, we have too much power dissipated. In fact, we clean forgot about this when prototyping and had a resistor value that gave ideal current but was dissipating 2.7W on a 0.5W package!
Luckily we smelled it before it melted the breadboard.
So, if you know that you will never measure voltages as high as 36V from an LED string plugpack, then you can use lower resistance values and get better regulation from the circuit.
We haven't covered calculating power before. Power is voltage multiplied by current, always in whole base units (so, A and not mA). If you draw it as a triangle like Ohm's Law, you can easily choose how to calculate what you want. With P on top over I (for current ) and next to V, you add which values you have to find what you need. So, if you want to find the current from a known power rating and voltage, P ends up over V so it's a division calculation to find I.
This goes for power dissipation, which is the amount of voltage drop over a component at the current going through it; or for rated power, the amount of current a power supply can feed at its supply voltage. For example, a 12V power supply that can give 2A of current is a 24W power supply. Power dissipation is noted by PD with the subscript D representing 'dissipation'.
WHERE TO NEXT
Unfortunately, resistors are not perfect and Zener diodes are even less so. We use metal film resistors with a 1% tolerance, but many hobby packs come with 5% carbon film resistors. This means a resistor could be 1% or 5% above or below its value. For a 100Ω resistor, that's 99Ω to 101Ω for 1% and 95Ω to 105Ω for 5%. Not a huge deal but the bigger the value, the bigger the difference. This will affect the exact current.
The same goes for the gain of the transistor, which could be anywhere between 100 and 300, and the Zener has a 5% tolerance to if it has an 'A' after the part number, or 10% without the 'A'. You could replace R2 and R3 with trimpots so that you can precisely tune the current of each sink. This way, you could plug in a load and adjust the trimpots until you have exactly the current that you want. The best way to do this is with a resistor, and a value of 100Ω should allow enough current at a 5V test voltage for any LEDs.
You would need a multimeter to do this, however, connected in series and with the dial set to measure current. Connect the red probe to the junction of D1 and R1, and the black probe to the end of the test resistor. The other end of the test resistor goes to the collector of Q1. In other words, the test resistor replaces the LED for this task. Then, you can swap the probes over on the power supply to reverse the polarity, and repeat in the equivalent locations on the other half of the circuit. To connect the trimpot, connect one end to the wiper in the middle, and use this as one common terminal to connect to the emitter of the transistor. The other end goes to the 'ground' rail for whichever half of the circuit you're changing. In other words, connect the wiper to one end of the trimpot to make it a two-lead device, then replace R2 or R3 with it.
Another place the circuit can vary is the value of R1 and R4. If you know you will never be using this circuit at 36V, then you can reduce the 2.4kΩ value of these two resistors to get better regulation on the Zener. If you have not read the 'How It Works' section, there is some important information there about these resistor values. Keep in mind that the Zener can dissipate 1W of power, so look at the Ohm's Law and Power triangles in that section and make sure you calculate first whether the Zener can tolerate the current a given resistor value will give it, and that the resistor can dissipate that much power and the voltage and current you need.
The circuit works as-is but if you want to keep this as a test tool, it would benefit from being more permanent. It will be more reliable that way, and last longer. You can get solder versions of these breadboards which are hole-for-hole copies of the plastic prototyping boards we use in Kids' Basics. However, you will need soldering skills or the help of an adult who can solder. This image shows one such board that we drew on with marker to show where the rails and rows are. This is the kind of thing you'll need to make this circuit permanent. Because they're hole-for-hole the same, you can just transfer the circuit straight over. You can even solder the same wire links used in the plastic version!