Use a Sun Mouse Systems Optical Mouse on a PC

The classic Sun Optical Mouse

Optical mice, computer pointing devices with no little moving balls or wheels, seem to be all the rage these days. I first saw an optical mouse back in the late 80's, attached to a Sun workstation. Unlike some of the recent optical mice, the "Sun 4" mouse by Mouse Systems disussed here requires a special metal optical mouse "pad".

photograph of Sun-4 mouse by Mouse Systems

I always liked the sun mouse, although I won't say it was my favorite. Since I had the mouse mouse and matching pad in my junk pile, I decided to investigate if it could be used on a current PC. It turns out that the adaptor is fairly simple. What follows is a detailed description of the connector, an outline of the protocol, and how to build the adaptor to allow use of this classic mouse on today's PC.

photograph of Sun mouse and connector

At first glance, the connector on the Sun-4 mouse's tail looks similar to that on a "PS/2" mouse. But its not: the Sun-4 mouse has an 8-pin mini-DIN connector, while the PS/2 mouse/keyboard connector has 6 pins.

The pinout of this connector is widely described on the web, but the electrical signaling details for the Sun mouse are not so widely known.

Figuring out the electrical Signaling

To start reverse-engineering the signaling, we build an adaptor to let us conveniently plug the 8-pin mini-din connector into a solderless breadboard. Since I had PCB-mounted 8-pin mini-din female connectors in my junk box, I attached one to a DIP header.

Breadboard setup I connected a 5v power supply to pins 3 and 8, with ground on pin 1 and 2, and noticed that the red LED in the mouse lit up. But no data stream was observable at pin 4. It was time to take a look inside the mouse.

Mouse Guts

Interior of Sun Mouse Removing two screws lets the top cover lift off. Notice the two mirrors on the inside of the top cover, and the spherical lenses below the PC board. The lenses are only held in by the board, so be careful not to lose them if you decide to disassemble your mouse.

Notice also the paper-and-foil shield which is the only connection to the braided outer conductor of the cable. This probably provides both EMI shielding and a path for electrostatic discharge - notice how the foil shield folds up near the buttons. When a charged finger approaches the mouse, the static shock will probably go to the foil shield, and not jump over to the electrical connections and cause damage or unintended operation.

Besides the shield, there are only three wires in the mouse cable. For completeness, here is a table of how they are wired:

Din-8 pinwire color3-pin connectorfunction
shieldbare braidto foil shield onlyESD/EMI shield
2black1power supply ground
3brown2+5v power

Partial mouse schematic Since the board is single-sided, it is quite easy to trace out the relevant part of its schematic. I've omitted the connections from the buttons and optical sensors to the processor chip. Nothing particularly surprising here. The circuit reveals why we didn't see any data stream - the output is driven by an open-collector 2n3904 transistor, obviously expecting the far end to provide a pullup resistor.

Oscilloscope Photo of Data Stream Once we add a pullup to our breadboard, we see a data stream on the scope. Carefully pushing a mouse button without moving it yields the scope trace shown here, which appears to be smallest unit of data it can send. When the mouse is still, the data stream stays at 0 volts. Bits are sent by turning off the transistor to let the pullup raise the signal to the higher voltage.

The smallest pulse seen in the trace is about 840 microseconds; the reciprocal of that is almost exactly 1200 bits per second. The pattern of the bits is consistent with the teletype-style asynchronous serial data format sent by the common PC uart, if we assume that idle, "mark," or 1 is represented by 0 volts, and "space" or 0 is represented by a more positive voltage.

A little web research shows that many PC "serial" mice operate at 1200 bits per second, and that there is a "five byte mouse systems protocol." Mouse links:

That trace on the scope sure looks like it could be a sequence of 5 serial bytes. Indeed, the bits near the left change when different mouse buttons are pressed, and seems to match the specification where the button bits are in the first byte.

While a signal that swings between 0 and +5 volts isn't quite legal RS-232, it is good enough to be accepted by most PC serial ports. Once we hook it up, we find that it works - we're getting 5-byte packets.

Screen capture showing hex bytes

This hex-mode screen capture (from sgsterm) shows the result of pressing and releasing the left button: 10 bytes total, in two groups of 5.

Testing with GPM software

To confirm that existing software can interpret the byte stream without requiring a special driver, we try to fire up the linux console mouse tool, GPM. I used these commands:

gpm -k                             # shut down any existing gpm process 
gpm -b 1200 -m /dev/ttyS12 -t msc  # run gpm for mouse-systems mouse

Users that other PC operating system will have to dig up a serial mouse driver for the Mouse Systems 5-byte protocol.

Building a permanent Sun Mouse to PC-Serial adaptor

Given that it works, I designed and built a more permanent adaptor cable assembly to give this old rodent a serious trial on a 2005 linux machine.

The biggest problem is getting power for the mouse. My multimeter says that the mouse draws 28 milliamps of +5v power, which is more than we can steal from a PC serial port. The typical RS232 port's control lines limit their current to 10mA, so even using both DTR and RTS together doesn't provide enough current. I actually tried, but the supposed "12 volts" of the RS232 control lines fell to 4.25 volts when powering the mouse. (While trying this I used a 5.1v zener diode to prevent excessive voltage from damaging the mouse in case the port actually could supply enough voltage.)

So I resigned myself to using two connections to the PC, one for power, and the other to the serial port. I borrowed +5v from the 15-pin game port; drawing power from USB or PS/2 mouse connectors also would have been a possibility.

Schematic of Adaptor Cable A schematic of the adaptor cable assembly is at the right. We're pulling up the mouse data output with the serial port's transmit data output, which results in a slightly higher signal voltage than would pulling up to the +5v power supply.

For safety, I always use a current-limiting device when borrowing supply current from a PC to power an external device. A typical PC power supply can source as much as 20 amps of +5v, plenty enough to melt small-diameter wires, vaporize tiny PC-board traces, or even start a fire if you're particularly unlucky.

Here, I'm using a "self-reseting fuse," a positive-temperature-coeficient thermistor. At room temperature these devices have a very small resistance, but draw too much current and they heat up, which causes their resistance to rise dramaticly. This limits the short-circuit current to a safe value. I used the MF-R030 from Bourns, purchased from Digi-Key. They're available in a variety of current ratings; this one is designed to carry 300mA and trip at 600mA.

The finished adaptor cable

Photograph of D-Sub ends of Adaptor Cable I've used shielded twisted pair cable for both power and data connections, and been careful to connect the shield throughout but keep it seperate from the power-supply return "Ground". Since my junk box only had plastic hoods for the DA-15 and DE-9 connectors, I used a bit of copper foil tape to connect the shield wire to the connetor shell. This photograph shows both D-sub connector ends, with the PTC "fuse" in the game-port DA-15, and the pullup resistor in the RS-232 DE-9.

Photograph of Mini-DIN-8 end of cable Wiring the female mini-din was interesting because I only had a PCB-mount jack available. I began by cutting off the pins I didn't need to get them out of the way. I then soldered a loop of 18-guage solid wire to the shield tabs, to use as a handle and strain relief.

Pins 3 and 8, for +5v, are far apart, so I jumpered them with wire-wrap wrie first, and then soldered the power lead to pin 8. Pins 1 and 2, for power-supply ground, are adjacent so they were relatively easy.


Comming soon: Impressions after using this mouse for a while.

Complete Photo Album

All photographs from this project are in the Album