Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
/ pid-controller Public archive

A simple PID Controller, written as a Universal Windows Runtime Component in C#

Notifications You must be signed in to change notification settings

ms-iot/pid-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

PID Controller

A Universal Windows Runtime Component that implements a very simple proportional-integral-derivative controller.

Installation

Step 1: Create a new project!

  1. In Visual Studio select File -> New -> Project

  2. Select your language of choice. The PID Controller is a Universal Windows Runtime Component, meaning it is compatable with C++, C#, or JavaScript.

  3. Select the "Windows" option under the language you selected and choose "Blank App (Universal Windows)".

Step 2: Add the PidController project to your solution

  1. Clone the PID Controller repository or download the zip file.

  2. Right-click on your solution in the Solution Explorer and select Add -> Existing Project

  3. Navigate to your local copy of the PID Controller repository and select PidController.csproj

  4. Right-click on References in your main project within the solution. Select Add Reference

  5. Under the "Projects" tab, select PidController

  6. Rebuild your solution by selecting Build -> Rebuild All

Example

For an example of this code being used to control motor RPM see our Closed-Loop Control Demo.

Constructor

PidController controller = new PidController(float GainProportional, float GainIntegral, float GainDerivative, float OutputMax, float OutputMin);
  • GainProportional - The proportional gain in the feedback loop
  • GainIntegral - The integral gain in the feedback loop
  • GainDerivative - The derivative gain in the feedback loop
  • OutputMax - The maximum value the ControlVariable property can return
  • OutputMin - The minimum value the ControlVariable property can return

Properties

Property Type Access Description
GainProportional double get/set The proportional gain in the feedback loop
GainIntegral double get/set The integral gain in the feedback loop
GainDerivative double get/set The derivative gain in the feedback loop
OutputMax double get The maximum value the ControlVariable function can return
OutputMin double get The minimum value the ControlVariable function can return
IntegralTerm double get Tracks the accumulated error in the control loop
ProcessVariable double get/set Current value of the process under control
ProcessVariableLast double get Last stored value of the process under control
SetPoint double get/set The desired value of the process under control

Functions

Function Return Type Description
ControlVariable(TimeSpan timeSinceLastUpdate) double The control variable that drives the process under control, depending on the amount of time that passed since the last time it was called

Tuning

There are lots of resources online for learning how to tune a PID controller. For a quick primer see the Wikipedia entry on manual tuning.

===

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

About

A simple PID Controller, written as a Universal Windows Runtime Component in C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages