Transistor Tester

Introduction

Of all the inventions of the twentieth century surely the most significant one must be the transistor, although my wife holds out for the dishwasher. The transistor is the basis of all modern electronics today from radios to computers, in fact in my school days a "transistor" meant a portable radio. However, today transistors are the three legged beasts that are the basic building block of all integrated circuits. I remember saving up three weeks' pocket money to buy one when I was thirteen, it cost seven shillings and sixpence and was called an OC71. In those days they only came in one variety and pin-out. Nowadays they come in two types and a bewildering variety of shapes and pin-outs. So much so, that the same transistor can be sold with many different pin-outs.

Now anyone, concerned at all with electronics, will have acquired a junk box containing several different types of transistor and probably will not have access to all the data sheets. In fact one popular way of purchasing transistors is to buy a bag of assorted unmarked ones. Now, you can get transistor curve tracers, they are very expensive and look like a large oscilloscope. However, the snag is that in order to test a transistor you need to know its pin-out, that is which pin is which. So I decided to see if I could design a transistor tester that would not only tell you if the transistor was working but also its type (PNP or NPN) along with its pin-out.

This project uses the robot-electronics USB to I2C interface to connect it’s electronics up to the computer. The software is written in Processing to allow it to be used on Windows, Macintosh or Linux systems.  Other I2C interfaces could be used, including using an Arduino to emulate the robot-electronics interface, see the end of the page.

USB to I2C interface

Processing screen

Tester hardware

Theory

Check if those transistors work and find their pin out

Looking at figure 1, you might think that there is no difference between the collector and the emitter and indeed in terms of solid state physics there isn't. However, in order to maximise the gain of a transistor the collector is made larger than the emitter. Therefore if you wired up a transistor with the emitter and collector reversed it would still work, but the gain would be reduced. That's something they don't tell you about in the theory book. In fact I was once asked that question in a job interview, I knew the answer and was offered the job!

Now that gives us a clue as to how we can tell the emitter from the collector, if we wire it up one way round and measure the gain, then do the same with them swapped over the configuration with the highest gain is the correct pin-out. But that still leaves us with the problem of which one is the base. Well if you connect the base to positive and the emitter to negative then there will be current flowing, if it is the other way round there won't be.

For a PNP transistor we have exactly the same procedure but with reversed polarities. Figure 2 shows the basic test set up we wish to achieve for each type of transistor. Note the different way the arrow points in the PNP symbol and the supplies are reversed polarity. So what we need for an intelligent transistor tester is to be able to connect any of its pins to the positive or negative supplies through either the base resistor or collector resistor. As each combination is tried, the base and emitter currents are measured and the one that gives the sensible answer is the correct configuration for the device under test.

So we have two problems here, first we have to connect the transistor up in any configuration and then we have to measure currents. Now for the first part we need a different type of component from the normal digital fair, an analogue switch. This is a device that when it is turned on will allow current to flow in either direction, and when it is off no current should flow at all. There is not time to go into the workings of such a device but you can get four in a single IC quite cheaply. Our computer can control each switch to make sure we try all the combinations.

Measuring current is quite simple, all we have to do is to pass the current through a resistor and measure the voltage across that resistor, using an A/D (analogue to digital converter). However, measuring across a resistor that could be any way round means using a differential input to the A/D. These are not very common but there is a differential mode on the PCF8591. It has an I2C bus interface so it is straightforward to drive.

The schematic is split into two parts, the first showing the 16 analogue switches or multiplexers and the two latches used to drive them from the 8 bit digital output. The second showing the I2C interface giving you an 8 bit digital output and four channels of A/D which can be configured as two differential inputs.

Note that this design uses the PCF8574A device, you can as easily use the PCF8574 the only difference being in the fixed part of the I2C address, this will have to be changed in the software.

What we are interested in is measuring the base and collector currents in a simple common emitter configuration. Once we know this, it is possible to tell if the transistor is working. In order to measure current with a computer it is necessary to turn it into a voltage. This is very simple here as we have resistors in both the emitter and the base. It turns out, that to get the dynamic range I was after, I needed to measure the voltage across half the resistor. Therefore, both base and collector resistors are split into two, and we measure the voltage across one of them, as shown here. We need to do this because the voltage is measured using the differential mode of the A/D converters, this uses the 8 bits in the converter to give a positive or negative 7 bit value. This is necessary because depending on what sort of transistor we are measuring the current can be flowing either way thus giving a voltage that can be either polarity.

But, before we begin we have to know how many analogue switches we need to use. Remember we have to switch any transistor pin to positive, negative, collector resistor or base resistor, and then we have to connect the other end of the base and collector resistors to either positive or negative. The final configuration I came up with is shown in figure 3, you will see that a quick count reveals that you need 16 analogue switches to do all this.

With a project as complex as this it is important to label the switches, at this stage it is irrelevant what the labels are but it will help up build up the final circuit.

You will see that to simplify this diagram I have shown the test terminals three times, in fact there is only one and all wires shown going to each box go to the same test terminal. I made the test terminals from miniature crocodile clips to allow easy connection to the transistor. The circuit uses two 74LS259 programmable latches to generate the 16 control lines we need to control the analogue switches from the 8 bits available from the digital interface. Note that bit 7 is used to supply the data, bits 0 to 2 to supply the address and bits 5 or 6 used to trigger the appropriate latch. So in order to control one of the analogue switches we put the on / off state on bit 7, the three least significant bits of the switch number on bits 0 to 2 and pulse bit 5 for the lower 8 or bit 6 for the upper 8 switches.

Now I remember a time when I had to constantly reassure people that they couldn't damage anything inside their computer by running a faulty programme, well with this interface you can. If you look back to the switching diagram from last month you will see some switches connected to +5 volts and others to earth. If, for example, you turned on S2 and S14 then you would short out the power supply through two analogue switches, at best the switches would get very hot but probably they would blow. This is not a problem when the programme is running as we simply avoid those combinations but on power up it could be. You see at power up very little is defined, that is the 74LS259 latches could be at any state, so there is a risk of meltdown. The IIC digital interface chip PC8574 powers up as inputs which look like logic ones so I use that fact to make sure the 74LS259 powers up with a clear signal that turns off all the analogue switches. As the latches need a logic zero to clear and the interface provides a logic one on power up we need to invert the signal with a transistor. Therefore, bit 4 acts as a  clear line on power up and it's also used when changing the switch combinations.

I built the prototype in a small plastic box with the three test terminals on the top. I used sub-miniature crocodile clips for this, the sort normally fitted with a plastic cover.

I removed the cover and drilled two 2mm holes in each and attached them to the lid of the box with miniature 2M bolts. You need two screws to stop the clips rotating and shorting out, they should be mounted as close together as possible without touching. In that way you don't have to bend the transistor's leads too much. Also I cut a rectangular hole in the lid to take the IIC interface connector, as this also carries the power it makes a very neat unit.

Now we need to work out what combinations of switches we need to turn on to get the desired configurations, remember we need to be able to treat any terminal as base, collector or emitter in either PNP or NPN configuration. This is only a few of the 65,536 possible combinations and is summarised in this table.

Note here that on the left is the pin-out combination we are trying and on the right is the binary value we need to send out to the switches. You can generate this table by looking at figure 3 above and seeing which switches need to be on.

Having got a transistor into one of our test configurations we need to work out a strategy for determining if it is working. I tried at first to make measurements of the base and collector currents and work it out from there but it's not as simple as that. Assume you have a faulty transistor with a collector emitter short, you will get a large collector current and a small base current and this is exactly the situation you would have with a good transistor of very high gain. Therefore, we must make measurements in two configurations. First of all we need to disconnect the base from any source of current by opening S4 and S3, now we measure the collector current, this should be zero. If it is not then we either have a faulty transistor or a incorrect configuration for the transistor's pin-out. If it is zero then we can now turn on either S4 or S3, depending on the transistor type, and measure the base and collector current. We can then work out the gain by dividing the collector current by the base current. If we note the gain for all the pin-out configurations the correct pin-out will be the one that gives the largest gain.

When converting the voltage readings from the A/D into current we need to simply divide it by the value of the resistor we are measuring across. As these are different in the base and collector circuits each current measurement has a different resolution. When this is coupled to the fact that any A/D can only give a reading to plus and minus the least significant bit the gain values can be only trusted to about 10% but that is more than good enough. You might find with a high gain transistor that one time you measure it the gain is 500 and the next time it is 530. This is all to do with the precision of a 7 bit value and plus or minus the least significant bit and is nothing to worry about.

This shows how the hardware look to the software, that is it tells us what bits to set in order to control a specific switch. The switch number is given by the address field and the latch bits. The most significant bit determines if the switch is on or off.

The software is written in “Processing” and the source code can be downloaded form this link Transistor_Tester.pde. Note that you need the I2C interface and associated circuitry before the screen will show anything so don’t try to run it alone.

Using an Arduino


If you want to use an Arduino board to emulate a robot-electronics interface, then you can download the sketch to do that here:- I2C_Interface.pde. The thing that caused me some trouble, was the way in which the Arduino handles the I2C addresses. Most software I have come across uses 8 bits for the address with the least significant bit indicating read or write. The Arduino however, uses just 7 bits as an address, and then has a different read or write call. Therefore, the sketch has to modify the incoming address by shifting it down. Also note that the Arduino will require pull up resistors on the I2C lines, the value is not too critical, I used 3K. The internal pull ups are too weak for this and the waveforms without a pull up are very poor, in some circumstances it might just work but you would be on the margin of operation. Analogue input 5 should be wired to the I2C clock with analogue input 4 being wired to the data.


Further work

You could cut down on the chip count of this circuit by using a MCP23016 in place of the two 74LS259s and the PCF8574A. However, you would have to protect against possible start up conditions causing analogue switches to be on shorting the supply before the software had configured it. Also the software would have to be changed to accommodate this.


You can take this project further by eliminating the USB to I2C interface and processing application altogether, making it a stand alone unit. This involves moving all the testing function over to the Arduino. You can use my circuit as is or use the Arduino’s own digital outputs and A/D inputs to cut down on hardware. Note the Arduino can’t be configured as a differential A/D input, but what you could do is to take two readings and subtract them to get a differential reading. There are lots of things you could do to customise it, for example by using multicoloured  LEDs next to each crocodile clip you can indicate the base, emitter and collector with a different colour. The same goes for the NPN or PNP transistor type. The gain could be indicated by an LED bar or by a calibrated knob. The knob attached to a potentiometer would be rotated with LEDs indicating if the gain was higher or lower. When the knob was right a green LED could come on and the approximate gain read out from the knob scale. You could even get an LCD shield and  have all the information displayed on that.

What ever you do though, do have fun.