0
\$\begingroup\$

I have a wireless keyboard that I would like to power through a USB cord, I am not a fan of wireless, especially due to the battery use. I would however like to have the possibility of having the voice to use the batteries whenever I please. Now the keyboard is powered by 4AA batteries, judging by how they are positioned I am guessing placed in parallel 2x2. In order to power it I am planning to attach a micro-usb connector, and a voltage regulator to drop the voltage to 3.3V. I looked a bit around on how to create a switch which would disconnect the batteries whenever the USB is attached, and found several posts like this one: Automatically switching from battery to DC wall adapter on insertion however I am still confused as to what I should do. I tried simulating a circuit using a p-MOSFET:

schematic

simulate this circuit – Schematic created using CircuitLab

While it appears to work when simulating it on http://www.falstad.com/circuit/, there is some back-current towards the battery. Also This seems like a bit too simple compared to other circuits I've seen around. Is this really a solution? I know there are some IC that can do power management, but they are a bit expensive for my taste, if I have to spend 10$ on it then I'd rather just cut off the battery part and go with the cabled solution. Thank you

\$\endgroup\$
6
  • 1
    \$\begingroup\$ The super-easy way is to find a power jack with a built-in switch for sensing when it's plugged in. They make those for 3.5mm headphone jacks, but I don't know if you could get them for barrel jacks. Probably. \$\endgroup\$
    – Hearth
    Commented Apr 30, 2017 at 13:11
  • 1
    \$\begingroup\$ And a quick search on digi-key shows that apparently, most of the DC power jacks they have have this feature. Here's a random example. You can just route the power flow from the battery through the switch in that connector, and it'll stop the battery as soon as you plug in the DC supply. However, this will make it not use the battery if the DC power supply is plugged in to the keyboard but not plugged into the mains. \$\endgroup\$
    – Hearth
    Commented Apr 30, 2017 at 13:21
  • \$\begingroup\$ Hi,thanks for the suggestion. I had seen those, it is more of a mechanical switch though, so as you mentioned if I just plug in the keyboard side it would still disconnect the power. Also I was was not able to find micro usb connectors with built in switches \$\endgroup\$ Commented Apr 30, 2017 at 13:32
  • 1
    \$\begingroup\$ I doubt that the battery topology in your keyboard is 2P2S (2x2), parallel cell connection is never used in long-term applications. In RC toys maybe, but not for keyboards. Can you double check the actual working voltage (inside the device) before designing something based on wrong assumptions? \$\endgroup\$ Commented Apr 30, 2017 at 16:53
  • 1
    \$\begingroup\$ a cheap 5v songle relay uses nothing when off. Put the pole on the KB, the battery on the NC, and the DC on NO+INP: adding DC will switch the relay to use DC, when it's removed, the relay closes and re-connects the battery. simple, safe, and effective. \$\endgroup\$
    – dandavis
    Commented May 1, 2017 at 1:01

2 Answers 2

1
\$\begingroup\$

I had posted an answer here before, but then I realized it was unnecessarily complicated and deleted it.

There's a simpler way to do what you want: a power multiplexer IC. The TI TPS2115A for example, will take care of everything for you. You can use it like this:

schematic

simulate this circuit – Schematic created using CircuitLab

A resistor between ILIM and ground can give it a current limit function as well. Here, I've shown a 400Ω resistor as in the datasheet examples, but tying ILIM directly to ground can disable current limit if for some reason you want that.

\$\endgroup\$
3
  • \$\begingroup\$ Why is this easier than using a pMOS. I appreciate the compactness of the single IC, but from what I found it would make it more expensive, with little benefit right? \$\endgroup\$ Commented Apr 30, 2017 at 16:55
  • \$\begingroup\$ Reliability. When there's an IC built specifically for the job you need, it's easier to use that and be sure it'll work well in the future than it is to use your own system that you're uncertain of. This also gives you the ability to limit current, and to manually switch the power source as well--you can switch to use the battery even if the power supply is plugged in, using the appropriate signals to D0 and D1. \$\endgroup\$
    – Hearth
    Commented Apr 30, 2017 at 17:00
  • \$\begingroup\$ Thanks to the suggestion by Ali Chan I realised that I actually have 6V coming in from the batteries, and the power multiplexors like the one you suggested all have a operating voltage up to 5.5V, so I'm not sure they would work in my case. \$\endgroup\$ Commented May 1, 2017 at 7:55
0
\$\begingroup\$

As mentioned, a mechanical relay is the second most simplest option, if you don't go with a manual switch or jack with a built in switch. The normally closed pole would go to the batteries. The normally open to the usb power. Also connect usb VCC to the relay coil. It will switch to USB when USB power is applied. Due to the small currents this would require, you could find some really tiny relays no problem.

\$\endgroup\$
8
  • \$\begingroup\$ here's an example i worked up for my comment: tinyurl.com/mnu3w7a \$\endgroup\$
    – dandavis
    Commented May 1, 2017 at 1:20
  • \$\begingroup\$ I guess? Of course you need a flyback diode as well. \$\endgroup\$
    – Passerby
    Commented May 1, 2017 at 1:25
  • \$\begingroup\$ where/why is a diode needed? \$\endgroup\$
    – dandavis
    Commented May 1, 2017 at 1:31
  • \$\begingroup\$ Reverse polarity across the relay coil. To dissipate the collapsing field that is created when the coil is energized. \$\endgroup\$
    – Passerby
    Commented May 1, 2017 at 1:33
  • \$\begingroup\$ oh, THAT diode... \$\endgroup\$
    – dandavis
    Commented May 1, 2017 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.