Casts added to several functions in PID section
Signed-off-by: mdhsweden <mdhsweden@gmail.com>
This commit is contained in:
parent
4b7fd40967
commit
40454ae608
@ -104,7 +104,6 @@ float calcGravity(accel_t profile ) //const float x_axis, const float y_axis, co
|
||||
float convertData(int inputRange, int outputRange, int offset, float value)
|
||||
{
|
||||
return ((float)outputRange/(float)inputRange)*(value-(float)offset);
|
||||
//return 1.0;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
@ -113,9 +112,9 @@ float convertData(int inputRange, int outputRange, int offset, float value)
|
||||
**************************************************************************/
|
||||
float constrainf(float amt, int low, int high)
|
||||
{
|
||||
if (amt < low)
|
||||
if (amt < (float)low)
|
||||
return (float)low;
|
||||
else if (amt > high)
|
||||
else if (amt > (float)high)
|
||||
return (float)high;
|
||||
else
|
||||
return amt;
|
||||
@ -313,7 +312,7 @@ void pidUAVcore(pidProfile_t *pidProfile, pidProfileBuff_t *pidProfileBuff,
|
||||
|
||||
// limit maximum integrator value to prevent WindUp - accumulating extreme values when system is saturated.
|
||||
// I coefficient (I) moved before integration to make limiting independent from PID settings
|
||||
ITerm = constrainf(ITerm, -PID_MAX_I, PID_MAX_I);
|
||||
ITerm = constrainf(ITerm, -(int)PID_MAX_I, (int)PID_MAX_I);
|
||||
|
||||
// Anti windup protection
|
||||
if (motorLimitReached)
|
||||
@ -363,8 +362,9 @@ void pidUAVcore(pidProfile_t *pidProfile, pidProfileBuff_t *pidProfileBuff,
|
||||
{
|
||||
ITerm = 0;
|
||||
pidProfileBuff->lastITerm[axis] = 0;
|
||||
pidProfileBuff->ITermLimit[axis] = 0;
|
||||
}
|
||||
pidProfile->PID_Out[axis] = constrainf(PTerm + ITerm + DTerm, -pidProfile->pid_out_limit, pidProfile->pid_out_limit);
|
||||
pidProfile->PID_Out[axis] = constrainf(PTerm + ITerm + DTerm, -(int)pidProfile->pid_out_limit, (int)pidProfile->pid_out_limit);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
Reference in New Issue
Block a user