Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
Loading...
Searching...
No Matches
pid Struct Reference

PID Controller. More...

Data Fields

float kP
 
float kI
 
float kD
 
float lastError
 
float integral
 

Detailed Description

PID Controller.

The PID controller is a linear control algorithm that has three terms:

  • Proportional: A simple scaling of the error value by a gain kP
  • Integral: Integration of the error value over time, then multipled by gain kI
  • Derivative: Rate of change of the error value over time, multiplied by gain kD

Terms of the controller can be removed by setting their gain to 0, creating a PI (kD = 0) or PD (kI = 0) controller. Depending on the control problem at hand, some terms may not increase the performance of the system, or may have a negative effect.

For a more mathematical expanation of the PID Controller, see https://en.wikipedia.org/wiki/PID_controller

Limitations of this implementation:

  • Since this implementation is just for demonstration, the pid_step function takes the dt as a parameter, and it can be provided by the user in main(). This allows deterministic experimentation with the algorithm, rather than using time(NULL) which would make the function non-deterministic.

Inputs: e(t) - Current error at time t. For example, how far a servo is off the desired angle Output: u(t) - Controller output at time t.


The documentation for this struct was generated from the following file: