GY-63_MS5611/libraries/PID_RT
2024-04-13 10:35:57 +02:00
..
.github bulk update GitHub actions 2024-04-13 10:35:57 +02:00
examples add wokwi to readme.md 2024-01-08 12:43:38 +01:00
test 0.1.6 PID_RT 2023-02-12 13:01:13 +01:00
.arduino-ci.yml 0.1.5 PID_RT 2022-11-22 11:48:02 +01:00
CHANGELOG.md 0.1.7 PID_RT 2023-11-14 17:40:51 +01:00
keywords.txt 0.1.4 PID_RT 2021-12-23 15:44:14 +01:00
library.json 0.1.7 PID_RT 2023-11-14 17:40:51 +01:00
library.properties 0.1.7 PID_RT 2023-11-14 17:40:51 +01:00
LICENSE bulk update GitHub actions 2024-04-13 10:35:57 +02:00
PID_RT.cpp 0.1.7 PID_RT 2023-11-14 17:40:51 +01:00
PID_RT.h 0.1.7 PID_RT 2023-11-14 17:40:51 +01:00
README.md add wokwi to readme.md 2024-01-08 12:43:38 +01:00

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

PID_RT

Arduino library for PID controller.

Description

The PID_RT class allows the user to instantiate a PID controller.

This library allows one to

  • adjust the K parameters runtime.
  • stop / start computing runtime.

(to be elaborated)

Some PID background

E-book

WOKWI

Interface

#include "PID_RT.h"

Constructor

  • PID_RT() minimal constructor.
  • PID_RT(float sp, float Kp, float Ki, float Kd) constructor that sets minimal parameters to get started.

Core

  • void reset() resets internals to startup (Kp == Ki == Kd == 0).
  • void setPoint(float sp) sets the setPoint, that needs to be reached.
  • float getSetPoint() read back the setPoint.
  • bool compute(float input) does one iteration of the PID controller. Returns true after a calculation is done. Returns false if not computed, either due to stop flag or not yet time to do the calculation.
  • float getOutput() get the last calculated output value.
  • bool setK(float Kp, float Ki, float Kd) Set the initial P I D parameters as a group. Overwrites the values set in the constructor.

Start Stop

  • void start() enable the PID controller to compute() new output values.
  • void stop() disable the PID controller, see compute().
  • bool isRunning() return the enable/disable flag.

Behaviour parameters

  • bool setInterval(uint32_t interval) set the interval between two compute() calls. Returns true if changed, otherwise false.
  • uint32_t getInterval() read back interval set.
  • void setOutputRange(float rangeMin, float rangeMax) tune the output range, default 0..100
  • float getOutputMin() read back setting rangeMin.
  • float getOutputMax() read back setting rangeMax.
  • void setReverse(bool reverse) reverse behaviour, seldom needed.
  • bool getReverse() read back the setting.

K-parameters

  • bool setKp(float Kp) runtime updates are allowed - at your own risk.
  • bool setKi(float Ki) runtime updates are allowed - at your own risk.
  • bool setKd(float Kd) runtime updates are allowed - at your own risk.
  • float getKp() read back setting.
  • float getKi() read back setting.
  • float getKd() read back setting.

Proportional

  • void setPropOnInput() this is default behaviour.
  • void setPropOnError() alternative.
  • bool isPropOnInput() read back setting.
  • bool isPropOnError() read back setting.

debugging calls

  • float getInput() read last input.
  • float getLastError() read the last error.
  • uint32_t getLastTime() get the last time compute() was called. Note this value is incremented with Interval every iteration so it may have some offset of the actual time. This is chosen as this way it is almost sure that no iterations are missed.

Operations

See examples and

Future

Must

  • update / improve documentation
  • more testing

Should

  • investigate if it works as PI or P controller too.
    • PI as derived or base class?
  • add examples to test more
  • improve unit test

Could

  • add reference to PID book / website?
  • move all code to .cpp

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,