en:software:qview:qview_6:qcl_library:ot11pidreg

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

OT11PidReg

O = Digital output

T = Control functions

The OT11PidReg function implements a PID controller to temperature (heating only) with self-tuning function.

OT11PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, agwOutReg )

Parameters:

IN/OUTVARIABLE TYPEEXAMPLE NAMEDIM
INARRSYSaswParReg [1]WSample time PID controller (msec) [0÷32767].
INARRSYSaswParReg [2]WMaximum scale limit of the process variable (UM) [-32768÷32767]
INARRSYSaswParReg [3]WMinimum scale limit of the process variable (UM) [-32768÷32767]
INARRSYSaswParReg [4]WMaximum value of control output [1÷32767]
INARRSYSaswParReg [5]WMinimum value of control output [0÷32767]
INARRSYSaswParUsr [1]WProportional band.( )[0÷1000]
INARRSYSaswParUsr [2]WIntegral time (min x 100) [0÷9999]
INARRSYSaswParUsr [3]WDerivative time (min x 100) [0÷9999]
INARRSYSaswParUsr [4]WSample time of the derivative [0÷255]
0=sample time PID controller
1=2*sample time PID controller
.
.
n=(n+1)*sample time PID controller
INARRSYSaswParUsr [5]RWTuning mode[0÷2]
0=no
1=self-tuning at next reboot
2=self-tuning the next time start adjusting
INGLOBALgwSetPointWTemperature setpoint (UM)
INGLOBALgwMeasureWValue of the process variable (UM)
INGLOBALgwEnaRegFEnabling regulation [0÷1]
0=regulator disabled
1=regulator enabled
OUTARRGBLagwOutReg[1]WPID output log
OUTARRGBLagwOutReg[2]WProportional output log
OUTARRGBLagwOutReg[3]WIntegral output log
OUTARRGBLagwOutReg[4]WDerivative output log
OUTARRGBLagwOutReg[5]WAdjusting digital output status
OUTARRGBLagwOutReg[6]WError code

After calling the function, the “error code” variable in agwOutReg[6] 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 the proportional band
4: Error setting integration time
5: Error setting derivative time
6: Error setting minimum and/or maximum value regulator output
7: Error setting sampling time derivative

Example

;---------------------------------------------
; Project           : REG_012
; Module Name       : PIDREG
; Author            : 
; Description       : PID regulator
;---------------------------------------------
	aswParReg [0]=500			; sampling time = 500ms
	aswParReg [1]=10000			; full scale over temperature = 1000.0 °C
	aswParReg [2]=0				; full scale ower temperature = 0.0 °C
	aswParReg [3]=500			; Maximum value output regulator = 500
	aswParReg [4]=0				; Minimum value output regulator = 0
 
        gfEnaReg = 1				;Enable Adjusting
MAIN:
	gwSetPoint = 800
        gwMeasure = glTemperatura		;Passes the measured temperature in UM
        OT11PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, agwOutReg )
	IF agwOutReg[5] EQ 0
		RESOUT ofOutPow
	ELSE
		SETOUT ofOutPow
	ENDIF		
 
WAIT 1
JUMP MAIN

A regulator reads an input signal process variable / measure), compares it to a reference signal (setpoint) and change the value of the process variable to achieve equality with the setpoint.

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

Proportional action

Provides a contributes, at the output, proportional to the error between the setpoint and measurement. The coefficient of proportionality is said “proportional Constant” (Kp)
OutP(t) = Kp*err(t)
Very often, instead of proportional coefficient is used the “proportional Band” defines as:
Kp=100/PB
Expressing variables as a percentage of full scale, PB is the error signal amplitude (setpoint-measure) able to bring the output proportional to the 100%.

The only proportional controller fails to clear the error in scheme, remains a small difference between the setpoint and measurement. If PB increases the error in steady increases, when PB decreases the error in steady decreases. Too small values of PB can bring the system into oscillation.

Integral action

Provides a contributes, at the output, proportional to the integral of the error. In hypothetical conditions of constant error, the integral output increases linearly and reaches the proportional output value after the integral time.

OutI(t) = 1/Ti*∫err(t)

The integral is used, in combination with the proportional, to eliminate the error.

Derivative action

Provides a contributes, at the output, proportional to the derivative of the error. In hypothetical failure conditions growing linearly (then its derivative is constant), the proportional output increases linearly and reach the derivative output value after the derivative time.

OutD(t) = Td*Δerr(t)/Δt

Self-Tuning function

The PID controller includes the steps of self-tuning that allows to calculate automatically the optimal value of PID control parameters in the starting phase of the process. It's important to execute this procedure when the measured temperature is close to that of the environment (equilibrium temperature in the absence of power).
The function enables the maximum power setting until the intermediate value between the initial temperature and the set point, then reset the power. The function evaluates the system response, therefore, the amplitude of the overshoot and the time between zero power and peak temperature, calculates the PID parameters.
After the evaluation of response function autodisables itself and the regulator starts regulating the new parameters for the reach of the set-point.

How to enable the function of self-tuning (mode 1 activation on power up):
  1. Disable the regulation (variabile gwEnaReg=0)
  2. Set the setpoint to the desired value
  3. Make sure that the temperature is close to environment temperature
  4. Enable self-tuning by setting the aswParUsr parameter [5] at the value 1
  5. Switch off the instrument (or execute the RESTART)
  6. Turn on the instrument (or go to RUN the application)
  7. Enable the setting
How to enable the function of self-tuning (mode 2 activation at the beginning of the regulation):
  1. Disable the regulation (variable gwEnaReg=0)
  2. Set the setpoint to the desired value
  3. Make sure that the temperature is close to environment temperature
  4. Enable selftuning by setting the aswParUsr parameter [5] al valore 2
  5. Enable the regulation
    NB: During the self-tuning the value of the aswParUsr parameter [5] takes the following values to indicate the status:
  6. Waiting setpoint temperature
  7. Waiting the temperature stops growing
  8. Waiting for the temperature begins to decrease
  9. Final stages of calculation
  • Last modified: 2019/08/29 17:01