{"id":28621663,"url":"https://github.com/Dlloydev/QuickPID","last_synced_at":"2025-06-12T05:06:02.405Z","repository":{"id":41242846,"uuid":"327486833","full_name":"Dlloydev/QuickPID","owner":"Dlloydev","description":"A fast PID controller with multiple options. Various Integral anti-windup, Proportional, Derivative and timer control modes.","archived":false,"fork":true,"pushed_at":"2023-06-10T19:43:02.000Z","size":182,"stargazers_count":133,"open_issues_count":0,"forks_count":42,"subscribers_count":15,"default_branch":"master","last_synced_at":"2023-11-07T16:27:20.662Z","etag":null,"topics":["arduino","autotune","controller","derivative","pid","proportional","quickpid","windup"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"br3ttb/Arduino-PID-Library","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dlloydev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-07T02:55:45.000Z","updated_at":"2023-11-06T16:35:49.000Z","dependencies_parsed_at":"2023-02-06T10:01:28.872Z","dependency_job_id":null,"html_url":"https://github.com/Dlloydev/QuickPID","commit_stats":null,"previous_names":[],"tags_count":38,"template":null,"template_full_name":null,"purl":"pkg:github/Dlloydev/QuickPID","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dlloydev%2FQuickPID","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dlloydev%2FQuickPID/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dlloydev%2FQuickPID/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dlloydev%2FQuickPID/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dlloydev","download_url":"https://codeload.github.com/Dlloydev/QuickPID/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dlloydev%2FQuickPID/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259402054,"owners_count":22851868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","autotune","controller","derivative","pid","proportional","quickpid","windup"],"created_at":"2025-06-12T05:01:59.931Z","updated_at":"2025-06-12T05:06:02.398Z","avatar_url":"https://github.com/Dlloydev.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# QuickPID   [![arduino-library-badge](https://www.ardu-badge.com/badge/QuickPID.svg?)](https://www.ardu-badge.com/QuickPID) [![PlatformIO Registry](https://badges.registry.platformio.org/packages/dlloydev/library/QuickPID.svg)](https://registry.platformio.org/packages/libraries/dlloydev/QuickPID)\nQuickPID is an updated implementation of the Arduino PID library with additional features for PID control. By default, this implementation closely follows the method of processing the p,i,d terms as in the PID_v1 library except for using a more advanced anti-windup mode. Integral anti-windup can be based on conditionally using PI terms to provide some integral correction, prevent deep saturation and reduce overshoot. Anti-windup can also be based on clamping only, or it can be turned completely off. Also, the proportional term can be based on error, measurement, or both. The derivative term can be based on error or measurement.  PID controller modes include timer, which allows external timer or ISR timing control.\n\n```\nNote: You can use this library in esp-idf tool to program esp32 by cloning\nthis repo into your components folder, then clean the build and rebuild.\n```\n\n### Features\n\nDevelopment began with a fork of the Arduino PID Library. Modifications and new features have been added as described in the [releases](https://github.com/Dlloydev/QuickPID/releases).\n\n#### New feature Summary\n\n- [x] New functions added: `SetProportionalMode`, `SetDerivativeMode` and `SetAntiWindupMode`\n- [x] `timer` mode for calling PID compute by an external timer function or ISR\n- [x] Proportional on error `pOnError`, measurement `pOnMeas` or both `pOnErrorMeas` options\n- [x] Derivative on error `dOnError` and measurement `dOnMeas` options\n- [x] New PID Query Functions `GetPterm`, `GetIterm`, `GetDterm`, `GetPmode`, `GetDmode` and `GetAwMode`\n- [x] New integral anti-windup options `iAwCondition`, `iAwClamp` and `iAwOff`\n\n### Functions\n\n#### QuickPID_Constructor\n\n```c++\nQuickPID::QuickPID(float* Input, float* Output, float* Setpoint, float Kp, float Ki, float Kd,\n                   pMode pMode = pMode::pOnError, dMode dMode = dMode::dOnMeas,\n                   iAwMode iAwMode = iAwMode::iAwCondition, Action action = Action::direct)\n```\n\n- `Input`, `Output`, and `Setpoint` are pointers to the variables holding these values.\n- `Kp`, `Ki`, and `Kd` are the PID proportional, integral, and derivative gains.\n- `pMode` is the proportional mode parameter with options for `pOnError` proportional on error (default), `pOnMeas`  proportional on measurement and `pOnErrorMeas` which is 0.5 `pOnError` + 0.5 `pOnMeas`.\n- `dMode` is the derivative mode parameter with options for `dOnError` derivative on error, `dOnMeas` derivative on measurement (default).\n- `awMode` is the integral anti-windup parameter with an option for `iAwCondition`  (default) that is based on PI terms to provide some integral correction, prevent deep saturation and reduce overshoot. The`iAwClamp` option clamps the summation of the pmTerm and iTerm. The `iAwOff` option turns off all anti-windup.\n- `Action` is the controller action parameter which has `direct` (default)  and `reverse` options. These options set how the controller responds to a change in input.  `direct` action is used if the input moves in the same direction as the controller output (i.e. heating process). `reverse` action is used if the input moves in the opposite direction as the controller output (i.e. cooling process).\n\n```c++\nQuickPID::QuickPID(float* Input, float* Output, float* Setpoint,\n                   float Kp, float Ki, float Kd, Action action)\n```\n\nThis allows you to use Proportional on Error without explicitly saying so.\n\n```c++\nQuickPID::QuickPID(float *Input, float *Output, float *Setpoint)\n```\n\nThis simplified version allows you to define the remaining parameters later via specific setter functions. By default, Kp, Ki, and Kd will be initialized to zero and should be later set via `SetTunings` to relevant values.\n\n#### Compute\n\n```c++\nbool QuickPID::Compute();\n```\n\nThis function contains the PID algorithm and it should be called once every loop(). Most of the time it will just return false without doing anything. However, at a  frequency specified by `SetSampleTime` it will calculate a new Output and return true.\n\n#### Initialize\n\n```c++\nvoid QuickPID::Initialize();\n```\n\nDoes all the things that need to happen to ensure a bump-less transfer from manual to automatic mode.\n\n#### Reset\n\n```c++\nvoid QuickPID::Reset();\n```\n\nClears `pTerm`, `iTerm`, `dTerm` and `outputSum` values.\n\n#### PID Query Functions\n\nThese functions query the internal state of the PID.\n\n```c++\nfloat GetKp();            // proportional gain\nfloat GetKi();            // integral gain\nfloat GetKd();            // derivative gain\nfloat GetPterm();         // proportional component of output\nfloat GetIterm();         // integral component of output\nfloat GetDterm();         // derivative component of output\nuint8_t GetMode();        // manual (0), automatic (1) or timer (2)\nuint8_t GetDirection();   // direct (0), reverse (1)\nuint8_t GetPmode();       // pOnError (0), pOnMeas (1), pOnErrorMeas (2)\nuint8_t GetDmode();       // dOnError (0), dOnMeas (1)\nuint8_t GetAwMode();      // iAwCondition (0, iAwClamp (1), iAwOff (2)\n```\n\n#### PID Set Functions\n\nThese functions set the internal state of the PID.\n\n```c++\nvoid SetMode(Control mode);                     // Set PID mode to manual, automatic or timer\nvoid SetOutputLimits(float Min, float Max);     // Set and clamps the output to (0-255 by default)\nvoid SetTunings(float Kp, float Ki, float Kd,   // set pid tunings and all computational modes\n     pMode pMode, dMode dMode, iAwMode iAwMode);\nvoid SetTunings(float Kp, float Ki, float Kd);  // only set pid tunings, other pid modes are unchanged\nvoid SetControllerDirection(Action Action);     // Set controller action to direct (default) or reverse\nvoid SetSampleTimeUs(uint32_t NewSampleTimeUs); // Set PID compute sample time, default = 100000 µs\nvoid SetProportionalMode(pMode pMode);          // Set pTerm based on error (default), measurement, or both\nvoid SetDerivativeMode(dMode dMode);            // Set the dTerm, based error or measurement (default).\nvoid SetAntiWindupMode(iAwMode iAwMode);        // Set iTerm anti-windup to iAwCondition, iAwClamp or iAwOff\nvoid SetOutputSum(float sum);                   // sets the output summation value\n```\n\n### Autotuner\n\n#### Get  [sTune](https://github.com/Dlloydev/sTune)   [![arduino-library-badge](https://www.ardu-badge.com/badge/sTune.svg?)](https://www.ardu-badge.com/sTune)  [![PlatformIO Registry](https://badges.registry.platformio.org/packages/dlloydev/library/sTune.svg)](https://registry.platformio.org/packages/libraries/dlloydev/sTune)\n\nA very fast autotuner capable of on-the-fly tunings and more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDlloydev%2FQuickPID","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDlloydev%2FQuickPID","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDlloydev%2FQuickPID/lists"}