FB_HVACTemperatureSensor

FB_HVACTemperatureSensor 1:

Application

This function block serves the acquisition and further processing of temperature values for sensor types PT100, PT200, PT1000, NI100, NI120 and NI1000. The function block FB_HVACTemperatureSensor is matched to the KL320x Bus Terminals. These Bus Terminals can either be ordered preconfigured or set to the corresponding sensor types in the software.

VAR_INPUT

eDataSecurityType      : E_HVACDataSecurityType;  
bSetDefault            : BOOL;  
iRawValue              : INT;               
byStatusRawValue       : BYTE;
tTaskCycleTime         : TIME;
tCtrlCycleTime         : TIME;                  
bEnableLimitCtrl       : 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_HVACTemperatureSensor 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: raw value of the temperature sensor in 1/10 °C from the Bus Terminal.

byStatusRawValue: status byte of the temperature sensor from the Bus Terminal. Serves for error diagnosis, e.g. wire break or short circuit.

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. tTaskCycleTime must be longer than T#0ms.

tCtrlCycleTime: the variable tCtrlCycleTime specifies the cycle time with which the 2nd order filter is processed internally. The cycle time tCtrlCycleTime must be greater than or equal to tTaskCycleTime. If this is not the case, an error bErrorCycleTime occurs and either the replacement value rReplacementValue or the last valid measured value will be output at rPresentValue, depending on the mode eTemperatureSensorMode that is set.

bEnableLimitCtrl: enables rHighLimit and rLowLimit for limit monitoring

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;
bErrorGeneral         : BOOL;               
byError               : BYTE;   
bErrorShortCircuit    : BOOL;                   
bErrorBrokenSensor    : BOOL;                   
bErrorHighLimit       : BOOL;               
bErrorLowLimit        : BOOL;       
bErrorCycleTime       : BOOL;                   
bInvalidParameter     : BOOL;

rPresentValue: temperature output variable with one decimal place, rPresentValue = (iRawValue / 10.0) + rOffset, if bErrorShortCircuit or bErrorBrokenSensor = TRUE, then rPresentValue depends on the operation mode eTemperatureSensorMode.

bErrorGeneral: the error message bErrorGeneral becomes TRUE as soon as one of the error messages bErrorHighLimit, bErrorLowLimit, bErrorCycleTime, bErrorShortCircuit or bErrorBrokenSensor = TRUE. The value of the output variable rPresentValue is then dependent on the operation mode eTemperatureSensorMode and is enabled once the error has been rectified and, depending on the operation mode, acknowledged with bReset.

byError: returns all error messages and warnings,
byError.1 := bInvalidParameter
byError
.2 := bErrorGeneral
byError.3 := bErrorHighLimit
byError.4 := bErrorLowLimit
byError.5 := bErrorShortCircuit
byError.6 := bErrorBrokenSensor
byError
.7 := bErrorCycleTime

bErrorShortCircuit: error, short circuit at the connected temperature sensor. After rectification of the error, acknowledgment depends on the operation mode.

bErrorBrokenSensor: error, wire break in the connected temperature sensor. After rectification of the error, acknowledgment depends on the operation mode.

bErrorHighLimit: warning upper limit value exceeded; becomes TRUE if rPresentValue >= rHighLimit. The warning that the upper limit value has been exceeded can only be acknowledged if rPresentValue <= rHighLimit - 1.0 for a time duration of 5 seconds.

bErrorLowLimit: warning lower limit value undershot; becomes TRUE if rPresentValue <= rLowLimit. The warning that the lower limit value has been undershot can only be acknowledged if rPresentValue >= rLowLimit + 1.0 for a time duration of 5 seconds

bErrorCycleTime: error caused by an incorrect time input at the input variables tTaskCycleTime and tCtrlCycleTime, which must be acknowledged after rectification of the error.

bInvalidParameter: indicates that an incorrect parameter is present at one of the variables rOffset, rHighLimit, rLowLimit, rReplacementValue, tFilterTime and eTemperatureSensorMode. An incorrect parameter specification does not lead to a standstill of the function block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

rOffset                : REAL;
rHighLimit             : REAL;
rLowLimit              : REAL;
rReplacementValue      : REAL;
tFilterTime            : TIME;
eTemperatureSensorMode : E_HVACTemperatureSensorMode;

rOffset: temperature compensation in Kelvin (-50..+50), rPresentValue = (iRawValue / 10.0) + rOffset. The variable is saved persistently. Preset to 0.
If an incorrect variable value is present, the last valid variable value, if available, is used. If there is no valid last value, then the default value is used.
bInvalidParameter will be set in the event of an incorrect parameter entry.

rHighLimit: upper limit (-250..+850), if rPresentValue >= rHighLimit, then the output bErrorHighLimit is set. rHighLimit must be greater than rLowLimit. The variable is saved persistently. Preset to 120.
If an incorrect variable value is present, the last valid variable value, if available, is used. If there is no valid last value, then the default value is used. bInvalidParameter will be set in the event of an incorrect parameter entry.

rLowLimit: lower limit (-250..+850), if rPresentValue <= rLowLimit, then the output bErrorLowLimit is set. The variable is saved persistently. Preset to -60.
If an incorrect variable value is present, the last valid variable value, if available, is used. If there is no valid last value, then the default value is used. bInvalidParameter will be set in the event of an incorrect parameter entry.

rReplacementValue: replacement value (-250..+850), that is output at rPresentValue in the case of the errors bErrorShortCircuit and bErrorBrokenSensor, if the selected operation mode eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue or eTemperatureSensorMode = eHVACTemperatureSensorMode_AutoResetReplacementValue. The variable is saved persistently. Preset to 0..
If an incorrect variable value is present, the last valid variable value, if available, is used. If there is no valid last value, then the default value is used. bInvalidParameter will be set in the event of an incorrect parameter entry.

tFilterTime: filter constant (1ms..100s). To avoid large fluctuations and jumps in the measuring signal, the function block is provided with a 2nd order filter. Upon a restart of the controller, or following correction of the error bErrorShortCircuit or bErrorBrokenSensor, the 2nd order filter is synchronized immediately and additionally after 2 seconds with the present measuring signal, so that the latter is output at rPresentValue. The measuring signal can be synchronized via the input bReset during running operation. The variable is saved persistently. Preset to 10 s.
If an incorrect variable value is present, the last valid variable value, if available, is used. If there is no valid last value, then the default value is used. bInvalidParameter will be set in the event of an incorrect parameter entry.

eTemperatureSensorMode: Enum that specifies the operation mode of the function block. The variable is saved persistently. Preset to 3%.

eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue: if bErrorShortCircuit or bErrorBrokenSensor = TRUE, then rPresentValue = rReplacementValue. After correction of the error, the function block must be acknowledged with a rising edge at the input variable bReset.

eTemperatureSensorMode = eHVACTemperatureSensorMode_LastValue: if bErrorShortCircuit or bErrorBrokenSensor = TRUE, then the last valid temperature value that was present 10 seconds previously is output at rPresentValue. After correction of the error, it must be acknowledged with a rising edge at the input variable bReset.

eTemperatureSensorMode = eHVACTemperatureSensorMode_AutoResetReplacementValue : if bErrorShortCircuit or bErrorBrokenSensor = TRUE, then rPresentValue = rReplacementValue. The function block acknowledges itself automatically following correction of the error.

eTemperatureSensorMode = eHVACTemperatureSensorMode_AutoResetLastValue: if bErrorShortCircuit or bErrorBrokenSensor = TRUE, then the last valid temperature value that was present 10 seconds previously is output at rPresentValue. The function block acknowledges itself automatically following correction of the error.

If an incorrect variable value is present, the last valid variable value, if available, is used. If there is no valid last value, then the default value is used. bInvalidParameter will be set in the event of an incorrect parameter entry.