Today, if you ask somebody what kind of mouse they need, they’ll probably be thinking
they need to pick between USB or Bluetooth.
But 30 years ago there were quite a few other standards including Microsoft Bus Mouse, IBM
PS/2, Sun Microsystems, Apple ADB, and Tandy..
And at least all of these guys used the different connectors along with different protocols.
But, then you also had serial, Commodore, Amiga, Atari, and the older Macintosh standards
which all used the same 9 pin connector, but were entirely incompatible electrically speaking.
But it isn’t so much the interface that I want to talk about today, but rather the
mechanics of how a mouse interprets motion.
The original mouse design back in the 1960s was a block of wood.
It had two perpendicular wheels on the bottom to register motion in both directions.
Of course, this meant that no matter which direction you were moving the mouse, it was
dragging one of the wheels sideways, which meant movement probably wasn’t super smooth.
Moving forward into the early 80s, I want to show you another design.
This Tandy mouse uses a stainless steel ball.
Let’s open it up so we can see how it works.
Here’s the ball.
It’s designed to be heavy so that it makes good friction with the surface.
You can see it uses two rollers on the ball for X and Y motion.
These rollers are connected to potentiometers.
And much like a potentiometer on a volume knob, they actually have a limited range of
motion.
To better illustrate what I am talking about, I’m going to draw some lines on the roller
here.
This is just to help you see the motion, especially for those watching on a small screen.
So, hopefully you can see the movement of the roller really well now.
So if you look closely, you can see that as I move the mouse, at some point the roller
will stop moving.
And you might just think there isn’t enough friction to make it move, but I’ll actually
remove the ball here and show you.
I physically cannot move the roller any more in this direction.
So, using this sort of mouse could be a pain.
Imagine drawing a box around your mouse and saying that you can never move the mouse outside
of this box AND you can never pick the mouse up and move it either.
So, yeah, that’s a pretty annoying design.
So, let’s have a look at the next step in evolution.
This mouse uses what appears to be a rubber ball.
But actually it’s a steel ball coated in rubber.
So it has the weight required, but the surface has more friction.
And again, we have rollers but this time there are no potentiometers.
Instead, there are these little wheels.
And on each side of the wheel, you may notice there are sensors.
These are actually optical sensors.
They aren’t cameras as such.
They either detect the presence or absence of light.
So as the wheel spins these two sensors receive input about the movement.
They can even tell the direction of movement depending on the order of the flashes of light.
Later on this design was cost reduced in most mice and instead there is what appears to
be a single sensor.
But all of they’ve done is moved both sensors to the same device.
So, as you can see it still works on the same principle.
But what does the mouse actually see.
Well, if you think of it as having 4 pixels, downward motion would look like pulses of
light like this.
And upward motion would look like this.
Move to the right, and you’d see this.
So, you get the idea.
So this sort of mouse is actually called an opto-mechanical mouse, because it incorporates
optics and it is also mechanical.
Of course, one big problem with these types of mice is that the rollers get gummed up
with crud over time and then they don’t work smoothly anymore, or sometimes don’t
work at all.
The average person seemed to have no idea how to properly clean the mouse.
Most people thought the ball was what got dirty, so they’d try to clean the ball,
but that never seemed to make it work better.
The real problem, was the rollers.
Crud would build up on these and need to be mechanically scraped off the rollers in order
to get the mouse working smoothly again.
And that’s where the benefit of an optical mouse comes in.
So let’s have a look at one of the first optical mice.
Actually, two of them.
These are the same mouse being sold for PCs and for Sun workstations.
In fact, turn them around and you’ll see both are manufactured by Mouse Systems.
The main difference of course is the interface style at the end of the cable.
But we’re really not interested in that at the moment.
The interesting thing about these optical mice is that they require a special mouse
pad.
It’s a bit hard to see, but this pad is a grid.
In fact through the help of a magnifier, hopefully you can see a bit better.
Actually, this pad is meant for a later Sun mouse like this one.
And thus it is incompatible with the mouse I’m actually showing.
But these pads are really hard to find as it is, and the older ones are practically
impossible to find.
But the main point was just to show that it needed a special pad.
Now, if we turn it upside down, you’ll notice there are two lenses but only one of them
is lit up.
You might be tempted to think that one of the LEDS is burned out, or maybe it only uses
one of the holes.
But, let’s take a look with a gameboy camera.
Mostly, I just wanted a quick way to look for infrared light.
And sure enough, you can see there is plenty of light coming out of the left side as well.
So how does this work?
Well, the pad is designed with reflective lines like this.
However, one set of lines is only reflective to infrared light, and the other set of lines
is reflective to red light.
So depending on which light source is used, only horizontal or vertical lines will appear.
And so that’s the magic here.
Let’s take a look inside the mouse.
Now, what we’re looking at here is a red LED and an infrared LED.
These are both facing down towards the pad.
There are two identical lenses here.
I know one looks RED, and that’s because we see the light from the red LED.
And then you’ll find a horizontal sensor and a vertical sensor.
And notice they are designed to pickup light in the form of a line and they are tuned perpendicular
to each other.
But how does the light reach the sensors?
Well, if you look at the inside cover of the mouse you’ll find two mirrors, and these
reflect the light down onto the sensor.
And to some extent, if you look down at these lenses while I move the mouse on the pad,
you can actually see the lines.
Now, if I had the correct pad for this mouse, the lines would be even more visible.
Anyway, the point is, believe it or not, this mouse sees more or less the exact same thing
that the opto-mechanical mouse sees.
So now, let’s move onto a more modern style optical mouse.
These do essentially have a camera in them, that looks at the surface.
But I wanted to see if it would be possible to hack into the camera and see exactly what
it sees.
And so here we go.
So, what are we looking at here?
This is the sensor.
We’ll talk more about this in a moment.
Here’s the LED that lights up the surface.
And this is a micro controller.
It’s job is to read the movement information from the sensor, also read the status of the
buttons and scroll wheel, and translate that into a PS/2 compatible data stream.
For the purposes of this hack, it was really important to find an older mouse with these
two items being separate.
In newer mice, they have combined these things into a single chip to reduce cost.
So in a newer mouse, the buttons would connect straight to this chip, as would the PC interface.
Well, with the separated design, it makes it possible for me to talk directly to the
sensor.
First I’ll need to see if I can find the chip number.
This is one of those chips where you have to look at it just the right angle to see
anything.
And with the help of a magnifying glass I was able to read it.
And fortunately, I was also able to find a datasheet.
This is a must as it explains exactly how the timing of the serial protocol works, as
well as what registers can be read and written to.
At this point the plan is to simply remove the micro controller.
And the easiest way for me to do that is just to cut the legs off, and then desolder them
one by one.
Then I used a multi-meter to figure out which wires went to the PS/2 connector, and which
ones went to the micro controller.
I made myself a little digram on a piece of paper.
The idea is, I can keep the existing wire here for power, ground, and 2 of the serial
lines.
Unfortunately, I realized later this serial connection requires 3 wires, so I had to run
a separate wire for that.
Anyway, for the moment I just added some jumper wires to connect the serial port of the sensor
straight up to the old PS/2 wires.
I decided to use the color maximize 2 for this project since it was still handy from
my recent project.
It took me a few hours to get code up and working.
But the idea here is I’d be able to display the camera image right on the screen.
Much easier to do here than with an Arduino.
The most basic test was to get to the point I could read and write registers.
So in this case, I’ll write to register 58, and a value of 90, which means to reset
the sensor.
My program actually shows onscreen the binary data transmitted one bit at a time over the
serial line, which helped me in troubleshooting.
The next thing I can do, is read a register, such as register zero.
This returns the version number of the sensor, which according to the data sheet should always
be a value of 12 hex.. which is 18 in decimal.
So, I’ve mastered reading and writing to the sensor.
You’d think all I need to do now is read register B here, which is pixel grab.
There are only 224 pixels, so don’t expect a super high resolution image.
I also have to read these pixels one at a time by requesting a specific pixel to read.
And here we go.
I have good news and bad news.
The good news is, it does work.
The bad news is, I could only ever read the first pixel correctly until I introduced a
50 millisecond delay between reads.
I’m not sure why this was necessary.
But it does mean that it takes a while to grab the entire sensor.
I was hoping to be able to show fluid motion.
Anyway, so you might wonder what it is we’re looking at here.
Well, it’s that Sun grid style mouse pad.
Unfortunately, the sensor is fixed on a very tiny area, almost microscopic.
So, I had a hard time finding anything to show you that you could actually recognize.
But anyway, it does work.
And if I move the mouse just a hair, you’ll see the image redraw just a bit as well.
And so that about wraps it up for this episode, but if you stick around for the next one,
I’m going to be showing off this little mini-PET, which I’m really excited about.
So, I hope you stick around for that, and of course thanks for watching!