Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Propeller Chip > Wii Controller Objects (Nunchuck, Classic Controller, MotionPlus)  Forum Quick Jump
 
New Topic Post Reply Printable Version
46 posts in this thread.
Viewing Page :
 1  2 
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

DogP
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/20/2009 12:21 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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,
DogP

Post 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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 1:20 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
neat ! Here is the TV version.
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



File Attachment :
TestMotionPlusTV.spin   1KB (application/octet-stream)
This file has been downloaded 72 time(s).

File Attachment :
i2cTVAppSCAN.spin   8KB (application/octet-stream)
This file has been downloaded 81 time(s).
Back to Top
 

Clock Loop
=MC²



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2005
Total Posts : 615
 
   Posted 6/20/2009 2:58 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
These devices need to be combined with Phills 3D Red/Blue video interface somehow...


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. "

Back to Top
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 3:05 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 3:29 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Or with a heads up camera
or my OSD
or
Back to Top
 

Rayman
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2007
Total Posts : 2677
 
   Posted 6/20/2009 3:31 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
This is good stuff... I have a few adapters that I piggybacked on another PCB board I did. I'll give them away free at the expo...

Hope to find time to try this out with my new PSM board!


My Prop Info&Apps:  http://www.rayslogic.com/propeller/propeller.htm

Back to Top
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 3:35 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 3:53 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Also, I find after initializing, 0xA0 shows up in my i2c bus scan.

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

Back to Top
 

DogP
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/20/2009 7:13 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 7:34 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Yes, and great work also. Here is my latest spin for the nunchuck as well as the motion plus with output going to the TV
Earl

next to combine them for a 6DOF demo !

File Attachment :
TestMotionPlusTV.spin   3KB (application/octet-stream)
This file has been downloaded 87 time(s).

File Attachment :
TestNunchuckTV.spin   3KB (application/octet-stream)
This file has been downloaded 55 time(s).
Back to Top
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 7:51 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/20/2009 8:31 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
Another atabbb....

here goes
Earl

File Attachment :
6DOFwiiTV.spin   4KB (application/octet-stream)
This file has been downloaded 86 time(s).

File Attachment :
6DOFwiiTV.spin   4KB (application/octet-stream)
This file has been downloaded 62 time(s).
Back to Top
 

DogP
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/20/2009 11:15 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 

microcontrolled
Spinning......



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2008
Total Posts : 1028
 
   Posted 6/21/2009 4:33 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
There is one thing that most neglect to do when they make an object: PUT YOUR OBJECT IN THE OBEX! If you leave it in the forum, the tread will die on comments an it will go off the starting page where it will never be seen agian. There are so many great objects written out there that are lost because they don't get posted in the OBEX. Phil's "talk" and "3D Graphics" objects, for example. These are great objects that no one ever sees!! Objects are written but then they the person who created it will wait for them to be perfect before they post them; and then they end up never being posted!!! Post these great objects!


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==

Back to Top
 

DogP
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/21/2009 8:40 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/21/2009 10:47 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 

microcontrolled
Spinning......



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2008
Total Posts : 1028
 
   Posted 6/21/2009 11:22 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Your right about that! The autopilot guys would love the gyro as a steadying system in thier aircraft, and the Hydra guys would come up with an interface to the nunchuck and classic controller. (or perhaps a new motion controlled Hydra) :-)


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==

Back to Top
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/21/2009 12:59 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/21/2009 8:00 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/22/2009 7:57 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Just wanted to say they're up in the obex now.

DogP
Back to Top
 

Ole Man Earl
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/22/2009 9:53 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



File Attachment :
06-21-09-wiiTV.zip   47KB (application/x-zip-compressed)
This file has been downloaded 73 time(s).

File Attachment :
06-21-09-wiiTVcombo.zip   47KB (application/x-zip-compressed)
This file has been downloaded 65 time(s).
Back to Top
 

Timmoore
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined May 2008
Total Posts : 756
 
   Posted 6/22/2009 10:35 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
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



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 258
 
   Posted 6/22/2009 11:28 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
see my combo code above...ALMOST works...deactivate etc...close but gyro numbers are not quite right.
Back to Top
 

DogP
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jan 2007
Total Posts : 125
 
   Posted 6/22/2009 12:47 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined May 2008
Total Posts : 756
 
   Posted 6/22/2009 12:50 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
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
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
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