Yaw PID in MultiWii 2.3

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
Romeo84
Posts: 16
Joined: Wed Aug 21, 2013 8:32 pm

Yaw PID in MultiWii 2.3

Post by Romeo84 »

Hi all!

Could You please explain, why in the Multiwii.cpp in the YAW PID block of code

Code: Select all

//YAW
  #define GYRO_P_MAX 300
  #define GYRO_I_MAX 250

  rc = (int32_t)rcCommand[YAW] * (2*conf.yawRate + 30)  >> 5;

  error = rc - imu.gyroData[YAW];
  errorGyroI_YAW  += (int32_t)error*conf.pid[YAW].I8;
  errorGyroI_YAW  = constrain(errorGyroI_YAW, 2-((int32_t)1<<28), -2+((int32_t)1<<28));
  if (abs(rc) > 50) errorGyroI_YAW = 0;
 
  PTerm = (int32_t)error*conf.pid[YAW].P8>>6;
  #ifndef COPTER_WITH_SERVO
    int16_t limit = GYRO_P_MAX-conf.pid[YAW].D8;
    PTerm = constrain(PTerm,-limit,+limit);
  #endif
 
  ITerm = constrain((int16_t)(errorGyroI_YAW>>13),-GYRO_I_MAX,+GYRO_I_MAX);
 
  axisPID[YAW] =  PTerm + ITerm;


it must reset yaw if (abs(rc) > 50) errorGyroI_YAW = 0; ?? It curves my helicopter when i try to turn it in any way (clockwise or counterclockwise)... How can i improve it?

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: Yaw PID in MultiWii 2.3

Post by shikra »

It means as you are actively inputting yaw then therefore no heading hold is required...

Post Reply