Author Topic: Powering devices via gpio pins?  (Read 6205 times)

0 Members and 1 Guest are viewing this topic.

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8241
  • Country: fi
Re: Powering devices via gpio pins?
« Reply #25 on: October 02, 2019, 01:54:15 pm »
But if we apply the same rigour to the case where the sensor is simply powered from the same 3v3 line as the mpu, might not additional circuitry be called for there too?

Yes, to a lesser degree though.

The noise coupling to the IO structure is not well defined. Noise may be low, or may not, and this may depend on the actual IO port and pin - how it happens to route inside the chip.

Note that the ripple comes from the internal logic (CPU, memory cells, etc.) switching. This high-current loop is shared by the supply that goes to the IO pin, so:

+Vcc -- RL -- IO pin -- RL -- core

is worse than

+Vcc -- RL -- IO pin
+Vcc -- RL -- core

(where RL denotes the R+Lparasitics of the internal wiring.)

, because the core current pulses affect the IO pin voltage in the first case, but not in the latter. (Assuming there is a good bypass capacitor at the +Vcc pin.)

Same happens in a poorly designed PCB, and people still usually get away with these!

But if you design the PCB properly, it's like the latter case:

+3V3 --- RL --- (bypass cap to GND), MCU Vcc
+3V3 --- RL --- (bypass cap to GND), Sensor Vcc
(Global bypass cap at +3V3 node.)


Yes, if the analog performance is of utmost importance, I wouldn't consider powering the device from the GPIO pin. Not only due to noise, but for precision work, you likely want stable, locally regulated voltage as well, because most precision devices don't have infinitely good Power Supply Rejection Ratio, and precision analog devices tend to be rated for a certain recommended operating voltage.

But do note that the typical 100nF capacitor exactly takes care about this high-freq noise resulting from gates switching. The IO port MOS resistance actually forms an RC filter in this combination.

And the typical 100nF cap doesn't cause too much loading for the port during switching. The peak current exceeds the MCU IO port ratings, sure, but it's a very short pulse and total energy dissipated shouldn't be enough to cause localized die heating, or electromigration. I would be far more careful with 10uF, though.
 
The following users thanked this post: I wanted a rude username, ColCon

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6419
  • Country: fi
    • My home page and email address
Re: Powering devices via gpio pins?
« Reply #26 on: October 03, 2019, 03:12:25 am »
Wouldn't a P-channel MOSFET (one with low threshold voltage, say VGS(th) ≤ 1V), gate controlled via a current-limiting resistor from the GPIO pin, with source to the a filtered or bypassed +Vcc, and drain to the load, work here?  Say, something like DMP2305U, in SOT-23-3, so one could even dead-bug it, solder directly to wires without a board?

This would also allow one to control the voltage to a sensor that uses +5V but communicates at 3.3V levels for 3.3V MCUs, or provide a voltage reference (selectable between a couple of different ones) to a sensitive sensor.
I know that the switching rate may be a problem (it isn't instant on or off, depending on the current-limiting resistor, but I would expect the switch time to be milliseconds or less).  Any other caveats a newbie like me should be aware of?
« Last Edit: October 03, 2019, 03:14:01 am by Nominal Animal »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8241
  • Country: fi
Re: Powering devices via gpio pins?
« Reply #27 on: October 03, 2019, 06:28:18 am »
Wouldn't a P-channel MOSFET (one with low threshold voltage, say VGS(th) ≤ 1V), gate controlled via a current-limiting resistor from the GPIO pin, with source to the a filtered or bypassed +Vcc, and drain to the load, work here?  Say, something like DMP2305U, in SOT-23-3, so one could even dead-bug it, solder directly to wires without a board?

Of course, a P-channel MOSFET is a cheap and small solution, so powering via GPIO pin is a kind of micro-optimization for extremely lowest cost or smallest solution (sometimes you won't have room for even the tiniest SMD MOSFET package).

This would also allow one to control the voltage to a sensor that uses +5V but communicates at 3.3V levels for 3.3V MCUs, or provide a voltage reference (selectable between a couple of different ones) to a sensitive sensor.
I know that the switching rate may be a problem (it isn't instant on or off, depending on the current-limiting resistor, but I would expect the switch time to be milliseconds or less).  Any other caveats a newbie like me should be aware of?

A simple P-channel MOSFET, though, won't necessarily solve the 5V/3V3 problem (which the OP didn't have (a reminder to avoid confusion)), because the gate voltage is referenced to the source pin, which sits at the sensor's supply voltage. If your sensor is at 5V, and your IO pin sits at 3.3V, you already have -1.7V at the gate in the supposed "off" state. Some microcontrollers have some 5V tolerant pins that support open drain mode, then this works by adding a pull-up to 5V. If such a pin is not available, then an extra NFET (and a pull-up resistor) is required. A dedicated power switch IC may be a smaller solution, then.
 
The following users thanked this post: Nominal Animal

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2324
  • Country: gb
Re: Powering devices via gpio pins?
« Reply #28 on: October 03, 2019, 06:01:09 pm »
A simple P-channel MOSFET, though, won't necessarily solve the 5V/3V3 problem

There are numerous dual NFET / PFET options in small packages to help with this, plus one external resistor and your done.
 
The following users thanked this post: Siwastaja

Offline MarkR42

  • Regular Contributor
  • *
  • Posts: 139
  • Country: gb
Re: Powering devices via gpio pins?
« Reply #29 on: October 03, 2019, 06:07:45 pm »
This thread is quite interesting, I'm a bit of a novice, but I thought I'd throw in one idea which may not have been mentioned yet:

* You could use your MCU as a low-side switch, instead of high-side

I'm not sure what advantage that would have, but it means that the pin should never be high, always high-z or low.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf