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:ot21pidreg [2017/01/23 18:02] – [Azione proporzionale] qem103 | en:software:qview:qview_6:qcl_library:ot21pidreg [2019/08/29 17:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== OT21PidReg ====== | ||
+ | |||
+ | **O = **//Digital Output// | ||
+ | |||
+ | **T = **//Control functions// | ||
+ | |||
+ | The OT21PidReg function __implements a generic PID controller__. In addition to providing the regulation value, the function operates two digital signals are modulated pulse width to handle positive and negative representation of control output. | ||
+ | |||
+ | ===== IMPLEMENTATION ===== | ||
+ | |||
+ | **OT21PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, aglOutReg )** | ||
+ | |||
+ | Parametri: | ||
+ | |||
+ | ^IN/ | ||
+ | |IN|ARRSYS|aswParReg [1]|W|Sample time PID controller (msec) [0÷32767].| | ||
+ | |IN|ARRSYS|aswParReg [2]|W|Maximum scale limit of process variable (UM) [-32768÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [3]|W|Minimum scale limit of process variable (UM) [-32768÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [4]|W|Maximum value control output [-32768 ÷32767]| | ||
+ | |IN|ARRSYS|aswParReg [5]|W|Minimum value control output [-32768 ÷32767]| | ||
+ | |IN|ARRSYS|aswParUsr [1]|W|Proportional gain.('' | ||
+ | |IN|ARRSYS|aswParUsr [2]|W|Integral time (msec) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [3]|W|Derivative time (msec) [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]|W|Derived filter time constant (msec.) [0÷9999]| | ||
+ | |IN|ARRSYS|aswParUsr [6]|W|Feed Forward (‰) [0÷2000]| | ||
+ | |IN|GLOBAL|gwSetPoint|W|Adjustment setpoint (UM)| | ||
+ | |IN|GLOBAL|gwMeasure|W|Value of the process variable (UM)| | ||
+ | |IN|GLOBAL|gfEnaReg|F|Enabling regulation [0÷1]\\ 0=regulator disabled\\ 1=regulator enabled| | ||
+ | |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 0 = State pwm output for positive adjustment \\ bit 1 = State pwm output for negative regulation \\ bit 2 = positive saturation state\\ bit 3 = negative saturation state\\ bit 4 + executing state regulation| | ||
+ | |OUT|ARRGBL|aglOutReg[8]|L|Error code| | ||
+ | |||
+ | ==== Errors ==== | ||
+ | |||
+ | Once call the function, the "Error Code" variable in aglOutReg[8] assumes 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 integral time\\ | ||
+ | 5: Error setting derivative time\\ | ||
+ | 6: Error setting feed-forward percentage value\\ | ||
+ | 7: Error setting minimum and/or maximum value regulator output\\ | ||
+ | 8: Error setting sampling time derivative\\ | ||
+ | 9: Error setting derived filter time constant | ||
+ | |||
+ | === Example === | ||
+ | |||
+ | <code QCL> | ||
+ | ; | ||
+ | ; Example | ||
+ | ; | ||
+ | aswParReg [0]=500 ; Sampling time = 500ms | ||
+ | aswParReg [1]=10000 ; | ||
+ | aswParReg [2]=0 | ||
+ | aswParReg [3]=500 ; Maximum value output regulator | ||
+ | aswParReg [4]=0 | ||
+ | |||
+ | aswParUsr[1] = 100 ; Proportional gain = 0.1 | ||
+ | aswParUsr[2] = 200 ; Integral time = 0.2 sec. | ||
+ | |||
+ | gfEnaReg = 1 ; | ||
+ | MAIN: | ||
+ | gwSetPoint = 800 | ||
+ | OT20PidReg ( aswParReg , aswParUsr, gwSetPoint, gwMeasure, gfEnaReg, aslOutReg ) | ||
+ | ofOutPow = aslOutReg[7] ANDB &H01 | ||
+ | WAIT 1 | ||
+ | JUMP MAIN | ||
+ | </ | ||
+ | |||
+ | ==== Definition of controller ==== | ||
+ | |||
+ | A regulator reads an (gwMeasure) input variable, compares with to a reference signal (gwSetPoint) and change the value of the (aslOutReg[7]) output to achieve equality of the variable with the reference. | ||
+ | |||
+ | ==== PID regulator ==== | ||
+ | |||
+ | One of the most popular types of regulator is the PID (Proportional, | ||
+ | |||
+ | === Proportional action === | ||
+ | |||
+ | This control action establishes a relationship of direct proportionality between the error (aglOutReg[6]) and the value at the regulator output. The gain proportional parameter (aswParUsr [1]) defines the degree of proportional controller; It's expressed in milliseconds for which to set a gain of 0.5 it should enter the value 500.\\ | ||
+ | The rule that 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 (in ms). The output signal is updated in a particular way: whenever the Integrator give an output value This 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 time it takes for the integral log (aglOutReg[3]) reaches the registry value proportional (aglOutReg[2]). From this last statement shows that the integral action is related to the proportional action. | ||
+ | |||
+ | === Derivative action === | ||
+ | |||
+ | The derivative action try to " | ||
+ | |||
+ | === Feed-forward action === | ||
+ | |||
+ | In addition to the PID controller is also the feed-forward action: it generates an output proportional to the setpoint value (as can be inferred from the name doesn' | ||
+ | |||
+ | === DIFFERENCES FROM THE OLDER RELEASES === | ||
+ | |||
+ | * (from 20 to 21) Added a running state regulation. (Avoided an error" " | ||