I got some very interesting and wonderful presents this Christmas (thanks Mom, Dad, and Father-in-Law!). So... what can you make with a microcontroller, a Wiimote, and a laser? More on that another time, if I can pull it off. But here's how you can run a Wiimote IR camera with an mbed and track a laser dot (or other light sources) on your Windows, Mac, or Linux host.
Meanwhile, my parents very generously gave me an mbed microcontroller -- a powerful ARM Cortex M3 on a 40-dip board. Thanks Mom and Dad!! You can see it hooked up in its first, post-"hello world" experiment.
The Wiimote I planned to hack was purchased with a most generous gift card from my father in law (thanks, Mike!) Inside the Wiimote is an infrared camera that tracks infrared light point sources and reports their coordinates over I²C.
I'm following in the footsteps of great hackers, here. Here are the sources for the Wiimote IR Camera hacks:
After disassembling the Wiimote, I desoldered the camera using solder braid with some extra flux paste. I soldered the camera's 8 thin leads onto a 2x4 pin header and soldered that onto a perfboard with 1x4 headers on either side so I could easily breadboard the thing.
Wiring the Camera to the mbed
Using the mbed, the interfacing is super simple.
The LPC1768 is a 3.3V device, eliminating all the voltage level translation hassle that the 5V Arduino owners had to endure.
And, since it's running at 96MHz, programmed one of the mbed's PWM signals to output an ~20MHz clock signal for the camera. No crystal oscillator necessary.
The camera pinout is shown in the image below.
Here's a quick and dirty schematic. Note the pullup resistors on SCL, SDA, and RESET. In kako's and others' schematics, there's a 0.1uF capacitor between RESET and GND, probably to filter glitches. So far I've gotten away with omitting the cap.
|Wiimote to mbed wiring schematic. Click for large version.|
I converted kako's source code to mbed C++ and added the ~20MHz clock signal on p21, and setup I2C communication on p9/p10. The source code listing can be found here.
Here some sample output over the USB serial device while the camera tracks a laser. The camera tracks four light sources and provides x and y coordinates. The output from the microcontroller is a comma-separated list of x-y pairs: x1,y1,x2,y2,x3,y3,x4,y4
239,272,360,299,1023,1023,1023,1023 235,267,353,292,1023,1023,1023,1023 237,274,359,300,1023,1023,1023,1023 251,284,368,305,1023,1023,1023,1023 253,292,375,319,1023,1023,1023,1023 253,298,374,322,1023,1023,1023,1023 256,299,376,322,1023,1023,1023,1023 258,299,376,319,1023,1023,1023,1023 ...
PC GUI Client Software
I wanted to visually display the camera's tracking data, so I wrote a Java Swing equivalent of the CC2's ATM 18 Project BlobTracker Front End software, since I couldn't get it to work. Well, the Java app works pretty well. Here is the source code for the Java app.
I mentioned the laser and used it here, but I have other plans. I'm still working on it. If I pull it off I'll be sure to post.
Happy New Year!
Great work!! I am going to try this.ReplyDelete
What a creative project! surely must try project :DReplyDelete
Do you think I could also generate the clock signal from an Arduino Uno board ?
@Anonymous: not at 20MHz since the Arduino boards run at 16. I think the best you can do with AVR is clk/2 -- you could either send it an 8MHz clock or just use a separate component to generate the clock signal.ReplyDelete
can I use the I2C bus of the pixart camera directly with an small arduino pro mini of 3.3v/8MHz.? Also Can I use any other level converters for it?ReplyDelete
@saurabh, since the pro mini runs 3.3v, you can connect directly to the pixart cam. Use a clock generator IC or xtal/caps/logic inverter circuit (http://www.kako.com/neta/2007-001/2007-001.html) to generate a 20mhz clock for the camera.ReplyDelete