SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
This thread is privately moderated by c2po, who may elect to delete unwanted replies.
Old May 21, 2011, 02:22 PM
Sudden Freak
c2po's Avatar
Atlanta, GA
Joined Oct 2006
330 Posts
Mini-HowTo
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:
http://homepage.hispeed.ch/peterfleu...ic2master.html
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).
c2po is offline Find More Posts by c2po
Last edited by c2po; May 21, 2011 at 04:31 PM.
Reply With Quote
Sign up now
to remove ads between posts
Old Jun 21, 2011, 03:45 PM
Registered User
Wagner Loebel's Avatar
Brazil
Joined Dec 2005
8 Posts
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 !
Wagner Loebel is offline Find More Posts by Wagner Loebel
Reply With Quote
Old Jun 21, 2011, 07:06 PM
Sudden Freak
c2po's Avatar
Atlanta, GA
Joined Oct 2006
330 Posts
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.
c2po is offline Find More Posts by c2po
Reply With Quote
Old Jun 21, 2011, 09:24 PM
Registered User
Wagner Loebel's Avatar
Brazil
Joined Dec 2005
8 Posts
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 !
Wagner Loebel is offline Find More Posts by Wagner Loebel
Reply With Quote
Old Sep 15, 2011, 11:10 AM
Registered User
Joined Sep 2011
7 Posts
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.
boko111 is offline Find More Posts by boko111
Reply With Quote
Old Sep 16, 2011, 01:28 AM
Sudden Freak
c2po's Avatar
Atlanta, GA
Joined Oct 2006
330 Posts
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.
c2po is offline Find More Posts by c2po
Reply With Quote
Reply

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 Talk 0 Mar 11, 2011 02:37 AM