USB charge control logic circuit - Page 1
Forum section: electronics / beginners

author: t8by
author_rank: Newbie
timestamp: June 17, 2023, 04:48:24 pm
content: Hi,I am currently working on a small project that is powered from a LiPo battery. I plan to use a charging IC from Microchip and charge the battery via a usb cable.One use case for the product is also streaming data to my mobile phone via USB connection and an OTG cable. Because of this, I don't want the charger to be enabled by default when a USB power source is plugged in as I don't want to charger the LiPo from my phone, potentially over drawing from the phone port.The charge IC current set pin can be used to disable the charger by being driven high. I hope to use this feature, in combination with a push button, to ensure that charging mode is only ever entered when the button is held closed whilst the USB cable is inserted.I've come up with the attached circuit, which uses a power on reset IC with both RST and nRST outputs (push pull).The idea is, if the switch is not held, and the USB is inserted, the RST pulse at CLK will have no effect on CHRG_En.If the switch is depressed as VUSB powers on, D is pulled high, and the reset pulse clocks this through the flip flop. The nRST signal will then go low, which will enable the flip flop output, causing CHRG_En to go high impedance, and charging starts.This feels like quite a complicated logic circuit for a fairly simple problem.Can anyone see any improvements or simplifications that could be made here? I am sure there is a far more elegant way of handling this.

author: CountChocula
author_rank: Unknown
timestamp: June 17, 2023, 05:59:22 pm
content: Hi! Three suggestions if you're looking for something simpler:Possibly the simplest way to solve the problem is to just use a SPDT switch—you just leave it off when you don't want to charge. But that's error prone, and probably inconvenient.If your circuit has some kind of MCU with a couple spare GPIO lines, you could use it to control the charger; at startup, simply sense whether the button is pressed on one input, and drive an output connected to the charger IC high or low accordingly.If these options aren't feasible, you could use a simple soft-latch circuit—something like the one I attached below should work; the transistors can be anything you have on hand.Hope this helps!—CC

author: t8by
author_rank: Newbie
timestamp: June 18, 2023, 03:04:12 pm
content: Hi CC,Thanks for your reply.I'd considered the switch but I knew it would only be a matter of time before something got fried...I'm struggling to get the circuit you've posted to work in LTSpice. I had to make the modification in my image to get it to work. One requirement that I don't believe this meets is one-time use, hence why I used a reset generator that (assuming V_USB doesn't brown out) can only enter the charging mode on first power up. If the device has been plugged into USB for some time and isn't charging, pressing the button will have no effect.

author: t8by
author_rank: Newbie
timestamp: June 18, 2023, 03:08:26 pm
content: Actually my last post has the wrong logic. This is amended such that pressing the switch enables 5V.

author: CountChocula
author_rank: Unknown
timestamp: June 18, 2023, 06:34:42 pm
content: Quote from: t8by on June 18, 2023, 03:04:12 pmYeah, that was a screw up on my part—apologies. I did wire it up to make sure it would work, but then I captured the schematic incorrectlyI missed the power up requirement. In that case, if you have a 555 handy, you could use something like the circuit below. The 555 is set up for single shot mode, and the output will go high if TRIGGER is pulled low. When the circuit is powered up, C3 starts charging through R2; if SW1 is depressed before C3/R2 reaches a critical voltage, TRIGGER will be able to discharge into C3 and switch the output high. After a while (maybe a little less than second or so in my experiment), the potential at C3/R2 will be sufficiently high that depressing the switch will have no effect. (R1 and C1 hold RESET low for just an instant at boot up to give the power supply time to stabilize. D1 and D2 help discharging the capacitors when power is removed from the circuit).This should do more or less what you're looking for. I wired it up and for me it works if hold the button down when powering up (orveryshortly thereafter), but, after a couple seconds, pushing the button has no effect. Hopefully, I captured the schematic right this time around—CC