geekhack

geekhack Community => Keyboards => Topic started by: Manyak on Sat, 25 July 2009, 06:37:46

Title: Passive Adapters
Post by: Manyak on Sat, 25 July 2009, 06:37:46
So, I've been thinking. How does a keyboard - like a Filco for example - detect if it's connected to PS/2 or USB?

Is there like, a secret handshake or something? :)
Title: Passive Adapters
Post by: keyb_gr on Sat, 25 July 2009, 07:01:25
It seems like the microcontroller does that based on the kind of signals it sees.
Title: Passive Adapters
Post by: Manyak on Sat, 25 July 2009, 07:25:34
Quote from: keyb_gr;104276
It seems like the microcontroller does that based on the kind of signals it sees.


Yeah but like, what's the process it uses to check that signal?
Title: Passive Adapters
Post by: huha on Sat, 25 July 2009, 07:42:25
Sorry to disappoint you, but it's much, much simpler in reality.
The passive adapter just swaps GND and VCC, so the controller gets a negative voltage in PS/2 mode.

-huha
Title: Passive Adapters
Post by: Rajagra on Sat, 25 July 2009, 07:50:45
USB and PS/2 both have 0V and +5V power lines, so initial power up is no problem.

PS/2 has two open collector data lines, normally at +5V unless pulled low by a transmission.

USB has a differential signal carried over the two data lines, one will be near 0V, the other at 2.8 - 3.6V.

Monitoring the two data lines for a short while should reveal what bus is in use.
Title: Passive Adapters
Post by: keyb_gr on Sat, 25 July 2009, 07:55:09
Negative supply? No way. That would be a good way to blow up the chip.

From the EM78M611 datasheet:
Quote
The firmware checks the state of R7 [4,5]. If the state of this two bit is 0b00, set the
IOCA
  • to “1” to define the “USB mode.” Otherwise, set the IOCA [1] to “1,” to

define “PS/2 mode.”

R7 is the Port I/O register, basically reflecting the state of the I/O ports. Bit 4 is mapped to P74 / D+ / CLK while bit5 is mapped to P75 / D- / DATA.
Title: Passive Adapters
Post by: JBert on Sat, 25 July 2009, 08:36:34
Quote from: keyb_gr;104282
Negative supply? No way. That would be a good way to blow up the chip.
A modified diode bridge could be used to swap the polarity and bring some extra detection pin high, hence it's not impossible.

This design looks a tradeoff of hardware versus controller complexity/cost.