{"id":24281246,"url":"https://github.com/auralius/yapid","last_synced_at":"2026-06-01T08:31:57.073Z","repository":{"id":271088621,"uuid":"912366868","full_name":"auralius/yapid","owner":"auralius","description":"Yet Another PID (YAPID) library for Arduino","archived":false,"fork":false,"pushed_at":"2026-03-25T14:45:55.000Z","size":22762,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-26T17:22:29.435Z","etag":null,"topics":["arduino-library","bilinear-transform","control-systems","digital-control","digital-signal-processing","low-pass-filter","pid"],"latest_commit_sha":null,"homepage":"https://auralius.github.io/yapid/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auralius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-05T11:32:07.000Z","updated_at":"2026-03-25T14:46:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a7b39a2-065c-4a43-8f1c-f406d8bb4c2f","html_url":"https://github.com/auralius/yapid","commit_stats":null,"previous_names":["auralius/yapid"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/auralius/yapid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auralius%2Fyapid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auralius%2Fyapid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auralius%2Fyapid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auralius%2Fyapid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auralius","download_url":"https://codeload.github.com/auralius/yapid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auralius%2Fyapid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33767435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-library","bilinear-transform","control-systems","digital-control","digital-signal-processing","low-pass-filter","pid"],"created_at":"2025-01-16T02:56:26.403Z","updated_at":"2026-06-01T08:31:57.068Z","avatar_url":"https://github.com/auralius.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yet Another PID (YAPID) library for Arduino   \n\nContact:\nAuralius Manurung, Universitas Telkom, \u003cauralius.manurung@ieee.org\u003e   \n\nDetailed documentations:\nhttps://auralius.github.io/yapid/\n\n---\n\nIn YAPID, the discrete implementations of both the control and the filter use bilinear transformation (Tustin or trapezoidal) method. **Check [this page](https://auralius.github.io/control-systems-with-sympy/digital-pid-2.html) for details on the control derivation.**\n\n\n## Implemented functions: \n\n* `float YAPID::Compute0(float set_value, float process_value)`\n  * This simply sends `set_value` as control output.\n  * There is no feedback control happening here.\n  * This function is useful to testing system's open-loop respose.\n    \n* `float YAPID::Compute1(float set_value, float process_value)`\n  * D-term is computed from the filtered errors.  \n  * Derivative kicks will happen\n  * Simple integral windup prevention with clamping technique \n    \n* `float YAPID::Compute2(float set_value, float process_value)`\n  * D-term is computed from the filtered process values    \n  * No more derivative kicks\n  * Simple integral windup prevention with clamping technique \n    \n* `float YAPID::FOLP(float tau, float in)`\n  * First-order low-pass filter (time-constant filter)\n \n* `float YAPID::SOLP(float tau, float in)`\n  * Second-order low-pass filter (Butterworth filter)\n\n## How to use the YAPID library\n\n__Abbreviations__:\n\n* ```sv```: set value\n* ```pv```: process value\n* ```co```: control output\n* ```P```: P-term control output\n* ```I```: I-term control output\n* ```D```: D-term control output\n* ```Kp```: proportinal gain\n* ```Ki```: integral gian\n* ```Kd```: derivative gain\n* ```N```: derivative filter coefficient\n\n\n__How to use__:\n\nYAPID **DOES NOT** measure the elapsed time every iteration. It simply uses the provided sampling time during the setup. Therefore, to guarantee control determinism, it is easier if we use a timer interrupt handler to run the control periodically. All provided examples use timer interrupts.   \n\nTo use YAPID library, first, we need to include the header file:\n\n```cpp\n#include \"yapid.h\"\n```\n\nNext, we create a global YAPID object and several global variables:\n\n```cpp\n// Create the PID controller\nfloat kp = 100.;  // kp\nfloat ki = 10.0;  // ki\nfloat kd = 1.0;   // kd\nfloat N  = 1.0;   // derivative filter coefficient (Hz)\nfloat Ts = 1e-3;\nYAPID pid(Ts, kp, ki, kd, N);\n```\n\nWithin the Arduino's ```setup()``` function, we define the limits for the control's output. The default limit is $0.0 \\leq \\text{CO} \u003c 255.0$. Since we use a timer interrupt, we setup out timer interrupt also in this ```setup()``` function.\n```cpp\n#define TIMER2_INTERVAL_MS 1  // 1kHz\n\nvoid setup()\n{\n  // Setup the timer interrupt (we use NANO, timer-1, and\n  // https://github.com/khoih-prog/TimerInterrupt)\n  ITimer1.init();\n  ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS, Timer1Handler);\n\n  // Define the control output limits\n  // Here, the output becomes PWM signals (0 to 255)\n  pid.SetOutputLimits(0., 255)\n\n  // ...\n  // ...\n}\n```\n\nFinally, in the timer interrupt function handler, we can put our PID control. The steps are: \n* read the sensor (```pv```)\n* compute the PID (```co```)\n* apply the output to the actuator/plant\n* measure the elapsed time\n\n```cpp\nvoid Timer1Handler()\n{ \n  float pv = (float)analogRead(A0) * 5.0 / 1024.0;\n\n  float co = pid.Compute1(SV, pv);\n  \n  analogWrite(pwm_port, (int)co);\n  \n  pid.UpdateTime();\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauralius%2Fyapid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauralius%2Fyapid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauralius%2Fyapid/lists"}