FB_HVACAnalogInput

FB_HVACAnalogInput 1:

Application

This function block serves the acquisition and scaling of analog input signals. Using the KL30xx, KL31xx und KL32xx terminals, the standard signals 0–20 mA, 4–20 mA, 0–10 V and 10–5000 Ohms can be acquired and converted to physical values.

VAR_INPUT

eDataSecurityType    : E_HVACDataSecurityType;
bSetDefault          : BOOL;
iRawValue            : INT; 
tTaskCycleTime       : TIME;
tCtrlCycleTime       : TIME;
bEnableLimitCtrl     : BOOL;
bCtrlVoltage         : BOOL;
bReset               : BOOL; 

eDataSecurityType:if eDataSecurityType:= eHVACDataSecurityType_Persistent, the persistent VAR_IN_OUT variables of the function block are stored in the flash of the computer if a value changes. For this to work, the function block FB_HVACPersistentDataHandling must be instanced once in the main program, which is called cyclically. Otherwise the instanced FB is not released internally.

A change of value can be initiated by the building management system, a local operating device or via a write access from TwinCAT. When the computer is restarted, the saved data are automatically read back from the flash into the RAM.

Application example: FB_HVACAnalogInput 2:Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Notice

A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eHVACDataSecurityType_Persistent. It would lead to early wear of the flash memory.

bSetDefault: If the variable is TRUE, the default values of the VAR_IN_OUT variables are adopted.

iRawValue: the raw value is transferred from the terminal to the function block with the parameter iRawValue.

tTaskCycleTime: cycle time with which the function block is called. If the function block is called in every cycle this corresponds to the task cycle time of the calling task.

tCtrlCycleTime: cycle time with which the function block is processed. This must be greater than or equal to the TaskCycleTime. The function block uses this input value to calculate internally whether the state and the output values have to be updated in the current cycle.

bEnableLimitCtrl: limit value monitoring is only activated if the variable bEnableLimitCtrl is TRUE. This way, limit value monitoring can be delayed with a timer until the heating or air conditioning system is in a controlled state. In the case of air conditioning systems, this is usually enabled by the system start program. See also FB_HVACStartAirConditioning regarding this point.

bCtrlVoltage: by means of checking the sensor supply voltage with the input bCtrlVoltage, error messages are suppressed if the supply voltage to the sensors is absent. If the sensor supply voltage is present, a TRUE is present at the input bCtrlVoltage.

bReset: acknowledge input in the event of an error. In addition the 2nd order filter can be synchronized via this input to the present measuring signal, so that this can be output at rPresentValue.

VAR_OUTPUT

rPresentValue       : REAL; 
byState             : BYTE;
bError              : BOOL;
eErrorCode          : E_HVACErrorCodes;
bErrorHighLimit     : BOOL;
bErrorLowLimit      : BOOL;
bErrorGeneral       : BOOL;
byError             : BYTE;
bInvalidParameter   : BOOL;

rPresentValue: determined output value.

byState: state of the function block.
byState.1:= TRUE, limit value monitoring is activated.
byState.7:= TRUE, sensor voltage supply is present.

bError: the variable bError becomes TRUE in the event of an internal error in the function block.

eErrorCode : contains the specific error code related to the bError.

bErrorHighLimit: TRUE if the upper limit value is reached.

bErrorLowLimit: TRUE if the lower limit value is reached.

bErrorGeneral: TRUE if a single error message from the process is present.

byError: output of the errors as byte.
byError.0:= bError
byError.1:= bInvalidParameter
byError.2:= bErrorGeneral
byError.3:= bErrorLowLimit is TRUE if the lower limit value is undershot.
byError.4:= bErrorHighLimit is TRUE if the upper limit value is exceeded.

bInvalidParameter: TRUE if an error occurs during the plausibility check. The message must be acknowledged with bReset.

VAR_IN_OUT

iHighRange   : INT;
iLowRange    : INT;
rHighRange   : REAL;
rLowRange    : REAL;
rHighLimit   : REAL;
rLowLimit    : REAL;
tFilterTime  : TIME;
rOffset      : REAL;

iHighRange: upper raw value of the input variable iRawValue. The variable is saved persistently. Preset to 32767.

iLowRange: lower raw value of the input variable iRawValue. The variable is saved persistently. Preset to 0.

rHighRange: the upper scaled measured value. The variable is saved persistently. Preset to 100.

rLowRange: the lower scaled measured value. The variable is saved persistently. Preset to 0.

rHighLimit: if the scaled measured value is larger than the upper limit value rHighLimit, an impermissibly high measured value can be reached. The function block indicates this error by setting the variable bErrHighLimit to TRUE. The variable is saved persistently. Preset to 100.

rLowLimit: if the scaled measured value is smaller than the lower limit value rLowLimit, an impermissibly low measured value can be reached. The function block indicates this error by setting the variable bErrLowLimit to TRUE. The variable is saved persistently. Preset to 0.

tFilterTime: to avoid large fluctuations and jumps in the measuring signal, the function block is provided with two 1st order filters. Both filters work with the same time constant. The filter constants are determined by the variable tFilterTime [s] (0..3600). The variable is saved persistently. Preset to 2 s.

rOffset: with this offset the linear equation determined by means of the two conversion points is shifted parallel upwards or downwards. The variable is saved persistently. Preset to 0.

With the two value pairs iHighRange/rHighRange and iLowRange/rLowRange a linear conversion of the raw value into the physical unit takes place.iHighRange and iLowRange correspond to the raw values. rHighLimit and rLowLimit correspond to the scaled values in the physical unit of the signal to be measured.

The output value is given by:

rPresentValue = [ { (rHighRange - rLowRange) / (iHighRange - iLowRange) } x (iRawValue - iHighRange ] + rHighRange + rOffset