Wii Wing/Wii Nunchuck questions


radu7

Recommended Posts

I've purchased a couple of Wii Wings and Wii Nunchucks from gadgetfactory.net and I'm having no success getting them working with my Papilio Pro and the WiiChuck example in DesignLab 1.0.8

I've connected the Wii wing to slot AL on the Papilio Pro and loaded the circuit and sketch for it, but the only output I get in the serial monitor is:

Starting
I2C at slot 9, instance 1, base register 0x0c800000
0
Chuck: 255 255 buttons 0 0
Chuck: 255 255 buttons 0 0
Chuck: 255 255 buttons 0 0
Chuck: 255 255 buttons 0 0
Chuck: 255 255 buttons 0 0

...

Pressing either button or moving the joystick does not cause any change in the output values.

As a test I powered the Papilio Pro up without the Wii wing connected and after starting the serial monitor pressed the reset button on the Papilip Pro and get:

Starting
I2C at slot 9, instance 1, base register 0x0c800000
0

with no further output, as expected.

I've tried both Wii wings and both nunchucks that I purchased and both give the same result.

As another test I wired the Wii wing with the nunchuck connected to an Arduino Uno and used the library and example at this site:

http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/

and received the same output values via the serial monitor as when connected to the Papilio Pro.

I've got the nunchucks connected to the Wii wing so that the nunchuck's pinout matches the silkscreen (The 'indented' side of the nunchuck connector that has no middle pin facing up) and I've verified connectivity from the pin on the wing to the pin of the nunchuck via a DMM.

Any ideas on what may be going on?  I wouldn't think that I managed to get two bad sets of Wii wings and nunchucks so I'm at a bit of a loss as to what the issue could be.

Best regards,

Anthony

 

 

Link to comment
Share on other sites

Quote

"and received the same output values via the serial monitor as when connected to the Papilio Pro. "


This seems to imply your Wii chucks are not properly powered?. I used a small adaptor back when I wrote the support code, and played with it for a whole maker faire (many people did).
Do you have any digital scope so we can look at the signals ?

Alvie

Link to comment
Share on other sites

Thanks for the reply Alvie!  I can get access to a DSO and an openbench logic sniffer that I can use to troubleshoot this.  I'll try and get to that after work today.  I'll verify that 3.3V is getting to the Wii chuck and then test for activity on the SCL and SDA pins while pressing the buttons, etc...

If you have any specific test scenarios I should try please do let me know.

 

Regards,

Anthony

Link to comment
Share on other sites

Update:

I decided to try a newer Arduino library for the Wii chuck and a test sketch to read the buttons and joystick position and surprisingly it worked perfectly.

I then took a Digilent Analog Discovery and used the Waveforms software to have a look at what was happening on the I2C bus on the working Arduino example and then the non-working DesignLab example on the Papilio and I could see a difference in the initialization sequence being sent from each.  I guess I should have compared the two libraries and found the issue without breaking out a scope, but where's the fun in that, right?

The Arduino example was sending hF0, h55, hFB, h00 as the init sequence.

The Papilio example was sending h40, h00, hFB, h00 as the init sequence.

After doing a bit more reseearch I changed the following section in the WiiChuck.cpp in the WiiChuck library in DesignLab as below:

int WIIChuck_class::init_nunchuck()
{
    int err = 0;
    if (I2C.start(WIICHUCK_ADDRESS,0)!=0)
        err = -1;
    if (err==0)
        // if (I2C.tx(0x40)!=0) - this is for OEM Wii nunchucks
        if (I2C.tx(0xF0)!=0) // for clone Wii nunchucks
            err = -1;
    if (err==0)
        // if (I2C.tx(0x00)!=0) - this is for OEM Wii nunchucks
        if (I2C.tx(0x55)!=0) // for clone Wii nunchucks
            err = -1;
    I2C.stop();

 

I recompiled the sketch, uploaded to the Papilio and I'm now getting the following results when testing:

No Joystick or button activity - Chuck: 128 127 buttons 0 0

Joystick left - Chuck: 46 127 buttons 0 0

Joystick right - Chuck: 255 127 buttons 0 0

Joystick up - Chuck: 128 255 buttons 0 0

Joystick down - Chuck: 128 46 buttons 0 0

Button C - Chuck: 128 127 buttons 0 1

Button Z - Chuck: 128 127 buttons 1 1

Button C+Z - Chuck: 128 127 buttons 1 0

I was not aware that some (all?) clone chucks do not respond properly to the standard init sequence.  The following comment was in the Arduino library that I used (https://playground.arduino.cc/Main/WiiChuckClass):

            // instead of the common 0x40 -> 0x00 initialization, we
            // use 0xF0 -> 0x55 followed by 0xFB -> 0x00.
            // this lets us use 3rd party nunchucks (like cheap $4 ebay ones)
            // while still letting us use official oness.
            // only side effect is that we no longer need to decode bytes in _nunchuk_decode_byte
            // seehttp://forum.arduino.cc/index.php?topic=45924#msg333160

Thanks for the advice Alvie, using the scope certainly revealed the issue even if it wasn't due to a hardware fault or misconfiguration.

Regards,

Anthony

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.