Table of Contents

Class PidController

Namespace
TimeSeriesAnalysis.Dynamic
Assembly
TimeSeriesAnalysis.dll

Proporitional-Integral-Derivative(PID) controller

that supports

  • first and second order low pass filtering of process variable
  • anti-windup
  • bumpless transfer between auto and manual mode
  • "warmstarting" -bumpless startup
  • feedforward
  • scaling of input and output values
  • gain scheduling of Kp
  • gain scheduling of Ti
  • "kicking" as is usually applied to compressor recycling controllers/anti-surge
  • min select/max select (also referred to as high select or low select: (multiple pid-controllers controlling the same output switch between auto and tracking mode)

By design decision, this class should be kept relativly simple in terms of coding patterns, so that it is possible to hand-port this class to other languages (c++/c/Structured Text/Labview/Matlab etc). To simulate PID-control, use the wrapper class PIDModel, as it wraps this class and impelments the ISimulatableModel interface needed to simulate with ProcessSimulator

PidModel
public class PidController
Inheritance
PidController
Inherited Members

Constructors

PidController(double, double, double, double, double)

Constructor

public PidController(double TimeBase_s, double Kp = 1, double Ti = 50, double Td = 0, double nanValue = -9999)

Parameters

TimeBase_s double
Kp double
Ti double
Td double
nanValue double

Methods

GetControllerStatus()

Returns a status code, to determine if controller is in manual, auto or in tracking(relevant for split range controllers.)

public PidStatus GetControllerStatus()

Returns

PidStatus

GetFeedForward()

Get the feedforward parameters of the controller

public PidFeedForward GetFeedForward()

Returns

PidFeedForward

GetGainScehduling(PidGainScheduling)

Get the gain scheduling settings of the controller

public PidGainScheduling GetGainScehduling(PidGainScheduling gainSchedulingObj)

Parameters

gainSchedulingObj PidGainScheduling

Returns

PidGainScheduling

GetScaling()

Get the object that contains scaling information

public PidScaling GetScaling()

Returns

PidScaling

GetTimeBase()

Sets the length of time in seconds between each iteration of the controller, i.e. the "clock time" or "time base". This is very important to set correctly for the controller to function properly. Normally the clock time is set only once during intalization.

public double GetTimeBase()

Returns

double

GetTrackingCutoff()

Get the tracking cutoff parameter

public double GetTrackingCutoff()

Returns

double

GetTrackingOffset()

Returns the tracking offset of the controller, the offset that a non-active controller will add or subtract from its output when inactive in a split range control scheme

public double GetTrackingOffset()

Returns

double

GetUIfInAuto()

Returns the value of the output u that the controller would give if it was in auto. This is useful when considering turning on a controller that is in manual to see that the controller gives a sensible output. Call "iterate" first to update the internals of the controller.

public double GetUIfInAuto()

Returns

double

GetUWithoutTracking()

Split range controllers add an offset to the output u for inactive or "tracking" controllers. This function returns the "raw" u without tracking, which can be useful for initalizing simulations with split range control.

public double GetUWithoutTracking()

Returns

double

Iterate(double, double, double?, double?, double?, double?)

Calculates the next u[k] output of the controller given the most recent process value and setpoint value, and optionally also including the tracking signal (only applicable if this is a split range controller) and optionally the gainScehduling variable if controller is to gain-schedule

public double Iterate(double y_process_abs, double y_set_abs, double? uTrackSignal = null, double? gainSchedulingVariable = null, double? feedForwardVariable = null, double? stepLength_s = null)

Parameters

y_process_abs double
y_set_abs double
uTrackSignal double?
gainSchedulingVariable double?
feedForwardVariable double?
stepLength_s double?

Returns

double

Iterate(double[], double[], double[])

Calculates an entire output vector u given vector of processes and setpoints (and optionally a tracking signal for split range) This method is useful for back-testing against historic data.

public double[] Iterate(double[] y_process_abs, double[] y_set_abs, double[] uTrackSignal = null)

Parameters

y_process_abs double[]
y_set_abs double[]
uTrackSignal double[]

Returns

double[]

SetAntiSurgeParams(PidAntiSurgeParams)

Sets the anti-surge "kick" paramters of the controller

public void SetAntiSurgeParams(PidAntiSurgeParams antiSurgeParams)

Parameters

antiSurgeParams PidAntiSurgeParams

SetAutoMode()

Set the control to autoamtic mode (i.e. u varies based on inputs and settings) (use SetManualMode to switch back)

public void SetAutoMode()

SetFeedForward(PidFeedForward)

Set the feedforward of the controller Re-calling this setter to update

public void SetFeedForward(PidFeedForward feedForwardObj)

Parameters

feedForwardObj PidFeedForward

SetGainScheduling(PidGainScheduling)

Set the gain scheduling of the controller (by default controller has no gain-scheduling) Re-calling this setter to update gain-scheduling

public void SetGainScheduling(PidGainScheduling gainSchedulingObj)

Parameters

gainSchedulingObj PidGainScheduling

SetKp(double)

Sets the Proportional gain(P) of the controller

public void SetKp(double Kp)

Parameters

Kp double

SetManualMode()

Set the control to manual mode (i.e. constant u). Will cause a bumpless transfer.(use SetAutoMode to switch back)

public void SetManualMode()

SetManualOutput(double)

Set the manual output of the model (will only be used if set)

public void SetManualOutput(double uManual)

Parameters

uManual double

SetPidFiltering(PidFilterParams)

Set the object that defines input filtering for the pid-controller

public void SetPidFiltering(PidFilterParams pidFiltering)

Parameters

pidFiltering PidFilterParams

SetScaling(PidScaling)

Gives a PIDscaling object that specifies how input and output is to be scaled.

public void SetScaling(PidScaling pidScaling)

Parameters

pidScaling PidScaling

SetTd(double)

Sets the differential(D) time contant of the controller in seconds

public void SetTd(double Td_seconds)

Parameters

Td_seconds double

SetTi(double)

Sets the Integral(I) time contant of the controller in seconds

public void SetTi(double Ti_seconds)

Parameters

Ti_seconds double

SetTrackingOffset(double, double)

Set the offset that is to be added or subtracte to a split range controller that is inactive or tracking. If this value is above zero, then the controller is MIN SELECT, if this value is negative then the controller is assumed MAX SELECT if this vlaue is zero, then trakcking will not work properly as controller will be unable to determine if its output was selected by looking at the tracking signal.

public void SetTrackingOffset(double uTrackingOffset, double uTrackingCutoff = 0.5)

Parameters

uTrackingOffset double
uTrackingCutoff double

SetU0ForPcontrol(double)

For proportional-only controllers (P-controllers), a u0 offset to be added to u is specified by this method.

public void SetU0ForPcontrol(double u0)

Parameters

u0 double

WarmStart(double, double, double, double, double, double, double)

Initalizes the controller internal state(integral term) to be steady at the given process value and output value, useful to avoid bumps when staring controller

public void WarmStart(double y_process_abs, double y_set_abs, double u_abs, double y_process_abs_prev = 0, double y_set_abs_prev = 0, double y_process_abs_prev_prev = 0, double y_set_abs_prev_prev = 0)

Parameters

y_process_abs double
y_set_abs double
u_abs double
y_process_abs_prev double
y_set_abs_prev double
y_process_abs_prev_prev double
y_set_abs_prev_prev double