-
Notifications
You must be signed in to change notification settings - Fork 21
Getting started
This article goes over how to get started with this PID library.
The first thing you need to do is to include the library.
#include <PIDController.h>
Then you need to create an instance of the class.
PIDController pid;
This creates an instance of the class PIDController called pid.
You can call it whatever you want, it can for example be myPIDController instead of pid.
It should look something like this:
#include <PIDController.h>
PIDController pid;In the setup function you need to call some methods.
void setup () {
Serial.begin(9600); // Required for graphing
pid.begin();
pid.setpoint(600);
pid.tune(1, 1, 1);
pid.limit(0, 255);
}-
If you want the PID controller to graph the values during computing, you have to call Serial.begin() first.
-
You need to call begin() on your instance before you can call other methods. The method begin() initializes the properties in your PID instance.
-
The setpoint() method defines the setpoint (or "goal") for your PID.
-
The tune() method tunes your PID. It takes the arguments
<kP> <kI> <kD>. The tuning variables are different for every control loop that uses a PID. You need to find the values that fit for your setup. Read more about tuning here. -
The limit method limits the output from your PID. It takes the arguments
<min> <max>. It's is important to set the limit to avoid integral windup. You can read more about integral windup here.
More info soon
View on arduino.cc