how to detect the presence of ps/2 keyboard or mouse from microcontroller

Hello,

I am making a device that uses a (st9) microcontroller and i have the clock and the data lines attached to some i/0 lines on the microcontroller. The other two lines of a ps/2 mouse are thepower and ground lines and they are hooked to the same 5v power source as my microcontroller. The clock and data lines have weak pullups on them as per the way ps/2 mice and keyboards should be interfaced, so these lines are normally high unless me or the mouse decides to bring them low in the course of generating signals.

My question is this: how can detect if the mouse is attached to my microcontroller since the user could unplug or plug it in at any time?

Since the clock and data lines have pull ups they wont go low when the user unplugs the mouse.

Should i do it by detecting the current the mouse draws when it plugged in? I basically want to make this thing plug and play. But i am guess that since personal computers dont do this after all these years, that is simply is not doable.

I am a bit of a newbie when it comes to elecronics to i might be missing something obvious,

Thanks! ~ Mark

Reply to
newssvr
Loading thread data ...

formatting link

Take a look at the host commands on the above page. The host can send commands to the keyboard and many (all?) are acknowledged by the keyboard. If you don't get the Ack then you can assume the keyboard isn't connected or isn't working.

For example these commands could be sent to the keyboard...

Quote:

*0xF2 (Read ID) - The keyboard responds by sending a two-byte device ID" 0xEE (Echo) - The keyboard responds with "Echo" (0xEE). end quote.

In addition: Keyboards do a Basic Assurance Test (BAT) when they are powered up and when complete send a message to the host. You have to detect this anyway because you can't be sure the keyboard is listening until the BAT is completed.

Colin

clock

mice

unless

user

in?

simply

Reply to
CWatters

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.