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:ot30pidreg [2017/01/27 17:08] – [Azione integrale] qem103 | en:software:qview:qview_6:qcl_library:ot30pidreg [2019/08/29 17:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== 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' | ||
+ | |||
+ | ===== IMPLEMENTATION ===== | ||
+ | |||
+ | **OT30PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, aglOutReg )** | ||
+ | |||
+ | Parameters: | ||
+ | |||
+ | ^IN/ | ||
+ | |IN|ARRSYS|aswParReg [1]|W|Sample time PID regulator (sec/100) [0÷32767].| | ||
+ | |IN|ARRSYS|aswParReg [2]|W|Maximum scale limit of regulation variable (UM) [-32768÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [3]|W|Minimum scale limit of regulation variable (UM) [-32768÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [4]|W|Maximum value of regulation output [-32768 ÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [5]|W|Minimum value of regulation output [-32768 ÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [6]|W|Positive saturation value regulation output [-32768 ÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [7]|W|Negative saturation value regulation output [-32768 ÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [8]|W|Setting flags:\\ **bit 0:** // | ||
+ | |IN|ARRSYS|aswParUsr [1]|W|Proportional gain.('' | ||
+ | |IN|ARRSYS|aswParUsr [2]|W|Integral time (sec/100) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [3]|W|Derivative time (sec/100) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [4]|W|Sample time of the derivative [0÷255]\\ 0=sample time PID regulator\\ 1=2*sample time PID regulator\\ …\\ …\\ n=(n+1)*sample time PID regulator| | ||
+ | |IN|ARRSYS|aswParUsr [5]|W|Derived filter time constant (sec/100) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [6]|W|Feed Forward (‰) [0÷2000]| | ||
+ | |IN|GLOBAL|gwSetPoint|W|Setpoint of regulation (UM)| | ||
+ | |IN|GLOBAL|gwMeasure|W|Value of the process variable(UM)| | ||
+ | |OUT|ARRGBL|aglOutReg[1]|L|PID output log| | ||
+ | |OUT|ARRGBL|aglOutReg[2]|L|Proportional output log| | ||
+ | |OUT|ARRGBL|aglOutReg[3]|L|Integral output log| | ||
+ | |OUT|ARRGBL|aglOutReg[4]|L|Derivative output log| | ||
+ | |OUT|ARRGBL|aglOutReg[5]|L|Feedforward output log| | ||
+ | |OUT|ARRGBL|aglOutReg[6]|L|Error log| | ||
+ | |OUT|ARRGBL|aglOutReg[7]|L|Regulator states:\\ bit 2 = positive saturation state\\ bit 3 = negative saturation state\\ bit 4 = executing state regulation| | ||
+ | |OUT|ARRGBL|aglOutReg[8]|L|Error code| | ||
+ | |||
+ | ==== Errors ==== | ||
+ | |||
+ | 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 === | ||
+ | |||
+ | <code QCL> | ||
+ | ; | ||
+ | ; Example | ||
+ | ; | ||
+ | aswParReg [1]=500 ; sample time = 500ms | ||
+ | aswParReg [2]=10000 ; | ||
+ | aswParReg [3]=0 ; full scale less = 0 | ||
+ | aswParReg [4]=5000 ; | ||
+ | aswParReg [5]=0 | ||
+ | aswParReg [6]=2000 ; | ||
+ | aswParReg [7]=0 | ||
+ | |||
+ | 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 | ||
+ | </ | ||
+ | |||
+ | ==== Definition of regulator ==== | ||
+ | |||
+ | A regulator reads an input variable (gwMeasure), | ||
+ | |||
+ | ==== PID regulator ==== | ||
+ | |||
+ | One of the most popular types of regulators is the PID (Proportional, | ||
+ | |||
+ | === 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, | ||
+ | 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 " | ||
+ | |||
+ | === 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 " | ||
+ | |||
+ | === 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' | ||
+ | Setting a value of 100%, when the setpoint (gwSetPoint ) will be equal to " | ||