Thread Tools
This thread is privately moderated by c2po, who may elect to delete unwanted replies.
May 21, 2011, 02:22 PM
Sudden Freak
c2po's Avatar

How to make cheap Nunchuk clone work with MultiWii code

I've got quite a few cheap Nunchuk clones from Ebay, all of them are different, and pretty much all of them work fine, but...
One of the clones had a nice Bosch BMA140 analog accelerometer instead of a usual ADXL335, and looking at the raw data using special Arduino test sketch I like it much better than others.

So after I made MultiWii work directly with ITG3205 gyro from Motion+ I decided to add standalone Nunchuk as accelerometer. As I know this one works fine, so I was kind of surprised when I saw no data in MultiWii GUI after I connected it to the board. I looked at the code, verified connections, tried few options, changed I2C speed back and forth between 100 and 400kHz, even did a voodoo dance and casted some spells - nothing, nada, zip.

Puzzled with that I put in debugging print statement - well, all six bytes of data read as 0xA5, which is actually the Nunchuk read address sent in the previous statement.
Hmm... I know it works, OK? I'm sure the problem is not in the connections or the hardware. This Nunchuk works in test sketch just fine at 400kHz I2C speed.
I started looking at the I2C read and write procedures, and there was something in them that made me suspicious...

So three hours later around 4am in the morning original MultiWii I2C read/write code was replaced with very similar code borrowed from Peter Fleury I2C Master library:
Looks like Alex code is also based on that, but was heavily optimized for speed and size, removing some parts.
The result - absolutely fine working cheap Nunchuk clone accelerometer in the MultiWii code at the 400kHz I2C speed, and the only thing I changed were I2C procedures. Cycle time is about 2250-2300us (so update loop is around 440Hz) which is really not bad. It flies beautifully and very stable in both Acro and Stable mode, need to make a video to prove it.

So I guess a code optimization is a good thing, but only to a certain point, beyond which it works only with some particular hardware (like original Nunchuk) and/or not at all speeds (100kHz only).
Last edited by c2po; May 21, 2011 at 04:31 PM.
Sign up now
to remove ads between posts
Jun 21, 2011, 03:45 PM
Registered User
Wagner Loebel's Avatar
Oh boy... I'm angry with my MultiWii I have the same problem with NK clones, I tried everything but it refuses to work. Here in Brazil is very hard to get an original one... Glad to see that you can make it run !
I tried to replace the I2C code as you did but I'm getting some error messages when compiling.
Can you share your .pde with the new I2C library ?
Thanks !
Jun 21, 2011, 07:06 PM
Sudden Freak
c2po's Avatar
Sure, here it is attached.
It is based on the V1.7, but is heavily modified, it is for a QUADX configuration, a lot of code stripped out (like for other sensors), also I changed some pins (for LCD and LEDs), so check if it matches your particular setup and sensor orientation, I have my Nunchuk rotated 90 degrees from original.
All changes I made are pretty much documented at the beginning of the code and also in the comments.
Or you can just use the I2C code portion from it, it is right after the original code which is commented out.
Jun 21, 2011, 09:24 PM
Registered User
Wagner Loebel's Avatar
Wow, thanks ! I'm leaving the office right now and when I arrive at home I'll try it... Fingers crossed ! I'll be in touch !

Thank you !
Sep 15, 2011, 11:10 AM
Registered User

DE numchuck

I have the same one as you have a mp v3.0 2010.12.08 do you have a schematic of the pcb of the mp what is ground and how from 3v to 5v etc. thanks fore the software.
Sep 16, 2011, 01:28 AM
Sudden Freak
c2po's Avatar
I do not have a schematics and never really needed it, I'm using only ITG3205 gyro connecting to it directly as described in my other post. There is a picture in the post where ground and 3.3V power pads are shown with black and red color.
You need to power that board with no more that 3.3-3.5V.

Also read and search the main thread about MultiWiiCopter, there are tons of information, pictures, schematics, connection diagrams etc., most info is referenced in the first post of that thread.

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Help! How to make ailerons work? BillzillaAus The Builders Workshop 23 May 10, 2011 06:14 AM
Discussion Telemetry fuel gauge - How to make it work? S_YORAM1@BEZEQIN Hitec/Multiplex USA 2 May 03, 2011 09:24 AM
Discussion Calibrating ESC's using multiwii code mstanescu Multirotor Drone Talk 0 Mar 11, 2011 02:37 AM