PID (proportional-integral-derivative) controller. Implements a
discrete version of the following idealised equation:
out[t] = kp ( ϵ[t] + 1/ti × ∫ϵ[t]dt + td × dϵ[t]/dt ) where ϵ[t] = setPoint[t] − in[t]; increasing values of
t refer to earlier inputs. The actual implementation is:
out[t] = kp ( ϵ[t] + 1/ti × ∑ϵ[t] + td × (in[t] - in[t-1]) ) Note that the derivative term is modified to measure changes to in[t]
rather than ϵ[t], to avoid discontinuities caused by
instantaneous step changes to the setPoint.
The setPoint and Parameters are set via IORefs, and may be changed
at run-time. (TODO: Perhaps these inputs ought to be Protocols or
Channels? At least the setPoint, to allow for cascaded PID
controllers...)
See http://en.wikipedia.org/wiki/PID_controller for more details.
|