 |
First, let me thank Dave Watson, his I2C driver was the trigger.
I was really fascinated when I saw it and started to search for other
serial devices. I still use some lines of his code.
A very nice device is the TLC548/549, a serial ADC, you can read more about
it on my homepage. Another well known chip is the temperature sensor LM75.
And now comes the PS/2 mouse.
Elektrische functie
A PS/2 mouse has 4 pins: GND, +5V, Clock and Data. This means it uses a 2-line
serial protocol, and that's exactly what the calc's link port can cope with.
All you need to connect the mouse to your calc is some wires and a power
supply.
Don't ever think of powering the mouse from the link port! This may
work with some very small devices like the LM75, but not with a mouse!
You need to connect:
- pin 3 of the mouse to the base of the link port cable
- pin 5 of the mouse to the middle of the link port cable
- pin 1 of the mouse to the tip of the link port cable
- a power source to pins 3(GND) and 4(+5V)
I don't know what the limits for the power supply are, but if you don't
have 5V you should try 4.5V, the equivalent of 3 batteries. The mouse may
show improper reactions when using a voltage other than 5V, though.
The picture below also shows this. Look at the link in the next paragraph if
you're not sure where the pins of the PS/2 connector are located.
 (Click image to enlarge)
I opened a mouse and found some protection diodes in it, so you have more than
one chance if you mess the pins up.
Logische functie
Simply connecting the mouse to your calc is not enough, we need to know the
protocol, or better: protocols.
The first one is the PS/2 protocol itself. It's very well described
on this page, so I don't repeat it here.
But unfortunately, the knowledge of this protocol is not enough. If you
power a PS/2 mouse and look at the serial pins (e.g. with an oscilloscope)
you probably see nothing. The mouse has to be initialized.
A good point to proceed now is to look the the mouse driver that comes with
Linux, the file mice.c is the interesting one. If you search for the
function I_imps2 you can see the initialization sequence you have to send
to a mouse which understands the Intellimouse PS/2 protocol. After sending
these bytes to the mouse it should start sending by itself if you move it
around.
Het program
I've written this small demo program the day after I discovered that I got
the mouse working with my calc, so don't expect too much, it's just a demo.
After powering the mouse and plugging it to the link port you can start the
program. You now have to perform the following steps:
- Press '1' to send the initialization sequence to the mouse. The program
sends 13 bytes, and you should receive a message that 13 acks have been
received.
If there are 13 acks it is very likely that the mouse works, but it's not
guaranteed.
If there are less than 13 acks the mouse may still work, but only in
rare cases.
If there's no ack message at all then the mouse does not generate clocks
and the program hangs. In this case you have to short cut the base and
middle part of the link cable a few times to simulate the clocks.
Note: this does neither harm your link port nor the mouse.
Update: you can now press a key that is in the first row of the keyboard
matrix (e.g. the arrow keys); the left arrow key should always work and
exit from raw or pointer trace.
- After this succeeded you can press '2' or '3' to see either some bytes
rushing on the screen or a pointer moving. You can leave this by pressing
ESC and moving the mouse.
Update: pressing ESC should be sufficient now, the mouse doesn't need to
be moved, this was a bug in the old version.
If the calc seems to hang here you have to make short cuts as described
above while pressing ESC. This can be a bit tricky, so I strongly
recommend you to make a backup of your calc before!
Update: see above, press the left arrow key to leave.
The menu entry 4 is for accessing the link port directly (only setting the
lines, not reading it), so this may only be useful if you have an
oscilloscope.
I have tested this program successfully with an A4Tech 3D Mouse. A Logitech
Pilot Wheel Mouse refused to work properly, it gave 13 acks for the
initialization sequence, but didn't send bytes when moved.
Software
Now you need some software to get this mouse device working.
Download this file: ps2demo.zip (contains TIGCC source, precompiled binaries for 89/92 and documentation)
Auteur:
Stephan Effelsberg
b012414@dvz.fh-koeln.de
http://www.dvz.fh-koeln.de/~b012414
|
| |