hi ,

i am working on quad copter (x ) configuration its having the following spec

1)imu → mpu6050 with dmp
2) control board :Aurdino due

  • other usual things …

i had done the roll and pitch logic now , in that PID logic is mine …but when i am trying to tune the PID i am seeing a pendulum effect its rolling right and left uncontrollably…the pid lib in aurdino is not accepting -ve values thats y i had used my own code …kindly go through my code and throw some light on this issue

Midhun Mohan

x_quad.txt (25.6 KB)

the pid lib in aurdino is not accepting -ve values

Sorry, that is not true. The actual value can be above or below the setpoint, and the output should be defined correctly. Post some proof, if you are seeing different results.

I saw a really neat link on PID, where a guy had variations on the P, I, and D terms, and showed the effects of them individually and in combination. Unfortunately, I didn't save the link.

    attachInterrupt(INTERRUPT_PIN, dmpDataReady, RISING);

The attachInterupt() function does NOT take a pin number as the first argument. It takes an interrupt number which is related to a pin.

Which Arduino is this code for? You have 7 calls to attachInterrupt(). Most Arduinos don't have 7 external interrupt pins.

    PIDR (Roll_Des , Roll_Act , KP ,  KI , KD  );
    PIDP (Pitch_Des , Pitch_Act , KP ,  KI , KD  );

Does it really make sense to use the same terms for roll and pitch?

How do those two functions REALLY differ? Why do you need two functions that appear (without a lot of study) to do the same thing? At first glance, it is only the static variables in the functions that are different. Use global variables, arguments, and ONE function, unless there is some non-obvious, fundamental difference.