PID Library/Kalman Filter problem

Hi,

I am making a quadrotor controller using an arduino micro, and an MPU6050 gyroscope with a kalman filter (based on the one found here https://decibel.ni.com/content/docs/DOC-30248). I am also using the PID library (Arduino Playground - PIDLibrary)

The Kalman filter works fine, and I can include one axis PID control, but if I try to add this: //PID pid1(&Input[1], &Output[1], &Setpoint,KP,KI,KD, DIRECT); for the second PID controller, then for some reason I get a problem.

Once I add the second controller, the Kalman filter stops working. The problem seems to be in passing the variables accel_angle_y and accel_angle_x to the function getAngle(). They end up as NaN within the function, but the other variables which are passed are fine.

I have no idea what's going wrong here, so any advice would be great!

(The code attached is working, but if you uncomment the line above then it you get the problem.)

Thanks a lot in advance, and sorry for the state of the code!
James

CompleteWithPID.ino (42.6 KB)