More suggestions for reducing integral wind-up (or my $.02):
- Only add to it when the motor can actually driver (ie, !disabled_mode)
- At the end of the loop (before you save the I value), multiply it be a fraction, eg:
Code:
static_I = (long)I * 8L / 10
This means that big values last longer than little ones, but it also decreases the possibility of big values building up. Tweak the 0.8 value.