PID Controller

Credit Arturo Urquizo

What is it?

A PID Controller implements the PID control algorithm. The PID control is a useful form of control loop in robotics. It simplifies control of a mechanism by creating a system that you can tell to go to some setpoint and it takes care of automatically moving to that setpoint and maintaining that setpoint as long as the PID loop is tuned.

There are 4 important constants that influence the behavior of the PID Controller, by setting any of these to 0, you can ignore that coefficient and use a simpler controller if it meets your needs. The 4 constants are the proportional, integral, derivative, and forcing constants which are explained below.

The Proportional Term

The proportional control constant of the PID loop is often referred to as P or kP. It is the simplest parameter to use and in many cases when using PID you really only need the proportional constant. The proportional term is very simple, you know where you are and where you want to be (i.e. the setpoint), so you just take the difference and multiply by kP which acts as a scaling factor.

The Integral Term

The integral control constant of the PID loop is often referred to as I or kI. It is useful for overcoming unexpected resistance that would stop a simple loop using only the proportional constant. The integral term represents the area under the curve of the error over time. You know where you are and where you want to be (the setpoint), so you just add this up over time and multiply by kI which acts as another scaling factor.

The Derivative Term

The derivative control constant of the PID loop is often referred to is D or kD. It is useful for preventing oscillation that otherwise occurs in a control loop. Derivative is the rate of change of the error over time. You know where you are and where you want to be (the setpoint), and you know this from the past time, so you take the setpoint difference, divide by the time difference and as always multiply by a scaling factor. The scaling factor in this case is kD.

The Forcing Term

The forcing control constant of the PID loop is often referred to as F or kF. It is used as the feed forward term and is very useful for velocity PID. TODO: Fill in

Properties

Name
The name of this PID Controller.
Send to SmartDashboard
Whether or not to send this PID Controller to the SmartDashboard for easy tuning and viewing.
Input
The sensor that tells the PID loop where it is.
Output
The actuator that controls movement of the mechanism.
P
The proportional constant for this PID Controller.
I
The integral constant for this PID Controller.
D
The derivative constant for this PID Controller.
F
The forcing constant for this PID Controller.
Tolerance
How close is close enough for the PID Controller to be considered on target, or at the right location.
Period
The loop time for doing calculations. This particularly effects calculations of the integral and differential terms. The default is 20ms.
Continuous
When true, the PID controller to consider the input to be continuous. Rather then using the max and min in as constraints, it considers them to be the same point and automatically calculates the shortest route to the setpoint.
Limit Input
Whether or not to limit the range of acceptable input values.
Minimum Input
The minimum input value, any value lower than this will be considered to have this value.
Maximum Input
The maximum input value, any value higher than this will be considered to have this value.
Limit Output
Whether or not to limit the range of acceptable output values.
Minimum Output
The minimum output value, any output that would have value lower will be output as this value.
Maximum Output
The maximum output value, any output that would have value higher will be output as this value.

Applications

Elevator Control

When setup with an elevator and tuned appropriately, the elevator can be told to go to predetermined heights by setting the setpoint to predetermined values. With this, a press of a button can move the elevator to a known height where it can pickup and place pieces.

Shooter Control

With a spinning wheel shooter, a PID controller with a forcing term can be used to set the speed of the wheel. When the wheel is spinning at the same speed, it will consistently shoot the same distance. By determining the setpoint for a distance, you can use PID controller to consistently shoot into a basket.

Usage

Java

Setting the setpoint in java is easy, just call my_pid_controller.setSetpoint(2);

C++

Setting the setpoint in C++ is easy, just call my_pid_controller.Setsetpoint(2);

See Also