Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Modified use of an optical mouse

Status
Not open for further replies.

bsodmike

New Member
Hello all :)

I'm thinking of modifying an optical mouse so that it measures the distance travelled. Ignoring what comes out over the PS/2 or USB connection do you guys have any idea what comes out on the bit stream.

Would it be incorrect to say that the mouse sends a signal (between 0 - 256) that represents the accelaration of the mouse 'pointer'?

My biggest problem is getting my head around the task (in coding terms) of relating this reading to a real world scale (meters for example)...

I'm thinking of looking at it this way:

(1) Take samples of this 8bit reading at regular intervals and measure the time taken from starting point to destination (in real time). There by calculating average distance travelled by applying s= ut + 1/2at^2

(2)

Any ideas and comments would be greatly appreciated :)

--Mike
 
a ps/2 mouse sends data that represents the distance traveled in the last set amount of time (some number of milliseconds, i forget the exact amount)

all you'd have to do to change that to actual distance moved is multiply it by some constant factor, which you would probably have to find experimentally, since all mice would have different levels of sensitivity.

I've done a project using a ps/2 mouse that implemented some features very similar to this... I'll try to give some more info later, I have to get to class now ;)
 
Hey dude :)

Wow that would be awesome. I would like to also try and see how it would work via USB (no lock, just a data signal) and see which would be easier and see if adapting it would be any harder.

Where did you find out 'what' the mouse exactly sends out? I've looked at the datasheet for USB but no luck...

Thanks, Mike
 
I'm curious, why you want to use USB?

using USB would be unnecessarily complex... PS/2 is a very simple data transmission scheme (similar in complexity to synchronous RS232) and is only intended for keyboards and mice, so it's a simple job to decode it... and there's really no overhead, because it's pretty much just direct serial data. (my routines for PS/2 communication on a PIC are some pretty simple C code, nothing very fancy at all) not to mention, you can easily find all the information you would ever need on PS/2 communication in just a couple minutes of google searches.

with a USB mouse, it would (presumably) interface with a PC appearing as a human interface device, which the computer would then recognize as a mouse and deal with accordingly... however, to actually use one in your project, you would have to deal with all the overhead of the USB communication, including recognizing the device, configuring things, and then maintaining USB communications. the actual data transmission would probably be just a small part of the complexity of the communications link.
not to mention, you'd probably have a harder time finding information on interfacing a USB device with a microcontroller, than having a microcontroller appear as a USB device to a computer. if you are curious, try searching google for using a PIC as a HID (human interface device) on the USB port and see how much work is involved...

Bear in mind that USB mice can generally be used as PS/2 mice as well (with those little usb-ps2 adapter plugs that they usually come with), and I would imagine those are nothing but wiring inside... so presumably the mouse detects from the state of the data/clock lines whether it is connected to a USB or a PS/2 port, and sets its communication mode accordingly. in this case, even if you wished to use a USB mouse simply because they're becoming more common, you should still be able to use it without having to deal with the headache of USB communications.

*edit: here's the two pages that were pretty much everything I needed to know for doing my PS/2 communication routines:*
one describing the actual communication protocol:
**broken link removed**
and one describing the data that the mouse sends, and how to control it:
**broken link removed**
 
Thanks a lot for that but the reason for considering USB as well is that either way both would hook up to a PIC where I grab the info off the D+ and D- lines. Sorry if I wasn't clear here, either case the mouse would interface with a PIC which would handle the task of 'figuring' out how far the mouse has traveled...

Still I feel that I'll go with a PS/2 mouse or if I end up with a USB rodent I'll stick a PS/2 adaptor on the end...

Thanks a lot, this is what I was looking for :)

--Mike
 
I thought it would be interesting to increase the focal length of an optical mouse, so it could operate an inch or so away from the surface. Optical mice have a very low-resolution (16x16 pixel) but fast scanning camera with a fixed lense focused for use with the mouse resting on the surface. So it should be possible to change the focal length and allow the mouse to operate at much greater distances, assuming lighting was good and vibration was low.

Another idea is to use a notebook touchpad facing towards the surface. That should work much better on uneven surfaces. I have an external PS/2 ALPS touchpad I bought around ten years ago that is perfectly suited for that type of thing.

Dan East
 
Dan East said:
Another idea is to use a notebook touchpad facing towards the surface. That should work much better on uneven surfaces. I have an external PS/2 ALPS touchpad I bought around ten years ago that is perfectly suited for that type of thing.

I don't see how that could work. typically touchpads are capacitive sensors, set up as an array of crossed wires, and by introducing your finger near them you change the capacitance between the wires in a certain area (or depending on the design, by pressing on the surface with any object you deform it enough that the proximity of the wires changes, changing the local capacitance as well)
by placing it face down on a surface, it wouldn't have anything to detect, as the capacitance change due to the surface would most likely be uniform enough to be insignificant... in theory, it could be done by using it on a mousepad that had some sort of objects embedded in it, like metal pellets, at regular intervals, however typical touchpads are designed to track one finger, not multiple objects, so you'd probably have to rip out the controller and design your own from scratch if you wanted to try that...
 
Yea, I'm going to have to look into lenses and how I can go about increasing the sensing distance and also ensuring a decent DOF which would mean adequate lighting. I'm hoping to increase the distance between lens and surface to about at least 10 - 15cm...

Of course I'm not too sure how this would affect the 'resolution' of the sensing. i.e. if set to 8 counts/mm after changing this would it be a 'linear' increase? This would probably boil down to experimentation.

Thanks :)
 
wow... that sounds like a big challenge... good luck I guess!

you're probably going to need some serious light, as bear in mind that in an optical mouse, the surface is lit by that blinding red LED all the time in very close proximity, so you'd probably need to provide a similar amount of illumination on the surface to be sensed...

just curious, but what are you using this for that requires such a large sensing distance?
 
Yea, it might be a problem...Well the reason for this is because the little robot will have to move in a fashion that it avoids obstacles (underneath) so having this right next to the floors surface will not work. Maybe a cluster of say 10x 10000mcd red LEDs would do the trick...

Will have to see...thanks :)
 
I really think you're going to have a huge problem with angles.

in a mouse, the "camera" is purposely kept perpendicular to the surface at a specific distance, by having it firmly mounted and having the mouse slide on 4 feet, keeping it flat. if you're trying to sense at 10-15cm, it seems unlikely that you will be able to keep the sensor perfectly perpendicular to the ground (unless your robot has solid wheels, no suspension, and is riding on a nice smooth surface at all times) in which case a slight change in the angle of the sensor could produce a pretty significant displacement of the spot that it is looking at on the surface, which would result in the robot having a tougher time keeping track of where it was... i suppose that over time, wobbling back and forth would average itself out somewhat, but then you have to start dealing with accumulation of error... if used for short-term navigation, like sensing the speed and direction of its own movement, it would probably be pretty confused by thinking it suddenly slid sideways several centimeters and then back, when one of the wheels runs over a bump.
 
bsodmike said:
Yea, I'm going to have to look into lenses and how I can go about increasing the sensing distance and also ensuring a decent DOF which would mean adequate lighting. I'm hoping to increase the distance between lens and surface to about at least 10 - 15cm...

Of course I'm not too sure how this would affect the 'resolution' of the sensing. i.e. if set to 8 counts/mm after changing this would it be a 'linear' increase? This would probably boil down to experimentation.

Thanks :)
bsodmike said:
Thanks a lot for that but the reason for considering USB as well is that either way both would hook up to a PIC where I grab the info off the D+ and D- lines. Sorry if I wasn't clear here, either case the mouse would interface with a PIC which would handle the task of 'figuring' out how far the mouse has traveled...

Still I feel that I'll go with a PS/2 mouse or if I end up with a USB rodent I'll stick a PS/2 adaptor on the end...

Thanks a lot, this is what I was looking for

Actually I am doing the exact same thing, I have reached to a point where i can get the data into MATLAB for further processing but the lenses is still a problem. Now I want to know how are you interfacing your "Optical Mouse"??

1. Are you interfacing the USB chip or the sensor??
Interfacing PS/2 on a microcontroler is very difficult since its a PS2 protocol why? PS/2 protocol generates its own CLK! It was hell when I tried interfacing the mouse directly to my BS2. It uses a PIC too. this way can get extreeemly complicated.

2. Why dont you try connecting the ADNS or whatever sensor chip directly to the PIC, instead of taking the dagta from PS/2 or USB chip? Which sensor chip is there in the mouse??

3. Here is some info:

Athena uC to Optical mouse
https://www.electro-tech-online.com/custompdfs/2007/07/Athena20to20Optical20Mouse.pdf

A PPT on Mouse as sensor!
**broken link removed**
 
navigation by USB optical mouse

I think its not a good idea to directly connect USB mouse to micro controller in your robot!
mainly it will suffer you in managing 'master Slave model' of the USB technology!

its easy, if you can find a PS/2 optical mouse! it can support up to 1.5Km/hr motion detect!

other wise best plan is to use the optical sensor itself by ruin the optical mouse!

its pretty simple! but the matter is that you have to keep the optical architecture of the mouse! because optical mouse can sens only few mm<2mm. so the lens distance and LED needs to be properly mounted.
below link has a good research paper on this issue,if you read!

**broken link removed**

else

look at here
**broken link removed**


here you can see the real power of an Optical sensor!
Sprites mods - Optical mouse-cam - Optical mouse cam


regards!

chandpriyankara
BSc Engineering-Undergraduate
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top