Code: Select all
// PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value
if (rcData[THROTTLE]<1500) prop2 = 100;
else if (rcData[THROTTLE]<2000) prop2 = 100 - (uint16_t)dynThrPID*(rcData[THROTTLE]-1500)/500;
else prop2 = 100 - dynThrPID;
for(axis=0;axis<3;axis++) {
uint16_t tmp = min(abs(rcData[axis]-MIDRC),500);
#if defined(DEADBAND)
if (tmp>DEADBAND) { tmp -= DEADBAND; }
else { tmp=0; }
#endif
if(axis!=2) { //ROLL & PITCH
uint16_t tmp2 = tmp/100;
rcCommand[axis] = lookupRX[tmp2] + (tmp-tmp2*100) * (lookupRX[tmp2+1]-lookupRX[tmp2]) / 100;
prop1 = 100-(uint16_t)rollPitchRate*tmp/500;
prop1 = (uint16_t)prop1*prop2/100;
} else { //YAW
rcCommand[axis] = tmp;
prop1 = 100-(uint16_t)yawRate*tmp/500;
}
dynP8[axis] = (uint16_t)P8[axis]*prop1/100;
dynD8[axis] = (uint16_t)D8[axis]*prop1/100;
if (rcData[axis]<MIDRC) rcCommand[axis] = -rcCommand[axis];
}
rcCommand[THROTTLE] = MINTHROTTLE + (int32_t)(MAXTHROTTLE-MINTHROTTLE)* (rcData[THROTTLE]-MINCHECK)/(2000-MINCHECK);
I wondering what tmp means.. in order for that i need to understand what rcData[axis] and MIDRC mean..
and whats the difference between rcData[axis] and rcCommand[axis]?
sorry too many questions..