AltIMU-10 NAN problem

Hello all
I just bought AltIMU-10 and start to play with it.
At Resource tabe is great info and program MinIMU-9 + Arduino AHRS that i upload on my Atmega128 and all was working more less ok - my 3D object has some vibration when its sit flat on table( due roll value it change rom -3,58 to 2.1)… so by google i found if i make some changes vibration will be smaller so i made change in :

// i2c code i change to :
compass.writeReg(LSM303::CTRL_REG4_A, 0x08); // +-2 g scale high resolution output mode
// at main program i change:
// lSM303 akcelerometr +/-2 4g sensitvy
// 1mg/dig, 1g = 1000
#define GRAVITY 1000

[u]After updating atmega128 i have “NAN” at Pitch Roll and Yaw.After turning on output on this values looks like this:

Can someone tell me what is problem ?
Is is some kind overflow?
I see correlation - when GRAVITY value will be some small like…850 or something nen will occur but after long time (1h or more)


The magnetometer on the AltIMU-10 needs to be calibrated carefully to get good results. Changing the way the AHRS program works might be hard. I recommend trying the other two Arduino examples found under the “Resources” tab of the AltIMU-10 product page before attempting to modify the Arduino AHRS program.

- Jeremy

I think problem is in software not in magnetometer (i made calibration), but my lack knowledge about C cant point me where to look an error.
The same problem NAN can be obtained by adding long delay(400ms or more) in main loop


I tried making the same changes to the code that you did (defining GRAVITY as 1000 and selecting +/-2 g accelerometer full scale) and I was unable to reproduce your problem with an Arduino Leonardo. Are these the only two changes you made? Could you please zip your entire MinIMU9AHRS directory and post the zip file as an attachment so I can look over your code?

What type of Arduino or microcontroller board are you using? Does it really have an ATmega128? (Many Arduino boards, like the Uno, use the ATmega328.)

Does the problem happen when the IMU is sitting on a level surface without moving?)

- Kevin

Hi :
I’m sure i have atmega128( i use different type of configuration file my arduino 1.0.5)
I added RTC clock on PFC chip and write to SD card in my code , temp and pressure, speed of tx is 115200 but when all will be turn off by /* */ it still have NAN error
Error occurs when i move board it is not always in the same orientation.

I tried running your code with both an Uno (ATmega328P) and a Leonardo (ATmega32U4), but I still haven’t been able to reproduce your problem. (I had to comment out the RTC code). Unfortunately, I do not have an ATmega128 available to try it on. Can you give some details about the specific ATmega128 board you are using (what it is called and who makes it) and what you had to do to be able to program it from the Arduino environment?

If you run our original AHRS program without any changes in your setup, does the problem still occur? If not, what if you only change the accelerometer sensitivity and GRAVITY, but nothing else? One possibility is that your microcontroller is running out of RAM with the additions you made to the program.

Alternatively, do you have a different Arduino that you can try using?

- Kevin

PCB is my design , but to get it work under arduino i use this configuration file
As i write before when i upload original AHRS code and change Gravity also some times i’ve got NAN, when Gravity has original value 256 - no NAN (i try hard to obtain this error but no result )

Atmega128 has 4Kbyt of ram, so i think its OK for this project

One last thing to check: what clock speed is your ATmega128 running at? I was able to reproduce the “nan” output by adding a long delay to the main loop, like you said in an earlier post, and I think that makes the value of G_Dt too big (this is a measured value of how long each iteration of the loop takes to run and is used to integrate the gyro readings) and overflows a later multiplication. This should never happen if your main loop is running at close to 50 Hz as intended, but if your microcontroller is running at a clock rate much slower than the 16 MHz of most Arduinos, or if you’ve added way too much extra code to the main loop that’s slowing it down, then it might cause problems.

If that isn’t the issue, then unfortunately, I don’t have any other ideas at the moment. If you get a chance to try your code with a standard Arduino (like an Uno or Leonardo), you should see if the problem still occurs.

- Kevin

My board have round 11,0590 MHz clock
So you think problem is bad timing of main loop ?
that can be problem for me, because i use SD card lib , and some time writing on SD can take time

It’s possible the timing is the problem. As I mentioned, I haven’t been able to really reproduce the exact problem you’re having, so it seems like it’s something to do with your particular setup. I would suggest trying to increase your clock speed or trying a different Arduino running at a higher speed.

- Kevin