Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:software:qview:qview_6:qcl_library:ot11pidreg [2017/01/23 15:30] – [Definizione di regolatore] qem103 | en:software:qview:qview_6:qcl_library:ot11pidreg [2019/08/29 17:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== OT11PidReg ====== | ||
+ | |||
+ | **O = **//Digital output// | ||
+ | |||
+ | **T = **//Control functions// | ||
+ | |||
+ | The OT11PidReg function __implements a PID controller to temperature (heating only) with self-tuning function__. | ||
+ | |||
+ | ===== IMPLEMENTATION ===== | ||
+ | |||
+ | **OT11PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, agwOutReg )** | ||
+ | |||
+ | Parameters: | ||
+ | |||
+ | ^IN/ | ||
+ | |IN|ARRSYS|aswParReg [1]|W|Sample time PID controller (msec) [0÷32767].| | ||
+ | |IN|ARRSYS|aswParReg [2]|W|Maximum scale limit of the process variable (UM) [-32768÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [3]|W|Minimum scale limit of the process variable (UM) [-32768÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [4]|W|Maximum value of control output [1÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [5]|W|Minimum value of control output [0÷32767]| | ||
+ | |IN|ARRSYS|aswParUsr [1]|W|Proportional band.('' | ||
+ | |IN|ARRSYS|aswParUsr [2]|W|Integral time (min x 100) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [3]|W|Derivative time (min x 100) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [4]|W|Sample time of the derivative [0÷255]\\ 0=sample time PID controller\\ 1=2*sample time PID controller\\ .\\ .\\ n=(n+1)*sample time PID controller| | ||
+ | |IN|ARRSYS|aswParUsr [5]|RW|Tuning mode[0÷2]\\ 0=no\\ 1=self-tuning at next reboot\\ 2=self-tuning the next time start adjusting| | ||
+ | |IN|GLOBAL|gwSetPoint|W|Temperature setpoint (UM)| | ||
+ | |IN|GLOBAL|gwMeasure|W|Value of the process variable (UM)| | ||
+ | |IN|GLOBAL|gwEnaReg|F|Enabling regulation [0÷1]\\ 0=regulator disabled\\ 1=regulator enabled| | ||
+ | |OUT|ARRGBL|agwOutReg[1]|W|PID output log| | ||
+ | |OUT|ARRGBL|agwOutReg[2]|W|Proportional output log| | ||
+ | |OUT|ARRGBL|agwOutReg[3]|W|Integral output log| | ||
+ | |OUT|ARRGBL|agwOutReg[4]|W|Derivative output log| | ||
+ | |OUT|ARRGBL|agwOutReg[5]|W|Adjusting digital output status| | ||
+ | |OUT|ARRGBL|agwOutReg[6]|W|Error code| | ||
+ | |||
+ | ==== Errors ==== | ||
+ | |||
+ | 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 === | ||
+ | |||
+ | <code QCL> | ||
+ | ; | ||
+ | ; Project | ||
+ | ; Module Name : PIDREG | ||
+ | ; Author | ||
+ | ; Description | ||
+ | ; | ||
+ | aswParReg [0]=500 ; sampling time = 500ms | ||
+ | aswParReg [1]=10000 ; | ||
+ | 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 ; | ||
+ | MAIN: | ||
+ | gwSetPoint = 800 | ||
+ | gwMeasure = glTemperatura ; | ||
+ | OT11PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, agwOutReg ) | ||
+ | IF agwOutReg[5] EQ 0 | ||
+ | RESOUT ofOutPow | ||
+ | ELSE | ||
+ | SETOUT ofOutPow | ||
+ | ENDIF | ||
+ | |||
+ | WAIT 1 | ||
+ | JUMP MAIN | ||
+ | </ | ||
+ | |||
+ | ==== Definition of regulator ==== | ||
+ | |||
+ | 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. | ||
+ | |||
+ | ==== PID regualtor ==== | ||
+ | |||
+ | One of the most popular types of regulators is the PID (Proportional, | ||
+ | |||
+ | === Proportional action === | ||
+ | |||
+ | Provides a contributes, | ||
+ | OutP(t) = Kp*err(t)\\ | ||
+ | Very often, instead of proportional coefficient is used the " | ||
+ | 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, | ||
+ | |||
+ | | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The integral is used, in combination with the proportional, | ||
+ | |||
+ | === Derivative action === | ||
+ | |||
+ | Provides a contributes, | ||
+ | |||
+ | | ||
+ | |||
+ | === 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, | ||
+ | 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): == | ||
+ | |||
+ | - Disable the regulation (variabile gwEnaReg=0) | ||
+ | - Set the setpoint to the desired value | ||
+ | - Make sure that the temperature is close to environment temperature | ||
+ | - Enable self-tuning by setting the aswParUsr parameter [5]** **at the value 1 | ||
+ | - Switch off the instrument (or execute the RESTART) | ||
+ | - Turn on the instrument (or go to RUN the application) | ||
+ | - Enable the setting | ||
+ | |||
+ | == How to enable the function of self-tuning (mode 2 activation at the beginning of the regulation): | ||
+ | |||
+ | - Disable the regulation (variable gwEnaReg=0) | ||
+ | - Set the setpoint to the desired value | ||
+ | - Make sure that the temperature is close to environment temperature | ||
+ | - Enable selftuning by setting the aswParUsr parameter [5]** **al valore 2 | ||
+ | - Enable the regulation\\ NB: During the self-tuning the value of the aswParUsr parameter [5] takes the following values to indicate the status: | ||
+ | - Waiting setpoint temperature | ||
+ | - Waiting the temperature stops growing | ||
+ | - Waiting for the temperature begins to decrease | ||
+ | - Final stages of calculation | ||