Powering a peripheral via GPIO which requires a substantial capacitor - Page 1
Forum section: electronics / beginners

author: jameswilddev
author_rank: Contributor
timestamp: January 02, 2022, 09:49:47 am
content: Hello!I'm currently working on a project which is designed to spend most of its time asleep, but wake up in response to RTC/button input.One of its peripherals is a VS1838B infrared receiver (https://www.elecrow.com/download/Infrared%20receiver%20vs1838b.pdf). In this datasheet you can see both a 100nF and a 100uF capacitor between VCC and GND near the receiver. I found a thread where people were discussing this requirement here:https://electronics.stackexchange.com/questions/493720/replacing-capacitor-across-power-input-to-vs1838b-infrared-sensorand the consensus was that it was likely to be important.I was looking to be able to shut the receiver down completely when not in use and the simplest way (given it draws 1.5mA) seems to be to power it from GPIO (https://www.eevblog.com/forum/microcontrollers/powering-devices-via-gpio-pins/25/).If I combine these two ideas however I have a relatively large capacitor being charged through a GPIO pin. Plugging the numbers into a calculator shows 10ms to charge with a peak current draw of 33mA which is quite high (near the limits of the MCU).What might be the most pragmatic approach here? Should I include this capacitor? Compromise on lower capacitor values? Rely on the MCU's power filtering (series inductor + dual capacitors) with only a 100nF near the receiver (the two are physically very close)?Thanks.

author: SeanB
author_rank: Super Contributor
timestamp: January 02, 2022, 10:49:40 am
content: Appnote also shows the series 100R resistor in the power line. you probably can get by with a lower value resistor, likely 10R to 22R resistor instead of the 100R, and swap out the 100uF for a 10 to 22 uF ceramic capacitor, which will reduce the current pulse as well while still providing enough supply decoupling. Just make sure you do not have any high current traces running near the IR receiver, and put the receiver in it;s own little island of ground, leading back to the MCU ground pin with a wide trace, with the power and data running on the other side of the board to this trace. Capacitors right by the pins, and the resistor near the capacitor as well.

author: Ian.M
author_rank: Super Contributor
timestamp: January 02, 2022, 11:22:47 am
content: The consensus elsewhere seems to be that the VS1838B is very sensitive to noise on its supply, so IMHO any design that cant provide the recommended decoupling in the datasheet risks shooting yourself in the foot!If you can parallel two output pins on the same port and set/clear them with a single instruction, you can halve the current demand from each pin. If not, two pins feeding it each through their own 200R resistor would be equivalent, but not demand they be set/cleared absolutely synchronously, so would relax the same port, single instruction constraint.If you cant free up an extra I/O pin or simply want a cleaner solution, bite the bullet and add a low Vgs threshold small signal P-MOSFET as a high side switch.

author: jameswilddev
author_rank: Contributor
timestamp: January 03, 2022, 10:57:36 am
content: Thank you guys!

author: Ian.M
author_rank: Super Contributor
timestamp: January 03, 2022, 12:08:33 pm
content: Please follow up with your eventual decision, and how it works out for you.

author: jameswilddev
author_rank: Contributor
timestamp: January 05, 2022, 06:27:28 pm
content: I'm probably going to just do the full 100R + 100u directly from GPIO; there's still mA headroom so it should be fine. I'm still waiting on a few bits to arrive for other parts of the circuit before I finalize a design but I'll report back however it turns out.This is sort of what is currently planned (1K load as stand-in for receiver, with a logic input as stand-in as GPIO):https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKABkRMVxCqUAWKmF5RRAMwCGAGwDOdENmjYoLAE6cM3YVWxoeVIXBYBjBXu1m++UTHiRSDx09JRYdhATyEwxBPxRg-oTYSLaQrADmlpzWunwCNiwA7tEW2Hj8+iop6ZloeNH5Kuq5WaVFhkYA9pwghJlUgi5hAvyBkIQooW5wZIQInaG13NgsNYR1DSBNxK7o-G2Cg3PwfQNd4LUTo0AI had this idea but I'm pretty sure it won't work in the real world:https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKABkRs8AWENPENzCE++KOBAAzAIYAbAM51O0bFBYAnPhhThCVbGl1UqYOCwDGnQ8P2H+4mPEikXrt6WUo33DNx4YEQgFHSFYAdysTPU4eIzVNLl4bGN57E3gWAHNI0QEDKhQUXmMWACUtHWSiqONxbn0VByhoBBYAez4QQmLBZ2JqELgyQkCUJALO7HbBLp76jxCwQsgMSGwl8dh4YdGkCB1eKaA

author: Ian.M
author_rank: Super Contributor
timestamp: January 05, 2022, 06:54:00 pm
content: Hmmm. I'd put an unpopulated footprint for a small jellybean P-MOSFET between the GPIO and the 100R resistor, with a narrow track linking its Gate and Drain pads, and VCC on its Source pad, so *IF* I ran into trouble, I could cut the narrow track and solder one in, without needing to bodge-wire it.

author: Kim Christensen
author_rank: Super Contributor
timestamp: January 05, 2022, 07:01:13 pm
content: QuoteIf the voltage drop across the 100R resistor is a problem you could use 2 GPIOs with a single resistor. GP1 is connected to the VS1838B via the 100R and GP2 is connected directly (other end of 100R). But GP2 is set to input mode (Hi-Z) and it's output buffer is set high. To power on the VS1838B you'd do this:Set GP1 highwait a few milliseconds. (For capacitor on VS1838B PCB to charge)Change GP2 to an output pin.Then to power off:Change GP2 to an input pin.Set GP1 low.

author: Ian.M
author_rank: Super Contributor
timestamp: January 05, 2022, 08:46:14 pm
content: Quote from: Kim Christensen on January 05, 2022, 07:01:13 pmThat would short out the 100R resistor and raise the 3db corner point of the decoupling network to a high enough frequency for supply line noise to disturb the IR receiver's operation.However if done at the other end of the resistor it could have merit to avoid contention between two GPIOs (GP1 and GP2) that are directly in parallel while in the process of changing them to a matching state. Let GP1 be the one that's always an output. Start off with GP1 low and GP2 set as an input but with '1' in its output latch. To enable the IR module power set GP1 high and immediately make GP2 an output so the '1' in its latch makes it go high. To disable power, make GP2 an input before setting GP1 low.

author: Kim Christensen
author_rank: Super Contributor
timestamp: January 05, 2022, 09:39:49 pm
content: Quote from: Ian.M on January 05, 2022, 08:46:14 pmAh yes, you are quite correct. Brain fart on my part.