Digital Outputs are Dead Simple, Right?
#1
One of the simplest elements in a data acquisition and control system is a digital output. Its state is either ON or OFF. What could be simpler than that? If the output comes from a logic chip, the exact properties will depend on the logic family and the power supply voltage for the logic chip. Those details are the stuff of data sheets, but are not our focus here. You can count on a few things, regardless. The digital output will either be near the logic power supply voltage or near ground, corresponding to a logical one or a logical zero, on or off. The current available to drive the digital load will be a few mA, more or less. If you need, say, 25 mA of drive current, you need help in the form of a digital buffer. A buffer provides the same one or zero output, but at higher current, and possibly at a higher voltage as well. The amount of help needed depends on how much drive current is required. Up to a few hundred milliamps, a small one-transistor buffer will do the job. Up to a few amps, a big transistor is called for. For higher power loads, you are looking at a relay, or a solid-state output module, or a more sophisticated buffer, probably using a FET switch. A big relay needs more than a few milliamps to drive it, so you may have a two-stage interface involving a small buffer to drive a big relay. For AC loads powered from a wall outlet, you will need isolation for safety. Here, we will limit ourselves to lower voltage DC loads.

A single transistor can handle most of these cases. A transistor used as a switch takes in a small current and turns it into a much larger current. That is called current gain. A transistor might have a current gain of 50, so that 2 mA of drive could provide 100 mA of load current. For extreme current gain you will use two transistors together in a single package called a Darlington, but from the outside, it looks the same as a single transistor. Without going into what, exactly, a transistor is, lets stick to a simple functional description of an NPN transistor. It has three terminals labeled collector, base and emitter.  When voltage is applied to the base, current flows from collector to emitter. The collector emitter current can be much higher than the base current.

   

First, select a transistor for the buffer that can handle the current you need. Next, consider the voltage. Your digital output is probably 0 or 5 volts, but your load might require 12 or 24 volts. That is not a problem. Almost any transistor will handle those sorts of voltages. The collector voltage can be lots higher than the base voltage, up to the rating of the transistor. The base voltage, however, will be limited to about 0.6 volts above the emitter voltage by the intrinsic diode represented by the arrow on the emitter. For that reason, you will put a resistor in series with the base of the transistor buffer. The resistor will establish the base current.

Transistors have specifications for maximum base current. You don't want or need to approach those limits. You just need sufficient base current to insure that the transistor is turned on strongly enough to pass the necessary load current. As in the example above, say your transistor guarantees a current gain of times 50, and you need 100 mA to drive your load, so you need at least  2 mA of base drive. If the digital output voltage when loaded is at least 4.6 volts, and the base of the transistor when on is at 0.6 volts, there will be a 4 volt drop across the base resistor. Using Ohm's law, 4 volts / 0.002 amps yields a resistor value of 2 K ohms. It is fine to use less resistance. You want the buffer to turn on vigorously and excess base current is not a problem so long as you avoid approaching the maximum allowed.

In case the above was too much detail, just think of the transistor as a switch. Zero volts is off, and something above 0.6 volts is on. Before building your buffer, there is one more thing that needs to be considered. Will it get too hot? The transistor has a power dissipation rating that should not be exceeded. The wattage dissipated by the buffer depends on the voltage drop across the transistor when it is turned on. The transistor specifications will show a saturation voltage, which is the voltage across the transistor when it is turned all the way on. The saturation voltage goes up with the current, so keep on the conservative side. Say that number is 0.5 volts. Power is voltage times current, so 0.5 volts  * 0.1 amps equals 0.05 watts. The small through-hole transistor package is always good for 1/4 watt, so everything looks good. For those loads of around 100 ma, common transistor types 2N3904 or PN2222  will be fine up to 50 volts. For more than a few hundred mA, you will want a transistor in a larger package. Usually that would be a TO-220 package instead of a TO-92 package.  You may pick something like a TIP41C in a TO-220 package, which handles many watts at up to 100 volts. The TIP41C might have 1.5 volts across it when turned on, but it can handle a lot of power. It does have more limited current gain than the smaller transistors, with a minimum gain of times 15. If you need more than that, the aforementioned Darlington is your buffer. The TIP112 has a current gain of over 1000, so that won't be what limits you.
 
To summarize, pick a buffer transistor that will handle the current and voltage and power needed for your load, and put 1 or 2k ohms in series with the base, and you should be ready to go. One last caveat- inductive loads like mechanical relays have a nasty habit. The coil current keeps flowing for a brief period after the switch is turned off because the magnetic field in the relay coil takes time to collapse. That causes a negative voltage spike that can damage your buffer transistor. Use a diode as a clamp across the relay coil to dissipate any reverse energy. Most relays are available with built-in diode clamps. Recommended.

For loads of more than a few amps, the power dissipation in a bipolar transistor like a TIP41 will become the limiting factor. You don't want too much heating close to your precision data system if you can help it. In that case, you may use a FET switching element instead of a bipolar transistor. FETs can have milliohm resistance when on, which allows them to carry high currents without much self-heating. We have already expanded this seemingly very simple subject into a bit of an exercise, so FETs will await another day.


Tom Lawson
May 2021
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)