{"id":27873292,"url":"https://github.com/wpbonelli/cspid","last_synced_at":"2025-05-05T01:09:02.934Z","repository":{"id":144132391,"uuid":"202265756","full_name":"wpbonelli/cspid","owner":"wpbonelli","description":"C# PID controller","archived":false,"fork":false,"pushed_at":"2020-05-06T22:37:26.000Z","size":29,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T01:08:58.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wpbonelli.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}},"created_at":"2019-08-14T03:16:32.000Z","updated_at":"2025-02-10T05:29:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"7cf49c34-54f4-42b0-91b0-abc1c7f64c55","html_url":"https://github.com/wpbonelli/cspid","commit_stats":null,"previous_names":["wpbonelli/cspid","w-bonelli/cspid"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbonelli%2Fcspid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbonelli%2Fcspid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbonelli%2Fcspid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbonelli%2Fcspid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpbonelli","download_url":"https://codeload.github.com/wpbonelli/cspid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252420956,"owners_count":21745154,"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-05-05T01:09:02.375Z","updated_at":"2025-05-05T01:09:02.926Z","avatar_url":"https://github.com/wpbonelli.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSPID\n\nCSPID (pronounced \"speedy\") is a C# PID (proportional-integral-derivative) controller targeting .NET Standard 2.0.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\nClone the repo with `git clone https://github.com/w-bonelli/CSPID.git` or pull the package from [Nuget.org](https://www.nuget.org/packages/CSPID/) with PowerShell: `Install-Package CSPID`.\n\n## Usage\n\nThere's one class: `PIDController`. It has one method: `double Next(double error, double elapsed = 1)`. CSPID doesn't care how you measure your error or the passage of time. To construct a controller, provide:\n\n- `errorRange`: the range you expect your error values to take\n- `controlRange`: the range of values your control variable may take\n\nYou can tune gain in real time:\n\n- `ProportionalGain`\n- `IntegralGain`\n- `DerivativeGain`\n\nYou can also impose a `MaximumStep` (the largest permissible change between successive control values).\n\n```csharp\n// create a controller\nvar controller = new PIDController(\n    errorRange: new Range\u003cdouble\u003e(-5, 5), // Range\u003cT\u003e models an inclusive range\n    controlRange: new Range\u003cdouble\u003e(0, 10))\n{\n    MaximumStep = double.MaxValue,\n    ProportionalGain = 1,\n    IntegralGain = 1,\n    DerivativeGain = 1\n} as IPIDController; // interface is handy if you need to mock\n\n// or do it the old-fashioned way\ncontroller = new PIDController(\n    minimumError: -5,\n    maximumError: 5,\n    minimumControl: 0,\n    maximumControl: 10)\n{\n    MaximumStep = double.MaxValue,\n    ProportionalGain = 1,\n    IntegralGain = 1,\n    DerivativeGain = 1\n} as IPIDController;\n\n// get a control value\nvar value1 = controller.Next(error: 1); // elapsed defaults to 1\n\n// get another one\nvar value2 = controller.Next(error: -1, elapsed: 0.5);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpbonelli%2Fcspid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpbonelli%2Fcspid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpbonelli%2Fcspid/lists"}