FB_HVACScale_nPoint

FB_HVACScale_nPoint 1:

Curves can be reproduced in the PLC with the function block FB_HVACScale_nPoint. These can be, for example, positive or negative temperature coefficients (PTC/NTC). The analog raw resistance value of a PTC/NTC is applied to the input rX and output as a temperature value via the output rY. The individual parameters and the number of individual points on the XY axis of the characteristic curve are specified by the structure stParameterScale_nPoint.
Analog raw resistance values can be represented in the PLC with the KL32xx Bus Terminals. Detailed information can be found in the documentation on FB_HVACConfigureKL32xx.

FB_HVACScale_nPoint 2:

When measuring resistances from 10 to 5000 Ω with the KL32xx, 1 digit = 0.5 Ω, i.e. the indicated raw value must be divided by 2 in the PLC. Example: 2500 Ω would be represented in the controller by a raw value of 5000. The raw value must be divided by 2 in the PLC in order to arrive at the ohmic value of 2500 Ω.

FB_HVACScale_nPoint 3:

The measurement of resistances from 10 to 10000 Ω is possible only with the special terminal KL320x-0027. Exclusively the resistance measurement 10...10000 Ω can be performed on this special terminal.

FB_HVACScale_nPoint 4:

The EL3692 EtherCAT Terminal is a resistance measurement terminal that covers the measuring range up to 10 MΩ.

VAR_INPUT

rX                              : REAL;
stParameterScale_nPoint         : ST_HVACParameterScale_nPoint;

rX: Raw value that scales to the indicated measured value of the structure stParameterScale_nPoint and is output via rY. The raw value can be, for example, the raw resistance value of the KL32xx. The terminal must be set to resistance measurement for this. Detailed information on the procedure can be found in the documentation FB_HVACConfigureKL32xx.

stParameterScale_nPoint: Structure via which the individual points of the XY coordinates are given their valency (see ST_HVACParameterScale_nPoint). Regardless of which curve is to be reproduced, the following conditions must be met: either stParameterScale_nPoint.rX[1] < stParameterScale_nPoint.rX[2] < stParameterScale_nPoint.rX[n] OR stParameterScale_nPoint.rX[1] > stParameterScale_nPoint.rX[2] > stParameterScale_nPoint.rX[n].
stParameterScale_nPoint.iNumberOfPoint must not be smaller than 2 OR larger than g_iMaxNoOfScale_nPoint(60).
stParameterScale_nPoint.rX[1..iNumberOfPoint] – array containing the valency of the individual points on the X axis. The number of points specified depends on iNumberOfPoint.
stParameterScale_nPoint.rY[1 ..NumberOfPoint] – array containing the valency of the individual points on the Y axis. The number of points specified depends on iNumberOfPoint.

VAR_OUTPUT

rY                          : REAL;
stStateParameterScale_nPoint: ST_HVACParameterScale_nPoint;
bErrorNumberOfPoint         : BOOL;
bErrorParameter             : BOOL;
uiErrorPositionX_Parameter  : INT;

rY: rY is the scaled temperature value of the specified raw value rX.

stStateParameterScale_nPoint: State of the structure stParameterScale_nPoint. If bErrorNumberOfPoint or bErrorParamter = TRUE, then the state of the individual parameters in the structure stStateParameterScale_nPoint = 0. If stParameterScale_nPoint.iNumberofPoint = 20, then the individual parameters of stStateParameterScale_nPoint.rX[1..20] / stStateParameterScale_nPoint.rY[1..20] are displayed; from 21 to 60 the state = 0 (see ST_HVACParameterScale_nPoint).

bErrorNumberOfPoint: IfiNumberOfPoint < 2 or iNumberOfPoint > g_iMaxNoOfScale_nPoint, then bErrorNumberOfPoint = TRUE and 0 is output at the output variable rY. If the error has been rectified, then bErrorNumberOfPoint goes FALSE.

bErrorParameter: Care must be taken when parameterizing the structure stParameterScale_nPoint that either
stParameterScale_nPoint.rX[1] > stParameterScale_nPoint.rX[2] > stParameterScale_nPoint.rX[n] OR
stParameterScale_nPoint.rX[1] < stParameterScale_nPoint.rX[2] < stParameterScale_nPoint.rX[n].
If this is not adhered to, then bErrorParameter goes TRUE. If the error has been rectified, then bErrorParameter goes FALSE. The exact field position in the array stParameterScale_nPoint.rX[uiErrorPositionX_Parameter] is specified via the output variables uiErrorPositionX_Parameter.

uiErrorPositionX_Parameter: If bErrorParameter = TRUE, then the exact field position in the array stParameterScale_nPoint.rX[uiErrorPositionX_Parameter] at which the error has occurred is indicated by uiErrorPositionX_Parameter.

VAR_GLOBAL CONSTANT

g_iMaxNoOfScale_nPoint      : INT := 60;

g_iMaxNoOfScale_nPoint: Global constant that specifies the maximum number of points of the XY coordinates of the structure ST_HVACParameterScale_nPoint (see Parameter).

Formulas for the linear equation, two-point form:

m = gradient

m = (Y2 - Y1) / (X2 - X1)

m = (stParameterScale_nPoint.rY[2] - stParameterScale_nPoint.rY[1]) /
(stParameterScale_nPoint.rX[2] - stParameterScale_nPoint.rX[1])

Y = Y1 + m * (X - X1)

rY = rY[1] + m * (rX - stParameterScale_nPoint.rX[1]

Example curve 1 with calculation

FB_HVACScale_nPoint 5:

m =  rM = slope
X = rX = 1199.8
X2 = stParameterScale_nPoint.rX[2] = 1209
X3 = stParameterScale_nPoint.rX[3] = 1163
Y2 = stParameterScale_nPoint.rY[2] = 20
Y3 = stParameterScale_nPoint.rY[3] = 21

m = (Y3 - Y2) / (X3 - X2)

rM = (stParameterScale_nPoint.rY[3] - stParameterScale_nPoint.rY[2]) /
(stParameterScale_nPoint.rX[3] - stParameterScale_nPoint.rX[2])

rM = (21 - 20) / (1163 - 1209) = -0.02174

Y = Y2 + m * (X - X2)

rY = stParameterScale_nPoint.rY[2] + rM * (rX - stParameterScale_nPoint.rX[2])

rY = 20 + -0.02174 * (1199.8 - 1209) = 20.2

Example curve 2 with calculation

FB_HVACScale_nPoint 6:

m =  rM = slope
X = rX = 1124
X3 = stParameterScale_nPoint.rX[2] = 1112
X4 = stParameterScale_nPoint.rX[3] = 1142
Y3 = stParameterScale_nPoint.rY[2] = 20
Y4 = stParameterScale_nPoint.rY[3] = 25

m = (Y4 - Y3) / (X4 - X3)

rM = (stParameterScale_nPoint.rY[4] - stParameterScale_nPoint.rY[3]) /
(stParameterScale_nPoint.rX[4] - stParameterScale_nPoint.rX[3])

rM = (25 - 20) / 1142 - 1112) = 0.166

Y = Y3 + m * (X - X3)

rY = stParameterScale_nPoint.rY[3] + rM * (rX - stParameterScale_nPoint.rX[3])

rY = 20 + 0.166 * (1124 - 1112) = 21.992

Example curve 3

FB_HVACScale_nPoint 7:

Requirements

Development environment

required library

required function

TwinCAT 3.1 build 4022.16 or higher

Tc2_HVAC V3.3.1.0

TF8000 | TC3 HVAC V1.0.0.0