Debounce a Mouse the Hard Way.
by themoreyouknow in Circuits > Arduino
5464 Views, 1 Favorites, 0 Comments
Debounce a Mouse the Hard Way.
This guide is suitable if you have a mouse that double or triple clicks accidentally or releases accidentally when performing a dragging task. It's also suitable for a mouse that accidentally clicks when you release. It won't repair a switch that fails to actuate at all. As it is arduino based it may not be to everybodys tastes, although it is not difficult.
There are any number of guides showing how to repair a mouse by swapping microswitches or manipulating internal springs. The problem usually comes back because of the substandard build quality of the cheap switches ubiquitously used. In the above picture of a microswitch internals you may see round copper switch contacts that indicate excellent build quality. those contacts are missing in many mice.
Take note of the microswitch construction. the button is located above the common terminal. In most mouses this terminal is soldered to GND. The middle terminal is normally open and the opposite terminal to GND is normally closed. In this instructable i'll be using a logitech usb mouse. It is so old the model number has sanded off the base. The case is identical to the sbf96 however, but logitech kept the same shell design since their ball mouses so it's hard to say.
Tools needed:
Voltmeter
Insulating tape
soldering iron and 60/40 flux cored solder
wire cutters
philips screwdriver to fit mouse
sharp edged file or flat screwdriver to etch the pcb.
How It Works.
You might ask if this is such a good idea why don't manufacturers do it in the factory. Well, they should but maybe there's a little planned obsolescence going on too. The only downside is it takes twice the digital pins to implement. Some cheap mice can have 3 buttons sharing 2 pins. This guide will not work with those without adaptions such as optoisolators and rewriting the code for separate pins. Above you can see some earlier versions i built but abandoned due to their large size.
I found that by using an arduino there was much less cutting of pcbs and I could combine the function of 2 or more wires into 1 to make the install much easier. In fact the pcb modification is so minimal the mouse will work normally with the cuts made and without the mod installed so it is completely reversible. I suggest using a mouse with a single sided pcb to make it easier.
Bouncing is when a switch oscillates between on and off. This mod uses a arduino coded state machine to latch the mouse controller switch trace on when the switch is first pressed and to release the latch when the normally closed contact closes again. It does not increase bounce period delay by any constant. To minimise the wires used I found it necessary to toggle the pinmode between input_pullup and output. This has not caused an issue as it is within the debouncing capabilities of the original mouse, so no double click is registered. It happens right when the switch is operated so it will not change as the switch degrades.
Try to find the smallest arduino you can get. I used a clone nano which was tight, but did fit. I recommend cat5 cable for any wires needed. If you have a small mouse then the digispark may suit.
Modifying the Pcb
Now that you've opened your mouse, probe with the voltmeter at the usb plug on the pcb. find out which wire is 5v by plugging in the mouse or searchin the web for usb pinout. Only proceed if all the microswitches have common soldered to GND. Tin and solder the 5v and GND wires to their respective arduino pins.
Now inspect the microswitch pin opposite to the common pin, ie. the pin under the side of the microswitch without a button. If the pin is unsoldered you're good to go, if not take a file or screwdriver and file away the copper in a circle to around the contact to isolate it from the rest of the pcb, like is done in the picture above. It may be tempting to cut across a ground plane to isolate the pin but if you do so remember to bridge other components if they do not have a path to ground. Cutting ground planes may cause erratic behaviour in the mouse.
Now tin the wires and solder two wires to each microswitch. try to have them colour coded for normally open and normally closed to avoid confusion. you can check the code to know which is which, or just solder them in and swap the pins in the code. Do not solder a wire to the common terminal. On the arduino you may choose any pin between 2 and 13 but for your first switch i recommend 2 and 3, as that is what the code is set for. 4 and 5, 6 and 7 are all the pairs in the code. you must modify the code if you want to debounce more buttons.
Now upload the arduino code and press the buttons to see does it work. if you run into problems use the ohmmeter to check for continuity in the pcb islands you created. You may need to swap the two wires on the nonworking microswitch.
Downloads
Finishing Up.
This is probably the hardest part. if you can't get the mouse back together then you've failed. But before you try remember to wrap the arduino up in insulating tape. Try to route the wires around the case standoffs, if you don't then the microswitch buttons may be pressed when the covers are screwed together. On the plus side if you do manage to get the case together as I did then at least it won't rattle and break wires, though the cat 5 wires are fairly tough. Someday I may try this on a high end gaming mouse but the dual layer pcb is a little tricky to handle.
After using it for a while the voltage dropped down to 3volts. It turns out in some cases you may need to upgrade the wiring as what comes with the mouse is the cheapest they could make.
I'd like to hear any comments or suggestions back from anyone who tried this out.