View Source PidController (PidController v0.1.3)

Documentation for PidController.

controller-action

Controller action

By default, the controller will produce a direct control action, meaning that an increasing error term will result in an increasing control value. If the controller action is set to :reverse, an increasing error term will result in a decreasing control value. (This is generally needed only if the element being controlled, such as a valve, requires it.)

Link to this section Summary

Functions

Returns the controller action (direct or reverse).

Returns the derivative coefficient (Kd) for the controller.

Returns the integral coefficient (Ki) for the controller.

Returns the proportional coefficient (Kp) for the controller.

Create a new instance.

Calculates the control value from the current process value.

Returns the range to which the control value will be limited, in the form {min, max}. If either value is nil, the range is unbounded at that end.

Sets the controller action. Returns the new state.

Sets the derivative coefficient (Kd) for the controller. Returns the new state.

Sets the integral coefficient (Ki) for the controller. Returns the new state.

Sets the proportional coefficient (Kp) for the controller. Returns the new state.

Sets the range to which the control value will be limited, in the form {min, max}. If either value is nil, the control value will not be limited in that direction.

Sets the setpoint for the controller. Returns the new state.

Returns the current setpoint for the controller.

Link to this section Types

@type controller_action() :: :direct | :reverse
@type state() :: %{required(atom()) => any()}

Link to this section Functions

@spec action(state()) :: controller_action()

Returns the controller action (direct or reverse).

@spec kd(state()) :: float()

Returns the derivative coefficient (Kd) for the controller.

@spec ki(state()) :: float()

Returns the integral coefficient (Ki) for the controller.

@spec kp(state()) :: float()

Returns the proportional coefficient (Kp) for the controller.

Link to this function

new(initial_values \\ [])

View Source
@spec new(keyword()) :: state()

Create a new instance.

@spec output(float(), state()) :: {:ok, float(), state()}

Calculates the control value from the current process value.

Returns `{:ok, output, state}``.

@spec output_limits(state()) :: {float() | nil, float() | nil}

Returns the range to which the control value will be limited, in the form {min, max}. If either value is nil, the range is unbounded at that end.

Link to this function

set_action(state, new_action)

View Source
@spec set_action(state(), controller_action()) :: state()

Sets the controller action. Returns the new state.

@spec set_kd(state(), float() | nil) :: state()

Sets the derivative coefficient (Kd) for the controller. Returns the new state.

@spec set_ki(state(), float() | nil) :: state()

Sets the integral coefficient (Ki) for the controller. Returns the new state.

@spec set_kp(state(), float() | nil) :: state()

Sets the proportional coefficient (Kp) for the controller. Returns the new state.

Link to this function

set_output_limits(state, new_output_limits)

View Source
@spec set_output_limits(
  state(),
  {float() | nil, float() | nil}
) :: state()

Sets the range to which the control value will be limited, in the form {min, max}. If either value is nil, the control value will not be limited in that direction.

Link to this function

set_setpoint(state, new_setpoint)

View Source
@spec set_setpoint(state(), float() | nil) :: state()

Sets the setpoint for the controller. Returns the new state.

@spec setpoint(state()) :: float()

Returns the current setpoint for the controller.