56 double timeChange = (double)(now - state->
last);
57 double error = should - is;
58 double newErrorSum = state->
sumError + (error * timeChange);
59 if ((newErrorSum >= state->
intMin) && (newErrorSum <= state->
intMax))
61 double dError = (error - state->
lastError) / timeChange;
62 double output = (state->
kp * error) + (state->
ki * state->
sumError) + (state->
kd * dError);
65 if (output > state->
outMax) {
68 if (output < state->outMin) {
75 for (uint8_t i = 0; i < 2; i++) {
81 void pidSet(
PIDState *pid,
double kp,
double ki,
double kd,
double min,
double max,
double iMin,
double iMax) {