 # How to use PS2 mouse's encoders to measure angular velocity?

I'm using library PS2.h to interface a PS2 mouse with my UNO. I do this to obtain sensor outputs from its 2 encoders. The mouse's controller is EM84510F.

My problem is that the outputs are X and Y values. As a matter of fact, I don't care about the translational movement of the mouse, but the angular rate of the encoder wheel shaft. Anyway, looking up in the data sheet of EM84510F, I couldn't get any piece of info which telling me what the unit of X and Y is. Without understanding what X and Y really mean, I can't relate their values to the angular velocity.

There're some information I got from the data sheet: -Resolution: 2 dot/count---> I didn't understand this "dot/count" and not sure whether "dot" or "count" relates to X and Y values. -Sampling rate: 100/s. (These are the default values. Though according to the datasheet, I should be able to change the resolution : 1 ,2 ,4, 8 dot/count, or the sampling rate(Need 2-byte long for the argument). But the mouse.write() function built in the PS2.h library just has one byte-long argument.)

This is a piece of result sent to Serial monitor while I'm rotating the shaft. 1000 X=0 Y=0 1000 X=0 Y=0 1000 X=0 Y=0 1000 X=0 Y=0 11000 X=-2 Y=0 11000 X=-3 Y=0 11000 X=-2 Y=0 11000 X=-2 Y=0 11000 X=-1 Y=0 1000 X=0 Y=0 1000 X=0 Y=0 1000 X=0 Y=0 1000 X=0 Y=0

Hope someone being experienced with encoders could help me! Thanks!

The X and Y there would be refering to the two directions that the device measures, and not the X-Y coordinate position.

The "count" is the number being returned. The "dot" is some unit like a pixel.

So where you get a number like X=-2, it would mean the device moved two "dots" to the left during the last 1/100 second period. If it is zero, means the device is not moving.

So X=-2 means it is moving at -200 dots per second during that time interval. Divide by the radius of the ball ( measured in dots ) and you have the angular velocity of the ball in radians/second.

Thanks for your answer. Anyway, I suppose that X and Y mean the coordinates cursor would have on computer's screen. And the unit is measured by "dot" or "pixel" as you said. Of course, it's just the relative coordinates, so after every new movement, a new pivot (origin) is set, and the new coordinates are taken in reference with the new pivot.

I have a question. How can you measure the radius of the ball in dot?

I did think about a solution that I first convert from the number of dots to the number of counts . Then divided by the number of slots on the encoder wheel, I may obtain the angular velocity. But I realized the values of X and Y should have been even number, cuz the resolution is 2dots/count, while you can see they're both odd and even.

Anyway, I suppose that X and Y mean the coordinates cursor would have on computer's screen.

No, it is not a coordinate position. It is just the direction. X means left and right. Y means up and down. If you look inside the mouse, you will see two separate mechanisms measuring the position of the rotating mouse ball.

The mouse doesn't know anything about your computer screen. The pointer on the screen is controlled by the screen display software, not the mouse. The mouse only knows how it is rolling around your desk. The mental illusion of the link between the mouse on the desk and the pointer on the screen is actually a remarkable invention that everybody takes for granted.

To answer your other question, you'd have to find out what a "dot" is. Someone must know, I don't. It's probably 1/100 of an inch or 1/72 of an inch, or something. I had an early 80's book on how this stuff actually works, but I can't find it right now. Do an experiment. Move the mouse exactly one inch, and add up how many dots that it reports it has moved. In your previous experient, your mouse moved 11 dots to the left in 5 hundredths of second. How far did you move it ?