ESP Line Following Buggy
2nd Year Embedded System Project (Group 48 - 2023/24)
Loading...
Searching...
No Matches
PID Class Reference

PID Control Class. More...

#include <PID.h>

Public Member Functions

 PID (float kp_, float ki_, float kd_, float tau_, float lim_min_output_, float lim_max_output_, float lim_min_int_, float lim_max_int_, float update_period)
 Construct a new PID object.
 
float ** get_terms (void)
 Get the PID terms.
 
void update (float set_point, float measurement)
 Updates the output of PID controller based on the real time measurement.
 
void set_constants (float kp_, float ki_, float kd_)
 Takes in the 3 parameters to set the PID coefficients values.
 
void set_tau (float tau_)
 
void reset ()
 Reset the PID controller.
 
float get_output (void)
 Get the output of the PID controller.
 
float * get_constants (void)
 

Detailed Description

PID Control Class.

Requires manual update of output using update() function

Assumes a constant period between updates, so a ticker that calls update() is recommended

Definition at line 20 of file PID.h.

Constructor & Destructor Documentation

◆ PID()

PID::PID ( float kp_,
float ki_,
float kd_,
float tau_,
float lim_min_output_,
float lim_max_output_,
float lim_min_int_,
float lim_max_int_,
float update_period )

Construct a new PID object.

Parameters
kp_Propotional Term Gain Constant
ki_Integral Term Gain Constant
kd_Differentiator Term Gain Constant
tau_Time Constant Tau
lim_min_output_min output limit
lim_max_output_max output limit
lim_min_int_min integral term limit
lim_max_int_max integral term limit
update_periodupdate period (secs)

Definition at line 5 of file PID.cpp.

Member Function Documentation

◆ get_constants()

float * PID::get_constants ( void )

Definition at line 149 of file PID.cpp.

Here is the caller graph for this function:

◆ get_output()

float PID::get_output ( void )

Get the output of the PID controller.

Returns
The output of the PID controller.

Definition at line 108 of file PID.cpp.

Here is the caller graph for this function:

◆ get_terms()

float ** PID::get_terms ( void )

Get the PID terms.

Returns
A pointer to an array of floats containing 8 PID terms in the order: 0. Time index,
  1. set point,
  2. sensor measured value,
  3. error,
  4. propotional term
  5. integral term
  6. differentiator term
  7. output of the PID

Definition at line 144 of file PID.cpp.

Here is the caller graph for this function:

◆ reset()

void PID::reset ( void )

Reset the PID controller.

This function resets the integral term and clears any internal state of the PID controller.

Definition at line 114 of file PID.cpp.

Here is the caller graph for this function:

◆ set_constants()

void PID::set_constants ( float kp_,
float ki_,
float kd_ )

Takes in the 3 parameters to set the PID coefficients values.

Parameters
kp_Propotional Term Gain Constant.
ki_Integral Term Gain Constant.
kd_Differentiator Term Gain Constant.

Definition at line 132 of file PID.cpp.

Here is the caller graph for this function:

◆ set_tau()

void PID::set_tau ( float tau_)

Definition at line 139 of file PID.cpp.

Here is the caller graph for this function:

◆ update()

void PID::update ( float set_point,
float measurement )

Updates the output of PID controller based on the real time measurement.

Parameters
set_pointThe desired set point.
measurementThe current measurement.

Definition at line 57 of file PID.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: