PicoLowLevel
Loading...
Searching...
No Matches
PID Class Reference

PID controller library. More...

#include <PID.h>

Public Member Functions

 PID (float kp, float ki, float kd, float max_output, float alpha)
 Initializes the PID class with necessary parameters.
 
void updateReferenceValue (float ref)
 Sets the reference value.
 
void setKp (float kp)
 Sets the proportional gain.
 
void setKi (float ki)
 Sets the integrative gain.
 
void setKd (float kd)
 Sets the derivative gain.
 
float getOutput ()
 Gets output computed from the last iteration of calculate()
 
float getReferenceValue ()
 Gets the currently used reference value.
 
void calculate ()
 Main PID routine.
 
void updateFeedback (float fb)
 Updates the feedback for PID computation.
 
void resetState ()
 Resets the PID state, as if it was the first iteration.
 

Detailed Description

PID controller library.

Constructor & Destructor Documentation

◆ PID()

PID::PID ( float  kp,
float  ki,
float  kd,
float  max_output,
float  alpha 
)

Initializes the PID class with necessary parameters.

Parameters
kpProportional gain.
kiIntegrative gain.
kdDerivative gain.
max_outputTo define the range of the output, from -max_output to max_output.
alphaError filte, 1 to disable filtering.

Member Function Documentation

◆ calculate()

void PID::calculate ( )

Main PID routine.

Should be executed at a fixed frequency, which will influence the behaviour for a given set of gains.

Here is the caller graph for this function:

◆ getOutput()

float PID::getOutput ( )

Gets output computed from the last iteration of calculate()

Returns
float Output value of the PID controller.
Here is the caller graph for this function:

◆ getReferenceValue()

float PID::getReferenceValue ( )

Gets the currently used reference value.

Returns
float The currently set reference value.

◆ resetState()

void PID::resetState ( )

Resets the PID state, as if it was the first iteration.

Here is the caller graph for this function:

◆ setKd()

void PID::setKd ( float  kd)

Sets the derivative gain.

Parameters
kdValue of the derivative gain.

◆ setKi()

void PID::setKi ( float  ki)

Sets the integrative gain.

Parameters
kiValue of the integrative gain.
Here is the caller graph for this function:

◆ setKp()

void PID::setKp ( float  kp)

Sets the proportional gain.

Parameters
kpValue of the proportional gain.
Here is the caller graph for this function:

◆ updateFeedback()

void PID::updateFeedback ( float  fb)

Updates the feedback for PID computation.

Parameters
fbFeedback value.
Here is the caller graph for this function:

◆ updateReferenceValue()

void PID::updateReferenceValue ( float  ref)

Sets the reference value.

Parameters
refReference value for the PID.
Here is the caller graph for this function:

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