Class ControllerDeviceBaseClass
- All Implemented Interfaces:
Serializable, ControllerDeviceInterface, NamedInterface
- Direct Known Subclasses:
IntegratedSafetySystemExample.ESDController, IntegratedSafetySystemExample.HIPPSController
The controller operates on a MeasurementDeviceInterface
transmitter and exposes a standard PID API through
ControllerDeviceInterface.
- Version:
- $Id: $Id
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ControllerDeviceInterface
ControllerDeviceInterface.StepResponseTuningMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected UUIDUnique identifier of which solve/run call was last called successfully.private doubleprivate doubleprivate doubleprivate doubleprivate List<ControllerEvent> private NavigableMap<Double, double[]> private double(package private) booleanprivate doubleprivate double(package private) static org.apache.logging.log4j.LoggerLogger object for class.private doubleprivate doubleprivate doubleprivate double(package private) intprivate doubleprivate booleanprivate static final longSerialization version UID.private doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate MeasurementDeviceInterfaceprivate StringFields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for ControllerDeviceBaseClass.Constructor for ControllerDeviceBaseClass. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGainSchedulePoint(double processValue, double Kp, double Ti, double Td) Add a gain schedule point that switches controller parameters when the measured value exceeds the specified threshold.private voidapplyGainSchedule(double measurement) Apply gain-scheduled controller parameters based on the current measurement value.voidautoTune(double ultimateGain, double ultimatePeriod) Auto tune controller using ultimate gain and period from a closed-loop test.voidautoTune(double ultimateGain, double ultimatePeriod, boolean tuneDerivative) Auto tune controller using ultimate gain and period from a closed-loop test with optional derivative tuning.booleanAutomatically tune the controller parameters using the recorded controller event log.booleanautoTuneFromEventLog(boolean tuneDerivative) Automatically tune the controller parameters using the recorded controller event log with the option to omit derivative tuning.voidautoTuneStepResponse(double processGain, double timeConstant, double deadTime) Auto tune controller from an open-loop step response using process gain, time constant and dead time.voidautoTuneStepResponse(double processGain, double timeConstant, double deadTime, boolean tuneDerivative) Auto tune controller from an open-loop step response using process gain, time constant and dead time with optional derivative tuning.private doubleaverageOfLast(int count, ToDoubleFunction<ControllerEvent> extractor) Calculate the average value of theControllerEventproperties for the last entries in the event log.doublegetControllerSetPoint.Retrieve the controller event log.doubleGet the integral of absolute error accumulated during the simulation.doublegetKp()Get proportional gain of PID controller.doublegetMeasuredValue.doublegetMeasuredValue(String unit) getMeasuredValue.doublegetResponse.doubleGet the settling time computed from the event log.Retrieve the currently selected step-response tuning correlations.doublegetTd()Get derivative time of PID controller.doublegetTi()Get integral time of PID controller.getUnit()getUnit.booleanisActive()isActive.booleanisReverseActing.voidReset the controller event log.voidReset accumulated performance metrics.voidrunTransient(double initResponse, double dt, UUID id) runTransient.voidsetActive(boolean isActive) setActive.voidsetControllerParameters(double Kp, double Ti, double Td) Set PID tuning parameters.voidsetControllerSetPoint(double signal) setControllerSetPoint.voidsetControllerSetPoint(double signal, String unit) setControllerSetPoint.voidsetDerivativeFilterTime(double timeConstant) Set derivative filter time constant.voidsetKp(double Kp) Set proportional gain of PID controller.voidsetOutputLimits(double min, double max) Set minimum and maximum controller output for anti-windup handling.voidsetReverseActing(boolean reverseActing) setReverseActing.voidSelect the tuning correlations that should be used when calling one of the step response auto-tuning helpers.voidsetTd(double Td) Set derivative time of PID controller.voidsetTi(double Ti) Set integral time of PID controller.voidsetTransmitter.voidsetUnit.Methods inherited from class NamedBaseClass
getName, getTagName, setName, setTagNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ControllerDeviceInterface
equals, hashCode, runTransient
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
static org.apache.logging.log4j.Logger loggerLogger object for class. -
calcIdentifier
Unique identifier of which solve/run call was last called successfully. -
unit
-
transmitter
-
controllerSetPoint
private double controllerSetPoint -
oldError
private double oldError -
oldoldError
private double oldoldError -
error
private double error -
response
private double response -
propConstant
int propConstant -
reverseActing
private boolean reverseActing -
Kp
private double Kp -
Ti
private double Ti -
Td
private double Td -
stepResponseTuningMethod
-
TintValue
private double TintValue -
derivativeState
private double derivativeState -
derivativeFilterTime
private double derivativeFilterTime -
minResponse
private double minResponse -
maxResponse
private double maxResponse -
isActive
boolean isActive -
gainSchedule
-
eventLog
-
totalTime
private double totalTime -
integralAbsoluteError
private double integralAbsoluteError -
lastTimeOutsideBand
private double lastTimeOutsideBand -
settlingTolerance
private double settlingTolerance
-
-
Constructor Details
-
ControllerDeviceBaseClass
public ControllerDeviceBaseClass()Constructor for ControllerDeviceBaseClass.
-
ControllerDeviceBaseClass
Constructor for ControllerDeviceBaseClass.
- Parameters:
name- Name of PID controller object
-
-
Method Details
-
setActive
public void setActive(boolean isActive) setActive.
Set if controller is active- Specified by:
setActivein interfaceControllerDeviceInterface- Parameters:
isActive- Set true to make controller active.
-
isActive
public boolean isActive()isActive.
Specifies if controller is active- Specified by:
isActivein interfaceControllerDeviceInterface- Returns:
- a boolean
-
setTransmitter
setTransmitter.
- Specified by:
setTransmitterin interfaceControllerDeviceInterface- Parameters:
device- aMeasurementDeviceInterfaceobject
-
getMeasuredValue
public double getMeasuredValue()getMeasuredValue.
- Specified by:
getMeasuredValuein interfaceControllerDeviceInterface- Returns:
- a double
-
getMeasuredValue
getMeasuredValue.
- Specified by:
getMeasuredValuein interfaceControllerDeviceInterface- Parameters:
unit- aStringobject- Returns:
- a double
-
runTransient
runTransient.
Calculates controller output. Sets calc identifier UUID.If no engineering unit is configured, the controller falls back to the legacy percent-based error formulation used by earlier NeqSim versions.
- Specified by:
runTransientin interfaceControllerDeviceInterface- Parameters:
initResponse- Init value for response calculationdt- Delta time [s]id- Calculation identifier
-
setControllerSetPoint
public void setControllerSetPoint(double signal) setControllerSetPoint.
- Specified by:
setControllerSetPointin interfaceControllerDeviceInterface- Parameters:
signal- a double
-
setControllerSetPoint
setControllerSetPoint.
- Specified by:
setControllerSetPointin interfaceControllerDeviceInterface- Parameters:
signal- a doubleunit- aStringobject
-
getControllerSetPoint
public double getControllerSetPoint()getControllerSetPoint.
- Specified by:
getControllerSetPointin interfaceControllerDeviceInterface- Returns:
- current controller set point
-
getUnit
getUnit.
- Specified by:
getUnitin interfaceControllerDeviceInterface- Returns:
- a
Stringobject
-
setUnit
setUnit.
- Specified by:
setUnitin interfaceControllerDeviceInterface- Parameters:
unit- aStringobject
-
getResponse
public double getResponse()getResponse.
- Specified by:
getResponsein interfaceControllerDeviceInterface- Returns:
- a double
-
isReverseActing
public boolean isReverseActing()isReverseActing.
- Specified by:
isReverseActingin interfaceControllerDeviceInterface- Returns:
- a boolean
-
setReverseActing
public void setReverseActing(boolean reverseActing) setReverseActing.
- Specified by:
setReverseActingin interfaceControllerDeviceInterface- Parameters:
reverseActing- a boolean
-
setOutputLimits
public void setOutputLimits(double min, double max) Set minimum and maximum controller output for anti-windup handling.
Set minimum and maximum controller output for anti-windup handling.
- Specified by:
setOutputLimitsin interfaceControllerDeviceInterface- Parameters:
min- Minimum controller responsemax- Maximum controller response
-
setDerivativeFilterTime
public void setDerivativeFilterTime(double timeConstant) Set derivative filter time constant. Set to zero to disable filtering.
Set derivative filter time constant. Set to zero to disable filtering.
- Specified by:
setDerivativeFilterTimein interfaceControllerDeviceInterface- Parameters:
timeConstant- Filter time constant in seconds
-
getKp
public double getKp()Get proportional gain of PID controller.
- Returns:
- Proportional gain of PID controller
-
setKp
public void setKp(double Kp) Set proportional gain of PID controller.
- Parameters:
Kp- Proportional gain of PID controller
-
setControllerParameters
public void setControllerParameters(double Kp, double Ti, double Td) Set PID tuning parameters.
- Specified by:
setControllerParametersin interfaceControllerDeviceInterface- Parameters:
Kp- Proportional gainTi- Integral time in secondsTd- Derivative time in seconds
-
getTi
public double getTi()Get integral time of PID controller.
- Returns:
- Integral time in seconds
-
setTi
public void setTi(double Ti) Set integral time of PID controller.
- Parameters:
Ti- Integral time in seconds
-
getTd
public double getTd()Get derivative time of PID controller.
- Returns:
- Derivative time of controller
-
setTd
public void setTd(double Td) Set derivative time of PID controller.
- Parameters:
Td- Derivative time in seconds
-
setStepResponseTuningMethod
Description copied from interface:ControllerDeviceInterfaceSelect the tuning correlations that should be used when calling one of the step response auto-tuning helpers.
- Specified by:
setStepResponseTuningMethodin interfaceControllerDeviceInterface- Parameters:
method- tuning rule to use
-
getStepResponseTuningMethod
Description copied from interface:ControllerDeviceInterfaceRetrieve the currently selected step-response tuning correlations.
- Specified by:
getStepResponseTuningMethodin interfaceControllerDeviceInterface- Returns:
- the active tuning method
-
autoTune
public void autoTune(double ultimateGain, double ultimatePeriod) Auto tune controller using ultimate gain and period from a closed-loop test.
- Specified by:
autoTunein interfaceControllerDeviceInterface- Parameters:
ultimateGain- Ultimate gain where oscillations startultimatePeriod- Ultimate period of sustained oscillations [s]
-
autoTune
public void autoTune(double ultimateGain, double ultimatePeriod, boolean tuneDerivative) Auto tune controller using ultimate gain and period from a closed-loop test with optional derivative tuning.
- Specified by:
autoTunein interfaceControllerDeviceInterface- Parameters:
ultimateGain- Ultimate gain where oscillations startultimatePeriod- Ultimate period of sustained oscillations [s]tuneDerivative- true to tune derivative action, false to tune PI only
-
autoTuneStepResponse
public void autoTuneStepResponse(double processGain, double timeConstant, double deadTime) Auto tune controller from an open-loop step response using process gain, time constant and dead time.
- Specified by:
autoTuneStepResponsein interfaceControllerDeviceInterface- Parameters:
processGain- Process gain from step responsetimeConstant- Process time constant [s]deadTime- Process dead time [s]
-
autoTuneStepResponse
public void autoTuneStepResponse(double processGain, double timeConstant, double deadTime, boolean tuneDerivative) Auto tune controller from an open-loop step response using process gain, time constant and dead time with optional derivative tuning.
- Specified by:
autoTuneStepResponsein interfaceControllerDeviceInterface- Parameters:
processGain- Process gain from step responsetimeConstant- Process time constant [s]deadTime- Process dead time [s]tuneDerivative- true to tune derivative action, false to tune PI only
-
autoTuneFromEventLog
public boolean autoTuneFromEventLog()Automatically tune the controller parameters using the recorded controller event log. The implementation typically analyses a previously executed step test and estimates the process dynamics before calculating PID settings.
- Specified by:
autoTuneFromEventLogin interfaceControllerDeviceInterface- Returns:
trueif tuning succeeded, otherwisefalse
-
autoTuneFromEventLog
public boolean autoTuneFromEventLog(boolean tuneDerivative) Automatically tune the controller parameters using the recorded controller event log with the option to omit derivative tuning.
- Specified by:
autoTuneFromEventLogin interfaceControllerDeviceInterface- Parameters:
tuneDerivative- true to tune derivative action, false to tune PI only- Returns:
trueif tuning succeeded, otherwisefalse
-
addGainSchedulePoint
public void addGainSchedulePoint(double processValue, double Kp, double Ti, double Td) Add a gain schedule point that switches controller parameters when the measured value exceeds the specified threshold.
- Specified by:
addGainSchedulePointin interfaceControllerDeviceInterface- Parameters:
processValue- Measurement threshold for parameter setKp- Proportional gain at this operating pointTi- Integral time [s] at this operating pointTd- Derivative time [s] at this operating point
-
getEventLog
Retrieve the controller event log.
- Specified by:
getEventLogin interfaceControllerDeviceInterface- Returns:
- list of controller events
-
resetEventLog
public void resetEventLog()Reset the controller event log.
- Specified by:
resetEventLogin interfaceControllerDeviceInterface
-
getIntegralAbsoluteError
public double getIntegralAbsoluteError()Get the integral of absolute error accumulated during the simulation.
- Specified by:
getIntegralAbsoluteErrorin interfaceControllerDeviceInterface- Returns:
- integral of absolute error
-
getSettlingTime
public double getSettlingTime()Get the settling time computed from the event log.
- Specified by:
getSettlingTimein interfaceControllerDeviceInterface- Returns:
- settling time in seconds
-
resetPerformanceMetrics
public void resetPerformanceMetrics()Reset accumulated performance metrics.
- Specified by:
resetPerformanceMetricsin interfaceControllerDeviceInterface
-
applyGainSchedule
private void applyGainSchedule(double measurement) Apply gain-scheduled controller parameters based on the current measurement value. The schedule selects the parameter set with the highest threshold not exceeding the measurement.- Parameters:
measurement- current process value
-
averageOfLast
Calculate the average value of theControllerEventproperties for the last entries in the event log.- Parameters:
count- number of samples to include in the averageextractor- function returning the value to average from the event- Returns:
- average of the selected event property
-