1
\$\begingroup\$

I am planning to modify a wired keyboard to use a wireless connection, using the HID Relay project (YT, GitHub) as the communication method, along with a LiPo battery, with accompanying charger and booster (for simplicity's sake, I will refer to the charger/battery/booster/HID Relay combo as just HID Relay from now on).

Thing is, I still wish to use the keyboard using just a cable, in case of a low battery or the device where I want to use it doesn't have Bluetooth capability.

All those components will be inside the keyboard, with just the USB female connector and the switch being exposed.

1st version (Works partially)

My idea is to, instead of using an USB switching IC, just route the power line between a direct connection to the keyboard and the power input of the HID Relay, along with a option to just charge the battery.

I read from this article that power can be joined by using diodes.

Here is a (rather crappy, sorry) diagram for it: USB power switcher circuit (The HID Relay was condensed as a component for simplicity's sake)

My questions are:

1) Is this schematic correct? As in, is there something placed improperly?

2) On the 3rd position (Charge and Bluetooth enabled), in case of plugging the cable to a device that can interact with the keyboard, how can be the data pins from that source can be suppressed?

Here's what SW1 will do:

Position 1) Direct mode - pass 5V directly to the keyboard. In circuit 2, powers the IC to pass the data pins through.

Position 2) OFF / Charge only - Only the battery charging IC will receive 5V from the input USB port.

Position 3) BT mode - Allows for battery charging, while connecting the internal battery to the booster circuit (the 2nd connection set on SW1) that in this case, powers the HID Relay circuit.

Thanks in advance.

UPDATE: This version would not work in the case of, while using BT mode, a usb connection to a PC would interfere in the data lines shared by the HID Relay

2nd version (not tested yet)

Here's a version using a switch IC: 2nd version

Another thing: I would prefer to not use a switching IC because they would be the only component not available locally.

This version is not tested as I don't have the IC in hand

3rd Version (UPDATE: Does not work)

Instead of the USB-specific IC, this version uses a 74HC157 selector IC, which is more accessible to me.

Sadly this version does not work, as the IC data lines are not bidirectional.

3rd version

4th Version (Works as intended)

After checking the problem with version 3's data direction, I tried to use a combination of a inverter and an analog switch ICs (that I had lying around) to block the unwanted case of the external USB data lines interfering while the HID Relay was active. This seems to work perfectly.

Also, the physical switch used (3 positions, 6 terminals) guarantees that the VBUS line is cut while changing modes.

4th version

As the ICs are just what I had at the moment, the inverter IC could be any that have at least 2 channels.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ why do you need a USB switcher? ... just build the bluetooth device into a small enclosure with a female USB-A connector ... then you can plug in the keyboard \$\endgroup\$
    – jsotola
    Apr 13 '20 at 1:26
  • \$\begingroup\$ The intention is to put all those components inside the keyboard's enclosure, as I already assessed that there is space underneath the PCB. Will update the question to point this out. \$\endgroup\$ Apr 13 '20 at 12:25
0
\$\begingroup\$

Not totally sure what you're trying to do but... You can't be connected to two USB endpoints at the same time unless you can ensure one is not active. You probably need an analog switch here to choose the connection. Also, Vbus signals that a device has been connected. No Vbus no talking. Also Vbus can be dropped to reset the connection for whatever reason. But if your Vbus is coming from somewhere else then it won't see the Vbus break and won't reset. I've been working on a USB project for a few months now and have learned the hard way but it's all in the specs.

\$\endgroup\$
4
  • \$\begingroup\$ So there's no simple way (aka no ICs) to suppress the two data pins from the input USB port when using the HID relay as the connected device? I will add a 2nd version using a switch IC to the post. \$\endgroup\$ Apr 13 '20 at 14:56
  • \$\begingroup\$ Also, in regard to VBUS, "direct mode" is in SW1 position 1, while "BT mode" is in position 3, so switching between them will interrupt VBUS while passing by position 2 (that's when EN/BAT pin on HID relay will be open and the HID Relay proper will not be powered), so the reset behavior should be kept. \$\endgroup\$ Apr 13 '20 at 15:00
  • \$\begingroup\$ New schematic looks better. Your R1 is wrong though. I think you meant to tie one end of R1 to gnd. \$\endgroup\$ Apr 14 '20 at 14:14
  • \$\begingroup\$ Right, R1 is meant to be a pull-down input for the IC. Also I found a more accessible IC and made a new version with this IC and the corrected pull-down pin. \$\endgroup\$ Apr 15 '20 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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