Wii Controller Objects (Nunchuck, Classic Controller, MotionPlus)
DogP
Posts: 168
Hey,
Here's some Wii Controller Objects for the Propeller (in Spin). They allow you to connect the Wii extension controllers (ones that plug into the Wii Remote) to the Propeller (Nunchuck, Classic Controller, MotionPlus). The devices are I2C, so the easiest way to connect them is to pins 28 and 29 of a Prop board that already has an I2C EEPROM (otherwise you can use any pins and make sure you add the pullup resistor on the SDA line), and of course connect to VCC and GND. The sample programs output the data to the serial port. This format isn't the best since the field width varies, so it's hard to watch as you go, but you can view the data in Excel as comma seperated values, or output in a fixed width format (I didn't see a fixed width output for signed decimal in the serial object I used and didn't feel like messing with it). I figure the code shows how to use it and anyone else will see it work with that demo then implement it into their own code anyway.
This code is based on a Wii nunchuck example project by John Abshier, which was based on code originally by Jo
Here's some Wii Controller Objects for the Propeller (in Spin). They allow you to connect the Wii extension controllers (ones that plug into the Wii Remote) to the Propeller (Nunchuck, Classic Controller, MotionPlus). The devices are I2C, so the easiest way to connect them is to pins 28 and 29 of a Prop board that already has an I2C EEPROM (otherwise you can use any pins and make sure you add the pullup resistor on the SDA line), and of course connect to VCC and GND. The sample programs output the data to the serial port. This format isn't the best since the field width varies, so it's hard to watch as you go, but you can view the data in Excel as comma seperated values, or output in a fixed width format (I didn't see a fixed width output for signed decimal in the serial object I used and didn't feel like messing with it). I figure the code shows how to use it and anyone else will see it work with that demo then implement it into their own code anyway.
This code is based on a Wii nunchuck example project by John Abshier, which was based on code originally by Jo
Comments
My motion plus shows up on 0xA0...
Nunchuck on 0xA4
Any Ideas ?
Here is a scanner for i2c bus
Earl
Post Edited (Ole Man Earl) : 6/20/2009 9:28:05 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
TERMS OF USE: MIT License
"Permission is hereby granted, free of charge, to any pers...........................
..............................OMITTED FOR FORUM...............................................
.................. OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "
If the ranges go outside about 8400, the thing quits with values 8407,8203,8124
then I need to reload or rerun the program.
Earl
or my OSD
or
Hope to find time to try this out with my new PSM board!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
Yup, it was noise..
And dog, feel free to use any of my mods!
Post Edited (Ole Man Earl) : 6/21/2009 12:26:42 AM GMT
BTW, you can see the Nunchuck and Classic Controller in action here: . They're hooked to the propeller, which is also emulating the controller to the Nintendo Virtual Boy. The first part (with the nunchuck) is one of my homebrew demo apps, and the second part (with the Classic Controller) is a commercial game (Red alarm). I'm outputting it to my projector rather than the headset since it's easier to get a video of (although my camera had some problems which made some video glitches and choppy audio). I haven't done a video for anything with the MotionPlus yet... I'll have to make a demo app that shows off 3 axis rotation.
DogP
Earl
next to combine them for a 6DOF demo !
here goes
Earl
DogP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontroled.
If it's not Parallax then don't even bother. :-)
Propeller SRAM TV driver winner: ==NOT COMPLEATED:·2 1/2·WEEKS UNTIL ENDING TIME==
I just figured a couple days on the forum to get some feedback would be good since I've never put anything on there, so if I'm doing something wrong, I'd rather fix it before posting. I saw someone get ripped for not using document comments, which I never used before, since I'm mostly a C programmer where there's just one type of comment. I also didn't know if there was a certain convention for varous things like constants and other things (in C, typically #define'd constants are ALL_CAPS). But yeah, I think I did most things right (from looking at other code and reading the manual), but if not, I'd like to change now, and get any immediate feedback that anyone has, and maybe make any quick changes before posting.
DogP
How about we get a team together to develop a 6DOF with Kalman filtered output on a circuit board with a prop and a place to mount the nunchuck and motion plus boards ? Would not be hard to do. I can design the circuit board, and some of the software. Just think of it. A <$50 6DOF that is accurate over time ! The autopilot and UAV guys will go bananas over it.
Earl
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontroled.
If it's not Parallax then don't even bother. :-)
Propeller SRAM TV driver winner: ==NOT COMPLEATED:·1 1/2·WEEKS UNTIL ENDING TIME==
Don't wait that long...most of the stuff in the Obj's are not perfect and could use some work. That's the purpose of the Obj's. Post it and they will come !
DogP
DogP
Great on the Obex !
I will take on the project of a 6DOF wii with Kalman filter and a PCB to mount then on.
This won't be real quick as I am flying out to the Expo on Friday.
First is to combine the nunchuck and motion plus into one program and display on TV. I have made some progress on this one but the gyro wont work at the same time as the nunchuck.
Here is the progress I made so far.....help someone ?
Post Edited (Ole Man Earl) : 6/22/2009 7:28:32 PM GMT
There are a couple of choices I can see.
1. Connect them to the prop with separate pins, i.e. have 2 I2C buses then they will not conflict.
2. Activate and deactivate the devices before and after accessing them. You have the activate code - http://abstrakraft.org/cwiid/wiki/MotionPlus describes the deactivate for motion plus to be write $55 to $a400f0. There might be a similar command for the numchuck - might be the same.
3. Try connecting numchuck to the motion plus extension socket. It could be when the motion plus is activated the expansion socket is deactivated, then you only need to activate/deactivate the motion plus via 2.
DogP
There is some hints (see https://docs.google.com/Doc?id=dds4pks_606fmcd6zwt&hl=en) that the motion plus can take some time to initialize.
You might want to put a long delay (several seconds) from enabling motion plus to reading and see if this corrects the problem. If yes then reduce the timeout until it fails
Surely we can also read both quickly for the 6DOF !
The nunchuck and motion plus individually give correct data. Can't seem to put them in one program to get both. What happens is the nunchuck data is fine but the motion plus is all over the place. Yes, like they are fighting for the i2c bus, except for the fact the nunchuck data is correct so I don't thing they are competing for the bus. The motion plus data must be on a different address when the nunchuck is plugged in ??
I don't think the "pass-through" is truly a pass-through... IIRC the pins aren't shared between the front and back (the Wiimote communicates to the MP, which communicates to the pass-through peripheral). I'm going completely by memory though, so you should verify. I'm guessing there's a command or memory location to talk to the pass-through (I don't have any MP games or I'd log them on my Logic Analyzer when they talk to an extension). What I do know though is with the MP plugged in with a nunchuck, the nunchuck doesn't work on old games (so it must not just pass it through).
DogP
That said, the NEW games that take advantage of the MP and NC connected to the back of the MP must access something in the MP to get the acceleration data while also having access to the MP gyro data in the first six bytes. I will do a program to dump the MP data and see what bytes are changing relative to the NC movement.
Once we have that figured out, THEN we can write a 6DOF program for the Parallax Propeller that will open the prop to many new programs and applications !
I realize this it not a forum for the Wii, BUT a collaboration of ideas to get inexpensive hardware to work with the prop for more prop applications.
OK, I think I have run out of all the big words I can look up in the dictionary.......
I hope we all can figure this out. Any other efforts along this line I have seen are thru linux and bluetooth, not i2c.
But yeah... there's not many people working this from the I2C side... luckily it's easy to figure out how to use it over I2C from how people interface through the Wiimote in Linux or over Bluetooth to a PC.
DogP