A PID (proportional/integral/derivative) controller in Elixir. “PID” in this context is not to be confused with process ID.
controller =
PidController.new(kp: 0.2, ki: 0.1)
|> PidController.set_setpoint(5.0)
# in a loop
{:ok, output, controller} = PidController.output(input, controller)
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.
Detailed documentation is available at https://craigcottingham.github.io/pid_controller/.
Add pid_controller
to your list of dependencies in mix.exs
:
def deps do
[
{:pid_controller, "~> 0.1.3"}
]
end
Don’t forget to run mix deps.get
afterwards.
Documentation can be found at https://hexdocs.pm/pid_controller or https://craigcottingham.github.io/pid_controller/hexdocs.
- Clone the repository.
- Install dependencies with
mix deps.get
.
Pull requests are welcome. Pull requests with specs covering the changes
are especially welcome. Pull requests with specs, which have been run through
mix format
, and pass mix credo
are extra-especially welcome. 😄
Unit tests were written with ESpec.
See the open issues on Github.
Copyright (c) 2019-2020 Craig S. Cottingham, except where stated otherwise.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.