You should choose the channel signal as 4~20ma in the template configuration, and distinguish whether it is an active meter or a passive meter, a two-wire meter or a four-wire meter.
Then make a symbol table.
With all this done, we can talk about the operation of the programming part.
Analog data can be compiled by a formula, or it can be done by calling FC 105 or FC 106.
Details are as follows:
Chinese Description of FC 105 and FC 106 Parameter Settings
1、FC 105
The SCALE function accepts an integer value (in) and converts it into a real value between the lower limit and the upper limit (LO_LIM and HI_LIM) of the engineering unit. Write out the results. The proportional function uses the following formula:
OUT =[(FLOAT(IN)-k 1)/(K2- 1))*(HI _ LIM-O _ LIM)]+LO _ LIM
Constants K 1 and K2 are set according to whether the input value is bipolar or unipolar.
Bipolar: it is assumed that the input integer value is between 7648 and 27648, so K 1 = -7648.0 and K2 = +27648.0.
Unipolarity: Assume that the input integer value is between 0 and 27648, so K 1 = 0.0 and K2 = +27648.0.
If the input integer value is greater than K2, the output (out) will be clamped at HI_LIM and an error will be returned. If the input integer value is less than K 1, the output will be clamped at LO_LIM and an error will be returned.
By setting LO_LIM > HI_LIM, the reverse calibration can be obtained. When the inverse transformation is used, the output value will decrease with the increase of the input value.
FC 105 parameter
Parameter description data type storage description
EN input BOOL I, q, m, d, l enables the input terminal, and the function is activated when the signal state is 1
ENO outputs BOOL I, q, m, d, l If there is no error in the execution of this function, the signal state of the enable output is 1.
Input the input values of INT I, q, m, d, l, p and constants, and convert them into real values expressed in engineering units.
HI_LIM Enter the upper limit values of real numbers I, Q, M, D, L, P and constants in engineering units.
LO_LIM Enter the lower limit values of real numbers I, Q, M, D, L, P and constants in engineering units.
The signal state of input BOOL I, Q, M, D and L of biped is 1, that is to say, the input value is bipolar. A signal state of 0 indicates that the input value is unipolar.
OUT outputs the results of actual I, Q, M, D, L and P conversions.
RET_VAL outputs WORD I, Q, M, D, L, P. If the instruction is executed without errors, it will return the value W# 16#0000. For values other than W# 16#0000, see "Error Messages".
error message
If the input integer value is greater than K2, the output (out) will be clamped at HI_LIM and an error will be returned. If the input integer value is less than K 1, the output will be clamped at LO_LIM and an error will be returned. The signal state of ENO will be set to 0, and RET_VAL is equal to W# 16#0008.
example
If the signal state of input I0.0 is 1 (valid), the proportional function is executed. In this example, the integer value 22 will be converted to a real value between 0.0 and 100.0 and written into OUT. As shown in the signal state of I2.0, the input value is bipolar.
If there is no error in the execution of this function, the signal states of ENO and Q0.0 will be set to 1, and RET_VAL is equal to W# 16#0000.
Pictures related to this topic
2、FC 106
UNSCALE function receives the actual input value (in) in engineering units, calibrates between the lower limit and the upper limit (LO_LIM and HI_LIM), and then converts it into an integer value. Write out the results.
The UNSCALE function uses the following formula:
OUT =[(IN-O _ LIM)/(HI _ LIM-O _ LIM))*(K2- 1)]+k 1
, and set constants K 1 and K2 according to whether the input value is biped or biped.
Bipolar: Suppose the output integer value is in? Therefore, between 7648 and 27648, K 1 = -7648.0 and K2 = +27648.0.
Unipolarity: It is assumed that the output integer value is between 0 and 27648, so K 1 = 0.0 and K2 = +27648.0.
If the input value is OUT of the range of LO_LIM and HI_LIM, the output (out) will bring the clamp closer to the lower or upper limit of the specified range of its type (biped or biped) and return an error.
FC 106 parameter
Parameter description data type storage description
EN input BOOL I, q, m, d, l enables the input terminal, and the function is activated when the signal state is 1
ENO outputs BOOL I, q, m, d, l If there is no error in the execution of this function, the signal state of the enable output is 1.
When inputting real numbers I, Q, M, D, L, P, constants should be converted into integer values.
HI_LIM Enter the upper limit of real numbers I, Q, M, D, L, P and constants in engineering units.
LO_LIM Enter the lower bounds of real numbers I, Q, M, D, L, P and constants in engineering units.
The signal state 1 of the input BOOL I, Q, M, D and L of the biped indicates that the input values are bipolar. A signal state of 0 indicates that the input value is unipolar.
OUT outputs the conversion results of INT I, q, m, d, l and p.
RET_VAL outputs WORD I, Q, M, D, L, P. If the instruction is executed without errors, it will return the value W# 16#0000. For values other than W# 16#0000, see "Error Messages".
error message
If the input value is OUT of the range of LO_LIM and HI_LIM, the output (out) will bring the clamp closer to the lower or upper limit of the specified range of its type (biped or biped) and return an error.
The signal state of ENO will be set to 0, and RET_VAL is equal to W# 16#0008.
example
If the signal state of input I0.0 is 1 (valid), the scale-free function is executed. In this example, the true value 50.588 calibrated between 0.0 and 100.0 will be converted into an integer value and written into OUT.
. As shown in the signal state of I2.0, the input value is bipolar.
If there is no error in the execution of this function, the signal states of ENO and Q0.0 will be set to 1, and RET_VAL is equal to W# 16#0000.
Pictures related to this topic