{"id":26407233,"url":"https://github.com/blockos/pid","last_synced_at":"2025-03-17T17:29:37.499Z","repository":{"id":136207862,"uuid":"37380241","full_name":"BlockoS/PID","owner":"BlockoS","description":"A simple PID template library.","archived":false,"fork":false,"pushed_at":"2016-01-05T13:28:37.000Z","size":43,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-10T19:25:52.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlockoS.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":"2015-06-13T17:07:24.000Z","updated_at":"2023-03-17T02:33:44.487Z","dependencies_parsed_at":"2023-05-19T23:15:53.141Z","dependency_job_id":null,"html_url":"https://github.com/BlockoS/PID","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlockoS%2FPID","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlockoS%2FPID/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlockoS%2FPID/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlockoS%2FPID/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlockoS","download_url":"https://codeload.github.com/BlockoS/PID/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244077580,"owners_count":20394324,"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":[],"created_at":"2025-03-17T17:29:37.047Z","updated_at":"2025-03-17T17:29:37.494Z","avatar_url":"https://github.com/BlockoS.png","language":"C++","readme":"# Simple PID template #\n\nThis is a simple template class for PID computation first intended for the Arduino and fixed-point maths.\nIt features output clamping, integral anti-windup. Integration mechanism can be selected at compile time.\nThe currently available integration schemes are : standard, trapezoidal and Simpson.\n\nOnly automatic mode is supported for the moment.\n\n# Example #\nThe following example uses fixed-point PID and outputs the setpoint and process value (speed) in a file.\n```cpp\n// file: test/cruise.cpp\n#include \u003ccstdint\u003e\n#include \u003ciostream\u003e\n#include \"PID.h\"\n\n// Fixed point bias.\n#define BIAS 256\n\ntypedef PID\u003cint64_t, int64_t\u003e PID_t;\n\nint main()\n{\n    PID_t control;\n    \n    // Vehicle mass.\n    PID_t::value_type mass      = 1000;\n    // Damping factor.\n    PID_t::value_type damping   = 50;\n    // Target speed.\n    PID_t::value_type reference = 10;\n    // Current vehicle speed.\n    PID_t::value_type speed     = 0;\n    // PID output.\n    PID_t::value_type output    = 0;\n    \n    control.Setup(720,1, 40,1, 10,1, 100);\n    control.SetSetpoint(reference * BIAS);\n    control.SetOutputLimits  (      0*BIAS, 32768*BIAS);\n    control.SetIntegralLimits( -32768*BIAS, 32768*BIAS);\n    \n    control.Start(speed);\n    \n    for(int i=0; i\u003c120; i++)\n    {\n        // Compute PID.\n        output = control.Update(speed);\n        // Compute speed.\n        speed += (output - damping*speed) * control.GetSamplingTime() / mass / 1000;\n    \n        // Output speed and setpoint.\n        std::cout \u003c\u003c i \u003c\u003c '\\t' \u003c\u003c (speed / (float)BIAS) \u003c\u003c '\\t';\n        std::cout \u003c\u003c (control.GetSetpoint() / (float)BIAS) \u003c\u003c std::endl;\n    }\n\n    return 0;\n}\n```\nThe generated file is then used to produce the following plot with Gnuplot.\n![](http://www.blockos.org/mooz/input.png) \n\n# License #\n\nAll files are licensed under the Apache License version 2.0 unless otherwise marked. Full text of the Apache License version 2.0 is available in LICENSE.txt\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockos%2Fpid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblockos%2Fpid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockos%2Fpid/lists"}