File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,7 +219,17 @@ float pid2_apply(
219219 // pid->I = (pid->u0 - pid->va) / pid->vb - pid->kp * (pid->beta * r - y);
220220 // this is dangerous, if pid->I starts nonzero with very low or zero kI, then
221221 // it will never settle!
222- pid -> I = 0.0f ;
222+ // pid->I = 0.0f;
223+ // whether ki is zero or non-zero, when doing 'reconfigure' we start with setpoint==actual
224+ pid -> I = (pid -> u0 - pid -> va ) / pid -> vb ;
225+ // if ki is non-zero
226+ if (pid -> bi > 5e-7f ) {
227+ // then the output can wind up/down to get rid of a difference between setpoint and actual
228+ // so we can generate the full bumpless transfer here
229+ // else leave off the part that can vary due to difference between setpoint and actual
230+ // so that it is repeatable (for tuning purposes at least)
231+ pid -> I -= pid -> kp * (pid -> beta * r - y );
232+ }
223233 }
224234
225235 // compute proportional part
You can’t perform that action at this time.
0 commit comments