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_HVACTemperatureSensorEx2 is tailored to the Bus Terminals KL3201/02/04, KL3222, KL3228 and KL3208-0010. These Bus Terminals can either be ordered preconfigured or set to the respective sensor type via the software.
The raw temperature value is transferred either in 1/10 or 1/100 °C to the function block via the input variable iRawValue and output via rPresentValue as a floating point number. iRawValue, for example, can be linked directly with the raw temperature value of the following Bus Terminals: KL3201/02/04, KL3222, KL3228 and KL3208-0010.
The output value rPresentValue depends on one of the following two smoothing functions:
iConversionFactor = 0: rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
iConversionFactor = 1: rPresentValue := ((iRawValue / 100 + 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, KL3222, KL3228 and KL3208-0010.
rHighLimit/rLowLimit can be used to specify temperature limit values.
Unlike FB_HVACTemperatureSensor, this function block has the input variable bEnable, which is useful when the sensor characteristic curves in the Bus Terminals KL3201/02/04, KL3222, KL3228 and KL3208-0010 are to be adjusted 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. However, these outputs still exist in the error byte udiError.
Unlike FB_HVACTemperatureSensorEx, sensors with the raw temperature value 1/10 or 1/100 °C can be transferred on this function block.
VAR_INPUT
eDataSecurityType : E_HVACDataSecurityType;
bSetDefault : BOOL;
bEnable : BOOL;
iRawValue : INT;
byStatusRawValue : BYTE;
iConversionFactor : INT;
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 or 1/100 °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.
iConversionFactor: Conversion factor (0..1) for the output value rPresentValue.
iConversionFactor = 0: rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
iConversionFactor = 1: rPresentValue := ((iRawValue / 100 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
If a value outside its range of 0 to 1 is specified at iConversionFactor, this is signaled by bErrorConversionFactor = TRUE.
bEnableLimitCtrl: Enables rHighLimit and rLowLimit for limit monitoring
bReset: Acknowledgement input in the event of an error with rising edge at bReset. Depending on mode iTemperatureSensorMode, errors are acknowledged either with bReset or automatically.
VAR_OUTPUT
rPresentValue : REAL;
bErrorGeneral : BOOL;
udiError : UDINT;
bErrorSensor : BOOL;
bErrorHighLimit : BOOL;
bErrorLowLimit : BOOL;
bErrorConversionFactor : BOOL;
bInvalidParameter : BOOL;
rPresentValue: Temperature output variable with two decimal places.
The value for rPresentValue is calculated and output according to the following formula:
iConversionFactor = 0: rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
iConversionFactor = 1: rPresentValue := ((iRawValue / 100 + 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 iTemperatureSensorMode.
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 iTemperatureSensorMode and is enabled once the error has been corrected and, depending on the operation mode iTemperatureSensorMode, acknowledged with bReset.
udiError: Delivers all error messages and warnings,
udiError.1 := bInvalidParameter
udiError.2 := bErrorGeneral
udiError.3 := bErrorHighLimit
udiError.4 := bErrorLowLimit
udiError.5 := bErrorShortCircuit
udiError.6 := bErrorBrokenSensor
udiError.7 := bErrorSensor
udiError.8 := bErrorConversionFactor
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 iTemperatureSensorMode.
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 iTemperatureSensorMode.
bErrorSensor: Goes TRUE if byError.5 / bErrorShortCircuit or byError.6 / bErrorBrokenSensor = TRUE. Once the fault has been corrected, the message is acknowledged either with bReset or automatically, depending on mode iTemperatureSensorMode. 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 iTemperatureSensorMode, 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 iTemperatureSensorMode, the warning is acknowledged either with bReset or automatically.
bErrorConversionFactor: If a value outside its range of 0 to 1 is specified at iConversionFactor, this is signaled by bErrorConversionFactor = TRUE. The message need not be acknowledged after rectifying the cause.
bInvalidParameter: Indicates that there is an incorrect parameter on one of the variables rHighLimit, rLowLimit, rSmoothFactor, iConversionFactor or iTemperatureSensorMode. 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 iTemperatureSensorMode.
VAR_IN_OUT
rOffset : REAL;
rHighLimit : REAL;
rLowLimit : REAL;
rReplacementValue : REAL;
rSmoothFactor : REAL;
iTemperatureSensorMode: INT;
rOffset: Temperature compensation in Kelvin. The variable is saved persistently. Preset to 0.
rHighLimit: Upper limit value. The variable is saved persistently. Preset to 120.
If rPresentValue >= rHighLimit , then output bErrorHighLimit is set. rHighLimit must be greater than rLowLimit.
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. The variable is saved persistently. Preset to -60.
If rPresentValue <= rLowLimit , then output bErrorLowLimit is set.
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 errors bErrorShortCircuit and bErrorBrokenSensor if the selected operation mode iTemperatureSensorMode = 0 or 2.
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:
iConversionFactor = 0: rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
iConversionFactor = 1: rPresentValue := ((iRawValue / 100 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;
rPresentValueOld is the value of rPresentValue that was output in the previous PLC cycle.
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.
iTemperatureSensorMode: Specifies the operation mode of the function block.
iTemperatureSensorMode = 0: 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.
iTemperatureSensorMode = 1: 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.
iTemperatureSensorMode = 2 : If bErrorShortCircuit or bErrorBrokenSensor = TRUE, then rPresentValue = rReplacementValue. The function block acknowledges itself automatically following correction of the error.
iTemperatureSensorMode = 3: 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 there is an incorrect variable value on iTemperatureSensorMode, operation continues with the default value. 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 |