Mouse Robot Serial
As a part of my work developing Plobot , we were trying to think of ways to improve the robot’s performance on carpet. The trouble is that a degree of wheel slippage is inevitable on carpet, and so encoders cannot be very accurate. Another team member, Maciej, suggested an interesting solution: the sensor from an optical mouse. So, after doing some reading on the topic, I went around the corner and bought a cheap optical mouse, and took it apart.
The inside looked a lot like this: I knew from my reading that the maker of most of these low-cost optical mouse sensors is Pixart, and I saw “KA8” written on the module, so I typed “Pixart KA8” into Google and this datasheet came up: Seeing the staggered pin arrangement was the same in that document, I became confident that I had the right datasheet, and I extracted the module from the mouse PCB. I then cobbled together my own circuit based on the schematic in the datasheet, running the module at 3.3v and communicating with it with an Arduino Uno.
Optical Mouse Odometer for (Arduino) Robot by jazzycamel in arduino. Why when we stop moving mouse.the serial monitors show x=0 and y=0, it suppose have reading. The mouse wouldn't light up and I got nothing from the serial port. Optical Mouse Odometer for (Arduino) Robot. Further Modifications and Finishing Up.
I added voltage dividers on the two serial lines to level shift. Unfortunately I saw a lot of garbage coming from the chip, and the serial protocol was not defined in the datasheet. I searched Google some more and came across this more complete datasheet for a related part, which turned out to have the same serial protocol: I then realized that the serial synchronization was essential to getting meaningful results from the module. I added code to synchronize every 100 read commands, and was able to read the product ID. As it turned out, I was in fact working with the PAW3204DB, and had been overvolting it the whole time at 3.3v.
I was lucky that it held up. I added a voltage divider and a large capacitor on the power supply to get a stable 2.7v, with the optical sensor consuming. The results with this sensor were not accurate enough to be a full solution for moving on the rug on its own. However, it could work well to complement encoders to detect slip, and I will be experimenting with higher quality sensors as well. The control program works on the principle that when robot rotates, the optical sensor senses horizontal (X) movement, since its horizontal axis is always tangent to the circle. When the robot moves forward/backward, it senses vertical (Y) movement. So, when going straight, motor power is balanced to minimize X movement.
While turning, it is balanced to minimize Y movement. Likewise, when going straight, a certain total Y offset is counted to determine the length moved, and when turning, a certain total X movement is counted.
Accurately determining the progress of a wheeled robot can be pretty tricky (and expensive!). Assumes that our motors are perfectly matched, our wheels don't slip and the surface we are running on is perfectly flat: most of these conditions are unattainable and are never guaranteed. On the wheels or motors are more accurate, they certainly remove the need for matched motors and can deal with incline changes, however slippage is still an issue. Or range sensors circumvent all of the mechanical issues that plague dead reckoning and encoders but require stationary fixed points of reference, are subject to interference (objects coming between the robot and the reference point) and have issues with regard to range, accuracy and resolution (the more you want, the more it costs!). Ideally, we want a sensor that can accurately measure positional changes in two dimensions, has a simple interface, has low power requirements, is easily obtainable and cheap into the bargain.
The solution: that old optical mouse you have lying around! Computer mice are designed to do just what we want: very accurately track the two dimensional movement of an object in near to real time. They actually have a resolution 1000 which means we are able to measure a movement of 0.03mm in any direction! We do have to choose our mouse a little carefully however. We need one that either has a connector (6 pin ) or a mouse that is compatible (should be stated on the bottom of the mouse somewhere, see picture). This is because the PS/2 protocol is really easy to implement (particularly for microcontrollers) whereas USB is somewhat more difficult!
I happened to have an old USB1.1/PS/2 compatible mouse hanging around that I wasn't using, so I decided to sacrifice it to my robotical pursuits in the manner described herein. First things first, we need to open the case and liberate the electronic goodies within.
I chose to do this because the mouse is far too big and bulky for my robot. If you don't want to this you just need a USB Type A or PS/2 socket that can be wired to the processor (Arduino in this case) into which the mouse can be plugged without modification, just skip this bit. So, the process to deconstruct my mouse was as follows (also see pictures):. Remove rubber adhesive feed covering screws (at the rear) and clips (at the front. Remove the two screws at the back and then use a small flat bladed screwdriver to push back the clips holding the top and bottom parts of the case together at the front. (This may take a bit of fiddling, I actually inadvertently broke one of the clips in the process.).
Once the case is open, remove the scroll wheel and then any screws hold the circuit board to the case. There may also be a few small plastic clips that retain the circuit board. The small screwdriver used before and some wiggling should free the circuit board(s) from the case.
There should be a clear plastic piece under the circuit board (the lens) which will also need, so retain this and the circuit boards, discard (or file!) the rest. If you plug the mouse into a computer or laptop, ensuring the lens is correctly in place on the bottom, the mouse should work normally when you move it around. Now we've got our hands on the board we need to connect it to our microcontroller.
Micro Mouse Robot
To do this we can either use the existing cable (USB) in my case and wire an appropriate socket or we can replace this wire with some of our own. We also need to determine the function of each of our new wires. This is done simply by using a multimeters continuity setting and working out which connection on the board is connected to which pin on the USB (or PS/2) connector. The original wiring can be seen in the first image above and functions are, left to right, as follows:. Red: Vcc (USB pin 1).
Activating and. Email Templates. You will always create your survey in the test version of LimeSurvey. Getting Started To create a survey, click the. BUT Folder structure in /limesurvey/upload/templates/TEMPLATEFOLDER looks. Complete LimeSurvey version. Database & DB-Version: mysql 5.0.11: Operating. LimeSurvey bugs and feature requests Toggle user menu. Confirmation and registration email templates. Database & DB-Version: mysqlnd 5.0.11-dev. Downloaded version. Though MySQL 4.1 should be supported by Limesurvey. Installed mysql 5.0.95-community Nothing new. Joomla templates version 1.5.
White: Data (USB pin 2). Green: Clock (USB pin 3). Black: Gnd (USB pin 4). Black: Shield I chose to desolder the existing cable form the board and replace it with some wires with Arduino friendly Dupont connectors. I also chose not to connect a wire to the shield connection as its not strictly necessary. We then connect the mouse to our microcontroller of choice, an Arduino Leonardo Nano clone in this case, as follows:. Mouse Vcc to Arduino Vcc.
Mouse Gnd to Arduino Gnd. Mouse Clock to to Arduino Pin 6. Mouse Data to Arduino Pin 5.
Macro Mouse Robot Style
Now we've connected everything up we need some software for the microcontroller. Firstly we need some code that implements the. Helpfully there is an Arduino available for this, however I found it to be a little outdated and I wanted to add some new functionality so I reimplemented and extended it a bit and it can be found here:. The library contains a simple example sketch ( PS2 Mouse.ino) which requests the mouses status and position delta (the change in X and Y directions since we last asked) and prints it to the serial port once every second. If we program the Arduino, and everything has gone well, the mouse will light up and your favourite terminal application (or the Arduino IDE's serial monitor) will show a stream of status, X and Y deltas once a second. The X and Y data has a (theoretical) range of -255 to +255 and each step (theoretically) represents 0.25mm which means we can (theoretically) measure up to 63.75mm change in any direction (for X positive values are to the right, for Y positive values are forwards). Note: the above numbers are theoretical for the following a reasons:.
Whilst a mouse can report the range -255 to 255, so far all the mice I've used only return -128 to 127. Whilst each step supposedly represents 0.25mm, I've found this to be very dependent on the mouse and the surface its on. Generally the step size seems a lot smaller. Once I'd got everything up and running I decided to remove the extra circuit board which has the electronics for the mouses buttons and scroll wheel as I didn't need these features and they were just taking up space. I desoldered both of the ribbon cables, plugged everything in and.
The mouse wouldn't light up and I got nothing from the serial port. A little investigation with the multimeter told me that three of the pins (1,3, and 6) on the rightmost connector (looking from the top) were usually connected together when the button board was connected, so I just shorted them together with some scrap wire as shown in the picture. I then plugged everything back in and Hey Presto! We were back in business! The final touch was to superglue the clear plastic lens in place on the circuit board to retain it and so I wouldn't lose it. The next step will be to mount this on my robot and put it to use. I actually intend to cannibalise another mouse in the same way and fit both to the robot so as to be able to accurately determine orientation as well as progress (as described ).
I hope people find this little tutorial useful, please feel free to ask any questions. Thank you for writing this. I am having the issue with being hung on setup.
The only theory as to why that I can come up with is that my old (IDK how old) logitech usb mouse does not support USB. The only evidence I have to support this is that there is no mention of PS/2 on the bottom. I believe that the pins are hooked up correctly because when I connect the green & white one way the mouse LED lights but when I swap those wires the mouse does not light up. Therefore I think I can rule that out. In both cases the serial monitor sits on setup. Any further troubleshooting recommendations would be appreciated.
Thanks 6 months ago. Hi - I followed your (good) tutorial but the serial output makes no sense -reading x=0, y=0 and then responding only occasionally to some jerky motion, but not to others. Could be that I just have crappy mouse?
Or something else? In particular, what variable is 'stat' reporting? Isnt x or y reporting the counts (delta) since the last time through loop? If when I get this to work - is the -127 to +127 meant to be 63.7mm range?
Please see sample serial output below - Thanks for any help: 1000x=0y=0 1000x=0y=0 1000x=0y=0 1000x=0y=0 1000x=0y=0 1000x=0y=0 1000x=0y=0 1000x=0y=0 111000x=-127y=-127 11000x=-127y=103 11000x=-127y=73 11000x=-127y=0 11000x=-30y=0 1000x=0y=0 1000x=0y=0 1000x=0y=0 6 months ago.