Microcontroller Interfacing –  Part 8

High Side PNP Transistor Switching

Goals

This section covers the use of PNP transistors to perform high side switching with a microcontroller.

High Side Switching

Part 7 covered using transistors to switch loads that require higher currents or voltages than the microcontroller can handle.  All the circuits had similar topologies. The load was connected to the power source, and an NPN transistor acted as a switch to ground. Since the switching element (the transistor) was at ground, it is called a “low side switch.”

With low side switching the load is at Vcc potential.  Sometimes it is desired to have the load at ground potential, and to switch the power supplied to it. This is called high side switching. Figure 8-1 shows the difference between high and low side switching.

You can’t just connect an NPN transistor’s collector to Vcc and the emitter to the load which is grounded.  As explained in the previous section, negative feedback will prevent the NPN transistor from being driven into saturation.

  

Arduino I/O Expander

Figure 8-1  

The alternative is to use a PNP type transistor.  Using PNP transistors is essentially the same as NPN transistors, except the polarities are reversed.  Figure 8-2 shows a circuit using a PNP transistor as a high side switch.  Notice that the emitter is connected to the positive voltage.  The arrow in the emitter of a PNP transistor points in the opposite direction than in an NPN transistor.  Base current flows from the emitter to the base, and collector current flows from the emitter. This is all backwards compared to an NPN transistor.

The signal needed to control the PNP transistor is also reversed from NPN transistors.  With the NPN transistor you set the port pin to the high state to turn on the transistor.  With the PNP transistor you need to bring the port pin low to turn on the transistor.

The calculations for base current and the base resistor are identical to those outlined in Part 7 for NPN transistors except the polarities are reversed.

One additional thing you need to be careful with PNP high side switches is the voltage used to drive the load.  Normally it is best to use the same voltage to drive the load that is used to power the microcontroller.  Consider the following. 

Suppose the load voltage is +12V and the microcontroller is running at 5 volts.  Ignore R2. R2 would normally have a value high enough to have little effect  and ignoring it makes the calculations that follow simpler. Assume that P0 is high, at 5V, and R1 is 1000 ohms.  Base current would be calculated by

Ib =  (Vcc – Vp0 – Vbesat)/R1 =( 12 – 5 - .7)/1000 = .0063A = 6.3ma

Unless the transistor has exceptionally low gain, it will be turned on even though with P0 high it should be turned off.  Worse yet, the microcontroller pin P0 will be seeing more than 5V, which greatly exceeds the usual limitation of the microcontroller supply voltage plus 0.3V.  The microcontroller would likely be damaged in this situation.  Part 12 discusses ways of driving a PNP transistor when the load must be driven with a higher voltage than the microcontroller.

Figure 8-2

The circuit in figure 8-2 contains two other components, D1 and R2.  D1 is a snubbing diode and is needed if the load is inductive like a relay, solenoid or motor. The previous section discussed the use of diodes across inductive loads in more detail. 

R2 is used to keep the base pulled high if the microcontroller output pin is in the high impedance state, which it is after power up until the I/O pins are configured.  This prevents the load from being powered until the microcontroller has active control of the transistor.  R2 might not be needed in applications where the load being briefly turned on will not cause problems, say in an LED indicator.  This might not be tolerable in other applications, such as controlling a motor or other load where improper operation might cause damage or other harm.  As a rule of thumb, R2 should be 10 times the value of R1.

Summary

When the load must be at ground potential, and the microcontroller cannot supply enough current, a PNP transistor can be used to switch the load from the Vcc side.  The circuit analysis is almost identical to using an NPN transistor except that the polarities are all reversed. Be sure the transistor can handle the voltage and current requirements. 

Gotcha List

1. Don’t use the single PNP circuit to switch voltages greater than the microcontroller supply voltage.

2. Ensure the transistor can handle the voltage and current required by the load.

3. Protect the transistor with a snubbing diode if the load is a relay, solenoid, motor or otherwise inductive.

4. You must set the port pin low to turn on the PNP transistor. With NPN transistors  you set the port pin high.

  

© 2009 - 2014 Gary C. Sutcliffe

  

¸

Created with the QTH.com SiteBuilder.