Table of Contents

Class Pid

Namespace
Pamoja.Kit
Assembly
Pamoja.Kit.dll

Holds a value at a setpoint by trading off present, past, and predicted error.

public sealed class Pid : IDisposable
Inheritance
Pid
Implements
Inherited Members

Remarks

This is the controller behind holding a temperature, a pressure, or a speed steady against a load that keeps changing.

Constructors

Pid(float, float, float)

Creates a controller with the given gains and no output limits.

public Pid(float kp, float ki, float kd)

Parameters

kp float

The proportional gain, reacting to present error.

ki float

The integral gain, correcting accumulated error.

kd float

The derivative gain, damping predicted error.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Reset()

Clears the accumulated integral and last error.

public void Reset()

Update(float, float, float)

Advances the controller by one step.

public float Update(float setpoint, float measurement, float dt)

Parameters

setpoint float

The value being held.

measurement float

The latest measured value.

dt float

Seconds since the previous step.

Returns

float

The control output.

WithLimits(float, float, float, float, float)

Creates a controller whose output is clamped to a range.

public static Pid WithLimits(float kp, float ki, float kd, float min, float max)

Parameters

kp float

The proportional gain, reacting to present error.

ki float

The integral gain, correcting accumulated error.

kd float

The derivative gain, damping predicted error.

min float

The lowest output the controller may command.

max float

The highest output the controller may command.

Returns

Pid

The clamped controller.