public class PIDControl extends PropertyContainer
c(t)=kp·e(t)+ki·∫e(t)dt+kd·de(t)/dtThe name PID comes from these three proportional constant, that are related to the signal itself, its integral, respectively differential with time. Determining the values of this three parameter is some science on its own.
This class allows basic access to PID-control. It allows registering
of an Integrator and Differentiator. The three constants
are provided in the PIDControl's properties. Calling the
getCorrection() method evaluates the formular above and returns the
c(t).
| Modifier and Type | Class and Description |
|---|---|
static class |
PIDControl.Test
Test string representation.
|
| Modifier and Type | Field and Description |
|---|---|
private static double |
DEFDIFFERENTIAL
The default value of the differential constant.
|
private static Class |
DEFDIFFERENTIATOR
The default differentiator class .
|
private static double |
DEFINTEGRAL
The default value of the integral constant.
|
private static Class |
DEFINTEGRATOR
The default integrator class .
|
private static double |
DEFLIMIT
The default limit, zero=no limit.
|
private static double |
DEFPROPORTIONAL
The default value of the proportional constant.
|
private Differentiator |
differentiate
The differentiator to use.
|
private boolean |
initialized
True after the first error has been added.
|
private Integrator |
integrate
The integrator to use.
|
static String |
KEY_DIFFERENTIAL
The differential constant.
|
static String |
KEY_DIFFERENTIATOR
The class name of the differentiator.
|
static String |
KEY_INTEGRAL
The integral constant.
|
static String |
KEY_INTEGRATOR
The class name of the integrator.
|
static String |
KEY_LIMIT
The PID correction limit.
|
static String |
KEY_PROPORTIONAL
The proportional constant.
|
private double |
lastoffset
The last offset added, used for the proportional term.
|
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
PIDControl(Map<String,String> info)
Constructs a new PID-control.
|
PIDControl(String pid)
Convenience constructor allowing instantiation with a string like
|
| Modifier and Type | Method and Description |
|---|---|
void |
addError(double offset)
Adds an error signal in the equal time-step case.
|
void |
addError(double t,
double offset)
Adds an error signal with a varying time-step.
|
void |
clear()
Clears the PID and allows for a new run.
|
double |
getCorrection()
Returns the correction to the signal as derived from previous offsets.
|
double |
getDifferential()
Sets the differential term.
|
double |
getIntegral()
Sets the integral term.
|
double |
getProportional()
Gets the proportinal term.
|
private static boolean |
searchDouble(String key1,
String keyset,
Map<String,String> search,
PropertySupplying where)
Searches the map for a string representation of the key in the first
argument, tries to convert this to a double and set this as the
second string property in the property container.
|
void |
setDifferential(double diff)
Sets the differential term.
|
void |
setIntegral(double integral)
Sets the integral term.
|
void |
setProportional(double prop)
Sets the proportinal term.
|
String |
toString()
Returns the three main parameters of the pid as a string.
|
augment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiespublic static final String KEY_PROPORTIONAL
public static final String KEY_DIFFERENTIAL
public static final String KEY_INTEGRAL
public static final String KEY_LIMIT
public static final String KEY_INTEGRATOR
public static final String KEY_DIFFERENTIATOR
private static final double DEFPROPORTIONAL
private static final double DEFDIFFERENTIAL
private static final double DEFINTEGRAL
private static final double DEFLIMIT
private static final Class DEFINTEGRATOR
private static final Class DEFDIFFERENTIATOR
private double lastoffset
private Integrator integrate
private Differentiator differentiate
private boolean initialized
public PIDControl(String pid)
P=0.5:I=0.2:D=0.0:L=20.
public PIDControl(Map<String,String> info)
getCorrection() method before enough differences had
been added with addError(double) for the integrator/differentiator
to work. Additionally, the user must be aware that the integrator/
differentiator supplied in the properties is compliant with the
addError(double) method used, i.e. whether a fixed time-step or a
(error-t) pair is used.private static final boolean searchDouble(String key1, String keyset, Map<String,String> search, PropertySupplying where)
public void addError(double offset)
public void clear()
public void addError(double t,
double offset)
public double getCorrection()
addError(double) method.public double getProportional()
public void setProportional(double prop)
public double getDifferential()
public void setDifferential(double diff)
public double getIntegral()
public void setIntegral(double integral)
public String toString()
toString in class PropertyContainer