RoboJDETM v2.0

com.ridgesoft.robotics
Class PIDController

java.lang.Object
  extended by com.ridgesoft.robotics.PIDController
All Implemented Interfaces:
Controller

public class PIDController
extends Object
implements Controller

Implements a Proportional-Integral-Differential (PID) controller.

This class implements a controller that, when passed a target value and the current sample of the controlled variable, calculates an output based on the PID control algorithm and the gain constants specified.


Constructor Summary
PIDController(float pGain, float iGain, float dGain, float iTermMax, boolean doErrorPrediction)
          Constructs a PID controller
 
Method Summary
 float control(float target, float sample)
          Calculates the controller output given a target and current sample of the controlled variable.
 void setConstants(float pGain, float iGain, float dGain, float iTermMax)
          Sets the controller constants.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

PIDController

public PIDController(float pGain,
                     float iGain,
                     float dGain,
                     float iTermMax,
                     boolean doErrorPrediction)
Constructs a PID controller

Parameters:
pGain - proportional gain
iGain - integral gain
dGain - differential gain
iTermMax - cap on the value of the integral term
doErrorPrediction - true if the controller should predict the integral term when the target changes
Method Detail

control

public float control(float target,
                     float sample)
Calculates the controller output given a target and current sample of the controlled variable.

Invoke this method at a regular interval to calculate updates to the controller output.

Specified by:
control in interface Controller
Parameters:
target - target value of the sampled quantity
sample - value of most recent sample
Returns:
controller ouput

setConstants

public void setConstants(float pGain,
                         float iGain,
                         float dGain,
                         float iTermMax)
Sets the controller constants.

Parameters:
pGain - proportional gain
iGain - integral gain
dGain - differential gain
iTermMax - cap on the value of the integral term

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com