Class pid_loop

Class Documentation

class pid_loop

A simple PID loop class.

Public Functions

inline pid_loop(double kp, double kd, double ki, double dt, double min, double max)
Parameters:
  • kp – proportional gain.

  • ki – Integral gain.

  • kd – Derivative gain.

  • dt – Loop interval time (linear interpolation used).

  • max – Maximum value of manipulated variable and integral term.

  • min – Minimum value of manipulated variable and integral term.

double calculate(double setpoint, double pv)

Calculate a new value for the manipulated variable.

Parameters:
  • setpoint – Desired value of the manipulated variable.

  • pv – Current value of the variable.

Returns:

Correctional term.

inline void max(double max)

Get the max value of manipulated variable/integral term.

inline void min(double min)

Get the minimal value of manipulated variable/integral term.

inline void reset(void)

Reset the integral state, previous error (setpoint - pv)