Unplugging or re-connecting equipment to the serial COM or PS2 connector always gives problems if the PC is running. Even if you only need to swap a mouse or changeover from a graphics keyboard to a standard keyboard. The chances are that the connected equipment will not communicate with the PC, it will always be necessary to re-boot. If you are really unlucky you may have damaged the PC or the peripheral device.
n order to switch equipment successfully it is necessary to follow a sequence. The clock and data lines need to be disconnected from the device before the power line is removed. And likewise, the power line must be connected first to the new device before the clock and data lines are re-connected. This sequence is also used by the USB connector but achieved rather more simply by using different length pins in the connector.
The circuit shown here in Figure 1 performs the switching sequence electronically. The clock and data lines from the PC are connected via the N.C. contacts of relay RE2 through the bistable relay RE1 to connector K3. Pressing pushbutton S1 will activate relay RE2 thereby disconnecting the data and clock lines also while S1 is held down the semiconductor switch IC1B will be opened, allowing the voltage on C4 to charge up through R4. After approximately 0.2 s the voltage level on C4 will be high enough to switch on IC1A, this in turn will switch on T1 energising one of the coils of the bistable relay RE1 and routing the clock, data and power to connector K2. When S1 is released relay RE2 will switch the data and clock lines through to the PC via connector K1. It should be noted that the pushbutton must be pressed for about 0.5 s otherwise the circuit will not operate correctly. Switching back over to connector K3 is achieved similarly by pressing S2.
The current required to switch the relays is relatively large for the serial interface to cope with so the energy necessary is stored in two relatively large capacitors (C2 and C3) and these are charged through resistors R1 and R6 respectively. The disadvantage is that the circuit needs approximately 0.5 minutes between switchovers to ensure these capacitors have sufficient charge. The current consumption of the entire circuit, however, is reduced to just a few milliamps.
The PCB layout and component placement is shown in Figure 2 and is also available from the Elektor Electronics website. The PCB is designed to accept PS2 style connectors but if you are using an older PC that needs 9 pin sub D connectors then these will need to be connected to the PCB via flying leads. In this case the mouse driver software configures pin 9 as the clock, pin 1 as the data, pin 8 (CTS) as the voltage supply pin and pin 5 as earth.