WII nunchuck based Remote control

Now for something completely different :laughing: This is a work in progress. I thought I would give a heads up about this, to see if anyone else is interested in this and to see if anyone has any suggestions. Sorry in advance for this random babbling.

For awhile now I wondered about the feasibility of making a version of the remote control based on using two WII nunchucks instead of normal joysticks. So over the last couple of days I started to play with the concept. One nice thing about these is that you can pick up one of these for under $15, and it has accelerometerer, plus joystick and 2 buttons and I happened to have 2 of them that I used with a WII console. Here are some of the places I have found useful information:

sparkfun.com/products/9281 : I purchased two of these awhile to connect the nunchucks without having to modify the nunchuck. But I misplaced one of them :frowning:. So I used the other one to hook up the first one.

windmeadow.com/node/42 : This link shows which color wires are what. From this I connected up the 2nd one simply crimping pins onto the 4 wires.

todbot.com/blog/2008/02/18/wiich … available/ : Linked to by sparkfun. This is where I downloaded some test code for trying out one nunchuck on and Arduino using the hardware I2C.

hacknmod.com/hack/how-to-cheap-a … -nunchuck/

Step 1: Hook up the first nunchuck. I am using an Seeeduino Mega with prototype Botboarduino shield. Hooked up to 4 I2C pins. I tried out the test code up on todbot.com (link above) and it appears to work like a champ. I am passing 5V to the nunchuck and so far it appears to be fine…

Step 2: Hook up 2nd nunchuck. This is where it starts to get complicated. The nunchuck appears to have a fixed I2C address and I have not found any way to change it, so they can not be connected on the same I2C buss. I have seen a couple places on the net (like: wiimoteproject.com/general-d … uino-help/) , that fix this by using a couple of extra IO lines and transisitors hooked up to SDA lines of the two nunchucks to be used as enable lines. Did not like this approach as it requires hardware mods…

So I decided to try to hook up the 2nd one to 2 IO lines and use a software I2C library. I downloaded a library from (forums.adafruit.com/viewtopic.php?f=25&t=13722). I also hacked up the nunchuck test program from Step 1 to handle both. Unfortunately the 2nd one was not returning any valid data. I found that this library was a lot slower talking to the device than the hardware I2C, so I started to hack on the library. I replaced all of the calls like: digitalWrite(SDA_PIN, true), with a lot faster code. I did this by having the I2C init code map both the arduino SCL/SDA IO pins to the actual hardware port, pin, … So then at run time I could simple set/clear the appropriate bit. This sped it up a lot. Still no luck, so I spent a lot of time using my Logic Analyzer and looking at the hardware I2C trace and the Software I2C trace and tweaked the software code, until I finally got the timings almost identical and I now have it working pretty well. :slight_smile:

Still need to clean this up.

Next Steps: Clean up the code to abstract out if I am using hardware or software.

Then: Build a version of the Phoenix Control that uses this. Will hook up an XBee… Hardware wise I may simply add the Nuncucks to my Arduino Remote… Assuming this works well then the fun begins. Things like how best to use these controls.

For example could use Left joystick to do the walking

Maybe use 1 set of acceleramters to maybe control translation?
Maybe use 2nd set for rotations?
Things I need to play with is, do you use the values of the acceleramters all of the time to change settings, or maybe only when a button is pressed?
…

Suggestions?

Kurt

Kurt,

How about using an iPhone! ;>)

Alan KM6VV

Great work Kurt!
I’m not familiar with Wii products but it sounds like your having some fun though. :smiley:

Didn’t Xan also use the WII remote for controlling his Blackwido (Phoenix copy)?

Hi Kurt,

Looks like you are working on the controller I started with. Did you ever see my first few video’s on youtube?


It’s a long time ago so the phoenix code wasn’t that advanced at the moment. The Wii-remote uses bluetooth. It’s a HID client device. I searched for embedded BT modules that supported a BT HID devices. I could only find HID client or SPP devices at the time. So I made myself a small C# program on my PC. The PC connects tot the Wii remote using BT (HID) then translates the values in to a serial stream containing all remote values. The stream is send to the BlueSmirf using a second BT connection.

I see you are only planning on using the nun-chuck so that doesn’t give you the BT problem I had. But still, if you need some more info about my solution, let me know!

Xan

Thanks guys,

Xan, yep I remembered that you had done it earlier using the whole WII controller. I liked the way that you could control the positions and angles of the Phoenix by rolling and rotating your arm. So I always thought it might be fun to try making some with them. Also as some of the references mentioned, you can get one of the nunchucks for about $15 just to use the accelerometerer, which if you purchased a 3 axis breakout board from sparkfun (sparkfun.com/products/8791), it would cost you $45.

As you mentioned if you use the whole WII controller, you need to talk to it using BT, might be interesting at some point to work with it, but for now simply using I2C is a simplerlier (other than dealing with 2 devices with the same address).

Zenta - You always do such a great job of choreographing your robots moves and the great control you have with them with the current DIY remote, which I could never come close to emulating. I wonder if something like this would make it easier or not?

As I mentioned so far this is simply an experiment to try it out and see how well it works. Not sure what other hardware I will use with it. Maybe the touch display that should arrive late this week.

Just having fun.

Kurt

May help…
the controller i use for my copter use Wm+ and nunshuck sensors.
WWW.multiwii.com
It’s arduino based …!

Thanks,

I will look at it. I am still having a little issues getting the inputs correct on the software I2C. On the read of each packet, it appears to be getting the first several bytes correct, but the last couple can get screwed up. I noticed that on the hardware I2C line, that the timing between bytes is not consistent. That is the first byte after the write of the address, comes in 43us, the next ones come in at 23, 24, 25.5 27 and the last one at 34.5. My software version is clocking all of them in with about 24.5, may try bumping this up slightly and see what that does… But I wonder if the nunchuck is doing some clock stretching. May need to experiment to see if I can set it up to be able to detect this or not.

Kurt

Did you enable the pullup?

Thanks Eric,

Yes the internal Pullup is enabled on the data line. I am guessing that the issue is with the SCL line. As I mentioned in the previous post on the hardware I2C connection, the low period between when the previous bytes ACK bit was clocked and the first bit of the last byte appears to take a lot longer. Previous byte was 27us, but the last one is 34.5. On the software version I have the delays all pretty much fixed.

In the I2C Standard, a slave device can hold the CLK line low to say it is not ready (Clock stretching). On the ATMega the IO pins associated with SCL and SDA when in I2C mode are setup to be Open Drain and as such can detect this. What I am not sure of is with normal IO pins, that we set as either input or output, is there a way that when it is set to be an output pin and I tell it to go HI, but the other side has set it to go low, if there is any way I can detect this.

Back to looking at the PDF manual…

Kurt

Ok…

If that can help you in any way
source multiwii.googlecode.com/svn/tags/MultiWii_1_8_patch2.zip

Thanks Kurt! To be honest, I’m not sure if that would make it easier. Probably harder… Personally I find using my fingertips to give the most accurate result. I believe there is a reason why RC plane and copters still are controlled with joysticks.

But your project sure looks like fun though!

I would like to have that as an option in the DIY transmitter.
Just adding sensors in the case and use them if needed… :wink:

Thanks Zenta,

It will still be fun to get this far enough to try it out. Who knows maybe it will work great for people like me, who my brother used to kid that I was ambidextrous: equally uncoordinated with both arms :laughing:

Eric, as you mentioned, it could still open up a couple of different possibilities. Could add connections for two of them to the DIY to use when appropriate, or could use 1 of these and tear it apart and install inside the case of the DIY, just for the accelerometer…

Anyway having fun and learning a few things along the way.

Kurt

P.S. - I am enjoying Firefox’s spell checking as I type in :smiley:

Made a little progress today playing with the nunchucks. I cleaned up the code to have a base class (nunchuck) and two derived classes for one using the hardware I2C and another one that uses software I2C, also hacked up the test sketch to try it out. Decided to upload the sketch as well as my hacked up software I2C in case anyone might be interested.

Kurt
WiichuckDemo-111104a.zip (6.78 KB)

Woot woot…!

I have been playing around some more with the touch display. Still lots to do, but some things are limping along:

I have buttons that press, and I have some real real ugly sliders, that sort-of work. That is if you press inside them drag around and release they will update. Need to update the mechanics some and for sure the visuals of them.

The buttons are still fixed 0-F and up/down/OK type buttons. I probably need to rework how the touch operations work some as I hard hang in loop once you press, until you release. So no messages will be sent out during that time. Not sure yet if I will handle this with call-outs, or if I will handle it with having the press return before it is done and remember state…

Will play a little more here and then will work on getting the DIY XBee data sent and try to control a robot with the 2 nun-chucks…

Kurt