Class PID

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, SequenceActor, TimedActor, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class PID
    extends DETransformer
    Generate PID output for a given input. The output is the sum of a proportional gain (P), discrete integration (I), and discrete derivative (D).

    The proportional component of the output is immediately available, such that yp[n]=Kp*x[n], where yp is the proportional component of the output, Kp is the proportional gain, and x is the input value.

    For integral gain, the output is available after two input symbols have been received, such that yi[n]=Ki*(yi[n-1]+(x[n] + x[n-1])*dt[n]/2), where yi is the integral component of the output, Ki is the integral gain, and dt[n] is the time differential between input events x[n] and x[n-1].

    For derivative gain, the output is available after two input symbols have been received, such that yd[n] = Kd*(x[n]-x[n-1])/dt, where yd is the derivative component of the output, Kd is the derivative gain, and dt is the time differential between input events events x[n] and x[n-1].

    The output of this actor is constrained to be a double, and input must be castable to a double. If the input signal is not left-continuous and the derivative constant is nonzero, then this actor will throw an exception as the derivative will be either infinite or undefined. If the derivative constant is zero, then this actor may receive discontinuous input.

    y[0]=Kp*x[0]
    y[n] = yp[n] + yi[n] + yd[n]
    y[n] = Kp*x[n] + Ki*sum{x=1}{n}{(x[n]+x[n-1])/2*dt[n]} + Kd*(x[n]-x[n-1]/dt[n])

    In postfire(), if an event is present on the reset port, this actor resets to its initial state, where integral and derivative components of output will not be present until two subsequent inputs have been consumed. This is useful if the input signal is switched on and off, in which case the time gap between events becomes large and would otherwise effect the value of the derivative (for one sample) and the integral.

    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Jeff C. Jensen
    See Also:
    Integrator, Derivative
    • Field Detail

      • reset

        public TypedIOPort reset
        The reset port, which has undeclared type. If this port receives a token, this actor resets to its initial state, and no output is generated until two inputs have been received.
      • Kp

        public Parameter Kp
        Proportional gain of the controller. Default value is 1.0.
      • Ki

        public Parameter Ki
        Integral gain of the controller. Default value is 0.0, which disables integral control.
      • Kd

        public Parameter Kd
        Derivative gain of the controller. Default value is 0.0, which disables derivative control. If Kd=0.0, this actor can receive discontinuous signals as input; otherwise, if Kd is nonzero and a discontinuous signal is received, an exception will be thrown.