# Voltage shift 5V to 3.3V for PIC16LF145x 3.3V I/O input, several approaches

For USB device detection I need a way to shift that VBUS 5V to 3.3V in order being able to connect it as I/O input pin. The input pin should be high as long as VBUS = 5V, and low as soon as VBUS = 0V. This pin will be configured to generate an interrupt on input change. Only in high state USB functionality will be enabled as specified in USB 2.0 specification.

Low power consumption and low BOM is absolutely important in my case.

A design with a zener diode was rejected due the relative high required minimum zener current.

I decided to use a reistor divider with very high impedance.

simulate this circuit – Schematic created using CircuitLab

This voltage divider would ideally sink at most 0.4µA current as long as VBUS is 5V. The question is, is it enough for the PIC16LF145x micro controller I/O pin in order to detect a high signal? Theoretically it should since I/O pins are basically MOSFETS. Since there is some design specific capacitance it would take some time I/O pin to become "high", but this delay is no problem. However, there is also an input leakage current (datasheet, parameter no D060) of 5-120 nA. Does it mean, that the current provided into input has to be higher than that leakage current? Can R1, R2 even be higher for even lower constant sink current?

Is a MOSFET design the better approach?

simulate this circuit

An MOSFET for example this BSS138 also has some constant current in the range of some 100nA to 5µA (Zero Gate Voltage Drain Current, VGS>0V, VDS=0V). For this reason, this circuit is also not to be considered as an ideal solution.

What would you use, is there an even better/simpler solution (in regard to power consumption)?

Edit: Both the microcontroller as well as the USB host is powered by a battery (the same battery). However the micro controller should run independend of the VBUS voltage (USB host can be off, suspended...). My intention was to keep the energy consumption of the whole system as low as possible.

• 0.4 microamps would take nearly 70 years to drain a single CR2032 button cell. Just how small is the battery you're running this off? Commented Apr 13, 2015 at 13:39
• On the same subject, since the PIC controller is powered by the very same battery: take its current consumption from the datasheet and use 1/100 to 1/1000 of that current as a target current in your divider. In the worst case (USB host running all the time and consuming 0 power) you will only reduce your battery life by 1% to 0.1% Commented Apr 13, 2015 at 13:46
• @DmitryGrigoryev: But 1/1000 of 1.5mA drawn current at 16 MHz is very small too (1.5µA). In low power slow clock mode (32 KHz) it even requires only 30µA. But you a right if you say as long as VBUS is powered the current drawn by the divider is negligible. If VBUS is not powered (host is off), it means no current is drawn, that is what I actually want. Commented Apr 13, 2015 at 14:00

If you want to use resistors, you need the current in your divider to be at least 10 times bigger than input leakage for a reliable operation (1.2uA in your case).

But quite frankly I don't understand the requirement to sink as little current as possible from USB - any device connected to it will probably consume around 100mA if not more, so taking even as much as 0.1mA for device detection doesn't sound unreasonable.

• Both the microcontroller as well as the USB host is powered by a battery. However the micro controller should be independend of the VBUS voltage. My intention was to keep the energy consumption of the whole system As low as possible. Commented Apr 13, 2015 at 13:34
• Your divider will only consume when the USB host is powered. Do you know a typical consumption of your host in idle state? I'm guessing tens of milliamperes. My advice is to save yourself the trouble and use lower resistance values. With megaohm values your divider may stop working with just one touch of a greasy finger. Commented Apr 13, 2015 at 13:38
• This sound reasonable. Typical power consumption of the entire micro controller it self (I guess including USB) is 1.5 mA (3V) at 16 MHz concerning datasheet. The host system that provides that VBUS voltage of course draws by far more current like 0.3A at 15V. Commented Apr 13, 2015 at 13:44

With resistances this high, many parasitics become concerning. You've highlighted one, input leakage current, but another is any dirt, flux residue, oils etc on the PCB, which can have resistances in the tens of megohms range, or even much lower if it's wet.

0.4 microamps is not a lot, even compared to the MCU's idle power consumption. You can probably stand to make this significantly less stiff and still consume minimal current, while having to worry less about the cleanliness of your PCB and other parasitics than you otherwise would.

Regardless of these concerns, the power drawn by the divider is drawn from the VBUS supply, not from your device's power supply - so power consumption should not be so pressing a concern here.

• Hello Nick, no the device is not USB bus powered. VBUS is only used for detection that the USB host is working. Commented Apr 13, 2015 at 13:30
• @bkausbk Even if it's not, the power consumed by the resistor divider will be drawn from the USB supply, not from your device's power supply. Commented Apr 13, 2015 at 13:32
• Both the microcontroller as well as the USB host is powered by a battery (the same battery). However the micro controller should run independend of the VBUS voltage (USB host can be off, suspended...). My intention was to keep the energy consumption of the whole system as low as possible. If the micro controller only requires 25µA/MHz, drawing some µA in resistor divider is pretty much in this case. Commented Apr 13, 2015 at 13:39