UPDATE 2: This thread is now obsolete! If you're having similar issues to what's been described below, please, report it in this thread.
UPDATE 1: It's now confirmed that there's been a bug found and that it affects some or most of the later production batches of APM2 boards. The bug doesn't affect earlier hardware versions -- only some of the APM2 boards. The problem is that some of the earlier MPU6000/6050 chips don't seem to conform to spec and they had different accelerometer readout scale in the 4g sensitivity range than the now-spec-conforming chips. What this bug does is it basically causes your accelerometer reading to be twice as big as it should which on the other hand causes the tilt angles calculated from the accelerometer readings to be erroneous causing the "creeping" of the attitude estimate. This problem if described in detail below.
THE EASY WAY TO CHECK IF YOU'RE AFFECTED: Just connect to your APM2 with Mission planner and in "Flight data" -view click "Status" and check out your ax, ay and az readings. While keeping your board level your az-reading should be about -1000: if so you're not affected! If the reading it is closer to -2000, however, you're affected by the bug..
If you're affected there's a quick and dirty patch below in the comments that you can use until the official update comes around.
I finally got my APM 2 a week ago and even flew my quad a couple of times more or less succesfully. However, last evening I finished installing my roll-tilt camera mount to the copter and noticed that after a short roll it takes 2-3 seconds for the copter to converge to the actual position. I then started looking into this matter more thoroughly and after shaking my copter around for quite a while I came to the conclusion that it appears the scaling factors of raw gyro output are too small: i.e. the attitude change given by the gyros is too small for any given movement and after the movement it takes 2-3 seconds for the APM2 to converge on the accelerometer reading. Here's a screencap demonstrating the issue:
What you see in the screen cap above happens every time and even after very slow movements. The problem exists on both the roll and pitch axis on my APM2 and makes the autopilot absolutely useless for stabilizing my camera mount as the error can easily be 10-20 degrees plus whatever lag the servos themselves induce.
Is this normal behaviour for APM2? If not what can I do about it?
Oh, and I'm on Win7, and ArduCopter quad 2.5.4. Log file demonstrating the issue further is attached.
I've had my headdown for the past few days working on other things but according to Pat + Tridge it does appear to be a Invesense hardware issue with the earlier batch of gyros. At least one dev (Justin) noticed the mismatch between the datasheet and the hardware way way back but we went ahead and tailored the software with scaling we were seeing with the hardware (which makes sense 'cuz specs can be wrong :-))
Now that the later batches do match the datasheet, our software doesn't! So Pat's sorting out a patch that will work for both and then we will need to do some testing and a release (probably 2.5.5).
nice analysis and patches!
can someone please provide the correct code for Arduimu v3 ?
Wow! Terrific find everyone. Two thumbs up from this guy. The new scaling and PD loop for the camera stabilization made all the difference in the world for me. March APM2.
EXACTLY THIS kind of global collaboration is why I love Open Source projects, reminding of the good old days when linux was born.
Thanks to all involved.
Congrats on a great find Sami. Also the improved camera stabilisation looks promising to me. Been having issues with camera stabilisation being too jerky. Can't wait to test your mod and see if it improves that.
Don't know if the mod I made will help jerkiness but it should help if your servos have been "lagging" behind. Also you might have to change the D coefficients in the Camrea.pde to make it work well with your servos and camera gimbal as it's now tuned for my cheapo analog servos which needed pretty high D coefficients. Hope this helps!
thanks again for your help on this.
At the risk of appearing to hijack your work on this, I've started a new discussion here. I set up a new discussion instead of using this one just because I wanted to make the instructions on what we need from the community to fix the bug really clear.
If people on this thread have found the problem could you go over there and post your logs? (Sami, we've already picked up yours from above).
I don't mind at all. It's a community effort and whatever is the quickest and best way to tackle this bug for everyone is the best way for me as well. Moreover my minuscule efforts hardly compare to what you developers have done for us -- so it's rather you and the other devs who should be thanked.
Is the issue here that the _earlier_ boards had an issue and not the later boards, but the code was written with the earlier ones in mind? IE, newer boards don't actually have something wrong with them? I'm asking this because my APM2 order is due to be filled in the next batch of orders (whenever that is :D)
Neither the earlier nor the later boards have any actual hardware issue but rather a deviation from specified properties of the inertial sensor chip which the current flight software doesn't take into account. The actual issue is more of a software bug so you have nothing to worry about: there's absolutely nothing wrong with the newer boards, AFAIK.
It's not really a "software bug" in a true sense, it's more of a hardware bug.
Invensis published a specification stating the scaling of the Gyro/Accel chip, but when the developers first starting writing code for APM2, they found that the scale was half of what it should be. So, they just wrote the code to work with that scale factor, and moved on. Boards continued to be made this way for an unknown period of time.
Then, at some unknown point, and with no warning, Invensis started to make the chips with the specified scale factor. This meant that the code designed for the old chips didn't work on the new boards.
So, the code doesn't have a bug. And neither of the boards/chips are "bad". It's just that we need to adapt the code to work with either chip. It's actually a very easy thing to do, Sami has already done it. But the difficult thing is to figure out a way to do it that doesn't require the user to do anything, or be aware of which board they have or a date code, or anything like that. Automatic, and invisible. Unfortunately, that may not be possible. We'll see.
my arduino doesn't seems to show proper heading values.On turning the board by 90 degrees,sometimes it shows about only 50 degrees of turn while other times may also show more than 170 degrees of turn ....
also my accelerometer doesn't seems to provide good results at a faster speed.I have tried both of the values of gravity 4096 and 9192....what should i do now ...also can some suggest me how to convert acceleration values to total distance covered if my sampling period is 1/8 sec so that i can cross check it .. ...plzz pour down ur suggestions...