The project originated
from my need to switch between keyboards and mice on two computers. I looked on Taobao and found that USB 2.0 keyboards cost around 30-40 yuan, while USB 3.0 keyboards cost around 100 yuan. I thought I might as well make one myself, and I could also practice drawing on the tablet. Why not? For
hardware selection
, switching USB signals is easiest using a multiplexer chip. I happened to see a chip from Youxin on Taobao called TS3USB221ERSER, which can multiplex USB signals and is reasonably priced at 1.9 RMB.
Since I need to switch between keyboard and mouse, requiring more than one USB port, I also need a USB docking station chip. After browsing Taobao, I found a few options:
1. FE8.1 (1.1 RMB, SSOP16 package, expands to 7 USB ports, a bit too many (slightly expensive, but a backup option).
2. SL2.1A (0.39 RMB, SOP16 package, expands to 4 USB ports, just right (I'm very optimistic about this one).
3. CH334R (1.5 RMB, QSOP16 package, expands to 4 USB ports, also just right (good overall, but a bit expensive).
4. FE1.1S At 1.25 RMB, it expands to 4 USB ports, which is just right, but the package is SSOP28 (the package is a bit large and a little expensive).
In conclusion, the SL2.1S is the best choice, perfectly meeting my needs.
Additionally, I need to control the enable pin of the multiplexer to switch signal sources, and I can also use LED indicators to identify the signal source. This can be achieved using a PY32F002AL15S6TU microcontroller, costing only 0.45 RMB. A Cortex-M0 microcontroller also costs only 0.45 RMB, truly a bargain.
Attachments:
usbhub.zip (PCB project file; note: this is an AD project from LCSC EDA, lost due to hard drive failure;
input can be switched to expansion dock.zip; production files exported from LCSC EDA before hard drive loss, can be directly used for free board fabrication);
PY32F002xx_SWITCH_DOCK.zip (main control chip code, including chip library functions).