pid_controller
A PID (proportional/integral/derivative) controller in Elixir. "PID" in this context is not to be confused with process ID.
QUICK START
controller =
PidController.new(kp: 0.2, ki: 0.1)
|> PidController.set_setpoint(5.0)
# in a loop
{:ok, output, controller} = PidController.output(input, controller)OVERVIEW
PidController implements a control loop-style feedback controller similar to
what is commonly found in industrial control systems. It takes a measured value
from the system under control (the process value or process variable),
compares it to a setpoint value to produce an error term, then generates a
control value based on proportional, integral, and derivative functions
of the error term. The control value is then fed back into the system under control.
For a full description of PID controllers and how they work, see https://en.wikipedia.org/wiki/PID_controller.
While the proportional term is a function of the error value only, the integral
and derivative terms are also functions of time. The first iteration of
PidController acts as if the output/2 function is being called at regular
and consistent intervals, even though in practice this is unlikely. A future version
will take into account the elapsed time between calls to output/2.
INSTALLATION
If available in Hex, the package can be installed
by adding pid_controller to your list of dependencies in mix.exs:
def deps do
[
{:pid_controller, "~> 0.1.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/pid_controller.