... your assumption ...

Conclusion. Conclusions are more classy than assumptions.

A solution could be to limit the integral value. But to what extent? To plus/minus the maximum expected error? Can you suggest a value?

Do a search on integrator anti-windup. It's a known problem. Note that unless your spreadsheet had the system working in closed loop your actual integrator may not overflow (how can you

**do** that with floating point math?), but it still may wind up.

To be self-serving, start

looking here in your search.

I may not know what I'm talking about, but if the proportional gain is 31000 times the integral gain and the integrator is overflowing, I would think something is wrong. Why would you have an integrator anyhow?

Without knowing the sampling rate it's hard to say if the ratio between proportional and integral gain is reasonable or not -- the way that Wolfgang has written the algorithm the continuous-time integrator gain is the stated ki times the sampling rate.

My analog mind says the transfer function of your controller is RPM command (s) / acceleration error (s) = Ki/s^{2} + Kp/s + Kd . Is that correct? Did I miss a feedback somewhere?

Tim, if you explain this, please type slowly so I'll understand.

Sorry, I'm on break, need to type quick.

You're off by a factor of 1/s, and some sampling rates. If the sampling

*interval* is T, then it's Ki / (T * s) + Kp + (T * s) * Kd/sampling_weirdness, where the "sampling_weirdness" term doesn't matter much unless you're a real control geek (or your system starts oscillating really, really fast due to too much gain at high frequencies -- then it matters, or you should use a bandlimited derivative).

I'm not sure if Wolfgang has an integrator to try to get the speed just exactly right (which is a debatable goal) or simply because he's cribbing off of some established "how to write PID code" article. It's not a

*bad* thing to try, if you can get the integrator response fast enough that you don't come down from on high and then go too fast for half a lap (or worse, have the motor goosed on the top line of the hourglass, and then

*really* be charging downward to that 4th turn!!).