#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 */
#endif // __PIDREG3_H__