# Controlling higher voltage and load via high-side switch from a microcontroller

I am building a battery-powered uC circuit with an RGB LED. The LED is common cathode, so the circuit for switching the LED elements has to be high-side. The LED is a higher-current LED, so it cannot be driven by the uC directly.

To save power, I was planning to have the uC (AVR ATmega328) run at whatever voltage the 2 AAA batteries will provide (1.8-3.0V), while the LEDs need to be driven at 4.0V to account for the LED vdrop - the plan was to use a boost converter to power the LEDs. I was wondering what is the best way to drive the LED output from the uC. I can think of a few ways:

## PNP BJT switch with three diodes

AVR docs state that the chip cannot "see" more then 0.5V above Vcc on any of the pins, so one option would be to use a diode $V_{forward}$ to present a lower voltage to the uC:

Perhaps D1 can be omitted? I am not sure if there is a E->B voltage drop in a PNP transistor.

## P-Channel MOSFET with an NPN BJT

Another option is to control the P-Channel MOSFET with an NPN BJT

simulate this circuit – Schematic created using CircuitLab

## N-Channel high-side MOSFET switch

This requires a charge-pump or something equivalent, so I am leaning against this solution.

Currently I am leaning towards the second solution, for no particular reason. Are there other solutions I should be considering? Are there other considerations that I should be thinking about?

• P-Channel MOSFET with an NPN BJT is the simplest choice. No real component-matching is required; you can build it with whatever you have lying around. If Q1 were a MOSFET (with low Vgs threshold) you could do away with R2. – CharlieHanson Jan 1 '16 at 18:17
• I agree with @CharlieHanson. Just want to add that the diodes will not really protect the uC input against high voltage, because the diode voltage will be zero unless some small current flows. Also wanted to add that a PNP BJT does have one diode drop between emitter and base. – mkeith Jan 1 '16 at 18:46
• Ah, good point about R2 @CharlieHanson - hice. – angelatlarge Jan 1 '16 at 18:49
• +1 and a favorite question. Nicely done, and a pleasure to read. Clearly written, with the problems described verbally and tentative solutions presented as schematics instead of words. – EM Fields Jan 1 '16 at 18:52
• – Nick Alexeev Jan 2 '16 at 0:44

Yeah, I think Option 2 is your simplest high-side option. Replace Q1 with a BSS138, and you can have a simple all MOSFET solution with discrete parts.

Alternately, if you're OK buying ICs, you can use an IC like the TPS2557 (which is an N-channel load switch with built-in charge pump), or an integrated dual N/P part like the Si3865DDV which basically squeezes the option 2 circuit into a convenient package. These would also take up less space than the discrete solution, and offer some protection features such as current-limiting if you would like. I can also understand the appeal of building something with parts you have lying around.

A N-channel device will have a lower on-resistance than a comparable P-channel device, but it does require a charge pump as you stated.

Finally, even with a MOSFET solution, I would personally keep R2 there and make it 1k or so, in addition to adding a pull-down to your UC enable pin so that when you are in reset, the LEDs stay off. By keeping R2, if you drop a screwdriver or something across the gate of the MOSFET to GND, it limits the current that can flow from the uC pin.

Here's the discrete solution:

simulate this circuit – Schematic created using CircuitLab

I vote for the second solution because the first one's kind of iffy with respect to the the 2AA battery voltage, Q1's Vbe, and the diode drops needed, while the second solution is rock-solid, especially with respect to the impossibility of ever back-driving the MCU I/O to any positive voltage.