This port is very common and available at almost any PC, some Sun (at least Ultra 5/ 10, Blade 100/150) and many other computers. With description of how PC serial mouse works.
9 pin D-SUB MALE connector at the computer
|DB-9 Pin||IDC internal|
|4||7||DTR||Data Terminal Ready|
|6||2||DSR||Data Set Ready|
|7||4||RTS||Request to Send|
|8||6||CTS||Clear to Send|
* Pin assignment may be different for different motherboard manufacturers. Pin 10 removed in connector.
Sample serial port device. How mouse system works
Typical PC mouse controlling system has the following parts:
sensors -> mouse controller -> communication link -> data interface -> driver -> softwareSensors are the movement detectors (typically optomechanical) which sense the mouse movement and button swiches which sense the button states. Mouse controller reads the state of those sensors and takes acount of current mouse position. When this information changes the mouse controller sends a packet of data to the computer data interface controller.
The mouse driver in the computer received that data packet and decodes the information from it and does actions based on the information. Typically mouse driver has the information of the current mouse state (position and button states) and tells them to the application or operating when it asks them. Typically the mouse drive calls mouse cursor moving routines when mouse is moved and sends messages to the software when buttons are pressed.
In typical modern PC mouse driver the actual cursor movement is not linearly related to the mouse movement. This might sound a bit strange but it has been found that there are better ways to change the mouse movement to cursor movement than just simply causing one mouse step to move the cursor one pixel. During the pioneering research done at Apple Computer in the development of the graphical user interface (GUI), it became apparent that no particular ratio between mouse movement and cursor movement was best suited for all tasks.
Early work detected that there are two basic movements in the use of pointing devices: move cursor to desired area and then exactly to desired target. Those two movements have contradictory requirements, so Apple solved the problem by monitoring the mouse movements and change it"s CPI (counts per inch) characteristics. When the mouse was moved slowly it remained 100 CPI and when the mouse was moved fast it appears to be 400 CPI mouse. This method of adjusting CPI based on its usage has now been adopted by the default driver in Windows 95 and is now the most commonly accepted way of translating mouse movements to cursor screen movement
Mouse takes standard RS-232C output signals (+-12V) as its input signals. Those outputs are in +12V when mouse is operated. Mouse takes some current from each of the RS-232C port output lines it is connected (about 10mA). Mouse send data to computer in levels that RS-232C receiver chip in the computer can uderstand as RS-232C input levels. Mouse outputs are normally something like +-5V, 0..5V or sometimes +-12V. Mouse electronics normally use +5V voltage.
PC serial mouse uses typically DRT and RTS lines for generating +5V power for microcontroller circuit in the mouse. Because typical optomechanical mouse also needs power for 4 leds in the optocoupler movevement detectors, there is not much power to loose. A typical approach is to use diodes to take current fron DTR and RTS lines and then feed it through resistor to all of the (infrared) leds in the movement detectors. All four (infrared) leds are connected in series, which gives about +5V voltage drop over all leds (typical to leds used in moused). This +5V is adequate power for low power mouse microcontroller. The serial data transimitting circuit consists of simple discrete transistor circuir to make it consume as little power as possible. The positive power supply usually taken from RTS and DRT lines (just after the diodes and before the resistor going to leds). The negative supply for transmitter is taken from TD pin. Typical PC serial port mouse takes 10 mA total current and operates at voltage range of 6-15V. The data itself in sent using standard asuncronous RS-232C serial format:
Start D0 D1 D2 D3 D4 D5 D6 D7 Stop Logic 0 ___ ___ ___ ___ ___ ___ ___ ___ ___ +3..+15V | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logic 1 | | | | | | | | | | -3..-15V | |___|___|___|___|___|___|___|___|_
Microsoft serial mouse
Microsoft serial mouse is the most popular 2 button serial mouse type. Typically that cheap tho button mouse which comes with the computer is Microsoft mouse system. Microsoft mouse is supported in all major operating systems.
Mouse resolution and tracking rate
Maximum tracking rate for Microsoft mouse is 40 reports/second * 127 counts per report = 5080 counts per second. The most common range for typical mouses is 100 to 400 CPI (count per inch) but can be up to 1000 CPI (cheap ones typically are 100 CPI or 200 CPI models). This means that you can move 100 CPI mouse up to speed of 50.8 inches per second and 400 CPI mouse maximally at 12.7 inches per second. The actual accuracy of movement the software sees is detemined by the settings of the mouse driver (many mouse drivers have option to adjust mouse sensitivity).
9 pin25 pin Wire NameComments shell 1 Protective Ground 3 2 TD Serial data from host to mouse (only for power) 2 3 RD Serial data from mouse to host 7 4 RTS Positive voltage to mouse 8 5 CTS 6 6 DSR 5 7 Signal Ground 4 20DTR Positive voltage to mouse and reset/detection
RTS = Request to Send CTS = Clear to Send DSR = Data Set ReadyDTR = Data Terminal ReadyTo function correctly, both the RTS and DTR lines must be positive. The lines DTR-DSR and RTS-CTS must NOT be shorted. Implement the RTS toggle function by setting the RTS line negative and positive again. The negative pulse width is at least 100ms. After a cold boot, the RTS line is usually set to a negative level. In this case, setting the RTS line to a positive level is also considered an RTS toggle.
Serial data parameters:1200bps, 7 databits, 1 stop-bit
Data packet format:
Data packet is 3 byte packet. It is send to the computer every time mouse state changes (mouse moves or keys are pressed/released).
D7 D6 D5 D4 D3 D2 D1 D0
- X 1 LB RB Y7 Y6 X7 X6
- X 0 X5 X4 X3 X2 X1 X0
- X 0 Y5 Y4 Y3 Y2 Y1 Y0Note: The bit marked with X is 0 if the mouse received with 7 databits and 2 stop bits format. It is also possible to use 8 databits and 1 stop bit format for receiving. In this case X gets value 1. The safest thing to get everything working is to use 7 databits and 1 stopbit when receiving mouse information (and if you are making mouse then send out 7 databits and 2 stop bits).
The byte marked with 1. is send first, then the others. The bit D6 in the first byte is used for syncronizing the software to mouse packets if it goes out of sync.
LB is the state of the left button (1 means pressed down) RB is the state of the right button (1 means pressed down) X7-X0 movement in X direction since last packet (signed byte) Y7-Y0 movement in Y direction since last packet (signed byte)
Graphical description how the data is contained in the packet
1st byte2nd byte 3rd byte ================ =============== ================
- 1 ? ? Y Y X X - 0 X X X X X X - 0 Y Y Y Y Y Y
================ =============== ================
| | \ / \ / -——–/ -——–/
| | | |||
| | | -—\ ||
| | -——-|——-|——–\ |
| | / \ /———\ / \ /———
| | ================ ================= | | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Left Button –/ | ================ ================= Right Button —-/X increment Y increment
Mouse identificationWhen DTR line is toggled, mouse should send one data byte containing letter "M" (ascii 77).
Logitech extension to protocol
Logitech uses this same protocol in their mouses (for example Logitech Pilot mouse and others). The origianal protocol supports only two buttons, but logitech as added third button to some of their mouse models. To make this possible logitech has made one extension to the protocol.
I have not seen any documentation about the exact documents, but here is what I have found out: The information of the third button state is sent using one extra byte which is send after the normal packet when needed. Value 32 (dec) is sent every time when the center button is pressed down. It is also sent every time with the data packet when center button is kept down and the mouse data packet is sent for other reasons. When center button is released, the mouse sends the normal data packet followed by data bythe which has value 0 (dec). As you can see the extra data byte is sent only when you mess with the center button.
Mouse systems mouse
Serial data parameters:1200bps, 8 databits, 1 stop-bit
The data is sent in 5 byte packets in following format:
D7 D6 D5 D4 D3 D2 D1 D0
- 1 0 0 0 0 LB CB RB
- X7 X6 X5 X4 X3 X2 X1 X0
- Y7 Y6 Y5 Y4 Y3 Y4 Y1 Y0
- X7” X6” X5” X4” X3” X2” X1” X0”
- Y7” Y6” Y5” Y4” Y3” Y4” Y1” Y0”
LB is left button state (0=pressed, 1=released) CB is center button state (0=pressed, 1=released) RB is right button state (0=pressed, 1=released) X7-X0 movement in X direction since last packet in signed byte format (-128..+127), positive direction right Y7-Y0 movement in Y direction since last packet in signed byte format (-128..+127), positive direction up X7”-X0” movement in X direction since sending of X7-X0 packet in signed byte format (-128..+127), positive direction right Y7”-Y0” movement in Y direction since sending of Y7-Y0 in signed byte format (-128..+127), positive direction upThe last two bytes in the packet (bytes 4 and 5) contains information about movement data changes which have occured after data butes 2 and 3 have been sent.