TL;DR: I made a USB arcade
trackball as my first serious electronics/arduino project!
Why? Well that's a long story ...
About 15 years ago, I retrofitted my upright arcade cabinet (Gauntlet II) into a JAMMA-friendly MAME cabinet with an old PC. In the process +Paul Shackel
hacked me up a trackball circuit out of an old $5 serial mouse board allowing me to connect it to a 9-pin RS232 serial port. You know, back when PCs had those ports.
Fast forward to a year or so ago, the Celeron 300A PC long dead replaced by a Raspberry Pi (Model B), original arcade monitor replaced by a 4:3 20" LCD panel. Everything was basically fine, except the trackball. Only a handful of games really need it. But, it was there. Surely connecting a 9-pin serial port to a RPi couldn't be that hard right?Oh So WRONG!
40 simple steps later ...
1: Order a ~$2 9-pin RS232 to USB adapter/cable/device from China.
2: Wait 2 months for the slow boat to arrive.
3: It arrives, then forget about it for many months.
4: Plug it in, and be totally surprised it doesn't work with MAME.
5: Learn that mame4all, unlike advancemame doesn't support serial mice.
6: Learn about inputattach
to make a serial mouse appear like a normal (usb) mouse to the rest of the system. No luck.
7: Give up on serial mice. Try to find a mechanical mouse that has a USB interface, and try the same hack as the original.
8: Months pass, and a trip to the USA, and a fortuitous trip to Weird Stuff. $5 usb mechanical mouse found.
9: Get back home, plug in mouse, it works. Now just have to hook it up to the trackball's optos.
10: Forget about it for a couple of months.
11: Try wiring up the mouse to the trackball. No luck. Doesn't work. Bummer.
12: Read up about the Serial->USB adapter. Most cheap ones don't do more than ±5V and have dodgy chipsets.
13: Find other adapters, namely FTDI chipset ones. (Thanks +Jamie Gillespie
for the loan)
14: Test FTDI adapter and my cheap one on a linux PC, with input attach. Success. \o/ Cheap one doesn't work. FTDI one has enough voltage to drive the mouse.
15: Before I order an adapter, think, I should just test this in the RPi.
16: Epic fail. Doesn't work. Why?
17: Spend a weekend trying to get the RPi to talk to the mouse behind the adapter. Many forum posts and other unhappy punters later.
18: Turns out the RPi's USB systems sucks puss. Think USB-OTG and drivers written with Intel arch in mind and half a dozen other design kludges take the RPi took. :-(
19: Borrow some more Serial to USB converters.
20: Test them on the RPi. Still no work-y. F#$king RPi USB serial.
21: Go back to using an old PC motherboard with a 9 pin serial on-board.
22: Try a few distros. Get it mostly working. However, it is big, noisy.
23: Turns out the video card isn't supported for SVGAlib, so has to run in full res in X11. It's slow as puss in native res on the LCD.
24: There has to be a better way... Back to the Pi.
25: Make my own mouse.
26: Learn from +Benjamin Low
enough basic opto-transistor basics and resistor know-how to be able to convert it to a digital-like signal.
27: Find out that the trackball's opto's are wired up completely differently than Ben expected. Circuit doesn't/won't work.
28: Design my own circuit after working out how the optos are hooked up.
29: Test out the digital signal via the new circuit. Success.
30: Connect it to an arduino, see if I can read the digital signals.
31: Expand out the circuit to handle all 4 optos on the trackball.
32: Success. Get 4 x Ones and Zeros as the ball moves.
33: Wire it up to a piece of veroboard. Much soldering. Test. Still works.
34: Write arduino code to calculate direction of optical wheel/disk rotation. Looking good.
35: Use the arduino 'mouse' library to be a HID usb device.
36: Tweak and calibrate parameters to be more like expected.
37: Cable-tie into neatness.
38: Pre-install into cabinet test indicates a problem. Shorting as cable ties pulled out some cables on the arduino side. Re-route wires and cable-tie to prevent from happening again.
39: Test on the RPi. It works!! Fit it back into the arcade cabinet.
40: Play a quick round of Missile Command
, it's done. Finally. Sorted. OCD itch has now been scratched. Clean up and turn off.
Photos, circuit diagrams attached.
My arduino code here: https://drive.google.com/file/d/0B2aVuEL1RXOuT1FRZllTak9xMmc/view?usp=sharing
Chuffness of having built a mouse from near-first principles won't upload. Sorry. :-)
(Edit: Yeah, I just realised I used the veroboard upside-down. Meh, it was my first time using it.)