FB_HVACTemperatureSensorEx

This function block is used for the acquisition and subsequent processing of temperature values, e.g. for the sensor types PT100, PT200, PT1000, NI100, NI120, NI1000, NI1000Tk5000. The function block FB_HVACTemperatureSensorEx is adapted to the Bus Terminals KL3201/02/04 and KL3228. These Bus Terminals can either be ordered preconfigured or set to the respective sensor type via the software.
The raw temperature value is transferred to the function block in 1/10 °C via the input variable iRawValue and output as a floating point number via rPresentValue . iRawValue, for example, can be linked directly with the raw temperature value of the following Bus Terminals: KL3201/02/04 and KL3228.
The output value rPresentValue depends on the following smoothing function:
rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
rPresentValueOld is the value of rPresentValue that was output in the previous PLC cycle. If bEnable goes TRUE, then rPresentValue = rPresentValueOld for one PLC cycle. If bErrorSensor = TRUE, the error has been corrected and bErrorSensor = FALSE, then rPresentValue = rPresentValueOld for one PLC cycle.
The state of the connected temperature sensor is monitored via the input variable byStatusRawValue and returned to the controller via the variable bErrorSensor in the event of an error. byStatusRawValue can be linked, for example, directly with the status byte of the following Bus Terminals: KL3201/02/04 and KL3228.
rHighLimit/rLowLimit can be used to specify temperature limit values.
In contrast to the FB_HVACTemperatureSensor this function block has the input variable bEnable, which is useful if the characteristic sensor curves in the Bus Terminals KL3201/02/04 and KL3228 are to be set from the PLC via the function block FB_HVACConfigureKL32xx. In this function block the second order filter in FB_HVACTemperatureSensor is replaced by the smoothing function described above. The output bErrorSensor is new and replaces the two outputs bErrorShortCircuit/bErrorBrokenSensor. These outputs continue to be available in the error byte byError.
VAR_INPUT
eDataSecurityType : E_HVACDataSecurityType;
bSetDefault : BOOL;
bEnable : BOOL;
iRawValue : INT;
byStatusRawValue : BYTE;
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: 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.
bEnable: The function block is enabled if bEnable = TRUE. If bEnable = FALSE, the value of rReplacementValue is output at the rPresentValue output. All error messages and bInvalidParameter are set to FALSE. If bEnable goes TRUE, then rPresentValue = rPresentValueOld for one PLC cycle.
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 fault diagnosis, e.g. wire breakage or short circuit. If the KL32xx is set to resistance measurement (Ω) there is no fault diagnosis.
bEnableLimitCtrl: Enables rHighLimit and rLowLimit for limit monitoring
bReset: Acknowledgement input in the event of an error with rising edge from bReset. Depending on mode eTemperatureSensorMode, errors are acknowledged either with bReset or automatically.
VAR_OUTPUT
rPresentValue : REAL;
bErrorGeneral : BOOL;
byError : BYTE;
bErrorSensor : BOOL;
bErrorHighLimit : BOOL;
bErrorLowLimit : BOOL;
bInvalidParameter : BOOL;
rPresentValue: Temperature output variable with one decimal place.
The value for rPresentValue is calculated and output according to the following formula:
rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
rPresentValueOld is the value of rPresentValue that was output in the previous PLC cycle. If bEnable goes TRUE, then rPresentValue = rPresentValueOld for one PLC cycle. If bErrorSensor = TRUE, the error has been corrected and bErrorSensor = FALSE, then rPresentValue = rPresentValueOld for one PLC cycle.
If bErrorSensor = TRUE, the value of rPresentValue depends on the operation mode eTemperatureSensorMode.
bErrorGeneral: The error message bErrorGeneral becomes TRUE if one of the error messages bErrorHighLimit, bErrorLowLimit or bErrorSensor isTRUE. 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 eTemperatureSensorMode, acknowledged with bReset.
byError: Delivers 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 := bErrorSensor
byError.5 := bErrorShortCircuit: Error, short circuit in the connected temperature sensor. Once the fault has been corrected, the message is acknowledged either with bReset or automatically, depending on mode eTemperatureSensorMode.
byError.6 := bErrorBrokenSensor: Error, wire breakage in the connected temperature sensor. Once the fault has been corrected, the message is acknowledged either with bReset or automatically, depending on mode eTemperatureSensorMode.
bErrorSensor: Becomes TRUE if byError.5/bErrorShortCircuit or byError.6/bErrorBrokenSensor is TRUE. Once the fault has been corrected, the message is acknowledged either with bReset or automatically, depending on mode eTemperatureSensorMode. If bErrorSensor = TRUE, the error has been corrected and bErrorSensor = FALSE, then rPresentValue = rPresentValueOld for one PLC cycle.
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 period of 5 seconds. Depending on mode eTemperatureSensorMode, the warning is acknowledged either with bReset or automatically.
bErrorLowLimit: Warning: lower limit value undershot; goes 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 period of 5 seconds. Depending on mode eTemperatureSensorMode, the warning is acknowledged either with bReset or automatically.
bInvalidParameter: Indicates that there is an incorrect parameter to one of the variables rHighLimit, rLowLimit, rSmoothFactor or eTemperatureSensorMode . An incorrect parameter specification does not lead to a standstill of the function block; see description of variables. Once the incorrect parameter specification has been corrected, the message bInvalidParameter is acknowledged either with bReset or automatically, depending on mode eTemperatureSensorMode.
VAR_IN_OUT
rOffset : REAL;
rHighLimit : REAL;
rLowLimit : REAL;
rReplacementValue : REAL;
rSmoothFactor : REAL;
eTemperatureSensorMode: E_HVACTemperatureSensorMode;
rOffset: Temperature compensation in Kelvin, rPresentValue = (iRawValue / 10.0) + rOffset. The variable is saved persistently. Preset to 0.
rHighLimit: Upper limit value. If rPresentValue >= rHighLimit , then 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, then the last valid variable value, if one, will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter specification.
rLowLimit: Lower limit value. If rPresentValue <= rLowLimit , then output bErrorLowLimit is set. The variable is saved persistently. Preset to -60.
If an incorrect variable value is present, then the last valid variable value, if one, will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter specification.
rReplacementValue: Replacement value that is output at rPresentValue in the case of the error bErrorShortCircuit and bErrorBrokenSensor if the selected operation mode eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue or eHVACTemperatureSensorMode_AutoResetReplacementValue. The variable is saved persistently. Preset to 0.
rSmoothFactor: Smoothing factor (>= 1) for the output value rPresentValue. The variable is saved persistently. Preset to 100.
The value for rPresentValue is calculated and output according to the following formula:
rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
rPresentValueOld is the value of rPresentValue that was output in the previous PLC cycle.
If rSmoothFactor = 1, then rPresentValue := ((iRawValue / 10 + rOffset)
If an incorrect variable value is present at rSmoothFactor , then the last valid variable value, if one, will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter specification.
eTemperatureSensorMode: Enum that specifies the operation mode of the function block (see E_HVACTemperatureSensorMode).
eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue: If bErrorSensor = 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 bErrorSensor = TRUE, then the last valid temperature value that was present 10 seconds before is output at the output variable 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 bErrorSensor = TRUE, then the last valid temperature value that was present 10 seconds before is output at the output variable rPresentValue. The function block acknowledges itself automatically following correction of the error.
If an incorrect variable value is present at eTemperatureSensorMode, the default value is used. bInvalidParameter is set in the case of an incorrect parameter specification.
The variable is saved persistently. Preset to 3.
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 |