#define _IQsat(A, Pos, Neg) __IQsat(A, Pos, Neg)
#define PID_MACRO(v) \
v.Err = v.Ref – v.Fdb; /* Compute the error */ \
v.Up= _IQmpy(v.Kp,v.Err); /* Compute the proportional output */ \
v.Ui= v.Ui + _IQmpy(v.Ki,v.Up) + _IQmpy(v.Kc,v.SatErr); /* Compute the integral output */ \
v.OutPreSat= v.Up + v.Ui; /* Compute the pre-saturated output */ \
v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin); /* Saturate the output */ \
v.SatErr = v.Out – v.OutPreSat; /* Compute the saturate difference */ \
v.Up1 = v.Up; /* Update the previous proportional output */
v.Err = v.Ref – v.Fdb; /* Compute the error */ \
v.Up= _IQmpy(v.Kp,v.Err); /* Compute the proportional output */ \
v.Ui= v.Ui + _IQmpy(v.Ki,v.Up) + _IQmpy(v.Kc,v.SatErr); /* Compute the integral output */ \
v.OutPreSat= v.Up + v.Ui; /* Compute the pre-saturated output */ \
v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin); /* Saturate the output */ \
v.SatErr = v.Out – v.OutPreSat; /* Compute the saturate difference */ \
v.Up1 = v.Up; /* Update the previous proportional output */
#endif // __PIDREG3_H__
// Add the lines below if derivative output is needed following the integral update
// v.Ud = _IQmpy(v.Kd,(v.Up – v.Up1));// v.OutPreSat = v.Up + v.Ui + v.Ud;
// v.Ud = _IQmpy(v.Kd,(v.Up – v.Up1));// v.OutPreSat = v.Up + v.Ui + v.Ud;
可以解释下v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin);这句话的意思吗,
个人理解IQsat是将v.OutPreSat限制在v.OutMax和 v.OutMin之间然后赋给v.Out,后面 v.SatErr = v.Out – v.OutPreSat; v.SatErr结果为0吗?
Brian Wang0:v.SatErr是限幅前和限幅后的差值,如果v.OutPreSat并没有超过限值,则v.SatErr的结果为0
#define _IQsat(A, Pos, Neg) __IQsat(A, Pos, Neg)
#define PID_MACRO(v) \
v.Err = v.Ref – v.Fdb; /* Compute the error */ \
v.Up= _IQmpy(v.Kp,v.Err); /* Compute the proportional output */ \
v.Ui= v.Ui + _IQmpy(v.Ki,v.Up) + _IQmpy(v.Kc,v.SatErr); /* Compute the integral output */ \
v.OutPreSat= v.Up + v.Ui; /* Compute the pre-saturated output */ \
v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin); /* Saturate the output */ \
v.SatErr = v.Out – v.OutPreSat; /* Compute the saturate difference */ \
v.Up1 = v.Up; /* Update the previous proportional output */
v.Err = v.Ref – v.Fdb; /* Compute the error */ \
v.Up= _IQmpy(v.Kp,v.Err); /* Compute the proportional output */ \
v.Ui= v.Ui + _IQmpy(v.Ki,v.Up) + _IQmpy(v.Kc,v.SatErr); /* Compute the integral output */ \
v.OutPreSat= v.Up + v.Ui; /* Compute the pre-saturated output */ \
v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin); /* Saturate the output */ \
v.SatErr = v.Out – v.OutPreSat; /* Compute the saturate difference */ \
v.Up1 = v.Up; /* Update the previous proportional output */
#endif // __PIDREG3_H__
// Add the lines below if derivative output is needed following the integral update
// v.Ud = _IQmpy(v.Kd,(v.Up – v.Up1));// v.OutPreSat = v.Up + v.Ui + v.Ud;
// v.Ud = _IQmpy(v.Kd,(v.Up – v.Up1));// v.OutPreSat = v.Up + v.Ui + v.Ud;
可以解释下v.Out = _IQsat(v.OutPreSat, v.OutMax, v.OutMin);这句话的意思吗,
个人理解IQsat是将v.OutPreSat限制在v.OutMax和 v.OutMin之间然后赋给v.Out,后面 v.SatErr = v.Out – v.OutPreSat; v.SatErr结果为0吗?
user5770821:
回复 Brian Wang0:
如果v.OutPreSat超过v.OutMax和 v.OutMin之间呢,是不是低于 v.OutMin就取v.OutMin,大于v.OutMax就取v.OutMax