High-side versus low-side switching

Simplified logic output.
Simplified logic output.
Figure 1. Simplified logic output stage showing the high-side and low-side switches.

Most micro-controllers and logic families have output stages which can connect the output to the positive supply or to ground. This allows the micro to put a definite ‘high’ (+5 V in this example) onto the output or a definite ‘low’ (ground) rather than let it float which could cause problems if the output is feeding into another device. Naturally, only one of the switches should be closed at any time. In this article we look at high-side versus low-side switching.

GPIO sourcing current for LED.
Figure 2. To power an LED connected to ground the micro simply connects the output to positive supply. In this configuration we use the upper transistor in the output stage to supply current to the output – much in the same way as S1 in the equivalent circuit.

Most micros can now source 10 to 20 mA safely on their GPIO1 pins. This is ample current to light an LED brightly. All that is require is to decide whether to source current for the LED or sink current.

Micro sinking current from LED.
Figure 3. To power an LED connected to positive supply the micro simply connects the output to ground. In this configuration we use the lower transistor in the output stage to sink current from the LED to ground – much in the same way as S1 in the equivalent circuit.

 

Some more detail

The switches in real devices will be constructed with transistors. These are imperfect and have various limits that we have to be aware of, such as maximum current and source resistance. For example, the ATmega328P used in the Arduino Uno states that the IO pins can handle up to 40 mA subject to a maximum total of 200 mA for the whole chip.

ATmega328 maximum current ratings.
Figure 4. The absolute maximum current handling capability of the ATmega328 and 328P micro.
At 20 mA the ATmega328P output is pulled up to 0.9 V above zero when low and about 0.8 V below positive supply when high.
Figure 5. At 20 mA the ATmega328P output is pulled up to 0.9 V above zero when low and about 0.8 V below positive supply when high.

Note on Figure 5 the \(V_{OL}\) voltage – the actual voltage measurable on the output pin (red) – when switched low and sinking 20 mA that the voltage won’t be zero as might be expected but could be as much as 0.9 V above ground. This is due to the voltage drop across the low-side transistor switch in the output.

Similarly, when the output is switched high and sourcing 20 mA the output won’t be +5 V (the test condition power supply voltage) but could be as much as 0.8 V below that.

It’s worth being aware of this as it could be significant in some low-voltage applications where there isn’t much “headroom” between the voltage required by the LED and that of the power supply.

Example 1 – 5 V supply

LED IV curve and calculation.
Figure 3. Using the LED IV curves to find the required R value for a green LED at 20 mA.

Figure 6 shows that the LED at 20 mA will have a forward voltage drop of about 2.2 V. If the supply voltage is 5 V then the resistor has to drop \(5 – 2.2 = 2.8\,\mathrm V \). The required value is \( R = \frac {V}{I} = \frac {2.8}{0.02} = 140\,\Omega \). The nearest standard value of 150 Ω will do fine.

The resistance calculation will be the same for the current sinking option of Figure 2.

Example 2 – 3.3 V supply

When running from a 3.3 V supply the headroom becomes substantially limited.

As the supply voltage is decreased to 3.3 V the "headroom" for driving an LED is reduced and, when output droop is taken into consideration, the device may not be able to provide enough current.
As the supply voltage is decreased to 3.3 V the “headroom” for driving an LED is reduced and, when output droop is taken into consideration, the device may not be able to provide enough current.

Here we can see that the LED is still requiring 2.2 V leaving 3.3 – 2.2 = 1.1  V for the resistor. If this 3.3 V chip’s output were to droop by, say, 0.5 V then that leaves us with only 0.6 V for the resistor: \( R = \frac {V}{I} = \frac {0.6}{0.02} = 30\,\Omega \).

The problem with this is that a low-value resistor is not a very good constant current source. If the forward voltage, \( V_F \) of the LED decreased by 0.1 V due to temperature or batch to batch variation then the voltage would go to 0.7 V and I would increase from 20 mA to \( I = \frac {V}{R} = \frac {0.7}{30} = 23\,\mathrm mA \). This might push the device a little closer to the absolute maximum ratings.

See all GPIO tricks.

Please link to us if you find the information helpful ...<br>Tweet about this on Twitter
Twitter
Share on Facebook
Facebook
Pin on Pinterest
Pinterest
Digg this
Digg
Share on LinkedIn
Linkedin
Share on Reddit
Reddit
Share on StumbleUpon
StumbleUpon
Share on Tumblr
Tumblr
  1. GPIO = general-purpose input/output.