Shop OBEX P1 Docs P2 Docs Learn Events
Nintendo Wii Nunchuck Object — Parallax Forums

Nintendo Wii Nunchuck Object

crgwbrcrgwbr Posts: 614
edited 2008-04-29 19:48 in Propeller 1
At the moment, I don't have the funds to buy a Wii nun chuck controller to use, so I could write an object for it. But I thought it might be useful to post some information on the com protocol I stumbled upon. The controller uses i2c for communication. The four wires coming out of the controller are the following:

white - ground
red - 3.3+v
green - data
yellow - clock

1. Send controller two bytes to start communication; $40 then $00
2. Send controller $00 every time you want feedback
3. Controller sends feedback in 6 byte packets
Byte     Description     Values of sample Nunchuk
1     X-axis value of the analog stick     Min(Full Left):0x1E / Medium(Center):0x7E / Max(Full Right):0xE1
2     Y-axis value of the analog stick     Min(Full Down):0x1D / Medium(Center):0x7B / Max(Full Right):0xDF
3     X-axis acceleration value     Min(at 1G):0x48 / Medium(at 1G):0x7D / Max(at 1G):0xB0
4     Y-axis acceleration value     Min(at 1G):0x46 / Medium(at 1G):0x7A / Max(at 1G):0xAF
5     Z-axis acceleration value     Min(at 1G):0x4A / Medium(at 1G):0x7E / Max(at 1G):0xB1
6     Button state (Bits 0/1) / acceleration LSB     Bit 0: "Z"-Button (0 = pressed, 1 = released) / Bit 1: "C" button (0 = pressed, 1 = released) / Bits 2-3: X acceleration LSB / Bits 4-5: Y acceleration LSB / Bits 6-7: Z acceleration LSB



Thought this might help,
Craig

P.S. I found this information here

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech

I would love to change the world, but they won't give me the source code

People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.

I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"

Comments

  • BergamotBergamot Posts: 185
    edited 2007-06-27 20:32
    $20 for a three-axis serial accelerometer, two buttons, and a joystick isn't bad...

    And if you don't need the buttons to work, you can disassemble it:

    nunchuck_apart.jpg

    Post Edited (Bergamot) : 6/27/2007 8:36:55 PM GMT
  • AcuboneAcubone Posts: 2
    edited 2008-04-28 09:33
    Hello, this is my first post, but, I have been reading this forums during this last year, and I· have carried out some begginer projects and studied a lot of documentation. I´m from Spain, Software Engineering at EADS-CASA, and I·write in english poorly, I just started learning with a· native teacher (KC30 jejjejje ), so please, if you want, you can correct·what·are not well writen.

    I am triying to read the Nunchuck data·by means of I2C·(James Burrows´s i2cObject v2.1), following instructions of the top post, $40, $00 for initialization, and $00 for reading 6 bytes, one by one, with readByte object method (I´m at office and forgot code·in home laptop..·), but code is soo easy, 10·sentences.

    The scan detecs Nunchuck ( I verified this plugging and unplugging Nunchuk from I2C bus) , but, all that I can read from Nunchuck is 255 x·6....
    There are any problem with Fast I2C with propeller? Is there·any·I2C object for this or any change in the mentioned library? I am looking a lot, but I have found·nothing yet.

    Thx!!!

    ·
  • simonlsimonl Posts: 866
    edited 2008-04-28 12:43
    Hi Acubone,

    Mike Green would be best to answer, but I believe the I2C object only runs at slow speed (100KHz?) not full-speed.

    BTW: Your English is very readable smile.gif

    So, if you're at EADS, are you working on space-craft or UAVs? (Sorry - off-topic).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif
  • BeanBean Posts: 8,129
    edited 2008-04-28 14:31
    I have read the nunchuck with the SX.
    I had to slow down the I2C to half-speed to get it to work correctly.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?

    www.iElectronicDesigns.com
  • AcuboneAcubone Posts: 2
    edited 2008-04-29 19:48
    SX is a 50 MIPS, ATmega168 up to 24, Propeller 20 MIPS per cog.... I thing Propeller can read nunchuck data, but I can´t calculate this. Perhaps in ASM? Only one cog running?

    The code that I test using basic_i2c_library doesn´t work:

    if i2cObject.devicePresent(i2cSCL,nunchuckAddr) == true
    ·· oled.ftext(0,1,2, 255,255,255, string("Nunchuck Present"), 0 )
    ·· i2cObject.start (i2cSCL)
    ·· i2cObject.write (i2cSCL, nunchuckAddr )
    ·· i2cObject.write (i2cSCL, $40 )
    ·· i2cObject.write (i2cSCL, $00 )
    ·· i2cObject.stop (i2cSCL)
    ·· delay.pauseMSec (200)
    ·· i2cObject.start (i2cSCL)
    ·· i2cObject.write (i2cSCL, $00 )
    ·· repeat 5
    ····· buffer[noparse][[/noparse]ind++] := i2cObject.Read(i2cSCL,i2cObject#ACK)
    ·· buffer[noparse][[/noparse]ind++] := i2cObject.Read(i2cSCL, i2cObject#NACK)···
    else
    ·· oled.ftext(0,1,2, 255,255,255, string("Nunchuck NO PRESENT"), 0 )
Sign In or Register to comment.