Maker Pro
Maker Pro

detect ps/2 mouse attached to a microcontroller

N

newssvr

Jan 1, 1970
0
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
 
L

Luhan Monat

Jan 1, 1970
0
newssvr said:
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
Mark,

One way to detect power draw is by using a PNP transistor as follows:

E - connect to +5 power
B - connect to mouse power feed
C - 10k to ground.

When the mouse is plugged in, the transistor is turned on. The voltage
at the collector goes to near 5 volts.

If there is any leakage in the transistor, you may get some voltage at
the collector without the mouse plugged in. In that case, try a
resistor from the Base to Emitter (1k - 100k) that keeps the transistor
turned off unless the mouse is plugged in.
 
Top