Power from GPIO pins?

Status
Not open for further replies.

onehorse

Well-known member
I have a sensor application with a maximum power requirement of 2 mA. Is it feasible to draw power (run VCC and GND) using the AnalogWrite function for GPIO pins instead of the designated GND and 3V3 pins on the Teensy 3.1. This is probably OK for digital signal power, but can I sink 2 mA with AnalogWrite? This would be very useful since I wouldn't be tied to physically locating the sensor at the designated power spigot! If this is not crazy, what is the current limit using this approach?
 
Port pin in digital 1/0 mode could source or sink a bit more than 2mA. Usually can sink more than source.
If multiple pins doing this, often there's a limit on the sum of currents, i.e., total source/sink current whereas fewer pins can have more current per pin.

The current limits are in the K20 chip specification.
 
Thanks for the reply. I'll consult the spec!

IIreadC it looks like the combined total of all pins is <100 mA output and any one pin < 25 mA, so this ought to work just fine. I'll give it a try and report the results.
 
Last edited:
I think this is current supplied/sourced; I don't recall seeing a separate sinking current limit although there is a 25mA injection current limit and I'm not sure what this is.
 
From the data sheet, the injection limit is for (error conditions) where the pin is pulled above the supply voltage, or below ground. The limit is 5 mA for an individual pin, 25 mA is the cumulative limit for a group of adjacent pins.

On these ICs (as opposed to CD4xxx-series CMOS ICs), the drive strength for pull-up and pull-down is designed to be simile. The spec. is 9 mA & 0.5 V -- from this you can infer that each driver has a resistance of less than 0.5/9m = 56 ohms. Therefore at a 2 mA load, you could expect that the pin voltage will pull up to within about 0.1 V of the 3.3 V supply.

Note that you could parallel two or more outputs if you needed more drive strength, but have to be very careful in software to toggle all those outputs simultaneously or otherwise avoid ross-conduction.

Don't use AnalogWrite for this -- digitalWrite is suitable.
 
Thanks for the explanation. The digitalWrite will power a voltage regulator that outputs 2.8 V to the sensor and accepts inputs between 3 and 5.5 V IIRC, so small input voltage variations at the board VIN aren't a concern for this application. I just want to make sure I can run the board without taxing the current limit of any given pin chosen as a convenient VIN or GND pin depending on where I decide to mount the board. There are only a few choices since I need to access the SDA/SCL pins also. But if I can use pins 15 and 10 (or 5 and 20, or 7 and 8) for VIN and GND, respectively, then I only have to take up six pins to run this board and leave all the rest for more fun stuff!

By the way, this sensor, the VL6180X from ST, should allow hand gesture recognition for sophisticated Teensy control. Rather than mechanical buttons and switches or even rotary encoders, this small board promises to allow access to multiple Teensy/add-on board functions with the wave of the hand! Placing it conveniently on top of the Teensy 3.1 makes this option very attractive.
 
Last edited:
Just an update on this issue. I put together this VL6180X sensor board and got it to work with SDA/SCL on pins 16/17 and either with 3V3 and GND for power inputs or with pins 8 and 9 for 3V3 and GND by using digitalWrite(HIGH) and digitalWrite(LOW), respectively. I didn't check current consumption but there was no diminution in the blinking Teensy 3.1 LED and the range function worked perfectly. So this method of using GPIO pins to power very low power sensor seems to work!
 
Status
Not open for further replies.
Back
Top