 |
|
 |
| Parallax Forums > Public Forums > Propeller Chip > Wii Controller Objects (Nunchuck, Classic Controller, MotionPlus) | Forum Quick Jump
|
|  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/20/2009 12:21 PM (GMT -8) |   | 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ão Geada... so many thanks to them for posting their code to these forums.
BTW, for those not familiar with the Wii controllers, the Nunchuck has a 3-axis accelerometer, analog joystick, and 2 buttons. The Classic Controller has 2 analog joysticks, 2 analog shoulder triggers, a d-pad, and 9 buttons. The MotionPlus has a 3-axis gyro sensor. Overall, there's a lot of good stuff for human input and motion sensors, and a good deal at ~$20 each.
Oh... to connect these, you can buy a pre-made adapter for $4 here: store.fungizmos.com/index.php?main_page=product_info&cPath=69&products_id=212 , or me... I was too impatient to wait for an adapter in the mail, so I took a piece of double sided PCB cut to the correct size and used a dremel to divide the contacts. Or, of course, you can cut wires and hard-wire them to your project, but I didn't want to destroy my Wii components when it was easy enough to make an adapter.
Anyway, feedback is appreciated since I've never posted any code here, and I'd like to post this to the Object Exchange, so if there's any changes I should make to conform to Propeller norms, please let me know.
Thanks, DogPPost Edited (DogP) : 6/20/2009 8:38:46 PM GMT
File Attachment : TestNunchuck - Archive [Date 2009.06.20 Time 15.44].zip 42KB (application/x-zip-compressed)This file has been downloaded 98 time(s). File Attachment : TestClassic - Archive [Date 2009.06.20 Time 15.44].zip 18KB (application/x-zip-compressed)This file has been downloaded 66 time(s). File Attachment : TestMotionPlus - Archive [Date 2009.06.20 Time 15.44].zip 17KB (application/x-zip-compressed)This file has been downloaded 132 time(s). | | Back to Top | | |
   |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/20/2009 3:05 PM (GMT -8) |   | Ok, it's working now on 0xA6 and changing to 0xA4 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 | | Back to Top | | |
 |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/20/2009 3:29 PM (GMT -8) |   | | | |
 |  Rayman Registered Member
        Date Joined Jul 2007 Total Posts : 2677 | Posted 6/20/2009 3:31 PM (GMT -8) |   | | | |
 |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/20/2009 3:35 PM (GMT -8) |   | | I think I found my problem. On the proto board I am using VDD and VSS near P24. I think I have some noise on it. I am going to try a decoupling cap near the source. | | Back to Top | | |
  |  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/20/2009 7:13 PM (GMT -8) |   | Good to hear it's working for you. But yeah, I noticed my MotionPlus ACKs on 0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0xA0, 0xA1, 0xA6, 0xA7, 0xF1, 0xF3, 0xF5, 0xF7, 0xF9, 0xFB, 0xFD, and 0xFF before initialization, and then all those plus 0xA2 after init (using i2cObject's devicePresent function). I'm assuming it'll be used for compatibility with passing through future devices or something. The ACKs seem to change if I've got a controller plugged into the passthrough port as well.
BTW, you can see the Nunchuck and Classic Controller in action here: http://www.youtube.com/watch?v=WkRTIhf2O1A . 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 | | Back to Top | | |
  |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/20/2009 7:51 PM (GMT -8) |   | | Now if we can take the Accel X,Y,Z and the Gyro X,Y,Z and put then thru a Kalman filter, wow, what a 6DOF you would have for $35 ! | | Back to Top | | |
  |  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/20/2009 11:15 PM (GMT -8) |   | Yeah, I was thinking about combining the two and doing a full 6DOF driver, but that only works if it's a rigid body... and a MotionPlus and Nunchuck together aren't :/ (although they can be with a little duct tape :P ). Of course a very practical use would taking the circuitry out and mounting it to a rigid body in a robot, aircraft, etc... but I haven't had a need to do that yet... so until then, it's someone else's job ;) . Good to see someone else interested in it though... any suggestions before I submit them to the obex?
DogP | | Back to Top | | |
  |  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/21/2009 8:40 AM (GMT -8) |   | Heh, yeah... I know what you mean... I always check the obex first when I want to do something, then search the forum. A lot of times I find what I'm looking for on the forum (as I did with the original nunchuck code). That's why I planned on putting it in the obex.
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 | | Back to Top | | |
 |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/21/2009 10:47 AM (GMT -8) |   | 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 | | Back to Top | | |
  |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/21/2009 12:59 PM (GMT -8) |   | DogP 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 ! | | Back to Top | | |
 |  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/21/2009 8:00 PM (GMT -8) |   | Sounds good... I'll upload it to the obex shortly. The 6DOF board sounds fun, but I've got lots of other projects I'd like to do that I have a specific purpose in mind for. Of course I'd be glad to help out if there's something you need, but I'm not really interested in taking on a project that isn't a high priority to me. A low cost development module with all types of tracking would be pretty sweet though (accelerometers, gyros, compass, GPS). Er... I guess I should get a compass module since I've got the rest hooked up to a prop. I really don't know a whole lot about them, but I think it'd work better/easier than gyros for absolute positioning (like rotational head tracking), although I guess I could use a gyro w/ IR for long term accuracy, or even IR for all rotation tracking.
DogP | | Back to Top | | |
 |  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/22/2009 7:57 AM (GMT -8) |   | Just wanted to say they're up in the obex now.
DogP | | Back to Top | | |
  |  Timmoore Registered Member
        Date Joined May 2008 Total Posts : 756 | Posted 6/22/2009 10:35 AM (GMT -8) |   | The problem is that both numchuck and motion plus are I2C and when activated are both on address A4 so accessing either will cause the other to activate making them fight over the bus. 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. | | Back to Top | | |
 |  Ole Man Earl Registered Member

       Date Joined Jun 2008 Total Posts : 258 | Posted 6/22/2009 11:28 AM (GMT -8) |   | | see my combo code above...ALMOST works...deactivate etc...close but gyro numbers are not quite right. | | Back to Top | | |
 |  DogP Registered Member
        Date Joined Jan 2007 Total Posts : 125 | Posted 6/22/2009 12:47 PM (GMT -8) |   | I assume there's a way to get the nunchuck data on the pass-through, but I never got around to trying to figure it out (I'm sure someone will figure it out and post it online somewhere eventually though, if it's not already). I figured the easiest way would be to run 2 I2C buses, since like Tim said, they're the same address, so they'd conflict unless you constantly deactivate and reactivate.
DogP | | Back to Top | | |
 |  Timmoore Registered Member
        Date Joined May 2008 Total Posts : 756 | Posted 6/22/2009 12:50 PM (GMT -8) |   | So the motion plus is giving incorrect results but the numchuck is working? 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 | | Back to Top | | |
 | 46 posts in this thread. Viewing Page : 1 2 | | Forum Information | Currently it is Monday, February 08, 2010 6:11 PM (GMT -8) There are a total of 415,872 posts in 57,629 threads. In the last 3 days there were 78 new threads and 858 reply posts. View Active Threads
| | Who's Online | This forum has 18513 registered members. Please welcome our newest member, SEL. 52 Guest(s), 11 Registered Member(s) are currently online. Details Peter Jakacki, W9GFO, Bob Lawrence (VE1RLL), Computer Geek 101, tonyp12, Harley, Jimm2, ciamo, Bane, Peter KG6LSE, atlstang |
Forum powered by dotNetBB v2.42EC SP2.02 dotNetBB © 2000-2010 |
|
|