The WiiMote and FEZ Domino


at the beginning....

FEZ Domino I2C

The I2C pins on the Domino board are:

  • Di2 – SDA
  • Di3 – SCL

Both Di2 and Di3 are open drain pins with 2.2K pull up resistors.

Try to use the main I2C bus (used for nunchuck & WMP)

Wii Connector specifications

Pinout for Nunchuck or WiiMotion Plus connectors

Pinout

|~~_____~~|
|         |
|  6 4 2  |
|  -----  |
|  5 3 1  |
\_________/

From the Wiimote side

Pin Cable color Description
1 Red 3.3V
2 Yellow SCL. I²C Serial Clock. (400 kHz)
3 Red Connected to 3.3V inside attachment connector
4 Not connected.
5 Green SDA. I²C Serial Data
6 White Ground

Try to read camera data

Connector to the main I2C bus

The WiiMote connected to the FEZ Domino board

It turns out I can’t read anything… I think (hope 🙂 ) it’s because this I2C bus is NOT connected to the IR Camera one…

Use the IR camera stand alone

No other choice, than to dismount the wiimote and create a separate circuit for the IRCamera.

HERE you can find clear and good documentation about the technical specifications of this IR Camera.

WiiMote disassembled

Here are some schematics from the Internet (not mine ! credit given where credit is due…):

IRCamera - pinout

IRCamera - circuit

Alternative schematics

Here’s an alternative mounting schema, simpler as it uses an Oscillator directly. Taken from this guy.

Simpler circuit using directly an Oscillator

PCB layout suggestion

The actual one I’ll be using, optimised for stripboard mounting:

Stripboard optimised PCB layout

First (unsuccessful 🙂 ) attempt

While building...

First failed attempt

You can see right away, that I was using the 2nd schematics, but instead of an oscillator I employed a simple resonator (as for the 1st schematic)… ! There was literally NO chance for this to be working… lol 🙂

At the same time as realising the crystal problem, I also became convinced that the extraction process had irreversibly damaged the camera… you can see it slightly melted, plus wire no 1 had to be re-soldered at the back of the chip.

Second (unsuccessful 🙂 ) attempt

So I have ordered a new WiiMote, and took the cheapest on eBay…

Wu mote (Wii clone)

Wu mote camera

As you can see straight away, it has a different camera… to be honest, a much easier to de-solder and to work with BUT I have already read warnings on the internet that these ones have a different protocol, and to be honest I’m getting frustrated enough with the first one not working to take on another challenge… so will send it back !

And the final attempt

WiiMote IR sensor stripboard circuit

The successful board and camera. Do notice the epoxy glue used to harden the mechanical fixation of the little camera.

Connected to the FEZ board

…which works… I’m quite happy.

And here’s the C# code :

using System;
using System.Threading;

using Microsoft.SPOT;

using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.Hardware;

using GHIElectronics.NETMF.FEZ;

class WiimoteCamera : IDisposable

{

private const byte ADDR_SENSOR = 0xB0 >> 1;

// structure with data from the camera

public class Blob

{

public int x;

public int y;

public int size;

public override String ToString()

{

return "X: " + x + " - Y: " + y + " - S: " + size;

}

}

private Blob _blob1;

private Blob _blob2;

private Blob _blob3;

private Blob _blob4;

private I2CDevice _camera = new I2CDevice(new I2CDevice.Configuration(ADDR_SENSOR, 400));

private byte[] _dataBuff = new byte[13];

public WiimoteCamera()

{

// INIT the camera sensor

//i2c(new byte[] { 0x30, 0x01 }, true, 10);

//i2c(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90 }, true, 10); // sensitivity part 1

//i2c(new byte[] { 0x07, 0x00, 0x41 }, true, 10); // sensitivity part 2

//i2c(new byte[] { 0x1A, 0x40, 0x00 }, true, 10); // sensitivity part 3

//i2c(new byte[] { 0x33, 0x03 }, true, 10); // sets the mode of Output Format : Short (1) - 9bytes, Medium(3) - 4x3 bytes or Long(5) - 2x8 bytes    http://wiki.wiimoteproject.com/IR_Sensor

//i2c(new byte[] { 0x30, 0x08 }, true, 10);

//// SIMILAR to

i2c(new byte[] { 0x30, 0x01 }, true, 10);

i2c(new byte[] { 0x30, 0x08 }, true, 10);

i2c(new byte[] { 0x06, 0x90 }, true, 10);

i2c(new byte[] { 0x08, 0xC0 }, true, 10);

i2c(new byte[] { 0x1A, 0x40 }, true, 10);

i2c(new byte[] { 0x33, 0x03 }, true, 10);

i2c(new byte[] { 0x30, 0x08 }, true, 10);

Thread.Sleep(100);

}

public void readData()

{

i2c(new byte[] { 0x36 }, true, 1);

i2c(_dataBuff, false, 1);

// have no idea why the 1st BLOB start at 1 not 0....

_blob1 = extractBlob(1);

_blob2 = extractBlob(4);

_blob3 = extractBlob(7);

_blob4 = extractBlob(10);

}

private Blob extractBlob(byte offset)

{

Blob result = new Blob();

result.x = _dataBuff[offset];

result.y = _dataBuff[offset + 1];

int extra = _dataBuff[offset + 2];

result.x += (extra & 0x30) << 4;

result.y += (extra & 0xC0) << 2;

result.size = (extra & 0x0F);

// VALID size < 15 if (result.size >= 15) return null;

return result;

}

private void i2c(byte[] buff, bool write, int delay)

{

try

{

if (write)  // WRITE

{

_camera.Execute(new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(buff) }, 1); // 1ms timeout

}

else // READ

{

_camera.Execute(new I2CDevice.I2CTransaction[] { I2CDevice.CreateReadTransaction(buff) }, 1); // 1ms timeout

}

}

catch (System.ArgumentException e)

{

throw new Exception("Can't communicate with the I2C bus. Probably the: " + ADDR_SENSOR + " address is wrong ?", e);

}

Thread.Sleep(delay);

}

public void Dispose()

{

_camera.Dispose();

}

public Blob Blob1

{

get

{

return _blob1;

}

}

public Blob Blob2

{

get

{

return _blob2;

}

}

public Blob Blob3

{

get

{

return _blob3;

}

}

public Blob Blob4

{

get

{

return _blob4;

}

}

}

21 Responses to The WiiMote and FEZ Domino

  1. Pingback: Wii Motion plus Gyros on RaspberryPi | Robotics / Electronics / Physical Computing

  2. james says:

    Thanks so much this really helped me out a lot.

  3. eugene says:

    where did you find the connector in this image? (the wii one not the 2×3 pin one)

  4. james says:

    how do i get your email so we can talk offline without making mine public?

  5. james says:

    trandi,
    just wanted to update you on my headtracking project using some of the great info i learned here. Ive got a video showing the headtracking data as seen from the camera (transmitted wirelessly to another xbee module plugged into a laptop). the video is here:

    -james

    • trandi says:

      Wow man, this looks really great !!! The only small comment I would have is that you could maybe add some filtering to the data, to smooth the movement… but that’s just a detail, it looks impressive !

      I’m really glad you found some of my stuff interesting !

      Dan

      • james says:

        yeah, i actually did that later (and put it in a smaller enclosure). i just averaged the last 3 readings and it gets rid of most of the twitching (which i think is caused by the resolution of the camera trying to make measurements on small dots that are 6+ feet from the camera). It makes the movements much smoother. I also have a small issue with the xbee’s losing part of the 2 byte readings every 20 or so seconds, makes the dot jump across the screen when it happens. Still a work in progress but its really coming along. Its definately working though and it is fast!

        Whats nice is that when i first did this i was using the johnny lee library and a laptop with a bluetooth (9600) module to transfer the data first from the wii to the laptop and then again from the laptop to the controller. I had the idea of scrapping the laptop and going much faster with the Xbee’s and getting away from all the extra wii stuff that was getting in the way. Its nice to see that all that reading and researching really paid off. thanks again for your help! what are you working on now?

      • trandi says:

        You’re welcome !

        As you can see on my blog I’ve worked on hacking an Ikea night lamp and making it remotely controllable from an Android phone, and more recently on automating a baby bouncer for my 3months old son (nothing yet published)… but unsurprisingly, I haven’t had much free time lately and it doesn’t seem to get any better… babies do tend to require a lot of taking care of… lol 🙂

        dan

  6. james says:

    Dan, it works! My board looks kinda like your second board (with some slight mods) but I wanted to do a PCB in box to clean it up but I was a little confused by something on your “suggested PCB layout”. The blue line that seems to hit the left side of the oscillator and becomes a red line (without hitting any of the oscillators posts) has me baffled. On my design I just skipped that and wired directly to the posts of the resistors. While it seems to work fine I figure I would ask you about it.

    • trandi says:

      I’m really glad you found a solution! Regarding the blue line that becomes red, it’s a “via” hole. Blue is one side of the PCB, red the other side…

      I took that layout from the internet and posted it here as information only. The one I used myself is the next one, with pencil lines and “stripboard optimised”.

      Dan

  7. james says:

    dan, i also have the domino, if i wanted to use 3.3v would i just connect these: 1 (VCC), 2 (GND), 5 (SCL) and 6 (SDA) but leave the 7 (CLK) disconnected because it gets the clock from the SCL?

    • trandi says:

      If you use 3.3V, then you don’t need the 2 diodes for the voltage drop, BUT you STILL need to connect the CLK to the 25MHz oscillator ! The IC inside the camera case needs it’s own clock / oscillator. The SCL signal is only for the I2C timing / syncronisation, but won’t allow the camera to work.

      Hope this helps, Dan

  8. james says:

    Dan, I’m a good programmer but a bit on an electrical noob. I’m having trouble understanding the bottom left part of the wiring diagram. The part with the two caps and two diodes, is that a voltage converter to drop the 5v coming from the fez domino down to the 3v needed by the camera? Any way you could post a pic of the bottom of your board? What about a link to the supplier of the oscillator?

    • trandi says:

      Hi James,

      Yes exactly:
      – each diode has around 0.7V of voltage drop, so in series that makes around 1.4V drop, which is OK to take from 5V to around 3.5V, close enough to the 3.3V needed by the IR camera
      To make it even more confusing 🙂 the FEZ Domino is actually a 3.3V board so I could have totally ignored that part of the schematic. BUT I wanted this IRCamera board to work with any 5V Arduino so I actually use a 5V pin on the FEZ Domino (otherwise it would drop the voltage too much)

      – the 2 caps are always there when you do voltage converting to “smooth” things out, and avoid peaks (don’t ask too many details, I’m not a professional electrical engineer… 🙂 )

      Here is a link to the exact oscillator that I’ve used (it’s a 24MHz one as the specs say so, but apparently 25MHz would work just fine too…):
      http://uk.farnell.com/jsp/search/productdetail.jsp?CMP=i-ddd7-00001003&sku=9712569

      I’ll try to post a picture of the bottom of my board, but it’s not nice to see… 🙂

      Hope this helps,
      Dan

      • james says:

        Dan,
        Awesome, thanks for the info, you think it would be possible to use a 3v 25mhz oscillator? What about skipping the oscillator and just using the clock from the i2c bus on the fez? Or is that clk at a different rate or voltage? I am using the fez domino as well, and had to do i2c to connect to an IMU. I like your idea of making it a stand alone i2c device but have also thought of eliminating as many components as possible to make it more simple.

      • trandi says:

        I don’t think an oscillator has its own voltage! It might have a max rating, but that’s all… The I2C bus runs at 100 or 400KHz, so far too slow ! You could theoretically generate a 25MHz signal from the FEZ Domino (it runs at 80MHz or something like this), but it’s not from C# that you can do this, and I don’t know how reliable it would be…

        I totally understand your need of simplicity, and I’m sure you can get rid of the 3.3V regulator, but I’m not sure about more than that…

        Dan

  9. james says:

    Which of the schematics above is the one you actually used in your successful final attempt? I made a project that interfaces a fez domino and a wii controller over Bluetooth but I had to use a laptop as the bridge between and want to remove the laptop and just use a fez attached to the camera talking to another fez over zigbee. Your post is awesome by the way. I just couldn’t tell what the final wiring diagram was from the unsuccessful ones. Thanks. A video of what I am doing is here: http://m.youtube.com/index?desktop_uri=/&gl=US#/watch?v=mEOa1TXq9zI

  10. Pingback: WiiMote IR Camera with Lego NXT Brick – LeJOS « Robotics / Electronics / Physical Computing

  11. Pingback: WiiMote IR Camera with Arduino « Robotics / Electronics / Physical Computing

Leave a comment