en:software:qview:qview_6:qcl_library:ot30pidreg

This translation is older than the original page and might be outdated. See what has changed.

OT30PidReg

O = Digital Output

T = Control functions

The OT30PidReg function implements a generic PID regulator. In addition to providing the regulation value, the function allows to suspend the regulator's update while maintaining the values of the various control registers and the same control output. In addition, you can adjust the control so that the control output is handled in inverse proportion to the error.

OT30PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, aglOutReg )

Parameters:

IN/OUTVARIABLE TYPEEXAMPLE NAMEDIM
INARRSYSaswParReg [1]WSample time PID regulator (sec/100) [0÷32767].
INARRSYSaswParReg [2]WMaximum scale limit of regulation variable (UM) [-32768÷32767]
INARRSYSaswParReg [3]WMinimum scale limit of regulation variable (UM) [-32768÷32767]
INARRSYSaswParReg [4]WMaximum value of regulation output [-32768 ÷32767]
INARRSYSaswParReg [5]WMinimum value of regulation output [-32768 ÷32767]
INARRSYSaswParReg [6]WPositive saturation value regulation output [-32768 ÷32767]
INARRSYSaswParReg [7]WNegative saturation value regulation output [-32768 ÷32767]
INARRSYSaswParReg [8]WSetting flags:
bit 0: EnableReg. Enables regulator; with disabled regulator everything is 0.
bit 1: FreezeReg. Freeze updating the controller.
bit 2: InvertOut. Reverses the regulator output
bit 3: DisIntTm Disable the internal timer, This function should be called every sampling time.
INARRSYSaswParUsr [1]WProportional gain.()[0÷9999]
INARRSYSaswParUsr [2]WIntegral time (sec/100) [0÷9999]
INARRSYSaswParUsr [3]WDerivative time (sec/100) [0÷9999]
INARRSYSaswParUsr [4]WSample time of the derivative [0÷255]
0=sample time PID regulator
1=2*sample time PID regulator


n=(n+1)*sample time PID regulator
INARRSYSaswParUsr [5]WDerived filter time constant (sec/100) [0÷9999]
INARRSYSaswParUsr [6]WFeed Forward (‰) [0÷2000]
INGLOBALgwSetPointWSetpoint of regulation (UM)
INGLOBALgwMeasureWValue of the process variable(UM)
OUTARRGBLaglOutReg[1]LPID output log
OUTARRGBLaglOutReg[2]LProportional output log
OUTARRGBLaglOutReg[3]LIntegral output log
OUTARRGBLaglOutReg[4]LDerivative output log
OUTARRGBLaglOutReg[5]LFeedforward output log
OUTARRGBLaglOutReg[6]LError log
OUTARRGBLaglOutReg[7]LRegulator states:
bit 2 = positive saturation state
bit 3 = negative saturation state
bit 4 = executing state regulation
OUTARRGBLaglOutReg[8]LError code

After calling the function, the “Error code” variable in aglOutReg[8] takes certain values, the meaning of these values is summarized below:
0: No error
1: Error setting sampling time
2: Error setting lower limit and/or greater of scale
3: Error setting value proportional gain
4: Error setting integration time
5: Error setting derivative time
6: Error setting value percentage feed-forward
7: Error setting minimum and/or maximum value regulator output
8: Error setting sampling time derivative
9: Error setting derived filter time constant
10: positive saturation value setting exceeds maximum output regulator
11: negative saturation value setting exceeds maximum output regulator

Example

;---------------------------------------------
;	Example
;---------------------------------------------
	aswParReg [1]=500			; sample time = 500ms
	aswParReg [2]=10000			; full scale top  = 10000
	aswParReg [3]=0 			; full scale less  = 0
	aswParReg [4]=5000			; Maximum output regulator value
	aswParReg [5]=0			        ; Minimum output regulator value
	aswParReg [6]=2000			; Positive saturation value regulator output
	aswParReg [7]=0			        ; Negative saturation value regulator output
 
        aswParUsr[1] = 100			; Proportional gain = 0.1
        aswParUsr[2] = 200			; Integral time = 2 sec.
 
        aswParReg [8]= aswParReg [8] ORB 1	; Enable regulation
MAIN:
	gwSetPoint = 800
        OT30PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, aslOutReg )
        WAIT 1
    	JUMP MAIN

A regulator reads an input variable (gwMeasure), compares it to a reference signal (gwSetPoint) and change the value of the output (aslOutReg[7]) to achieve equality of the variable with the reference.

One of the most popular types of regulators is the PID (Proportional, Integral, Derivative).

Proportional action

This control action establishes a relationship of direct proportionality between the error (aglOutReg[6]) and the controller output value. The proportional gain parameter (aswParUsr [1]) defines the extent of proportional action; it's expressed in thousandths, then to set gain of 0.5 you should enter the value 500.
The rule establishing the output value (aslOutReg[7]) defines: with unity gain (1000), the control output will be maximum when the error is equal to the difference between “Maximum scale limit” and “Maximum scale limit” that is the result between aswParReg [2] - aswParReg [3].

Integral action

The integral action of the PID regulator calculates the integral of the error on a user-settable time interval through the aswParUsr [2] parameter (expressed in hundredths of a second). The output signal is updated in a particular way: whenever the Integrator gives an output value that is added to the value that is on the register, then it will continue to increase or decrease (depending on the sign of the error). The output value is calculated as follows: with unit proportional gain, the integration time (aswParUsr [2]) is the necessary time that the integral log (aglOutReg[3]) reaches the proportional registry value (aglOutReg[2]). From this last statement shows that the integral action is related to the proportional action.

Derivative action

The derivative action try to in a sense of “anticipating” the behavior of the system being monitored. The output produced is proportional to the change of the input signal. The amount of the derivative effect is adjustable via the time derivative (aswParUsr [3]) parameter. The derivative action computing is based on the following convention: the derivative time is the time necessary for, with constant error variation, the derivative log (aglOutReg[4]) reaches a value equal to the proportional log (aglOutReg[2]). As for the integral action shows that even for the derivative action is there a link with the proportional controller. More higher is the derivative time of the error, more faster is the system in the transient error recovery. The derivative action may never be used alone because in the presence of constant mistakes its effect would be null.

Feed-forward action

In addition to the PID controller is also present the feed-forward action: it generates an output proportional to the setpoint value (as can be inferred from the name doesn't exploit any error feedback). Its function is to reduce the system response time providing an output already close to what the regulator should reach. The contribution of this action is adjustable via the feed forward parameter (aswParUsr [6]): This parameter is expressed as a portion to 0.001 mm (to introduce for example, 98.5% is necessary to set the value 985).
Setting a value of 100%, when the setpoint (gwSetPoint ) will be equal to “Maximum scale limit” (aswParReg [2]) the feed-forward output value will be equal to “maximum value of regulation output” (aswParReg [4]); when the setpoint setpoint (gwSetPoint ) will be equal to “Minimum scale limit” (aswParReg [3]) the feed-forward output value will be equal to “minimum value of regulation output” (aswParReg [5]);

  • Last modified: 2019/08/29 17:01