Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

otPID Class Reference
[PID - A proportional integral derivative controller, PID - A proportional integral derivative controller]

PID control library. More...

#include <otPID.h>


Public Types

enum  Controls { DIRECT = 0, REVERSE = 1 }

Public Member Functions

 otPID ()
void begin (F32 *Input, F32 *Output, F32 *Setpoint, F32 Kp, F32 Ki, F32 Kd, int ControllerDirection, U32 tickCounts)
bool compute (U32 tickCounts)
void setOutputLimits (F32 minValue, F32 maxValue)
void setTunings (F32 Kp, F32 Ki, F32 Kd)
void setControllerDirection (int Direction)
void setSampleTime (int NewSampleTime)
F32 getKp ()
F32 getKi ()
F32 getKd ()
int getDirection ()


Detailed Description


Member Enumeration Documentation

enum otPID::Controls
 

Enumeration values:
DIRECT  DIRECT means the output will increase when error is positive.
REVERSE  REVERSE means the output will decrease when error is positive.


Constructor & Destructor Documentation

otPID.otPID (   ) 
 


Member Function Documentation

void otPID.begin (  F32 *  Input,
F32 *  Output,
F32 *  Setpoint,
F32  Kp,
F32  Ki,
F32  Kd,
int  ControllerDirection,
U32  tickCounts
) 
 

Initialize the library, links the PID to the Input, Output, and Setpoint. Initial tuning parameters are also set here.

Parameters:
Input Input value of the PID. This value comes from the feedback sensor or other input.
Output Output from PID compute. This value represents the input to be used in the actuator that regulates the feedback process.
Setpoint This is the value you want to have at the equilibrium point.
Kp Proportional coefficient
Ki Integral coefficient
Kd Derevative coefficient
ControllerDirection Use DIRECT for +Output leads to +Input or REVERSE for +Output leads to -Input.
tickCounts System ticks as ms

bool otPID.compute (  U32  tickCounts  ) 
 

This, as they say, is where the magic happens.

Parameters:
tickCounts System ticks as ms
Returns:
true When the output is computed

int otPID.getDirection (   ) 
 

Return the controller direction

F32 otPID.getKd (   ) 
 

Return derevative coefficient

F32 otPID.getKi (   ) 
 

Return integral coefficient

F32 otPID.getKp (   ) 
 

Return proportional coefficient

void otPID.setControllerDirection (  int  Direction  ) 
 

Sets the Direction, or "Action" of the controller.

Parameters:
Direction DIRECT means the output will increase when error is positive. REVERSE means the opposite.

void otPID.setOutputLimits (  F32  minValue,
F32  maxValue
) 
 

Clamps the output to a specific range. 0-255 by default, but it's likely the user will want to change this depending on the application

Parameters:
minValue Minimum value accepted by the actuator that regulates the feedback process.
maxValue Maximum value accepted by the actuator that regulates the feedback process.

void otPID.setSampleTime (  int  NewSampleTime  ) 
 

Sets the frequency, in Milliseconds, with which the PID calculation is performed. Default is 100.

Parameters:
NewSampleTime Sample time as ms.

void otPID.setTunings (  F32  Kp,
F32  Ki,
F32  Kd
) 
 

This function allows the controller's dynamic performance to be adjusted.

PID_Compensation_Animated.gif
Parameters:
Kp Proportional coefficient
Ki Integral coefficient
Kd Derevative coefficient


The documentation for this class was generated from the following file: footer
otStudio - Library Reference - (C) 2020-25 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0