Shop OBEX P1 Docs P2 Docs Learn Events
Using the Wii Motion Plus (Gyro) and Nunchuck (Accelerometer) with the Propeller — Parallax Forums

Using the Wii Motion Plus (Gyro) and Nunchuck (Accelerometer) with the Propeller

Cluso99Cluso99 Posts: 18,069
edited 2011-11-13 15:56 in Propeller 1
The gyro is working fine but the accelerometer is always outputting the same data.

I am using the "TestMotionPlus.spin" files from the Obex by DogP.

My Wii Motion Plus and Wii Nunchucks are clones purchased on eBay earlier this year.

The results from the accelerometer are always the same...
-128,-128,-515,-490,-525,34,-136,1,1
no matter how I move the pcb. I know these results are coming from the nunchuck because I also tested the nunchuck standalone.

I have posted the code below. Note I am running my prop at 6.5MHz.

BTW I have not tested the nunchuck on a Wii as I don't have one and the nunchuck is now in pieces because I have extracted the pcbs for use in my quadcopter.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-09-10 22:02
    Ray,

    I have several projects that use a Wii Nunchuck with a Prop. I purchased several clones from Woot a while back and I have not been able to get them to work with the Prop.

    I've also had a bad experience with a cloned PlayStation 2 controller. I've given up on using game controller clones.

    I hope there is a solution to this problem. I have several cloned Nunchucks that I would like to use with Propeller projects.

    I don't have a Wii console (nor a PS2) so I don't know if my clones will work for their intended purpose of not.

    Duane
  • JonnyMacJonnyMac Posts: 8,924
    edited 2011-09-10 22:11
    I went round and round and round with the nunchuk and, after a lot of research and even more frustration, put together the attached object which seems to work well with genuine Nintendo products as well as with clones. That said, your mileage may vary....
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-09-10 23:27
    Jon,

    This is great! Thank you!

    The Propeller can now read these cloned Nunchucks I have. This is very exciting.

    I wrote a quick demo to display the data coming from the Nunchuck.

    This is what the output looks like.
    Joystick x = 128, y = 128, Accl x = 660, y = 444, z = 684, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 608, y = 476, z = 700, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 488, y = 500, z = 732, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 476, y = 492, z = 748, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 480, y = 508, z = 712, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 492, y = 516, z = 708, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 472, y = 496, z = 716, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 504, y = 504, z = 708, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 488, y = 488, z = 684, Buttons z = 1, c = 0
    Joystick x = 128, y = 128, Accl x = 504, y = 476, z = 732, Buttons z = 1, c = 0
    Joystick x = 128, y = 128, Accl x = 508, y = 480, z = 708, Buttons z = 1, c = 0
    Joystick x = 128, y = 128, Accl x = 508, y = 488, z = 716, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 500, y = 504, z = 700, Buttons z = 0, c = 1
    Joystick x = 128, y = 128, Accl x = 528, y = 476, z = 732, Buttons z = 0, c = 1
    Joystick x = 128, y = 128, Accl x = 500, y = 476, z = 716, Buttons z = 0, c = 0
    Joystick x = 128, y = 128, Accl x = 544, y = 460, z = 712, Buttons z = 0, c = 0
    

    The numbers aren't fixed width so they don't look so pretty once the joysticks or accelerometer information changes a lot.

    Thanks again,

    Duane

    Edit: I removed "jm" from the name of the demo. I didn't want JonnyMac to get blamed for my demo code.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-09-11 05:51
    Thanks Jon & Duane. I shall give it a try maybe late tomorrow which will be the next chance I get. I was reading a response so figured there was just something wrong.

    I have already removed the joystick and buttons from the pcb. Once I get home later this week I will post pics of the connections and pcbs for anyone interested. It is easier than searching the web or tracing the connections.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-09-11 08:13
    Just a thought, when a mate of mine tried to reform a controler for XBMC, on an original XBox, he took off the pots etc that he thought that he didn't need. This caused the remains of the controller to sent false information about all sorts of things. Eventually he sussed out that dummy presets had to be fitted in their place to hold the appearence of them being at a half way point.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-13 00:22
    I finally got around to installing 4x 5K resistors in place of the two joystick pots on the nunchuck pcb.

    The accelerometer values are now returned. other calculated values are also available.

    Here is my latest code (derived from others code, with acknowledgements in the files).
    TestMotionPlus_003 - Archive [Date 2011.11.13 Time 19.19].zip
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-13 10:03
    Cluso99,

    I took the PCBs out of one of my generic Nunchucks to use as an accelerometer. I found the accelerometer values lacked the precision of the non-generic Nunchuck. They use fewer bits and scale the values up so the range is the same as Wii brand Nunchucks. I haven't checked to see if the joystick values are also lower resolution or not.

    As I mentioned earlier, I had a similar problem with a generic PlayStation 2 controller. Instead of 8-bit resolution, the joysticks only had 5-bit resolution.

    Duane
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-13 15:56
    Thanks Duane. Initially I will only be using the gyro although I have wired both the gyro and accelerometer to my QuadCopter. At least now I can begin to check the results (time permitting).

    However, this does serve those who would like to use the wii clones (or legit) in other projects such as robots as well.
Sign In or Register to comment.