Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


TS8000 | TwinCAT PLC Lib: HVAC

Introduction

Foreword

Comfort, energy efficiency and low operating costs as well as quick return of investment, are demands of today’s building automation systems. These requirements can be reached by using integrated control system that can combine all functions of building in to one interoperable platform.

TwinCAT PLC HVAC library includes all needed functionalities for heating, cooling and ventilation systems and also for room automation controls. These functionalities are available as TwinCAT PLC function blocks that can be programmed and combined together to reach energy efficient controlling of building. By using these well tested function blocks, it is easy to realize complex building controls and hence reduce engineering time. Freely programmable controllers and modular I/O-system from Beckhoff, makes it possible to reduce life time costs of the control system when demands of the building are changing.

Room automation function blocks for air-conditioning, lighting and shading can be combined in order to reach energy efficient class A according to EN15232 standard.

This results in the following advantages for the system programmer in creating the system and for the system operator in running operation:

  • Fast creation of system programs.
  • Fast parameterization and commissioning of the systems.
  • Guarantee of a very large range of system functions at all times.
  • Transparency of programs (prerequisite for long-term maintainability and expandability of the systems)
  • Once created, good reusability of templates for systems or system subassemblies.
  • Easy training of staff.
  • Easy expansion and modification of existing systems.
  • Specifications for a clear, object-oriented structure for the creation of visualization objects in MMI and SCADA systems.
  • Programs are easier to document.


TS8000 | TwinCAT PLC Lib: HVAC

Target groups

This software library is intended for building automation system partners of Beckhoff Automation GmbH. The system partners operate in the field of building automation and are concerned with the installation, commissioning, expansion, maintenance and service of measurement and control systems for the technical equipment of buildings.


TS8000 | TwinCAT PLC Lib: HVAC

User requirement profile

The user of this library is required to have basic knowledge of the following.

  • TwinCAT PLC Control
  • TwinCAT System Manager
  • PCs and networks
  • Structure and features of the Beckhoff Embedded PC and its bus terminals
  • Technology of heating, ventilation, air conditioning and sanitary systems
  • Relevant safety regulations for building technical equipment


TS8000 | TwinCAT PLC Lib: HVAC

General technical characteristics

Integration into TwinCAT

Development Environment | Target System | TwinCAT PLC libraries to include | standard TwinCAT PLC libraries to include
TwinCAT v2.10 from Build 1302 | PC or CX (x86) CX (ARM) | TcHVAC.lib; TcFloatPC.lib; TcBaseMath.lib; TcMath.lib | TcBase.lib; TcIoFunctions.lib; TcPlcCoupler.lib; TcSystem.lib; TcUtilities.lib


TS8000 | TwinCAT PLC Lib: HVAC

General technical characteristics

Hardware requirements

The HVAC library is usable on all PC-based hardware platforms. The ideal target platforms for heating, ventilation, air conditioning and sanitary applications are the Embedded PCs from the CX series.


TS8000 | TwinCAT PLC Lib: HVAC

General technical characteristics

Remanent data

The controllers have either a NOVRAM and/or a flash for saving remanent data.
The IN_OUT variables are monitored for changes in their values for automatic saving after a parameter change. In the event of a change, an internal variable in the library is triggered, with which the function blocks FB_HVACNOVRAMDataHandling or FB_HVACPersistentDataHandling are activated.

The IN_OUT variables are saved in a binary file in the flash if eDataSecurityType: = eHVACDataSecurityType_Persistent. The prerequisite for this is a single instancing of the function block FB_HVACPersistantDataHandling. Writing of the IN_OUT variables is deactivated if eDataSecurityType: = eHVACDataSecurityType_Idle.

Nevertheless, the variables must be located or addressed for remanent storage. They will then be saved in the NOVRAM in the event of a change of value. The prerequisite for this is the instancing of the function block FB_HVACNOVRAMDataHandling, as well as an instance of the respective data type that is to be saved.
Example: An instance of FB_HVACNOVRAM_Byte must be used in the case of a variable of type BYTE.

Warning An IN_OUT variable that has been declared as persisitent must not be written cyclically if eDataSecurityType: = eHVACDataSecurityType_Persistent, since otherwise the flash will be prematurely destroyed. Regarding this subject, it is strongly recommended that you read the documentation on the function blocks FB_HVACNOVRAMDataHandling or FB_HVACPersistentDataHandling and familiarize yourself with the examples contained in the documentation!


TS8000 | TwinCAT PLC Lib: HVAC

General technical characteristics

Default values

Default values are declared inside the function block for all system parameters. When the controller is restarted, a check is made as to whether values already exist in the NOVRAM or flash of the controller. If values exist in the binary file in flash or NOVRAM, they will be written back automatically to the IN_OUT variables during the first cycle. Hence, the controller starts automatically with the last saved remanent data.

The default values can be activated at any time by a rising edge at the input variable bSetDefault.


TS8000 | TwinCAT PLC Lib: HVAC

General technical characteristics

Value range monitoring

A value range is defined for each input parameter of the function block. After the input of a value out of its premissible range the last valid value is automatically written back by the function block. The attempt to input an invalid parameter value is indicated by a TRUE at the output variable bInvalidParameter. The variable bInvalidParameter can be reset by a rising edge at the input variable bReset.


Übersicht Funktionsbausteine

TS8000 | TwinCAT PLC Lib: HVAC

Overview

Function blocks

HVAC Actuators

Name | Description
FB_HVAC2PointActuator | Control two-point valves or two-point dampers
FB_HVAC3PointActuator | Control three-point valves or three-point dampers
FB_HVACCirculationPump | Control pumps
FB_HVACCirculationPumpEx | Control pumps; switch -on conditions of bPump are different in comparison with FB_HVACCirculationPump
FB_HVACMotor1Speed | Control a single-speed drive
FB_HVACMotor2Speed | Control a two-speed drive
FB_HVACMotor3Speed | Control a tree-speed drive
FB_HVACMux8 | interpret the FIFO memory of the FB_HVACRedundancyCtrlEx
FB_HVACRedundancyCtrl | Control a certain of number (e.g. 8 pumps) dependent on working hours
FB_HVACRedundancyCtrlEx | Control a certain of number (e.g. 8 pumps) dependent on working hours; the working hours have to be specified externally as hourly values via VAR_INPUT

HVAC Analog modules

Name | Description
FB_HVACAnalogInput | Acquisition analog input signal
FB_HVACAnalogOutput | Control continuous actuators
FB_HVACAnalogOutputEx | Control continuous actuators with a integrated scale function
FB_HVACAnalogTo3Point | Convert an analog signal into a three-point step signal
FB_HVACConfigureKL32xx | Parameterization the connected analog sensor via TwinCAT PLC
FB_HVACScale | Scale function block
FB_HVACScale_nPoint | replication characteristic curves
FB_HVACTemperatureCurve | represent a temperature curve
FB_HVACTemperatureSensor | Acquisition temperature values in 1/10°C, is matched to the KL320x bus terminals
FB_HVACTemperatureSensorEx | Acquisition temperature values in 1/10°C, is matched to the KL320x bus terminals; without the second order filter, therefore with a smoothing function
FB_HVACTemperatureSensorEx2 | Acquisition temperature values in 1/10 or 1/100°C, is matched to the KL320x bus terminals; without the second order filter, therefore with a smoothing function

HVAC Controller

Name | Description
FB_HVAC2PointCtrl | 2-point controller
FB_HVAC2PointCtrlSequence | 2-point sequence controller
FB_HVACBasicSequenceCtrl | general sequence controller
FB_HVACI_CtrlStep | The function block serves the sequential control of power generators
FB_HVACI_CtrlStepEx | The function block serves the sequential control of power generators
FB_HVACMasterSequenceCtrl | master controller in a AC-plant
FB_HVACPIDCooling | PID cooling controller
FB_HVACPIDCtrl | PID-Controller
FB_HVACPIDCtrl_Ex | PID-Controller extended
FB_HVACPIDDehumidify | PID dehumidification controller
FB_HVACPIDEnergyRecovery | PID heat recovery controller
FB_HVACPIDHumidify | PID humidification controller
FB_HVACPIDMixedAir | PID mixed air chamber controller
FB_HVACPIDPreHeating | PID pre-heating controller
FB_HVACPIDReHeating | PID reheating controller
FB_HVACPowerRangeTable | represents a power range table and serves the sequential control of power generators such as boilers or refrigeration machines

HVAC Setpoint modules

Name | Description
FB_HVACHeatingCurve | Calculation the supply temperature depending on the outside temperature with four base
FB_HVACHeatingCurveEx | Calculation the supply temperature depending on the outside temperature
FB_HVACOutsideTempDamped | Calculation the damped outside temperature
FB_HVACSetpointHeating | Control an heating circuit with different operating modes
FB_HVACSetpointRamp | Moving setpoint ramp
FB_HVACSummerCompensation | summer compensation

HVAC Special functions

Name | Description
FB_HVACAirConditioning2Speed | Controls AC-plant with two-speed fans
FB_HVACAlarm | alarm function block
FB_HVACAntiBlockingDamper | prevents the blockage of an damper
FB_HVACAntiBlockingPump | prevents the blockage of a pump
FB_HVACBlink | flashing sequence
FB_HVACCmdCtrl_8 | With the function block can single aggregates of a plant in a certain order sequentially on or be turned off. FB_HVACCmdCtrl_8 can be used as start condition of a ventilation system.
FB_HVACCmdCtrlSystem1Stage | system switch one-stage
FB_HVACCmdCtrlSystem2Stage | system switch two-stage
FB_HVACConvertEnum | converts an Enum into an integer value and vice versa
FB_HVACEnthalpy | calculate the dew point, the specific enthalpy and the absolute humidity
FB_HVACFixedLimit | Limit value switch
FB_HVACFreezeProtectionHeater | freeze protection
FB_HVACMUX_INT_16 | contains two different types of multiplexers
FB_HVACMUX_INT_8 | contains two different types of multiplexers
FB_HVACMUX_REAL_16 | contains two different types of multiplexers
FB_HVACMUX_REAL_8 | contains two different types of multiplexers
FB_HVACOverwriteAnalog | manual overwrite analog
FB_HVACOverwriteDigital | manual overwrite digital
FB_HVACPowerMeasurementKL3403 | control a 3-phase power measurement terminal KL/KS 3403
FB_HVACPowerMeasurementKL3403Ex | compared with the FB_HVACPowerMeasurementKL3403 the results are available in LREAL format. The output is extended by the frequencies of the three phases.
FB_HVACPriority_INT_16 | can be used to prioritise events or as a multiplexer.
FB_HVACPriority_INT_8 | can be used to prioritise events or as a multiplexer.
FB_HVACPriority_REAL_16 | can be used to prioritise events or as a multiplexer.
FB_HVACPriority_REAL_8 | can be used to prioritise events or as a multiplexer.
FB_HVACOptimizedOn | Turns the heating/cooling on before the building is occupied with a self adapting timetable
FB_HVACOptimizedOff | Turns the heating/cooling off before the building is empty with a self adapting timetable
FB_HVACTempChangeFunctionEntry | Entry function for FB_HVACOptimizedOn / FB_HVACOptimizedOff
FB_HVACPWM | PWM
FB_HVACStartAirConditioning | start program for an AC-plant
FB_HVACSummerNightCooling | Summer night cooling
FB_HVACSummerNightCoolingEx | Summer night cooling
FB_HVACTimeCon | converts a TIME variable to three UDINT variables (udiSec, udiMin, udiHour)
FB_HVACTimeConSec | converts a TIME variable into an UDINT variable (udiSec)
FB_HVACTimeConSecMs | converts a TIME variable into two UDINT variables (udiSec, udiMs)
FB_HVACWork | working hours counter

HVAC Time schedule

Name | Description
FB_HVACScheduler1ch | Weekly time switch with 1 time switch channel
FB_HVACScheduler7ch | Weekly time switch with 7 time switch channel
FB_HVACScheduler7TCHandling | this FB can be used to select and modify an individual line from the data array of a weekly timer
FB_HVACScheduler28ch | Weekly time switch with 28 time switch channel
FB_HVACScheduler28TCHandling | this FB can be used to select and modify an individual line from the data array of a weekly timer
FB_HVACSchedulerSpecialPeriods | Yearly timer switch with day, month and exactly time
FB_HVACSchedulerPublicHolidays | Yearly timer switch with day and month

HVAC System

Name | Description
FB_HVACGetSystemTime | an internal clock can be implemented in the TwinCAT PLC
FB_HVACNOVRAMDataHandling | FB, it is necessary to start an instance in the main program
FB_HVACPersistentDataHandling | FB, it is necessary to start an instance in the main program
FB_HVACPersistentDataFileCopy | to copy binary data on the local TwinCAT PC or from a remote TwinCAT PC to the local TwinCAT PC
FB_HVACSetLocalTime | sets the local Windows system time and the date
FB_HVACSystemTaskInfo | determines system variables of the task

HVAC Backup Function blocks

Name | Description
FB_HVACNOVRAM_xyz | FBs for standard data types
FB_HVACPersistent_xyz | FBs for standard data types

Room function Lighting

Name | Description
FB_BARLightActuator | This function block serves to control a conventional light actuator
FB_BARLightCircuit | This block represents a simple light circuit without a dimming function
FB_BARLightCircuitDim | This block represents a light circuit with a dimming function.
FB_BARAutomaticLight | Function block for an automatic light circuit as used in corridors or sanitary facilities.
FB_BARStairwellAutomatic | Function block for a stairwell light circuit.
FB_BARTwilightAutomatic | Automatic twilight function.
FB_BARDaylightControl | Daylight switch without dimming.
FB_BARConstantLightControl | constant light control function block

Room function Shading (see also Overview)

Name | Description
FB_BARBlindPositionEntry | Shading protection: Entry of blind-positions
FB_BARSunblindEvent | This function block serves to preset the position and angle for any desired event.
FB_BARSunblindWeatherProtection | weather protection function
FB_BARSunblindSwitch | manual operating mode
FB_BARSunblindScene | manual operating mode with scenes
FB_BARSunblindTwilightAutomatic | Automatic twilight function.
FB_BARSunblindThermoAutomatic | Thermo automatic
FB_BARSunProtectionEx | Function block for the control of glare protection with the aid of a louvered blind.
FB_BARShadingObjectsEntry | Shading correction: imported data objects by FB
FB_BARReadShadingObjectsList | Shading correction: imported data objects by file
FB_BARFacadeElementEntry | Shading correction: imported data elements by FB
FB_BARReadFacadeElementList | Shading correction: imported data elements by file
FB_BARShadingCorrection / FB_BARShadingCorrectionSouth | Shading correction FB
FB_BARDelayedHysteresis | This function block represents a threshold switch for brightness
FB_BARWithinRangeAzimuth | This function block checks whether the current azimuth angle (horizontal position of the sun) lies within the limits entered
FB_BARWithinRangeElevation | This function block checks whether the current angle of elevation (vertical position of the sun) lies within the limits entered.
FB_BARSunblindPrioritySwitch | Priority controller for up to 9 positioning telegrams
FB_BARSunblindActuator / FB_BARSunblindActuatorEx | Sunblind Actuator
FB_BARSMISunblindActuator | SMI Sunblind Actuator
FB_BARollerBlind | Rollerblind Actuator
FB_BARSMIRollerBlind | SMI Rollerblind Actuator

Room function controller

Name | Description
FB_BARPICtrl | simple PI Controller

Room function climatisation

Name | Beschreibung
FB_BAREnergyLevel | The energy output can be adapted by the energy level to the use of the building
FB_BARFanCoil | This function block has three stages with the equivalent switch hysteresis
FB_BARFctSelection | The function block enables room heating or room cooling
FB_BARSetpointRoom | The functionblock FB_BARSetpointRoom assigns the energy level Protection, Economy, PreComfort and Comfort in each case a setpoint for cooling and heating operation.

Overview Library version

Date | Version | Created with TwinCAT Version | Remarks
10/29/2008 | 1.0.0 | V2.10.0 (Build 1328) | first Release
10/29/2009 | 1.1.0 | V2.11.0 (Build 1536) | new FBs (FB_HVACRedundancyCtrlEx; FB_HVACTemperatureSensorEx; FB_HVACEnthalpy; FB_HVACTimeCon; FB_HVACTimeConSec; FB_HVACMux8)
04/12/2010 | 1.2.7 | V2.11.0 (Build 1539) | new FBs (FB_HVACSetLocalTime; FB_HVACAnalogOutputEx; FB_HVACConfigureKL32xx; FB_HVACScale_nPoint; FB_HVACTemperatureCurve) new Function F_HVACRoundLREAL_EX
08/04/2010 | 1.3.0 | V2.11.0 (Build 1547) | new FBs (FB_HVAC2PointCtrlSequence; FB_HVACPowerMeasurementKL3403Ex; FB_HVACScheduler7TCHandling; FB_HVACScheduler28TCHandling)
01/13/2011 | 1.9.0 | V2.11.0 (Build 1552) | new FBs (FB_HVACTimeConSecMs; FB_HVACI_CtrlStep; FB_HVACPowerRangeTable; FB_HVACPriority_REAL_8; FB_HVACPriority_REAL_16; FB_HVACPriority_INT_16; FB_HVACPriority_INT_8; FB_HVACMUX_INT_8; FB_HVACMUX_INT_16; FB_HVACMUX__16; FB_HVACMUX_INT_8; FB_HVACCirculationPumpEx; FB_HVACHeatingCurveEx)
02/08/2011 | 1.10.1 | V2.11.0 (Build 1552) | new FB (FB_HVACConvertEnum)
28/07/2011 | 1.11.0 | V2.11.0 (Build 1552) | new FB_HVACSummerNightCoolingEx
05/12/2011 | 1.11.12 | V2.11.0 (Build 2038) | new FB_HVACTemperatureSensorEx2
28/12/2011 | 1.12.0 | V2.11.0 (Build 2038) | new FB_HVACCmdCtrl_8
30.03.2012 | 1.13.0 | V2.11.0 (Build 2218) | including new FBs for Room functions
30.06.2012 | 1.14.0 | V2.11.0 (Build 2224) | new FB_HVACI_CtrlStepEx


FB_HVAC2PointActuator

Application

This function block serves to control two-point valves or two-point dampers.

VAR_INPUT

      Name                       : Type

eDataSecurityType          : E_HVACDataSecurityType;
bSetDefault                : BOOL;
bEnable                    : BOOL;
bIn                        : BOOL;
eCtrlModeActuator          : E_HVAC2PointActuatorMode;
bManSwitch                 : BOOL;
bLimitSwitchClose          : BOOL;
bLimitSwitchOpen           : BOOL;
bCtrlVoltage               : BOOL;
bReset                     : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled by the PLC program with the input variable bEnable. The actuator always remains closed as long as the block is not enabled. Output bOut is permanently FALSE.

bIn: In automatic mode the actuator is closed by a FALSE and opened by a TRUE.

eCtrlModeActuator: Enum that specifies the operating mode.

bManSwitch:If the two-point drive has a manual/emergency switch in the control cabinet, this can be connected to the input bManSwitch ; the status of the manual/emergency switch will then be monitored. If bManSwitch = FALSE, then output bOut of the drive will be set to FALSE.

bLimitSwitchClose: Actuator feedback TRUE when the actuator is completely closed.

bLimitSwitchOpen: Actuator feedback TRUE when the actuator is completely open.

bCtrlVoltage: The parameter bCtrlVoltage serves to check the control voltage. The control voltage is present if the bCtrlVoltagevariable is TRUE. The feedback control is suppressed if the control voltage fails.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

bOut                      : BOOL;
byState                   : BYTE;
eStateModeActuator        : E_HVAC2PointActuatorMode;
bErrorLimitSwitch         : BOOL;
bInvalidParameter         : BOOL;

bOut: The actuator is connected to this output (FALSE = closing drive; TRUE = opening drive).

      byState: Shows the status of the control of the
actuator:
byState.0:= Enable
byState.1:= Manual Switch
byState.2:= Enable Feedback Control
byState.3:= Control Voltage
byState.4:= Reset
byState.5:= bOut

eStateModeActuator: Indicates which operating mode the actuator is in.

bErrorLimitSwitch: Becomes TRUE if no limit switch is triggered after the preset stroke time. bErrorLimitSwitch is acknowledged with a rising edge on the input bReset.

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

VAR_IN_OUT

      Name                       : Type               Persistent      Default         Range

bEnableLimitSwitch         : BOOL;                 x
tStrokeTime                : TIME;              x               t#200s          0 .. 3600

bEnableLimitSwitch: If the input is TRUE, then the function control of the drive is activated by means of the limit switch.

tStrokeTime: In order to set the function control correctly, the stroke time of the drive from fully closed to fully opened drive must be entered here.


FB_HVAC3PointActuator

Application

This function block serves to control three-point valves or three-point dampers, with or without constant positional feedback.
The block is often used in conjunction with the FB_HVACAnalogTo3Point function block.

VAR_INPUT

      Name                       : Type                                                       Range

eDataSecurityType          : E_HVACDataSecurityType;
bSetDefault                : BOOL;
bEnable                    : BOOL;
bAutoOpen                  : BOOL;
bAutoClose                 : BOOL;
eCtrlModeActuator          : E_HVAC3PointActuatorMode;
bManSwitch                 : BOOL;
rFeedb                     : REAL;                                                     0 .. 100%
bCtrlVoltage               : BOOL;
bReset                     : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled by the PLC program with the input variable bEnable. The three-point actuator always remains fully closed as long as the block is not enabled. Output bClose is permanently TRUE.

bAutoOpen / bAutoClose: In automatic mode the three-point drive is controlled by the input variables bAutoClose and bAutoOpen.

eCtrlModeActuator: Enum that specifies the operating mode.

bManSwitch:If the three-point drive has a manual/emergency switch in the control cabinet, this can be connected to the input bManSwitch ; the status of the manual/emergency switch will then be monitored. If bManSwitch= FALSE, then output bOut of the drive will be set to FALSE.

rFeedb: Analog positional feedback from the actuator.

bCtrlVoltage: Parameter for controlling the control voltage. The control voltage is present if the bCtrlVoltagevariable is TRUE. The feedback control is suppressed if the control voltage fails.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

bOpen                     : BOOL;
bClose                    : BOOL;
byState                   : BYTE;
eStateModeActuator        : E_HVAC3PointActuatorMode;
bErrorFeedb               : BOOL;
bInvalidParameter         : BOOL;

bOpen: The signal for opening the drive is connected to this output.

bClose: The signal for closing the drive is connected to this output.

byState: Shows the control status of the actuator:
byState.0:= Enable
byState.1:= Manual Switch
byState.2:= Enable Feedback Control
byState.3:= Control Voltage
byState.4:= Reset

eStateModeActuator: Indicates which operating mode the actuator is in.

bErrorFeedb: When setting the output bClose, the position of the drive must have decreased by at least the value of rHysteresisFeedb within the time tStrokeTime.
When setting the output bOpen, the position of the drive must have increased by at least the value of rHysteresisFeedb within the time tStrokeTime.
If the actual position is not in the tolerance range within the specified time following a drive command, this will be indicated by TRUE on the output bErrorFeedb. Outputs bOpen and bClose both become FALSE. The error is acknowledged by a rising edge on the input bReset.

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

VAR_IN_OUT

      Name                      : Type                Persistent      Default         Range

bEnableFeedbCtrl          : BOOL;                x
rMinValueFeedb            : REAL;                x               0              0 .. 100%
rMaxValueFeedb            : REAL;                x             100              0 .. 100%
rHysteresisFeedb          : REAL;                x              10              0 .. 100%
tStrokeTime               : TIME;                x           t#200s             0 .. 3600s

bEnableFeedbCtrl: If the input is TRUE, then the control of the feedback signal is activated.

rMinValueFeedb: Serves to scale the analogue positional feedback. rMinValueFeedb contains the value of the analogue signal when the actuator is fully closed.

rMaxValueFeedb: Serves to scale the analogue positional feedback. rMaxValueFeedb contains the value of the analogue signal when the actuator is fully open.

rHysteresisFeedb: Due to the stroke time of the drive, the positional feedback always lags in the case of a jump in the set position value. Using the variable rHysteresisFeedbCtrl, a range is specified within which the set position value of the actuator can deviate from the feedback signal without the feedback control (bErrorFeedb) being triggered.

tStrokeTime: Due to the lagging of the actual position in relation to the set position, the activation of the feedback control in the event of the maximum permissible difference being exceeded is delayed by the variable tStrokeTime. If the actuator is fully closed and receives a set value jump of 100 %, at least the stroke time of the drive over its entire range of movement should be entered as a time.


FB_HVACCirculationPump

Application

This function block serves to control pumps in HVAC systems.

VAR_INPUT

      Name                      :Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
bAuto                     : BOOL;
eCtrlModeActuator         : E_HVACActuatorMode;
rOutsideTemp              : REAL;
rValvePosition            : REAL;
bFeedbPump                : BOOL;
bPumpProtec               : BOOL;
bAntiBlocking             : BOOL;
bManSwitch                : BOOL;
bCtrlVoltage              : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE.

bAuto: Input for the request out of the automatic program. This request will be overridden by eCtrlModeActuator.

eCtrlModeActuator: Enum that specifies the operating mode.

rOutsideTemp: Input for transmitting the outside temperature value.

rValvePosition: If there is a control valve in the hydraulic circuit of the pump, the position of the control valve must be applied here.

bFeedbPump: This input shows the operating notification in the visualization system and it is useful for monitoring the status of the pump.

bPumpProtec: A pump error message is connected to the input bPumpProtec. There is a pump error if the input bPumpProtec is FALSE. The output bPump becomes FALSE in the event of an error. The pump can only be restarted after a reset on the input bReset.

bAntiBlocking: Input for transmitting the antiblocking request, i.e. at TRUE the request is active.

bManSwitch: If the pump has a manual/emergency switch in the control cabinet, this can be connected to the input bManSwitch; the status of the manual/emergency switch will then be monitored. If bManSwitch = FALSE, the output bPump is disabled. The output bPump can only be switched on if bManSwitch = TRUE (quiescent current principle).

bCtrlVoltage: In order to suppress a torrent of messages, the error message from bPumpProtec is only acquired if the input bCtrlVoltage is TRUE.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

bPump                     : BOOL;
byState                   : BYTE;
bStateManSwitch           : BOOL;
bReqOutsideTemp           : BOOL;
bReqValve                 : BOOL;
eStateModeActuator        : E_HVACActuatorMode;
bErrorPumpProtec          : BOOL;
bErrorPumpFeedb           : BOOL;
bErrorGeneral             : BOOL;
byError                   : BYTE;
bInvalidParameter         : BOOL;

bPump: Output variable for controlling a pump.

byState: Output of the pump status as a byte.
byState.0 := bEnable
byState.1 := bPump
byState.2 := bReqOutsideTemp
byState.3 := bReqValve
byState.4 := bAntiblocking
byState.5 := bFeedbPump
byState.6 := NOT bManSwitch
byState.7 := bCtrlVoltage

bStateManSwitch: Indicates the state of the manual/emergency switch. TRUE indicates that the manual/emergency operation level is activated.

bReqOutsideTemp: If the condition for requesting the pump depending on the outside temperature is TRUE, the output variable bReqOutsideTemp is TRUE.

bReqValve: If the condition for requesting the pump depending on the valve position is reached, the variable bReqValve is TRUE.

eStateModeActuator: Indicates the operating mode of the actuator.

bErrorPumpProtec: Pump error.

bErrorPumpFeedb: If the input bFeedbPump does not become TRUE within the time of tFeedPumpDelay (tFeedPumpDelay has to be > t#0s) after setting the output bPump an error will be sensed and the output will be set TRUE. The output bPump will be set FALSE. This error message has to be quit with bReset.

bErrorGeneral: General error.

byError: Output of the error as byte.
byError.1 := bInvalidParameter
byError.2 := bErrorGeneral
byError.3 := bErrorPumpProtec
byError.4 := bErrorPumpFeedb

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

VAR_IN_OUT

      Name                     : Type                          Range                Default

tStopDelay               : TIME;                                                t#0s
tFeedbPumpDelay          : TIME;                        0 .. 3600               t#0s
rOutsideTempLimit        : REAL;                     - 60 .. 60                 10°C
rValvePositionLimt       : REAL;                        0 .. 100                 3%
eReqOutsideTemp          : E_HVACReqOutsideTemp;        0 .. 2                   1
eReqValve                : E_HVACReqValve;              0 .. 2                   1

tStopDelay: The time tStopDelay delays the switching off of the pump after the switch-on conditions are no longer given.

tFeedbPumpDelay: The monitoring function for the operating feedback of the pump is only active if tFeedbPumpDelay > t#0s.

rOutsideTempLimit: Limit for switching the pump on or off depending on the outside temperature.

rValvePositionLimit: Threshold value for the position of a control valve associated with a pump, to switch on automatically, e.g. heater pump.

eReqOutsideTemp: Depending on the outside temperature, the pump can be compulsorily switched on, e.g. for frost protection purposes when the temperature limit value rOutsideTempLimit is undershot. The prerequisite is that bEnable = TRUE and that the pump is in automatic mode.

Attention Manual off oversteers the frost protection function!

eReqValve: Depending on the position of the valve associated with the pump, the pump can be switched on when the threshold value of rValvePositionLimit is exceeded. The ENUM activates the switching on via the valve position. In addition, the ENUM determines whether the temperature-dependent and valve position-dependent switch-on conditions are connected.

The table below shows a summary of all possible combinations:

eReqOutsideTemp | eReqValve | Function | Application
OTLowerLimit | NoRequest | outsidetemp lower limit |
OTLowerLimit | OrValvePosHigherLimit | outsidetemp OR valve higher limit | Heating circuit air heater
OTLowerLimit | AndValvePosHigherLimit | outsidetemp AND valve higher limit |
OTHigherLimit | NoRequest | outsidetemp higher limit |
OTHigherLimit | OrValvePosHigherLimit | outsidetemp OR valve higher limit |
OTHigherLimit | AndValvePosHigherLimit | outsidetemp AND valve higher limit | Cooling pump
NoRequest | NoRequest | no request | Primary Pump
NoRequest | OrValvePosHigherLimit | valve higher limit |
NoRequest | AndValvePosHigherLimit | not valid |

By means of various combinations of the two variables, eReqOutsideTemp und eReqValve, this function block can be adapted to the requirements of a heating circuit, an air heater, an air cooler or a feeder pump.


FB_HVACCirculationPumpEx

Application

This function block serves to control pumps in HVAC systems.

The following switch-on conditions must first be fulfilled in order to control the pump via bPump:

bEnable = TRUEAND bErrorPumpProtec = FALSEAND bManSwitch = TRUEAND bCtrlVoltage = TRUE

If one of the switch-on conditions is not fulfilled, then the output bPump is constantly FALSE.

On the basis of the following diagram it can be seen how the output bPump is controlled depending on the Enum eReqPump, the input bExternal, the outside temperature rOutSideTemp and the valve position rValvePosition. The switch-on conditions mentioned above must be fulfilled for this, and one of the two operating modes eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP must be preselected.

eHVACReqPump_No: There is no request on the part of the Enum to control the pump

eHVACReqPump_OT_LL: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit)

eHVACReqPump_OT_HL: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit)

eHVACReqPump_VP: The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_LL_OR_VP: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit) OR The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_HL_OR_VP: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit) OR the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_LL_AND_VP: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit) AND The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_HL_AND_VP: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit) AND the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

The output bPump switches itself off, after the switch-on conditions are no longer fulfilled, depending on the Enum eReqPump, the input bExternal, the outside temperature rOutSideTemp or the valve position rValvePosition, with a delay set by the time udiSecStopDelay.

bError goes TRUE if bErrorPumpProtec is TRUE. However, only the error bErrorPumpProtec leads to the deactivation of the output bPump. If the error message bErrorFeedb is also to lead to the switch-off of the pump, then the variable must be ANDed with the output bPump after calling the function block. The error message bErrorFeedb is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP and only if the time udiSecFeedbPumpDelay is greater than 0.

Example for AntiBlocking function

Application example

The application example shows the function block FB_HVACirculationPumpEx. The example is illustrated in the programming languages ST and CFC. The program example P_CFC_CirculationPumpEx.PRG for the CFC programming languages can be found in the folder Language CFC > Actuator, the program example P_ST_CirculationPumpEx.PRG for the ST programming languages in the folder Language Structure Text > Actuator.

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      :Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
bExternal                 : BOOL;
eCtrlModeActuator         : E_HVACActuatorMode;
rOutsideTemp              : REAL;
rValvePosition            : REAL;
bFeedbPump                : BOOL;
bPumpProtec               : BOOL;
bManSwitch                : 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: Example_PERSISTENT.zip

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

Attention 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 block is enabled if bEnable = TRUE. If bEnable = FALSE, then the output bPump is constantly FALSE.

bExternal: The output bPump can be switched on or off directly via the input bExternal. The following conditions must be fulfilled for this: bEnable = TRUEAND bErrorPumpProtec = FALSEAND bManSwitch = TRUEAND bCtrlVoltage = TRUEAND eCtrlModeActuator = eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP AND eReqPump = eHVACRequestPump_NoRequest. Otherwise, bExternal controls the output bPump depending on bReqOutsideTemp and bReqValve, see Application.
bExternal is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.

eCtrlModeActuator: Enum that specifies the operating mode. The following operating modes are supported by the function block FB_HVACCirculationPumpEx: eHVACActuatorMode_Auto_BMS, eHVACActuatorMode_Auto_OP, eHVACActuatorMode_Speed1_BMS, eHVACActuatorMode_Speed1_OP, eHVACActuatorMode_Off_BMS and eHVACActuatorMode_Off_OP.
The two operating modes eHVACActuatorMode_Auto_BMS and eHVACActuatorMode_Auto_OP mean that the function block is in automatic mode.
The output bPump can be switched on directly via the two operating modes eHVACActuatorMode_Speed1_BMS and eHVACActuatorMode_Speed1_OP, provided the following conditions are fulfilled: bEnable = TRUEAND bErrorPumpProtec = FALSEAND bManSwitch = TRUEAND bCtrlVoltage = TRUE
The operating modes eHVACActuatorMode_Off_BMS and eHVACActuatorMode_Off_OP switch the output bPump to the FALSE state.
If an incorrect variable value is present on eCtrlModeActuator, the last valid variable value is taken. The status of the Enum eCtrlModeActuator is output via eStateModeActuator.

rOutsideTemp: Input for transmitting the outside temperature value. Depending on the outside temperature, the pump can be switched on if the temperature falls below the limit value rOutsideTempLowLimit or exceeds the limit value rOutsideTempHighLimit. This depends on the Enum eReqPump for requesting the pump, see Application.
rOutsideTemp is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.

rValvePosition: Input for transmitting the valve position to the control loop. Depending on the position rValvePosition of the valve associated with the pump, the pump can be switched on when the threshold value rValvePositionLimitOn is exceeded. This depends on the Enum eReqPump for requesting the pump, see Application.
rValvePosition is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.

bFeedbPump: Feedback from the pump or a relay contact that the pump is switched on. If the output bPump = TRUE, then the input bFeedbPump must be TRUE within the time specification udiSecFeedbPumpDelay and must remain so until bPump = FALSE. This error is otherwise indicated via the output variable bErrorFeedb. After the rectification of the error it must be acknowledged at the input bReset. The error message bErrorFeedb has no effect on the control of the output bPump.
bFeedbPump is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP and only if the time udiSecFeedbPumpDelay is greater than 0.
If no pump status feedback is present, but the functions are nevertheless realised, then a TRUE may not be applied constantly to the input bFeedbPump. This would lead in the switched-off state to an error: bErrorFeedb = TRUE. In this case the output bPump should be applied to the input bFeedbPump.

bPumpProtec: The motor protection switch for the pump is connected to the input bPumpProtec. A pump error has occurred if the input bPumpProtec is FALSE. If there is an error, the output bPump goes FALSE and the error is displayed by means of the variable bErrorPumpProtec. The output bPump can only be switched on if bPumpProtec = TRUE (quiescent current principle). After the rectification of the error it must be acknowledged at the input bReset.

bManSwitch: If the pump has a manual / emergency switch, this can be connected to the input bManSwitch. The status of the manual / emergency switch is monitored. If bManSwitch = FALSE, the output bPump is disabled. The output bPump can only be switched on if bManSwitch = TRUE (quiescent current principle). The status of bManSwitch is indicated by the output variable bStateManSwitch.

bCtrlVoltage: The control voltage monitoring is applied to the input bCtrlVoltage. If bCtrlVoltage = FALSE, then the output bPump is constantly FALSE. In order to suppress error message torrents, the error messages bPumpProtec, bErrorFeedb and bError are registered only if the input bCtrlVoltage is TRUE.

bReset: Acknowledgment input in the case of an error following its rectification.

VAR_OUTPUT

      Name
      : Type                     Comment

bPump                                 : BOOL;
byState                               : BYTE;
bReqExternal                          : BOOL;                  Request External
bReqOutsideTemp                       : BOOL;                  Request Outside Temperature
bReqValve                             : BOOL;                  Request Valve
bStateManSwitch                       : BOOL;
udiSecRT_StopDelay                    : UDINT;                 Second Remaining Time Stop Delay
udiSecRT_FeedbPumpDelay               : UDINT;                 Second Remaining Time Feedback Pump Delay
eStateModeActuator                    : E_HVACActuatorMode;
bError                                : BOOL;
byError                               : BYTE;
bErrorPumpProtec                      : BOOL;
bErrorFeedb                           : BOOL;
bInvalidParameter                     : BOOL;

bPump: Output variable for controlling a pump. The following conditions must first be fulfilled in order to control the pump via bPump: bEnable = TRUEAND bErrorPumpProtec = FALSEAND bManSwitch = TRUEAND bCtrlVoltage = TRUE. If these conditions are fulfilled, then the pump can be switched on directly via the operating mode eCtrlModeActuator or via different possibilities in automatic mode, see Application.
The output bPump switches itself off, after the switch-on conditions are no longer fulfilled, depending on the Enum eReqPump, the input bExternal, the outside temperature rOutSideTemp or the valve position rValvePosition, with a delay set by the time udiSecStopDelay.

byState: Pump status output
byState.0 := bEnable;
byState.1 := bPump;
byState.2 := bReqExternal;
byState.3 := bReqOutsideTemp;
byState.4 := bReqValve;
byState.5 := bFeedbPump;
byState.6 := NOT bManSwitch;
byState.7 := bCtrlVoltage;

bReqExternal: If the condition bExternal = TRUE is fulfilled for switching on the pump via bPump, then the output variable bReqExternal goes TRUE. All switch-on conditions and the use of the output bReqExternal to control bPump are described in the Application.

bReqOutsideTemp: If the condition is achieved for requesting the pump via bPump depending on the outside temperature rOutsideTemp, then the output variable bReqOutsideTemp goes TRUE. All switch-on conditions and the use of the output bReqOutsideTemp to control bPump are described in the Application.

bReqValve: If the condition is achieved for requesting the pump via bPump depending on the valve position rValvePosition, the variable bReqValve goes TRUE. All switch-on conditions and the use of the output bReqValve to control bPump are described in the Application.

bStateManSwitch: Indicates the status of the manual/emergency switch. A TRUE signals that the manual/emergency operating level is activated. bStateManSwitch = NOT bManSwitch

udiSecRT_StopDelay: If the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP is selected, then the output bPump is switched off, after the switch-on conditions are no longer fulfilled, depending on the Enum eReqPump, the input bExternal, the outside temperature rOutSideTemp or the valve position rValvePosition, delayed by the time set by udiSecRT_StopDelay. The output is given in seconds.

udiSecRT_FeedbPumpDelay: If the output bPump = TRUE, then the input bFeedbPump must be TRUE within the time udiSecRT_FeedbPumpDelay and must remain so until bPump = FALSE. This error is otherwise indicated via the output variable bErrorFeedb.
udiSecRT_FeedbPumpDelay is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP and only if the time udiSecFeedbPumpDelay is greater than 0. The output is given in seconds.

eStateModeActuator: Indicates the operating mode of the function block. eStateModeActuator is equal to eCtrlModeActuator.

bError: bError goes TRUE if bErrorPumpProtec is TRUE. However, only the error bErrorPumpProtec leads to the deactivation of the output bPump. If the error message bErrorFeedb is also to lead to the switch-off of the pump, then the variable must be ANDed with the output bPump after calling the function block.

byError: Output of the error as a byte.
byError.1 := bInvalidParameter
byError.2 := bError
byError.3 := bErrorPumpProtec
byError.4 := bErrorFeedb

bErrorPumpProtec: The motor protection switch for the pump is connected to the input bPumpProtec. A pump error has occurred if the input bPumpProtec is FALSE. If there is an error, the output bPump goes FALSE and the error is displayed by means of the variable bErrorPumpProtec. The output bPump can only be switched on if bPumpProtec = TRUE (quiescent current principle). After the rectification of the error it must be acknowledged at the input bReset.

bErrorFeedb: If the output bPump = TRUE, then the input bFeedbPump must be TRUE within the time specification udiSecFeedbPumpDelay and must remain so until bPump = FALSE. This error is otherwise indicated via the output variable bErrorFeedb. After the rectification of the error it must be acknowledged at the input bReset. The error message bErrorFeedb has no effect on the control of the output bPump.
bErrorFeedb is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP and only if the time udiSecFeedbPumpDelay is greater than 0.

bInvalidParameter: Goes TRUE if an error occurs during the plausibility check of the following variables: rOutsideTempHighLimit, rOutsideTempLowLimit, rValvePositionLimitOn, rValvePositionLimitOff
The message must be acknowledged with bReset.

VAR_IN_OUT

      Name                             : Type                          Persistent            Range                Default                                                       Comment

udiSecStopDelay                  : UDINT;                            X                 0..4294967              0
udiSecFeedbPumpDelay             : UDINT;                            X                 0..4294967              0
rOutsideTempHighLimit            : REAL;                             X                 -60..60                4.0
rOutsideTempLowLimit             : REAL;                             X                 -60..60                1.0
rValvePositionLimitOn            : REAL;                             X                 0..100                 5.0
rValvePositionLimitOff           : REAL;                             X                 0..100                 1.0
eReqPump                         : E_HVACReqPump;                    X                                      eHVACReqPump_OT_LL_OR_VP

udiSecStopDelay: The time delay udiSecStopDelay delays the switching off of the pump after the switch-on conditions are no longer fulfilled. The input is given in seconds. If the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP is selected, then the output bPump is switched off, after the switch-on conditions are no longer fulfilled, depending on the Enum eReqPump, the input bExternal, the outside temperature rOutSideTemp or the valve position rValvePosition, delayed by the time delay set by udiSecStopDelay. The data is given in seconds.

udiSecFeedbPumpDelay: If the output bPump = TRUE, then the input bFeedbPump must be TRUE within the time delay udiSecFeedbPumpDelay and must remain so until bPump = FALSE. This error is otherwise indicated via the output variable bErrorFeedb.
udiSecFeedbPumpDelay is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP and only if the time udiSecFeedbPumpDelay is greater than 0. The input is given in seconds.

rOutsideTempHighLimit: Value above which the pump is switched on or off depending on the outside temperature rOutsideTemp and the Enum eReqPump, see Application.
rOutsideTempHighLimit is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.
If an incorrect variable value is present on rOutsideTempHighLimit, the last valid variable value is taken. bInvalidParameter is set in the case of an incorrect parameter specification.

rOutsideTempLowLimit: Value below which the pump is switched on or off depending on the outside temperature rOutsideTemp and the Enum eReqPump, see Application.
rOutsideTempLowLimit is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.
If an incorrect variable value is present on rOutsideTempLowLimit, the last valid variable value is taken. bInvalidParameter is set in the case of an incorrect parameter specification.

rValvePositionLimitOn: Threshold value for the position rValvePosition of a control valve associated with a pump, from which value the pump should switch on automatically, e.g. heater pump, see Application.
rValvePositionLimitOn is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.
rValvePositionLimitOn may not be smaller than rValvePositionLimitOff. Otherwise the last valid variable value is taken and bInvalidParameter is set.
If an incorrect variable value is present on rValvePositionLimit , the last valid variable value is taken. bInvalidParameter is set in the case of an incorrect parameter specification.

rValvePositionLimitOff: Threshold value for the position rValvePosition of a control valve associated with a pump, from which value the pump should switch off automatically, e.g. heater pump, see Application.
rValvePositionLimitOff is active only in the operating mode eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.
rValvePositionLimitOff may not be larger than rValvePositionLimitOn. Otherwise the last valid variable value is taken and bInvalidParameter is set.
If an incorrect variable value is present on rValvePositionLimit , the last valid variable value is taken. bInvalidParameter is set in the case of an incorrect parameter specification.

eReqPump: Using the Enum eReqPump, switch-on conditions or combinations of switch-on conditions can be set for switching on the pump.
The switch-on conditions are as follows:

- depending on the outside temperature, the pump can be switched on if the temperature falls below the limit value rOutsideTempLowLimit or exceeds the limit value rOutsideTempHighLimit.

- depending on the position rValvePosition of the valve associated with the pump, the pump can be switched on when the threshold value rValvePositionLimitOn is exceeded.

In addition, the Enum combinations can be used to specify whether the temperature-dependent and valve-position-dependent switch-on conditions are ORed or ANDed together.

The following switch-on conditions or combinations of switch-on condition can be set via the Enum in order to control the output bPump:

eHVACReqPump_No: There is no request on the part of the Enum to control the pump

eHVACReqPump_OT_LL: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit)

eHVACReqPump_OT_HL: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit)

eHVACReqPump_VP: The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_LL_OR_VP: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit) OR The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_HL_OR_VP: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit) OR the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_LL_AND_VP: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit) AND The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_HL_AND_VP: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit) AND the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

The prerequisites for the use of the Enum eReqPump are that bEnable = TRUE AND bErrorPumpProtec = FALSEAND bManSwitch = TRUEAND bCtrlVoltage = TRUEAND eCtrlModeActuator = eHVACActuatorMode_Auto_BMS OR eHVACActuatorMode_Auto_OP.
If an incorrect variable value is present on eReqPump, the last valid variable value is taken. bInvalidParameter is set in the case of an incorrect parameter specification.


FB_HVACMotor1Speed

Application

This function block serves to control a single-speed drive in HVAC systems. It is suitable for fans.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
bAuto                    : BOOL;
eCtrlModeActuator        : E_HVACActuatorMode;
bMotorProtec             : BOOL;
bFeedbContactor          : BOOL;
bFeedbProcess            : BOOL;
bRepairSwitch            : BOOL;
bManSwitch               : BOOL;
bCtrlVoltage             : BOOL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If bEnable = FALSE, the drive will be turned off after the adjustable time of the variable tStopDelay.

bAuto: bAuto is only active if the control mode eCtrlModeActuator is set either to eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP. If the input variable bAuto = TRUE the drive should run. If bAuto = FALSE the drive will be turned off after the adjustable time of the variable tStopDelay

eCtrlModeActuator: Enum that specifies the type of operating mode of the motor. In the event of an incorrect entry, operation continues internally with the last valid operating mode. This is eHVACActuatorMode_Auto_BMS in the case of a first-time start-up. bInvalidParameter is set in the case of an incorrect parameter entry.

bMotorProtec: Input for the motor protection breaker. There is a motor protection breaker error if the input bMotorProtec = FALSE (quiescent current principle). In the event of an error, the output bMotor = FALSE; the error is indicated at the output of the function block by bErrorMotorprotec. The motor can only be restarted if the error has been rectified and aknowledged at the input bReset.

bFeedbContactor: Feedback for the power section of the motor. The operating feedback is present if the input bFeedbContactor = TRUE. If this feedback is not present after switching on the motor the output bErrorFeedbContactor is set in order to indicate the error after the time delay set by tDelayFeedbContactor. The output bMotor becomes FALSE in the event of an error. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. If there is no feedback signal from the power section of the motor the output bMotor has to be connected to the input bFeedbContactor.

If there is no feedback signal from the power section of the motor the output bMotor has to be connected to the input bFeedbContactor. See application sample

bFeedbProcess: A process feedback signal, for example from a v-belt monitor or a flow monitor can be connected to the input bFeedbProcess. The process feedback is present if the input bFeedbProcess = TRUE (quiescent current principle). If, in the ramp-up phase after switching on the motor, the process feedback is not present after the time set by tFeedbProcessTimer, the drive switches off and indicates an error at the output bErrorFeedbProcess. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. In order to avoid undesired switching off the triggering of the input bFeedbProcess can be delayed by the time tDelayFeedbProcess. This may happen during operation due to the process monitoring, e.g. in the event of short-term pressure fluctuations.

bRepairSwitch: The status of the repair switch is monitored with the input bRepairSwitch. The motor can only be switched on if bRepairSwitch = TRUE (quiescent current principle). If the repair switch is switched off, bRepairSwitch = FALSE and the output bMotor becomes FALSE.

bManSwitch: The status of the manual/emergency switch is monitored with the input bManSwitch. The motor can only be switched on if bManSwitch = TRUE (quiescent current principle). If the manual/emergency switch is switched off, bManSwitch = FALSE and the output bMotor becomes FALSE.

bCtrlVoltage: The status of the control voltage is monitored with the input bCtrlVoltage. The motor can only be switched on if bCtrlVoltage = TRUE (quiescent current principle). If the control voltage is switched off, bCtrlVoltage = FALSE and the output bMotor becomes FALSE. In order to avoid a torrent of error messages in case of control voltage failure, the error messages of the function block are suppressed. If the control voltage is restored, the error messages are enabled again.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                     : Type

bMotor                   : BOOL;
byState                  : BYTE;
bStateAuto               : BOOL;
bStateRepairSwitch       : BOOL;
bStateManSwitch          : BOOL;
eStateModeActuator       : E_HVACActuatorMode;
bErrorGeneral            : BOOL;
byError                  : BYTE;
bErrorMotorprotec        : BOOL;
bErrorFeedbContactor     : BOOL;
bErrorFeedbProcess       : BOOL;
bInvalidParameter        : BOOL;

bMotor: Output variable for controlling a single-speed motor.

      byState: Status byte indicating the operating status of
the function block.
byState.0 :=
bEnable;
byState.1 := bMotor;
byState.2 := bStateAuto;
byState.5 := bStateRepairSwitch;
byState.6 := bStateManSwitch;
byState.7 := bCtrlVoltage;

bStateAuto: Status feedback for automatic mode, in case the operating mode eCtrlModeActuator is set either to eHVACActuatorMode_Auto_BMS or to eHVACActuatorMode_Auto_OP. The input variable bAuto has to be activated as well.

bStateRepairSwitch: Indicates the state of the repair switch. TRUE indicates that the repair switch is switched off.

bStateManSwitch: Indicates the state of the manual/emergency switch. TRUE indicates that the manual/emergency operation level is activated.

eStateModeActuator: Enum via which the operating mode status of the motor is fed back to the controller.

bErrorGeneral: The error message bErrorGeneral becomes TRUE as soon as one of the error messages bErrorMotorprotec, bErrorFeedbContactor or bErrorFeedbProcess = TRUE. The output bMotor is then set to FALSE and is only enabled again when the error has been rectified and acknowledged via bReset.

      byError: Delivers all error messages and warnings from
the function block.
byError.1 :=
bInvalidParameter;
byError.2 := bErrorGeneral;
byError.3 := bErrorMotorprotec;
byError.4 := bErrorFeedbContactor;
byError.5 := bErrorFeedbProcess;

bErrorMotorprotec: Motor protection breaker error, see input variable bMotorProtec.

bErrorFeedbContactor: Power section feedback error, see input variable bFeedbContactor.

If there is no feedback signal from the power section of the motor the output bMotor has to be connected to the input bFeedbContactor. See application sample

bErrorFeedbProcess: Process feedback error, see input variable bFeedbackProcess.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables eCtrlModeActuator, tStartDelay, tStopDelay, tDelayFeedbContactor, tFeedbProcessTimer or tDelayFeedbProcess. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                      : Type      Persistent     Default           Range

tStartDelay               : TIME;         X           t#0s          t#0s .. 3600s
tStopDelay                : TIME;         X           t#0s          t#0s .. 3600s
tDelayFeedbContactor      : TIME;         X           t#100ms       t#100ms .. 3600s
tFeedbProcessTimer        : TIME;         X           t#0s          t#0s .. 3600s
tDelayFeedbProcess        : TIME;         X           t#0s          t#0s .. 3600s

tStartDelay: The start-up of the motor after enablement and switch-on via the operating mode of the motor is delayed by the time tStartDelay.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tStopDelay: The switching off of the motor by means of switching off via the operating mode of the motor is delayed by the time tStopDelay.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbContactor: Time delay of the feedback of the power section after switching on the motor. If this time has elapsed and bFeedbContactor = FALSE, then this is fed back to the controller via the error message bErrorFeedbContactor.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tFeedbProcessTimer: Time delay of the process feedback bFeedbProcess after switching on the motor. If this time has elapsed and bFeedbProcess = FALSE, then this is fed back to the controller via the error message bErrorFeedbProcess.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbProcess: In order to avoid undesired switching off of the drive during operation due to the process monitoring, e.g. in the event of short-term pressure fluctuations, the triggering of the input bFeedbProcess can be delayed by the time tDelayFeedbProcess.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.


FB_HVACMotor2Speed

Application

This function block serves to control a two-speed drive in HVAC systems. The function block always runs in stage 1, the lower power stage. It cannot be switched on directly in speed 2. In the event of a restart, disablement, an error or switching off of the motor via the operating mode, restart of the motor is blocked for the duration of tDelaySpeed2toSpeed1.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
bAutoSpeed1               : BOOL;
bAutoSpeed2               : BOOL;
eCtrlModeActuator         : E_HVACActuatorMode;
bMotorProtecSpeed1        : BOOL;
bMotorProtecSpeed2        : BOOL;
bFeedbContactorSpeed1     : BOOL;
bFeedbContactorSpeed2     : BOOL;
bFeedbProcess             : BOOL;
bRepairSwitch             : BOOL;
bManSwitch                : BOOL;
bCtrlVoltage              : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If bEnable = FALSE, the according speed stage of the drive will be turned off after the adjustable time of the variable tStopDelay. If an enable is present, a restart of the motor is blocked for the duration of tDelaySpeed2toSpeed1.

bAutoSpeed1: bAutoSpeed1 is only active if the operating mode eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.
 If the input variable bAutoSpeed1 = TRUE and the input variable bAutoSpeed2 = FALSE, the function block is instructed that the drive should run at speed 1.
If bAutoSpeed1 = FALSE the according speed stage of the drive will be turned off after the adjustable time of the variable tStopDelay.

bAutoSpeed2: bAutoSpeed2 is only active if the operating mode eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.
If the input variables bAutoSpeed1 and bAutoSpeed2 are both TRUE, the function block is instructed that the drive should run at speed 2.
If bAutoSpeed1 and bAutoSpeed2 = FALSE the according speed stage of the drive will be turned off after the adjustable time of the variable tStopDelay.

eCtrlModeActuator: Enum that specifies the type of operating mode of the motor. In the event of an incorrect entry, operation continues internally with the last valid operating mode. This is eHVACActuatorMode_Auto_BMS in the case of a first-time start-up. bInvalidParameter is set in the case of an incorrect parameter entry.

bMotorProtecSpeed1: Input for the motor protection breaker speed 1. There is a motor protection breaker error if the input bMotorProtecSpeed1 = FALSE (quiescent current principle). In the event of an error, the outputs bMotorSpeed1 and bMotorSpeed2 are both FALSE; the error is indicated at the output of the function block by bErrorMotorprotecSpeed1. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset.

bMotorProtecSpeed2: Input for the motor protection breaker speed 2. There is a motor protection breaker error if the input bMotorProtecSpeed2 = FALSE (quiescent current principle). In the event of an error, the outputs bMotorSpeed1 and bMotorSpeed2 are both FALSE; the error is indicated at the output of the function block by bErrorMotorprotecSpeed2. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset.

bFeedbContactorSpeed1: Feedback from the power section of the motor for speed 1. The operating feedback is present if the input bFeedbContactorSpeed1 = TRUE. If this feedback is not present after switching on the motor the output bErrorFeedbContactorSpeed1 is set in order to indicate the error after the time delay set by tDelayFeedbContactorSpeed1. The outputs bMotorSpeed1 and bMotorSpeed2 become FALSE in the event of an error. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. If there is no feedback signal from the power section of the motor the output bMotorSpeed1 has to be connected to the input bFeedbContactorSpeed1.

If there is no feedback signal from the power section of the motor the output bMotorSpeed1 has to be connected to the input bFeedbContactorSpeed1. See application sample

bFeedbContactorSpeed2: Feedback from the power section of the motor for speed 2. The operating feedback is present if the input bFeedbContactorSpeed2 = TRUE. If this feedback is not present after switching on the motor the output bErrorFeedbContactorSpeed2 is set in order to indicate the error after the time delay set by tDelayFeedbContactorSpeed2. The outputs bMotorSpeed1 and bMotorSpeed2 become FALSE in the event of an error. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. If there is no feedback signal from the power section of the motor the output bMotorSpeed2 has to be connected to the input bFeedbContactorSpeed2.

If there is no feedback signal from the power section of the motor the output bMotorSpeed2 has to be connected to the input bFeedbContactorSpeed2. See application sample

bFeedbProcess: A process feedback signal, for example from a v-belt monitor or a flow monitor can be connected to the input bFeedbProcess. The process feedback is present if the input bFeedbProcess = TRUE (quiescent current principle). If, in the ramp-up phase after switching on the motor, the process feedback is not present after the time set by tFeedbProcessTimer, the drive switches off and indicates an error at the output bErrorFeedbProcess. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. In order to avoid undesired switching off, the triggering of the input bFeedbProcess can be delayed by the time tDelayFeedbProcess. This may happen during operation due to the process monitoring, e.g. in the event of short-term pressure fluctuations. The process feedback is active if either bMotorSpeed1 or bMotorSpeed2 = TRUE.

bRepairSwitch: The status of the repair switch is monitored with the input bRepairSwitch. The motor can only be switched on if bRepairSwitch = TRUE (quiescent current principle). If the repair switch is switched off, bRepairSwitch = FALSE and the outputs bMotorSpeed1 and bMotorSpeed2 are both FALSE. If the state of the repair switch is TRUE, a restart of the motor is blocked for the duration of tDelaySpeed2toSpeed1.

bManSwitch: The status of the manual/emergency switch is monitored with the input bManSwitch. The motor can only be switched on if bManSwitch = TRUE (quiescent current principle). If the manual/emergency switch is switched off, bManSwitch = FALSE and the outputs bMotorSpeed1 and bMotorSpeed2 are both FALSE. If the state of the manual/emergency switch is TRUE, a restart of the motor is blocked for the duration of tDelaySpeed2toSpeed1.

bCtrlVoltage: The status of the control voltage is monitored with the input bCtrlVoltage. The motor can only be switched on if bCtrlVoltage = TRUE (quiescent current principle). If the control voltage is switched off, bCtrlVoltage = FALSE and the outputs bMotorSpeed1 and bMotorSpeed2 are both FALSE. In order to avoid a torrent of error messages if the control voltage fails, the error messages of the function block are suppressed. If the control voltage is restored, the error messages are enabled again. If control voltage is present, a restart of the motor is blocked for the duration of tDelaySpeed2toSpeed1.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                              : Type

bMotorSpeed1                      : BOOL;
bMotorSpeed2                      : BOOL;
byState                           : BYTE;
bStateAutoSpeed1                  : BOOL;
bStateAutoSpeed2                  : BOOL;
bStateRepairSwitch                : BOOL;
bStateManSwitch                   : BOOL;
eStateModeActuator                : E_HVACActuatorMode;
bErrorGeneral                     : BOOL;
byError                           : BYTE;
bErrorMotorprotecSpeed1           : BOOL;
bErrorMotorprotecSpeed2           : BOOL;
bErrorFeedbContactorSpeed1        : BOOL;
bErrorFeedbContactorSpeed2        : BOOL;
bErrorFeedbProcess                : BOOL;
bInvalidParameter                 : BOOL;

bMotorSpeed1: Output variable for run speed 1 of the two-speed drive.

bMotorSpeed2: Output variable for run speed 2 of the two-speed drive.

      byState: Status byte indicating the operating status of
the function block
byState.0 :=
bEnable;
byState.1 := bMotorSpeed1;
byState.2 := bMotorSpeed2;
byState.3 := bStateAutoSpeed1;
byState.4 := bStateAutoSpeed2;
byState.5 := bStateRepairSwitch;
byState.6 := bStateManSwitch;
byState.7 := bCtrlVoltage;

bStateAutoSpeed1: Indicates the state of the automatic preselection of speed 1. If the operating mode eCtrlModeActuator is either eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP and speed 1 was activated via the input variable bAutoSpeed1.

bStateAutoSpeed2: Indicates the state of the automatic preselection of speed 2. If the operating mode eCtrlModeActuator is either eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP and speed 2 was activated via the input variable bAutoSpeed2.

bStateRepairSwitch: Indicates the state of the repair switch. TRUE indicates that the repair switch is switched off.

bStateManSwitch: Indicates the state of the manual/emergency switch. TRUE indicates that the manual/emergency operation level is activated.

eStateModeActuator: Enum via which the operating mode status of the motor is fed back to the controller.

bErrorGeneral: The error message bErrorGeneral becomes TRUE as soon as one of the error messages bErrorMotorprotecSpeed1, bErrorMotorprotecSpeed2, bErrorFeedbContactorSpeed1, bErrorFeedbContactorSpeed2 or bErrorFeedbProcess = TRUE. The outputs bMotorSpeed1 and bMotorSpeed2 are then set to FALSE and are only enabled again when the error has been rectified and acknowledged via bReset. After rectification of the error a restart of the motor is blocked for the duration of tDelaySpeed2toSpeed1.

      byError: Delivers all error messages and warnings from
the function block.
byError.1 :=
bInvalidParameter;
byError.2 := bErrorGeneral;
byError.3 := bErrorMotorprotecSpeed1;
byError.4 := bErrorMotorprotecSpeed2;
byError.5 := bErrorFeedbContactorSpeed1;
byError.6 := bErrorFeedbContactorSpeed2;
byError.7 := bErrorFeedbProcess;

bErrorMotorprotecSpeed1: Motor protection breaker error, see input variable bMotorProtecSpeed1.

bErrorMotorprotecSpeed2: Motor protection breaker error, see input variable bMotorProtecSpeed2.

bErrorFeedbContactorSpeed1: Power section feedback error, see input variable bFeedbContactorSpeed1.

If there is no feedback signal from the power section of the motor the output bMotorSpeed1 has to be connected to the input bFeedbContactorSpeed1. See application sample

bErrorFeedbContactorSpeed2: Power section feedback error, see input variable bFeedbContactorSpeed2.

If there is no feedback signal from the power section of the motor the output bMotorSpeed2 has to be connected to the input bFeedbContactorSpeed2. See application sample

bErrorFeedbProcess: Process feedback error, see input variable bFeedbackProcess

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables eCtrlModeActuator, tStartDelay, tStopDelay, tDelayFeedbContactorSpeed1, tDelayFeedbContactorSpeed2, tFeedbProcessTimer, tDelayFeedbProcess, tDelaySpeed1 or tDelaySpeed1ToSpeed2. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                        : Type      Persistent      Default           Range

tStartDelay                 : TIME;         X            t#0s         t#0s .. 3600s
tStopDelay                  : TIME;         X            t#0s         t#0s .. 3600s
tDelayFeedbContactorSpeed1  : TIME;         X            t#100ms      t#100ms .. 3600s
tDelayFeedbContactorSpeed2  : TIME;         X            t#100ms      t#100ms .. 3600s
tFeedbProcessTimer          : TIME;         X            t#0s         t#0s .. 3600s
tDelayFeedbProcess          : TIME;         X            t#0s         t#0s .. 3600s
tDelaySpeed1                : TIME;         X            t#3s         t#1s .. 3600s
tDelaySpeed1ToSpeed2        : TIME;         X            t#250ms      t#100ms .. 10s
tDelaySpeed2ToSpeed1        : TIME;         X            t#10s        t#1s .. 3600s

tStartDelay: The start-up of the motor after enablement and switch-on via the operating mode of the motor is delayed by the time tStartDelay.
If no correct variable value is present, then the last valid variable value, if one exists, will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tStopDelay: The switching off of the motor in the respective switch-on speed is delayed by the time tStopDelay. Either by switching bEnable to FALSE, or by switching off via the operating mode eCtrlModeActuator, or in automatic operating mode by switching the input variables bAutoSpeed1 and bAutoSpeed2 to FALSE. Once the delayed switch-off of the motor has been activated, it can no longer be aborted.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbContactorSpeed1: Time delay of the feedback of the power section after switching on the motor. If this time has elapsed and bFeedbContactorSpeed1 = FALSE, then this is fed back to the controller via the error message bErrorFeedbContactorSpeed1.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbContactorSpeed2: Time delay of the feedback of the power section after switching on the motor. If this time has elapsed and bFeedbContactorSpeed2 = FALSE, then this is fed back to the controller via the error message bErrorFeedbContactorSpeed2.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tFeedbackProcessTimer: Time delay of the process feedback bFeedbProcess during the motor ramp-up phase. If this time has elapsed and bFeedbProcess = FALSE, then this is fed back to the controller via the error message bErrorFeedbProcess.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbProcess: In order to avoid undesired switching off of the drive during operation due to the process monitoring, e.g. in the event of short-term pressure fluctuations, the triggering of the input bFeedbProcess can be delayed by the time tDelayFeedbProcess.
If no correct variable value is present, then the last valid variable value, if one exists, will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelaySpeed1: Time delay for the motor ramp-up phase in speed 1.
After this time has elapsed the motor can be switched from the first to the second speed if the operating mode for speed 2 has been selected.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelaySpeed1ToSpeed2: Time delay for the motor switchover phase from speed 1 to speed 2, so that both outputs bMotorSpeed1 and bMotorSpeed2 are FALSE for a short while. The purpose of this time delay is to preserve the motor windings.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelaySpeed2ToSpeed1: Time delay for the motor switchover phase from speed 2 to speed 1. In this phase both outputs bMotorSpeed1 and bMotorSpeed2 are FALSE for the time period tDelaySpeed2ToSpeed1 in order to reduce the speed of the motor when switching to speed 1.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.


FB_HVACMotor3Speed

Application

This function block serves to control a three-speed drive in HVAC systems. The function block always runs in speed 1, the lowest power stage, and switches to speed 2 or stage 3 depending on requirements. It cannot be switched on directly in speed 2 or 3. In the event of a restart, disablement, an error or switching off of the motor via the operating mode, restart of the motor is blocked for the duration of tDelaySpeed2ToSpeed1 + tDelaySpeed3ToSpeed2.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
bAutoSpeed1               : BOOL;
bAutoSpeed2               : BOOL;
bAutoSpeed3               : BOOL;
eCtrlModeActuator         : E_HVACActuatorMode;
bMotorProtecSpeed1        : BOOL;
bMotorProtecSpeed2        : BOOL;
bMotorProtecSpeed3        : BOOL;
bFeedbContactorSpeed1     : BOOL;
bFeedbContactorSpeed2     : BOOL;
bFeedbContactorSpeed3     : BOOL;
bFeedbProcess             : BOOL;
bRepairSwitch             : BOOL;
bManSwitch                : BOOL;
bCtrlVoltage              : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If bEnable = FALSE, The drive will be switched off via the time variable tStopDelay out of the respective power stage. If an enable is present, a restart of the motor is blocked for the duration of tDelaySpeed2ToSpeed1 + tDelaySpeed3ToSpeed2.

bAutoSpeed1: bAutoSpeed1 is only active if the operating mode eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.
If the input variables bAutoSpeed1 = TRUE, bAutoSpeed2 = FALSE and bAutoSpeed3 = FALSE, then the function block is forced to run the drive in speed 1. If bAutoSpeed1 = FALSE, the drive will be turned off after the adjustable time of the variable tStopDelay.

bAutoSpeed2: bAutoSpeed2 is only active if the operating mode eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.
 If the input variables bAutoSpeed1 = TRUE, bAutoSpeed2 = TRUE and bAutoSpeed3 = FALSE, then the function block is forced to run the drive in speed 2. If bAutoSpeed1 = bAutoSpeed2 = FALSE, the drive will be turned off after the adjustable time of the variable tStopDelay.

bAutoSpeed3: bAutoSpeed3 is only active if the operating mode eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.
 If the input variables bAutoSpeed1 = TRUE, bAutoSpeed2 = TRUE and bAutoSpeed3 = TRUE, then the function block is forced to run the drive in speed 3. If bAutoSpeed1 = bAutoSpeed2 = bAutoSpeed3 = FALSE, the drive will be turned off after the adjustable time of the variable tStopDelay.

eCtrlModeActuator: Enum that specifies the type of operating mode of the motor. In the event of an incorrect entry, operation continues internally with the last valid operating mode. This is eHVACActuatorMode_Auto_BMS in the case of a first-time start-up. bInvalidParameter is set in the case of an incorrect parameter entry.

bMotorProtecSpeed1: Input for the motor protection breaker speed 1. There is a motor protection breaker error if the input bMotorProtecSpeed1 = FALSE (quiescent current principle). In the event of an error, the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are all FALSE; the error is indicated at the output of the function block by bErrorMotorprotecSpeed1. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset.

bMotorProtecSpeed2: Input for the motor protection breaker speed 2. There is a motor protection breaker error if the input bMotorProtecSpeed2 = FALSE (quiescent current principle). In the event of an error, the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are all FALSE; the error is indicated at the output of the function block by bErrorMotorprotecSpeed2. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset.

bMotorProtecSpeed3: Input for the motor protection breaker speed 3. There is a motor protection breaker error if the input bMotorProtecSpeed3 = FALSE (quiescent current principle). In the event of an error, the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are all FALSE; the error is indicated at the output of the function block by bErrorMotorprotecSpeed3. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset.

bFeedbContactorSpeed1: Feedback from the power section of the motor for speed 1. The operating feedback is present if the input bFeedbContactorSpeed1 = TRUE. If this feedback is not present after switching on the motor the output bErrorFeedbContactorSpeed1 is set in order to indicate the error after the time delay set by tDelayFeedbContactorSpeed1. The outputs bMotorSpeed, bMotorSpeed2 and bMotorSpeed3 become FALSE in the event of an error. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. If there is no feedback signal from the power section of the motor the output bMotorSpeed1 has to be connected to the input bFeedbContactorSpeed1.

If there is no feedback signal from the power section of the motor the output bMotorSpeed1 has to be connected to the input bFeedbContactorSpeed1. See application sample

bFeedbContactorSpeed2: Feedback from the power section of the motor for speed 2. The operating feedback is present if the input bFeedbContactorSpeed2 = TRUE. If this feedback is not present after switching on the motor the output bErrorFeedbContactorSpeed2 is set in order to indicate the error after the time delay set by tDelayFeedbContactorSpeed2. The outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 become FALSE in the event of an error. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. If there is no feedback signal from the power section of the motor the output bMotorSpeed2 has to be connected to the input bFeedbContactorSpeed2.

If there is no feedback signal from the power section of the motor the output bMotorSpeed2 has to be connected to the input bFeedbContactorSpeed2. See application sample

bFeedbContactorSpeed3: Feedback from the power section of the motor for speed 3. The operating feedback is present if the input bFeedbContactorSpeed3 = TRUE. If this feedback is not present after switching on the motor the output bErrorFeedbContactorSpeed3 is set in order to indicate the error after the time delay set by tDelayFeedbContactorSpeed3. The outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 become FALSE in the event of an error. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. If there is no feedback signal from the power section of the motor the output bMotorSpeed3 has to be connected to the input bFeedbContactorSpeed3.

If there is no feedback signal from the power section of the motor the output bMotorSpeed3 has to be connected to the input bFeedbContactorSpeed3. See application sample

bFeedbProcess: A process feedback signal, for example from a v-belt monitor or a flow monitor can be connected to the input bFeedbProcess. The process feedback is present if the input bFeedbProcess = TRUE (quiescent current principle). If, in the ramp-up phase after switching on the motor, the process feedback is not present after the time set by tFeedbProcessTimer, the drive switches off and indicates an error at the output bErrorFeedbProcess. The motor can only be restarted if the error has been rectified and acknowledged at the input bReset. In order to avoid undesired switching off, the triggering of the input bFeedbProcess can be delayed by the time tDelayFeedbProcess. This may happen during operation due to the process monitoring, e.g. in the event of short-term pressure fluctuations.
The process feedback is active if either bMotorSpeed1, bMotorSpeed2 or bMotorSpeed3 = TRUE.

bRepairSwitch: The status of the repair switch is monitored with the input bRepairSwitch. The motor can only be switched on if bRepairSwitch = TRUE (quiescent current principle). If the repair switch is switched off, bRepairSwitch = FALSE and the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are all FALSE. If the state of the repair switch is TRUE, a restart of the motor is blocked for the duration of tDelaySpeed2ToSpeed1 + tDelaySpeed3ToSpeed2.

bManSwitch: The status of the manual/emergency switch is monitored with the input bManSwitch. The motor can only be switched on if bManSwitch = TRUE (quiescent current principle). If the manual/emergency switch is switched off, bManSwitch = FALSE and the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are all FALSE. If the state of the manual/emergency switch is TRUE, a restart of the motor is blocked for the duration of tDelaySpeed2ToSpeed1 + tDelaySpeed3ToSpeed2.

bCtrlVoltage: The status of the control voltage is monitored with the input bCtrlVoltage. The motor can only be switched on if bCtrlVoltage = TRUE (quiescent current principle). If the control voltage is switched off, bCtrlVoltage = FALSE and the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are all FALSE. In order to avoid a torrent of error messages if the control voltage fails, the error messages of the function block are suppressed. If the control voltage is restored, the error messages are enabled again. If control voltage is present, a restart of the motor is blocked for the duration of tDelaySpeed2ToSpeed1 + tDelaySpeed3ToSpeed2.

bReset: Input for acknowledgement of errors via a rising edge.

VAR_OUTPUT

      Name                         : Type

bMotorSpeed1                 : BOOL;
bMotorSpeed2                 : BOOL;
bMotorSpeed3                 : BOOL;
wState                       : WORD;
bStateAutoSpeed1             : BOOL;
bStateAutoSpeed2             : BOOL;
bStateAutoSpeed3             : BOOL;
bStateRepairSwitch           : BOOL;
bStateManSwitch              : BOOL;
eStateModeActuator           : E_HVACActuatorMode;
bErrorGeneral                : BOOL;
wError                       : WORD;
bErrorMotorprotecSpeed1      : BOOL;
bErrorMotorprotecSpeed2      : BOOL;
bErrorMotorprotecSpeed3      : BOOL;
bErrorFeedbContactorSpeed1   : BOOL;
bErrorFeedbContactorSpeed2   : BOOL;
bErrorFeedbContactorSpeed3   : BOOL;
bErrorFeedbProcess           : BOOL;
bInvalidParameter            : BOOL;

bMotorSpeed1: Output variable for controlling speed 1 of the three-speed drive.

bMotorSpeed2: Output variable for controlling speed 2 of the three-speed drive.

bMotorSpeed3: Output variable for controlling speed 3 of the three-speed drive.

      wState: Status word indicating the operating status of
the function block.
wState.0 :=
bEnable;
wState.1 := bMotorSpeed1;
wState.2 := bMotorSpeed2;
wState.3 := bMotorSpeed3;
wState.4 := bStateAutoSpeed1;
wState.5 := bStateAutoSpeed2;
wState.6 := bStateAutoSpeed3;
wState.7 := bStateRepairSwitch;
wState.8 := bStateManSwitch;
wState.9 := bCtrlVoltage;

bStateAutoSpeed1: Indicates the status for automatic preselection of speed 1 if the operating mode eCtrlModeActuator is either eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP and speed 1 was activated via the input variable bAutoSpeed1.

bStateAutoSpeed2: Indicates the status for automatic preselection of speed 2 if the operating mode eCtrlModeActuator is either eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP and speed 2 was activated via the input variable bAutoSpeed2.

bStateAutoSpeed3: Indicates the status for automatic preselection of speed 3 if the operating mode eCtrlModeActuator is either eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP and speed 3 was activated via the input variable bAutoSpeed3.

bStateRepairSwitch: Indicates the state of the repair switch. TRUE indicates that the repair switch is switched off.

bStateManSwitch: Indicates the state of the manual/emergency switch. TRUE indicates that the manual/emergency operation level is activated.

eStateModeActuator: Enum via which the operating mode status of the motor is fed back to the controller.

bErrorGeneral: The error message bErrorGeneral becomes TRUE as soon as one of the error messages bErrorMotorprotecSpeed1, bErrorMotorprotecSpeed2, bErrorMotorprotecSpeed3, bErrorFeedbContactorSpeed1, bErrorFeedbContactorSpeed2, bErrorFeedbContactorSpeed23 or bErrorFeedbProcess = TRUE. The outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are then set to FALSE and are only enabled again when the error has been rectified and reset via bReset. After rectification of the error a restart of the motor is blocked for the duration of tDelaySpeed2ToSpeed1 + tDelaySpeed3ToSpeed2.

      wError: Delivers all error messages and warnings from the
function block.
wError.1 := bInvalidParameter;
wError.2 := bErrorGeneral;
wError.3 := bErrorMotorprotecSpeed1;
wError.4 := bErrorMotorprotecSpeed2;
wError.5 := bErrorMotorprotecSpeed3;
wError.6 := bErrorFeedbContactorSpeed1;
wError.7 := bErrorFeedbContactorSpeed2;
wError.8 := bErrorFeedbContactorSpeed3;
wError.9 := bErrorFeedbProcess;

bErrorMotorprotecSpeed1: Motor protection breaker error, see input variable bMotorProtecSpeed1.

bErrorMotorprotecSpeed2: Motor protection breaker error, see input variable bMotorProtecSpeed2.

bErrorMotorprotecSpeed3: Motor protection breaker error, see input variable bMotorProtecSpeed3.

bErrorFeedbContactorSpeed1: Power section feedback error, see input variable bFeedbContactorSpeed1.

If there is no feedback signal from the power section of the motor the output bMotorSpeed1 has to be connected to the input bFeedbContactorSpeed1. See application sample

bErrorFeedbContactorSpeed2: Power section feedback error, see input variable bFeedbContactorSpeed2.

If there is no feedback signal from the power section of the motor the output bMotorSpeed2 has to be connected to the input bFeedbContactorSpeed2. See application sample

bErrorFeedbContactorSpeed3: Power section feedback error, see input variable bFeedbContactorSpeed3.

If there is no feedback signal from the power section of the motor the output bMotorSpeed3 has to be connected to the input bFeedbContactorSpeed3. See application sample

bErrorFeedbProcess: Process feedback error, see input variable bFeedbackProcess

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables eCtrlModeActuator, tStartDelay, tStopDelay, tDelayFeedbContactorSpeed1, tDelayFeedbContactorSpeed2, tDelayFeedbContactorSpeed3, tFeedbProcessTimer, tDelayFeedbProcess, tDelaySpeed1, tDelaySpeed2, tDelaySpeed1ToSpeed2ToSpeed3, tDelaySpeed2ToSpeed1 or tDelaySpeed3ToSpeed2. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                             : Type       Persistent     Default             Range

tStartDelay                      : TIME;          X           t#0s           t#0s .. 3600s
tStopDelay                       : TIME;          X           t#0s           t#0s .. 3600s
tDelayFeedbContactorSpeed1       : TIME;          X           t#100ms        t#100ms .. 3600s
tDelayFeedbContactorSpeed2       : TIME;          X           t#100ms        t#100ms .. 3600s
tDelayFeedbContactorSpeed3       : TIME;          X           t#100ms        t#100ms .. 3600s
tFeedbProcessTimer               : TIME;          X           t#0s           t#0s .. 3600s
tDelayFeedbProcess               : TIME;          X           t#0s           t#0s .. 3600s
tDelaySpeed1                     : TIME;          X           t#3s           t#1s .. 3600s
tDelaySpeed2                     : TIME;          X           t#3s           t#1s .. 3600s
tDelaySpeed1ToSpeed2ToSpeed3     : TIME;          X           t#250ms        t#100ms .. 10s
tDelaySpeed2ToSpeed1             : TIME;          X           t#10s          t#1s .. 3600s
tDelaySpeed3ToSpeed2             : TIME;          X           t#10s          t#1s .. 3600s

tStartDelay: The start-up of the motor after enablement and switch-on via the operating mode of the motor is delayed by the time tStartDelay.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tStopDelay: The switching off of the motor in the respective switch-on speed, either by switching the enable bEnable to FALSE, or by switching off via the operating mode eCtrlModeActuator, or in automatic operating mode by switching the input variables bAutoSpeed1, bAutoSpeed2 and bAutoSpeed3 to FALSE, is delayed by the time tStopDelay. Once the delayed switch-off of the motor has been activated, it can no longer be aborted.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbContactorSpeed1: Time delay of the feedback of the power section after switching on the motor. If this time has elapsed and bFeedbContactorSpeed1 = FALSE, then this is fed back to the controller via the error message bErrorFeedbContactorSpeed1.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbContactorSpeed2: Time delay of the feedback of the power section after switching on the motor. If this time has elapsed and bFeedbContactorSpeed2 = FALSE, then this is fed back to the controller via the error message bErrorFeedbContactorSpeed2.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbContactorSpeed3: Time delay of the feedback of the power section after switching on the motor. If this time has elapsed and bFeedbContactorSpeed3 = FALSE, then this is fed back to the controller via the error message bErrorFeedbContactorSpeed3.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tFeedbackProcessTimer: Time delay of the process feedback bFeedbProcess during the motor ramp-up phase. If this time has elapsed and bFeedbProcess = FALSE, then this is fed back to the controller via the error message bErrorFeedbProcess.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelayFeedbProcess: In order to avoid undesired switching off of the drive during operation due to the process monitoring, e.g. in the event of short-term pressure fluctuations, the triggering of the input bFeedbProcess can be delayed by the time tDelayFeedbProcess.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelaySpeed1: Time delay for the motor ramp-up phase in speed 1.
After this time has elapsed the motor can be switched from the first to the second speed if the operating mode for speed 2 has been selected.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelaySpeed2: Time delay for the motor ramp-up phase in speed 2.
After this time has elapsed the motor can be switched from the second to the third speed if the operating mode for speed 3 has been selected.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tDelaySpeed1ToSpeed2ToSpeed3: Time delay for the motor switchover phase from speed 1 to speed 2, or from speed 2 to speed 3, so that the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are FALSE for a short while. The purpose of this time delay is to preserve the motor windings.
If no correct variable value is present, then the last valid variable value 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 entry.

tDelaySpeed2ToSpeed1: Time delay for the motor switchover phase from speed 2 to speed 1. In this phase the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are FALSE for the time period tDelaySpeed2ToSpeed1 in order to reduce the speed of the motor when switching to speed 1.
If no correct variable value is present, then the last valid variable value 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 entry.

tDelaySpeed3ToSpeed2: Time delay for the motor switchover phase from speed 3 to speed 2. In this phase the outputs bMotorSpeed1, bMotorSpeed2 and bMotorSpeed3 are FALSE for the time period tDelaySpeed2ToSpeed2 in order to reduce the speed of the motor when switching to speed 2.
If no correct variable value is present, then the last valid variable value 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 entry.


FB_HVACRedundancyCtrl

Application

This function block serves to control a certain number of actuators, e.g. 8 pumps. Of all enabled actuators, the logic searches for those with the lowest amount of working hours and switches them on according to the runtime order. This continues until the number specified via iCountCtrl is reached. The actuators are routed internally via a FIFO memory so that they can be switched off again in the same order. Changeover during operation can be performed with the time specification uiMaxOnLevel or by the trigger bForceChange. The actuator that has been switched on longest is switched off, and the one with the lowest working hours is switched on. In order to avoid a hydraulic stroke in the pumps, an overlap time can be set via tOverlap1Actuator. This applies only to cases where an change between two actuators takes place.
In order to determine the runtimes, the function block FB_HVACWork is instanced internally and the outputs are relayed to the outside (rHours and uiCount). The recording of the operating time is controlled by the bFeedBackx inputs. If no feedback signal from the actuator is available, the actuator output must be fed back to the feedback input.

VAR_INPUT

      Name                       : Type                               Range

eDataSecurityType          : E_HVACDataSecurityType;
bSetDefault                : BOOL;                              0 - 8
iCountCtrl                 : INT;
bEn1 - bEn8                : BOOL;
bFeedBack1 - bFeedBack8    : BOOL;
bForceChange               : BOOL;
dtSystemTime               : DT;
bSysTakt1Hz                : BOOL;
bResetAllHours             : BOOL;
bResetAllCounter           : BOOL;
bReset                     : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

iCountCtrl : Number of actuators to be switched on

bEn1 - 8: Enables the corresponding actuator.

bFeedBack1 - 8: Operating feedback from the actuator. Evaluation only takes place if tNoFeedbActuator > t#0s.

bForceChange: A rising edge at the input switches off the first actuator in the FIFO and switches on the actuator from the pool that has the shortest runtime.

dtSystemTime: System time.

bSysTakt1Hz: 1 Hz clock signal as a replacement for dtSystemTime; if dtSystemTime is not available, or does not change its value for longer than 2 sec, then the clock signal is used as a replacement.

bResetAllHours: Resets all working counters.

bResetAllCounter: Resets all switch-on counters.

bReset: Acknowledge input in the event of an error.

VAR_IN_OUT

      Name                     : Type          Persistent       Default          Range          Unit

tOverlap1Actuator         : TIME;             X             t#20s        t#0ms .. t#1m
uiMaxOnLevel              : UINT;             X             200              0 .. 1000      h
tNoFeedbActuator          : TIME;             X             t#3s         t#0ms .. t#60s

tOverlap1Actuator: Overlap time for the case where an exchange between two actuators takes place.

uiMaxOnLevel: Max. time in hours that an actuator may be switched on. Forces an actuator change only if an actuator is available to be switched on.

tNoFeedbActuator: Time that is allowed to elapse before the lack of an operating feedback from the actuator leads to bErrorGeneral = TRUE. There is no evaluation if the time = 0.

VAR_OUTPUT

      Name                    : Type

bQ1 - bQ8               : BOOL;
rHours1 - 8             : BOOL;
uiCount1 - 8            : UINT;
eErrorCode              : E_HVACErrorCodes;
bErrorGeneral           : BOOL;
bInvalidParameter       : BOOL;

bQ1 - 8: Actuator signals.

rHours1 - 8: Operating hours with a resolution of 1/100 hours (internally with 1 s).

uiCount1 - 8: Switch-on cycle counter.

eErrorCode: Indicates which actuator has not returned an operating feedback within the prespecified time interval. The recognition of this group of errors is activated by a time greater than 0 in the variable tNoFeedbActuator.

eHVACErrorCodes_Error_NoFeedbackActuator1 := 15,
eHVACErrorCodes_Error_NoFeedbackActuator2 := 16,
eHVACErrorCodes_Error_NoFeedbackActuator3 := 17,
eHVACErrorCodes_Error_NoFeedbackActuator4 := 18,
eHVACErrorCodes_Error_NoFeedbackActuator5 := 19,
eHVACErrorCodes_Error_NoFeedbackActuator6 := 20,
eHVACErrorCodes_Error_NoFeedbackActuator7 := 21,
eHVACErrorCodes_Error_NoFeedbackActuator8 := 22,

bErrorGeneral: Error during evaluation of the operating feedback.

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


FB_HVACRedundancyCtrlEx

Application

This function block serves to control a certain number of actuators, e.g. of pumps, from a pool of 8 actuators. From all enabled actuators, the logic searches for those with the shortest runtimes and switches them on according to the runtime order. This continues until the number specified via iCountCtrl is reached. The actuators are routed internally via a FIFO memory so that they can be switched off again in the same order. Changeover during operation can be performed with the time specification uiMaxOnLevel or by the trigger bForceChange. The actuator that has been switched on longest is switched off, and the one with the shortest runtime is switched on.°In order to avoid a water hammer in the pumps, an overlap time can be set via tOverlap1Actuator. This applies only to cases where an exchange between two actuators takes place.
In contrast to FB_HVACRedundancyCtrl no internal timer is used for determining the run times. Instead, the times have to be specified externally as hourly values via Var_input.

VAR_INPUT

      Name                       : Type                               Range

eDataSecurityType          : E_HVACDataSecurityType;
bSetDefault                : BOOL;                              0 - 8
iCountCtrl                 : INT;
bEn1 - bEn8                : BOOL;
bFeedBack1 - bFeedBack8    : BOOL;
bForceChange               : BOOL;
rHours1-rHours8            : REAL;

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:= e HVAC DataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention 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.

iCountCtrl : Number of actuators to be switched on

bEn1 - 8: Enables the corresponding actuator.

bFeedBack1 - 8: Operating feedback from the actuator. Evaluation only takes place if tNoFeedbActuator > t#0s.

bForceChange: A rising edge at the input switches off the first actuator in the FIFO and switches on the actuator from the pool that has the shortest runtime.

rHours: Operating hours

VAR_IN_OUT

      Name                     : Type          Persistent       Default          Range          Unit

tOverlap1Actuator        : TIME;           X                t#20s        t#0ms .. t#1m
uiMaxOnLevel             : UINT;           X                200              0 .. 1000     h
tNoFeedbActuator         : TIME;           X                t#3s         t#0ms .. t#60s

tOverlap1Actuator: Overlap time for the case where an exchange between two actuators takes place.

uiMaxOnLevel: Max. time in hours that an actuator may be switched on. Forces an actuator change only if an actuator is available to be switched on.

tNoFeedbActuator: Time that is allowed to elapse before the lack of an operating feedback from the actuator leads to bErrorGeneral = TRUE. There is no evaluation if the time = 0.

VAR_OUTPUT

      Name                    : Type

bQ1 - bQ8               : BOOL;
arrFiFo                 : ARRAY[1..8] of INT;
eErrorCode              : E_HVACErrorCodes;
bErrorGeneral           : BOOL;
bInvalidParameter       : BOOL;

bQ1 - 8: Actuator on signal.

arrFiFo: Overview with switch on actuators. Indicate the switch off order. For example: arrFiFo[1]:= number of the next switching off actuator

eErrorCode: Indicates which actuator has not returned an operating feedback within the prespecified time interval. The recognition of this group of errors is activated by a time greater than 0 in the variable tNoFeedbActuator.
eHVACErrorCodes_Error_NoFeedbackActuator1 :=
15,
eHVACErrorCodes_Error_NoFeedbackActuator2 := 16,
eHVACErrorCodes_Error_NoFeedbackActuator3 := 17,
eHVACErrorCodes_Error_NoFeedbackActuator4 := 18,
eHVACErrorCodes_Error_NoFeedbackActuator5 := 19,
eHVACErrorCodes_Error_NoFeedbackActuator6 := 20,
eHVACErrorCodes_Error_NoFeedbackActuator7 := 21,
eHVACErrorCodes_Error_NoFeedbackActuator8 := 22,

bErrorGeneral: Error during evaluation of the operating feedback.

bInvalidParameter: TRUE if an error has occurred during the plausibility check. The message must be aknowledged with bReset.


FB_HVACAnalogInput

Application

This function block serves the acquisition and scaling of analogue 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

      Name                     : Type

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 written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 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 TaskCycleTime. The function block uses this input variable to calculate internally whether the state and the output variables 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-up 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 measurement signal, so that this can be output at rPresentValue.

VAR_OUTPUT

      Name                    : Type

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

rPresentValue: Determined output value.

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

bError : The variable bError changes to TRUE in the event of an internal error in the function block.

eErrorCode: Contains the specific error code related to bError.

bErrorHighLimit: TRUE if the upper limit value has been 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 error as a 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 has occurred during the plausibility check. The message must be acknowledged with bReset.

VAR_IN_OUT

      Name             : Type            Persistent         Default          Range

iHighRange       : INT;                X               32767
iLowRange        : INT;                X                   0
rHighRange       : REAL;               X                 100
rLowRange        : REAL;               X                   0
rHighLimit       : REAL;               X                 100
rLowLimit        : REAL;               X                   0
tFilterTime      : TIME;               X                t#2s           0 .. 3600
rOffset          : REAL;               X                   0

iHighRange: Upper raw value of the input variable iRawValue.

iLowRange: Lower raw value of the input variable iRawValue.

rHighRange: The upper scaled measuring value.

rLowRange: The lower scaled measuring value.

rHighLimit: If the scaled measuring value is larger than the upper limit value rHighLimit, an impermissibly high measuring value can be reached. The function block announces this error by setting the variable bErrHighLimitto TRUE.

rLowLimit: If the scaled measuring value is smaller than the lower limit value rLowLimit, an impermissibly low measuring value can be reached. The function block announces this error by setting the variable bErrLowLimit to TRUE.

tFilterTime: To avoid large fluctuations and jumps in the measurement 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.

rOffset: With this offset the linear equation determined by means of the two conversion points is shifted parallel upwards or downwards.

With the two value pairs iHighRange/rHighRange and iLowRange/rLowRange, the raw value is linearly converted to the physical unit. 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


FB_HVACAnalogOutput

Application

This function block serves to control continuous actuators, such as valves or dampers, with positional feedback.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rSetpoint                : REAL;
bCtrlVoltage             : BOOL;
eCtrlModeAnalogOutput    : E_HVACAnalogOutputMode;
rYManual                 : REAL;
rFeedb                   : REAL;
bFrost                   : BOOL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Warning A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If the block is not enabled the value zero is written to the output rY.

rSetpoint: The set value for the analogue output is transferred to the function block with the variable rSetpoint.

bCtrlVoltage: The control voltage is present if the bCtrlVoltage variable is TRUE. The feedback control is deactivated in the event of failure of the control voltage so that no false alarms occur.

eCtrlModeAnalogOutput: Enum that specifies the operating mode.
TYPE E_HVACAnalogOutputMode :
(
eHVACAnalogOutputMode_Auto_BMS := 0,
eHVACAnalogOutputMode_Manual_BMS := 1,
eHVACAnalogOutputMode_Auto_OP := 2,
eHVACAnalogOutputMode_Manual_OP := 3
);
END_TYPE

rYManual: Analogue input value, which is relayed to the output rY in manual mode.

rFeedb: Analog positional feedback from the actuator.

bFrost: This input serves to protect an air heater against frost. As soon as the input bFrost is TRUE, rY is set to the maximum size (rRangeHigh) and iYTerminal to 32767. The outputs rY and iYTerminal remain set until the input bFrost is once again FALSE.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type                                Range

rY                        : REAL;                             0 .. 100%
iYTerminal                : INT;                              0 .. 32767
eStateModeAnalogOutput    : E_HVACAnalogOutputMode;
bManualMode               : BOOL;
byState                   : BYTE;
bErrorFeedb               : BOOL;
bErrorGeneral             : BOOL;
byError                   : BYTE;
bInvalidParameter         : BOOL;

rY: Shows the current size of the control signal in %.

iYTerminal: Represents the value of the output signal scaled to the value range 0 to 32767.

eStateModeAnalogOutput: Enum that specifies the operating mode.

bManualMode: The analog output is in manual operating mode.

      byState: Status byte indicating the operating status of
the function block.
byState.0 := bEnable;
byState.1 := bManualMode;
byState.2 := bFrost;
byState.7 := bCtrlVoltage;

bErrorFeedb: Error feedback signal.

bErrorGeneral: This is a collective message for all function block errors.

byError: Delivers all error messages and warnings.
byError.1 := bInvalidParameter
byError.2 := bErrorGeneral
byError.3 := bErrorFeedb

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

VAR_IN_OUT

      Name                      : Type                Range           Unit

rRangeHigh                : REAL;           0 .. 100           %
rRangeLow                 : REAL;           0 .. 100           %
bDirection                : BOOL;
bEnableFeedbCtrl          : BOOL;
rHysteresisFeedbCtrl      : REAL;           0 .. 32767
tDelayFeedbCtrl           : TIME;        t#0s .. t#50s

rRangeHigh/rRangeLow: These two variables define the value range of rY.

Example: rSetpoint = 100, rRangeLow = 0, rRangeHigh = 200,
==> rY = 50
==> rYTerminal = 16384

rSetpoint = 200, rRangeLow = 0, rRangeHigh = 200,
==> rY = 100
==> rYTerminal = 32767

bDirection: The output signal of rY is inverted by the variable bDirection. FALSE corresponds to the direct control direction.

bEnableFeedbCtrl: Continuous actuators often have positional feedback. The function of the actuator is monitored by means of the positional feedback. Positional feedback monitoring is activated if the variable bEnableFeedbCtrl is TRUE.

rHysteresisFeedbCtrl: Due to the stroke time of typical drives used in heating and air conditioning systems, the positional feedback always lags in the case of a jump in the set position value. Using the variable rHysteresisFeedbCtrl, a range is specified within which the set position value rY of the actuator can deviate from the feedback signal.

tDelayFeedbCtrl: If the difference between the set position and the actual position of the actuator is greater than +/- rHysteresisFeedbCtrl, then the activation of the output bErrorFeedb is delayed by the time of the timer tDelayFeedbCtrl.


FB_HVACAnalogOutputEx

Application

This function block serves to control continuous actuators, such as valves or dampers, with positional feedback.
In comparison with FB_HVACAnalogOutput include this function block a integrated scale function; y=m*x + b.

Application example:

Damper with a operating voltage 2-10V in connection with KL4404 (Signal voltage 0-10V)

rX1 = 0 iY1 = 6553
rX2 = 100 iY2 = 32767

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rSetpoint                : REAL;
bCtrlVoltage             : BOOL;
eCtrlModeAnalogOutput    : E_HVACAnalogOutputMode;
rYManual                 : REAL;
rFeedb                   : REAL;
bFrost                   : BOOL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If the block is not enabled the value zero is written to the output rY.

rSetpoint: The set value for the analogue output is transferred to the function block with the variable rSetpoint.

bCtrlVoltage: The control voltage is present if the bCtrlVoltage variable is TRUE. The feedback control is deactivated in the event of failure of the control voltage so that no false alarms occur.

eCtrlModeAnalogOutput: Enum that specifies the operating mode.
TYPE E_HVACAnalogOutputMode :
(
eHVACAnalogOutputMode_Auto_BMS := 0,
eHVACAnalogOutputMode_Manual_BMS := 1,
eHVACAnalogOutputMode_Auto_OP := 2,
eHVACAnalogOutputMode_Manual_OP := 3
);
END_TYPE

rYManual: Analogue input value, which is relayed to the output rY in manual mode.

rFeedb: Analog positional feedback from the actuator.

bFrost: This input serves to protect an air heater against frost. As soon as the input bFrost is TRUE, rY is set to the maximum size (rRangeHigh) and iYTerminal to 32767. The outputs rY and iYTerminal remain set until the input bFrost is once again FALSE.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type                                Range

rY                        : REAL;                             0 .. 100%
iYTerminal                : INT;                              0 .. 32767
eStateModeAnalogOutput    : E_HVACAnalogOutputMode;
bManualMode               : BOOL;
byState                   : BYTE;
bErrorFeedb               : BOOL;
bErrorGeneral             : BOOL;
byError                   : BYTE;
bInvalidParameter         : BOOL;

rY: Shows the current size of the control signal in %.

iYTerminal: Represents the value of the output signal scaled to the value range 0 to 32767.

eStateModeAnalogOutput: Enum that specifies the operating mode.

bManualMode: The analog output is in manual operating mode.

      byState: Status byte indicating the operating status of
the function block.
byState.0 := bEnable;
byState.1 := bManualMode;
byState.2 := bFrost;
byState.7 := bCtrlVoltage;

bErrorFeedb: Error feedback signal.

bErrorGeneral: This is a collective message for all function block errors.

byError: Delivers all error messages and warnings.
byError.1 := bInvalidParameter
byError.2 := bErrorGeneral
byError.3 := bErrorFeedb

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

VAR_IN_OUT

      Name                      : Type       Persistent             Range             Unit

rX2                       : REAL;          x            -32768 .. 32767
rX1                       : REAL;          x            -32768 .. 32767
iY2                       : INT;           x                 0 .. 32767
iY1                       : INT;           x                 0 .. 32767
bDirection                : BOOL;          x
bEnableFeedbCtrl          : BOOL;          x
rHysteresisFeedbCtrl      : REAL;          x                 0 .. 32767
tDelayFeedbCtrl           : TIME;          x              t#0s .. t#50s

rX2: Upper limit of the X-axis.

rX1: Lower limit of the X-axis.

iY2: Upper limit of the Y-axis.

iY1: Lower limit of the Y-axis.

bDirection: The output signal of rY is inverted by the variable bDirection. FALSE corresponds to the direct control direction.

bEnableFeedbCtrl: Continuous actuators often have positional feedback. The function of the actuator is monitored by means of the positional feedback. Positional feedback monitoring is activated if the variable bEnableFeedbCtrl is TRUE.

rHysteresisFeedbCtrl: Due to the stroke time of typical drives used in heating and air conditioning systems, the positional feedback always lags in the case of a jump in the set position value. Using the variable rHysteresisFeedbCtrl, a range is specified within which the set position value rY of the actuator can deviate from the feedback signal.

tDelayFeedbCtrl: If the difference between the set position and the actual position of the actuator is greater than +/- rHysteresisFeedbCtrl, then the activation of the output bErrorFeedb is delayed by the time of the timer tDelayFeedbCtrl.


FB_HVACAnalogTo3Point

Application

This function block serves to convert an analogue signal into a three-point step signal. Hence three-point dampers or valves can be controlled by a controller with a constant control signal. The function block FB_HVACAnalogTo3Point works with or without a constant positional feedback signal from the drive.

Example: 3-Point-Actuator without feedback and limit switches

VAR_INPUT

      Name                     : Type                                         Range

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rSetpoint                : REAL;                                      0.0 .. 32767
rFeedb                   : REAL;                                      0.0 .. 32767
bLimitSwitchOpen         : BOOL;
bLimitSwitchClose        : BOOL;
bCtrlVoltage             : BOOL;
bReset                   : BOOL;
tTaskCycleTime           : TIME;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If control voltage is present and there are no errors and bEnable = FALSE, then the output bCloseis TRUE and the output bOpen is FALSE. If the reference mode eReferencingMode = eHVACReferencingMode_Emulation, then the output bClose remains set until either the limit position is reached, the enable signal is present again or there is an error.
If the reference mode eReferencingMode = eHVACReferencingMode_AnalogFeedback, then the output bClose remains set until either the enable signal is present again, or there is an error or rFeedback = rMinSetpoint.

rSetpoint: The set value for the position of the flap or the valve is transferred to the function block with the variable rSetpoint. The value range for rSetpointis specified by the parameters rMaxSetpoint and rMinSetpoint.
If no correct variable value is present at rSetpoint, then the last valid variable value will be taken. If no valid last value exists, operation continues internally with rMinSetpoint. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

rFeedb: The input variable rFeedb is only active if the referencing mode of the function block eReferencingMode = eHVACReferencingMode_AnalogFeedback. The actual position of the drive is fed back with the scaled input signal rFeedb. The scaling of rFeedb must correspond to the scaling of rSetpoint. The value range for rSetpoint is specified by the parameters rMaxSetpoint and rMinSetpoint.rFeedb is fedback to the controller via the output variable rPosition.
If no correct variable value is present at rFeedb , then the last valid variable value will be taken. If no valid last value exists, operation continues internally with rMinSetpoint. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

bLimitSwitchOpen/bLimitSwitchClose: If the three-point actuator is equipped with limit position switches, these can be connected to the inputs bLimitSwitchOpen and bLimitSwitchClose.
The limit position switches serve as references for the function block in the referencing mode eReferencingMode = eHVACReferencingMode_Emulation. Depending on the driving direction the currently calculated position rPosition is automatically set to the corresponding value of rMaxSetpoint/rMinSetpoint by a falling edge on one of the two inputs bLimitSwitchOpen/bLimitSwitchClose. This also takes place when the drive is at a standstill.
Regardless of which referencing mode the function block is in, the associated output bOpen or bClose remains TRUE after the respective limit position switch has been reached.
The limit position switches must be connected to the function block as normally closed contacts. If none exists, a TRUE must be applied to the two inputs bLimitSwitchOpen/bLimitSwitchClose.

bCtrlVoltage: A check is made of whether control voltage is present via the input variable bCtrlVoltage. Both bOpen and bClose are set to FALSE in the event of failure of the control voltage. Since many error messages are based on the quiescent current principle, there would be a torrent of error messages following failure of the control voltage. Therefore all error messages are suppressed in the FB_HVACAnalogTo3Point in the event of control voltage failure.
The control voltage is present if a TRUE is present at the input bCtrlVoltage.

bReset: Acknowledge input in the event of an error.

tTaskCycleTime: Cycle time with which the function block is called. If the block is called in every cycle this corresponds to the task cycle time of the calling task.
If an incorrect time value of T#0 s is present on tTaskCycleTime, then tTaskCycleTime is set internally to T#1 ms. bInvalidParameter is set in the case of an incorrect variable value.

VAR_OUTPUT

      Name                     : Type

bOpen                    : BOOL;
bClose                   : BOOL;
byState                  : BYTE;
rPosition                : REAL;
bErrorGeneral            : BOOL;
byError                  : BYTE;
bErrorLimitSwitch        : BOOL;
bInvalidParameter        : BOOL;

bOpen: Output for opening the three-point drive.

bClose: Output for closing the three-point drive.

byState: Status byte indicating the operating status of the function block.
byState.0 := bEnable
byState.1 := bOpen
byState.2 := bClose
byState.3 := bLimitSwitchOpen
byState.4 := bLimitSwitchClose
byState.7 := bCtrlVoltage

rPosition: With rPosition either the measured or the calculated position of the drive is fed back to the controller.
If eReferencingMode = eHVACReferencingMode_AnalogFeedback, then rFeedb is fed back to the controller via the variable rPosition. If rFeedb > rMaxSetpoint, then rPosition = rMaxSetpoint and bInvalidParameter is set. If rFeedb < rMinSetpoint, then rPosition = rMinSetpoint and bInvalidParameter is set.
If eReferencingMode = eHVACReferencingMode_Emulation, then the actual position of the drive will be emulated on the basis of a calculation and fed back to the controller via rPosition.

bErrorGeneral: The error message bErrorGeneral becomes TRUE as soon as bErrorGeneralLimitSwitch = TRUE. The outputs bOpen and bClose are then set to FALSE and are only enabled again when the error has been rectified and acknowledged via bReset.

      byError: Delivers all error messages and warnings from
the function block.
byError.1 := bInvalidParameter
byError.2 := bErrorGeneral
byError.3 := bErrorLimitSwitch

bErrorLimitSwitch: Becomes TRUE if both limit position switches are activated simultaneously or if ((rMaxSetpoint - rThreshold) < rSetpoint) and bOpen = TRUE ) or if ((rMinSetpoint + rThreshold) > rSetpoint) and bClose = TRUE). The error bErrorLimitSwitch can only occur if eReferencingMode = eEmulation.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables rMinSetpoint, rMaxSetpoint, rThreshold, rTolerance, tPauseMin, tPauseMax, tInterval, tStrokeTime, tSwitchOverDeadTime, eReferencingMode, rSetpoint or rFeedback. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                    : Type                       Persistent       Default            Range

rMinSetpoint            : REAL;                          X              0.0             0 .. 32767
rMaxSetpoint            : REAL;                          X            100.0             0 .. 32767
rThreshold              : REAL;                          X              5.0         0.001 .. 32767
rTolerance              : REAL;                          X              2.0         0.001 .. 32767
tPauseMin               : TIME;                          X             t#2s          t#0s .. t#3600s
tPauseMax               : TIME;                          X             t#8s          t#0s .. t#3600s
tInterval               : TIME;                          X            t#10s          t#0s .. t#3600s
tStrokeTime             : TIME;                          X           t#200s          t#0s .. t#3600s
tSwitchOverDeadTime     : TIME;                          X           t#500ms         t#0s .. t#3600s
eReferencingMode        : E_HVACReferencingMode;         X               0              0 .. 1

rMinSetpoint/rMaxSetpoint: The value range for rSetpointis specified by the parameters rMaxSetpoint and rMinSetpoint.rMaxSetpoint must be greater than rMinSetpoint. In addition the two variables rMaxSetpoint and rMinSetpoint are integrated in the calculation of the variable pulse/pause modulation; see fig. 1.1.
If an incorrect variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

rThreshold/rTolerance: If the difference between the set position value rSetpoint and the calculated or measured actual position value rPosition of the actuator is greater than the threshold value set by the variable rThreshold, then the function block begins to correct the position by cycling the outputs bOpen and bClose, depending on the control deviation value. Correction continues until the deviation is smaller than the value rTolerance. A hysteresis loop for the opening and closing movement of the drive is defined by the value of rThreshold – rTolerance. This is necessary in order to prevent the drive reacting to the smallest changes of the control value. Wear on the drive and the relay is hence reduced. rThreshold must be greater than rTolerance.
rSetpoint - rPosition > = rThreshold: bOpen is activated
rPosition - rSetpoint > = rThreshold: bClose is activated
If an incorrect variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tPauseMin/tPauseMax/tInterval: A variable pulse/pause modulation for cycling the three-point drive can be set with the parameters tPauseMin, tPauseMax and tInterval. The pause length is defined as a function of the offset by the parameters tPauseMin and tPauseMax. In the case of a small deviation the pause time is long in relation to the interval time. Analogously, the pause time is short if the deviation is large. The effective driving speed of the three point drive is hence higher for larger offsets than it is for smaller ones; see fig. 1.1. The following condition must be met in all cases: tPauseMin < tPauseMax < tInterval
If an incorrect variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tStrokeTime: The variable tStrokeTime specifies the complete stroke time of the drive. If the drive has no constant positional feedback, then the actual position of the drive will be emulated on the basis of a calculation. For this reason the precise input of the total stroke time of the actuator is important. The following condition must be satisfied in all cases: tStrokeTime > tInterval
If an incorrect variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tSwitchOverDeadTime: Dwell time at a change of direction. Both outputs are reset during this period.
If an incorrect variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

eReferencingMode: Enum that specifies the referencing mode of the block.
Depending on the features of the actuator used, the position is referenced depending on eReferencingMode.
If eReferencingMode = eHVACReferencingMode_Emulation , the position of the drive will be calculated on the basis of the activation of bOpen and bClose by means of tStrokeTime. However, as the operating hours of the three-point valve or three-point flap increase, deviations could occur due to mechanical inaccuracies in the drive. In order to achieve automatic matching of the actual and calculated values, one of the outputs bOpen or bClose will be set to TRUE by rMaxSetpoint or rMinSetpoint upon reaching the calculated position rPosition and it is correspondingly given the value of the parameter rMaxSetpoint or rMinSetpoint. A falling edge on the signal inputs bLimitSwitchOpen and bLimitSwitchClose is used to reference the position of the drive to rMaxSetpoint or rMinSetpoint. The associated output bOpen or bClose remains at TRUE after the respective limit position switch has been reached.
If eReferencingMode = eHVACReferencingMode_AnalogFeedback, the position of the drive will be transferred on the basis of the signal rFeedback. The associated output bOpen or bClose remains at TRUE after the respective limit position switch has been reached.
If an incorrect variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

Figure 1.1

Example
tInterval | 120 seconds
tPauseMin | 10 seconds
tPauseMax | 60 seconds
rSetpoint | 100%
rPosition | 50%
tPauseInterval / bClose OR bOpen | 35 seconds/85 seconds
rSetpoint | 50%
rPosition | 25%
tPauseInterval / bClose OR bOpen | 47,5 seconds/72,5 seconds


FB_HVACConfigureKL32xx

Application

With the function block FB_HVACConfigureKL32xx, the type of sensor of a channel of the KL3201/02/04, KL3208-0010 or the KL3228 can be set from the PLC. To do this, the variables byStatusKL32xx, iDataInKL32xx, byCtrlKL32xx and iDataOutKL32xx must be linked in the TwinCAT System Manager with the variables Status, Data In, Control and Data Out of a channel of the KL3201/02/04 or the KL3228.
The resistor elements specified in Table 1 can be selected with the Enum eSensorType.
The KS2000 configuration software is no longer needed for setting the temperature sensor.

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 Ω.
The measurement of resistances from 10 to 10000 Ω is possible only with the special terminal KL320x-0027. Exclusively the resistance measurement 10 to 10000 Ω can be performed on this special terminal.
The EL3692 EtherCAT Terminal is a resistance measuring terminal that covers the measurement range up to 10 MΩ.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                     : Type

byStatusKL32xx           : BYTE;
iDataInKL32xx            : INT;
bSetSensor               : BOOL;
bScanSensor              : BOOL;
eSensorType              : E_HVACSensorType;
tTimeOut                 : TIME;

byStatusKL32xx: The status byte (Status) of the Bus Terminal must be assigned here in the TwinCAT System Manager for the respective channel. If this is not the case, then this is indicated as an error with bErrorCommunication if the function block has been activated with a rising edge on bSetSensor/bScanSensor. If scanning or setting has been concluded with a rising edge on bSetSensor/bScanSensor, then this is indicated with a TRUE on bReady and byOutStatus: = byStatusKL32xx. If scanning or setting is activated, bReady = FALSE, then the value of byStatusKL32xx present before activation is output on byOutStatus.

iDataInKL32xx: The raw value (Data In) of the Bus Terminal must be assigned here in the TwinCAT System Manager for the respective channel. If this is not the case, then this is indicated as an error with bErrorCommunication if the function block has been activated with a rising edge on bSetSensor/bScanSensor. If scanning or setting has been concluded with a rising edge on bSetSensor/bScanSensor, then this is indicated with a TRUE on bReady and iOutDataIn: = iDataInKL32xx. If scanning or setting is activated, bReady = FALSE, then the value of iDataInKL32xx present before activation is output on iOutDataIn.

bSetSensor: The type of sensor specified on the Enum eSensorType is set in the Bus Terminal with a rising edge on bSetSensor. If the procedure has been concluded, scanning is activated internally in the block and the type of sensor that has been set is indicated via the Enum eStatusScanSensorType.

bScanSensor: The scanning of the respective channel of the Bus Terminal is activated by a rising edge on bScanSensor. The type of sensor that has been set is indicated via the Enum eStatusScanSensorType.

eSensorType: Enum with which the sensor type for the respective channel is indicated via bSetSensor for setting.

tTimeOut: Specifies the time until the abortion of the function and bErrorCommunication goes TRUE. If no time is specified, then T#5s is used internally in the function block.

VAR_OUTPUT

      Name                                 : Type

bReady                               : BOOL;
byOutStatus                          : BYTE;
iOutDataIn                           : INT;
byCtrlKL32xx                         : BYTE;
iDataOutKL32xx                       : INT;
eBusTerminalKL32xx                   : E_HVACBusTerminal_KL32xx;
eStatusScanSensorType                : E_HVACSensorType;
bErrorGeneral                        : BOOL;
byError                              : BYTE;
bErrorCommunication                  : BOOL;
bErrorBusTerminalNotSupported        : BOOL;
bErrorSensorType                     : BOOL;
bErrorScanSensor                     : BOOL;

bReady: If the function block is activated via a rising edge on bSetSensor/bScanSensor, then bReady goes FALSE. If scanning or the setting of the type of sensor has been concluded, then bReady goes TRUE.

byOutStatus: If scanning or setting has been concluded with a rising edge on bSetSensor/bScanSensor, then this is indicated with a TRUE on bReady and byOutStatus: = byStatusKL32xx. If scanning or setting is activated, bReady = FALSE, then the value of byStatusKL32xx present before activation is output on byOutStatus.

iOutDataIn: If scanning or setting has been concluded with a rising edge on bSetSensor/bScanSensor, then this is indicated with a TRUE on bReady and iOutDataIn: = iDataInKL32xx. If scanning or setting is activated, bReady = FALSE, then the value of iDataInKL32xx present before activation is output on iOutDataIn.

byCtrlKL32xx: The control byte (Control) of the Bus Terminal must be assigned here in the TwinCAT System Manager for the respective channel. If this is not the case, then this is indicated as an error with bErrorCommunication if the function block has been activated with a rising edge on bSetSensor/bScanSensor.

iDataOutKL32xx: The data output (Data Out) of the Bus Terminal must be assigned here in the TwinCAT System Manager for the respective channel. If this is not the case, then this is indicated as an error with bErrorCommunication if the function block has been activated with a rising edge on bSetSensor/bScanSensor.

eBusTerminalKL32xx: Enum that displays the type of Bus Terminal if the function block has been activated with a rising edge on bSetSensor/bScanSensor.

eStatusScanSensorType: Enum that displays the type of sensor for the respective channel if the function block has been activated with a rising edge on bSetSensor/bScanSensor.

bErrorGeneral: Goes TRUE as soon as either bErrorCommunication, bErrorBusTerminalNotSupported, bErrorSensorType or bErrorScanSensor is TRUE.

      byError: Delivers all error messages and warnings from
the function block.
byError.2 := bErrorGeneral;
byError.3 := bErrorCommunication;
byError.4 := bErrorBusTerminalNotSupported;
byError.5 := bErrorSensorType;
byError.6 := bErrorScanSensor;

bErrorCommunication: Goes TRUE if, for example, the variables byCtrlKL32xx, iDataOutKL32xx, byStatusKL32xx and iDataInKL32xx have not been assigned to a channel of the Bus Terminal. Communication to the Bus Terminal is then interrupted during scanning or the setting of the type of sensor. bErrorCommunication likewise goes TRUE if the tTimeOut time is not sufficient when scanning or setting the sensor types.

bErrorBusTerminalNotSupported: Becomes TRUE if the Bus Terminal is not supported by the function block.

bErrorSensorType: Becomes TRUE if the type of sensor specified at eSensorType is not supported by the Bus Terminal.

bErrorScanSensor: Becomes TRUE if, when scanning, the type of sensor is not supported by the Bus Terminals specified in the Enum eBusTerminalKL32xx.

Table 1: Types of sensor selectable via the Enum eTemperatureCharacteristic
Sensor type | KL3201/2/4-0000 |  | KL3201/2/4-0010 |  | KL3201/2/4-0012 |  | KL3201/2/4-0014 |  | KL3201/2/4-0016 |  | KL3201/2/4-0020
 |  | raw value |  | raw value |  | raw value |  | raw value |  | raw value |  | raw value
PT100 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
PT200 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
PT500 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
PT1000 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
Ni100 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
Ni120 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
Ni1000(DIN) | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C
Ni1000(Tk5000,LS) | not supported |  | not supported |  | not supported |  | not supported |  | not supported |  | not supported |
Resistance measurement 10 to 1200 Ω | x |  | x |  | x |  | x |  | x |  | x |
Resistance measurement 10 to 5000 Ω | x |  | x |  | x |  | x |  | x |  | x |
Resistance measurement 10 to 10000 Ω | not supported |  | not supported |  | not supported |  | not supported |  | not supported |  | not supported |
Sensor type | KL3201/2/4-0023 |  | KL3201/2/4-0025 |  | KL3201/2/4-0029 |  | KL3201/2/4-0031 |  | KL3228 |  | KL3208-0010
 |  | raw value |  | raw value |  | raw value |  | raw value |  | raw value |  | raw value
PT100 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | not supported |  | not supported |
PT200 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | not supported |  | not supported |
PT500 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | not supported |  | not supported |
PT1000 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/100°C
Ni100 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | not supported |  | not supported |
Ni120 | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | not supported |  | not supported |
Ni1000(DIN) | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/10°C | x | 1/100°C
Ni1000(Tk5000,LS) | not supported |  | not supported |  | x | 1/10°C | not supported |  | x | 1/10°C | x | 1/100°C
Resistance measurement 10 to 1200 Ω | x |  | x |  | x |  | x |  | not supported |  | not supported |
Resistance measurement 10 to 5000 Ω | x |  | x |  | x |  | x |  | not supported |  | not supported |
Resistance measurement 10 to 10000 Ω | not supported |  | not supported |  | not supported |  | not supported |  | not supported |  | not supported |


FB_HVACScale

Application

A raw analog signal value is scaled to the specified range of measurements and returned as the function value. If the value of the raw signal extends beyond the upper or lower measurement range, the corresponding limit value is output. There must be a difference of at least 0.01 between the upper and lower limit values for the raw data. If this is not the case, the lower limit value is output. The difference between the limit values is necessary to avoid a division through zero during the internal calculation of the linear equation.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
rRawData                 : REAL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

rRawData: Raw value from the terminal.

VAR_OUTPUT

      Name                     : Type

rScaledValue             :  REAL;

rScaledValue: Scaled value.

VAR_IN_OUT

      Name                     : Type         Persistent     Default

rRawDataLowOffLimit      :  REAL;           X            0.0
rRawDataHighOffLimit     :  REAL;           X        32767.0
rScaleDataLowOffLimit    :  REAL;           X            0
rScaleDataHighOffLimit   :  REAL;           X          100

rRawDataLowOffLimit: Lower limit for raw data.

rRawDataHighOffLimit: Upper limit for raw data.

rScaleDataLowOffLimit: Lower limit for scaled measured value.

rScaleDataHighOffLimit: Upper limit for scaled measured value.

Example in FBD:


FB_HVACScale_nPoint

Application

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 curve are specified by the structure stParameterScale_nPoint.
Analogue 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.

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 Ω.
The measurement of resistances from 10 to 10000 Ω is possible only with the special terminal KL320x-0027. Exclusively the resistance measurement 10 to 10000 Ω can be performed on this special terminal.
The EL3692 EtherCAT Terminal is a resistance measuring terminal that covers the measurement range up to 10 MΩ.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                                : Type

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. 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 to 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 to iNumberOfPoint] – array containing the valency of the individual points on the Y axis. The number of points specified depends on iNumberOfPoint.

VAR_OUTPUT

      Name                                : Type

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: Status of the structure stParameterScale_nPoint. If bErrorNumberOfPoint or bErrorParamter = TRUE, then the status of the individual parameters in the structure stStateParameterScale_nPoint = 0. If stParameterScale_nPoint.iNumberofPoint = 20, then the individual parameters of stStateParameterScale_nPoint.rX[1 to 20] / stStateParameterScale_nPoint.rY[1 to 20] are displayed; from 21 to 60 the status = 0.

bErrorNumberOfPoint: If iNumberOfPoint < 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: When parameterising the structure stScaleTemperatureCharacteristic, care must be taken 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

      Name                                : Type

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.

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

m =  rM = gradient
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

m =  rM = gradient
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_HVACTemperatureCurve

Application

A temperature curve stored internally in the function block is selected from Tables 1 and 2 via the Enum eTemperatureCurve and output via the structure stParameterScale_nPoint. Curves can be reproduced with this structure in conjunction with the function block FB_HVACScale_nPoint. In order to arrive at the raw resistance value of a sensor, the KL32xx Bus Terminals must be set to resistance measurement; see FB_HVACConfigureKL32xx.

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 Ω.
The measurement of resistances from 10 to 10000 Ω is possible only with the special terminal KL320x-0027. Exclusively the resistance measurement 10 to 10000 Ω can be performed on this special terminal.
The EL3692 EtherCAT Terminal is a resistance measuring terminal that covers the measurement range up to 10 MΩ.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                                : Type

eTemperatureCurve                   : E_HVACTemperatureCurve;

eTemperatureCurve: Enum via which a temperature curve can be selected from Tables 1 and 2, which are stored internally in the function block.

VAR_OUTPUT

      Name                                : Type

stParameterScale_nPoint             : ST_HVACParameterScale_nPoint;

stParameterScale_nPoint: Structure containing the number and valences of the points of the XY coordinates. stParameterScale_nPoint contains the curves stored in Tables 1 and 2, depending on the specification via the Enum eTemperatureCurve.

Example: eTemperatureCurve = eHVACTemperatureCurve_Ni1000Tk5000_TCR
stParameterScale_nPoint.iNumberOfPoint := 56;
stParameterScale_nPoint.rX[1] := 790.8;
stParameterScale_nPoint.rY[1] := -50.0;
stParameterScale_nPoint.rX[2] := 826.8;
stParameterScale_nPoint.rY[2] := -40.0;
 .
.
.
stParameterScale_nPoint.rX[56] := 1625.4;
stParameterScale_nPoint.rY[56] := 120.0;
stParameterScale_nPoint.rX[57] := 0;
stParameterScale_nPoint.rY[57] := 0;
 .
.
.
stParameterScale_nPoint.rX[60] := 0;
stParameterScale_nPoint.rY[60] := 0;

Table 1: Specified temperature curves, selectable via the Enum eTemperatureCurve

 | S+S Sensor type 1K3 A1 NTC 1 kOhm | S+S Sensor type 1.8K3 A1 NTC 1.8 kOhm | S+S Sensor type 2.2K3 A1 NTC 2.2 kOhm | S+S Sensor type 3.3K3 A1 NTC 3 kOhm | S+S Sensor type NI1000 DIN | S+S Sensor type PT1000 DIN | S+S Sensor type Ni1000/TCR (LAN1) Ni1000Tk5000
eHVACTemperatureCharacteristic_ | NTC1k_3_A1 | NTC1k8_3_A1 | NTC2k2_3_A1 | NTC3k3_3_A1 | Ni1000_DIN | Pt1000_DIN | Ni1000Tk5000_TCR
°C | Ω | Ω | Ω | Ω | Ω | Ω | Ω
- 50 | 32886 |  |  |  | 743 | 803 | 790.8
- 40 | 18641 |  |  |  | 791 | 843 | 826.8
- 30 | 11130 | 21695 | 27886 | 53093 | 842 | 882 | 871.7
- 20 | 6777 | 12987 | 16502 | 29125 | 893 | 922 | 913.4
- 15 | 5341 | 10153 | 12844 | 21887 | 920 | 941 | 934.7
- 10 | 4247 | 8011 | 10070 | 16599 | 946 | 961 | 956.2
- 5 | 3390 | 6347 | 8134 | 12698 | 973 | 980 | 978
0 | 2728 | 5071 | 6452 | 9795 | 1000 | 1000 | 1000
1 | 2613 | 4851 | 6164 | 9309 |  |  | 1004.4
2 | 2503 | 4640 | 5891 | 8849 |  |  | 1008.9
3 | 2399 | 4441 | 5631 | 8415 |  |  | 1013.3
4 | 2300 | 4252 | 5384 | 8005 |  |  | 1017.8
5 | 2205 | 4071 | 5150 | 7617 | 1028 | 1020 | 1022.3
6 | 2115 | 3899 | 4927 | 7251 |  |  | 1026.7
7 | 2030 | 3738 | 4715 | 6905 |  |  | 1031.2
8 | 1948 | 3582 | 4513 | 6575 |  |  | 1035.8
9 | 1870 | 3434 | 4321 | 6265 |  |  | 1040.3
10 | 1796 | 3294 | 4138 | 5971 | 1056 | 1039 | 1044.8
11 | 1724 | 3158 | 3964 | 5691 |  |  | 1049.3
12 | 1656 | 3029 | 3797 | 5427 |  |  | 1053.9
13 | 1590 | 2905 | 3639 | 5177 |  |  | 1058.4
14 | 1528 | 2788 | 3488 | 4938 |  |  | 1063
15 | 1469 | 2677 | 3345 | 4713 | 1084 | 1058 | 1067.6
16 | 1412 | 2570 | 3207 | 4500 |  |  | 1072.2
17 | 1358 | 2468 | 3076 | 4298 |  |  | 1076.8
18 | 1306 | 2371 | 2952 | 4104 |  |  | 1081.4
19 | 1256 | 2277 | 2832 | 3922 |  |  | 1086
20 | 1209 | 2189 | 2719 | 3747 | 1112 | 1078 | 1090.7
21 | 1163 | 2103 | 2610 | 3582 |  |  | 1095.3
22 | 1120 | 2023 | 2506 | 3426 |  |  | 1100
23 | 1078 | 1945 | 2407 | 3277 |  |  | 1104.6
24 | 1038 | 1871 | 2289 | 3135 |  |  | 1109.3
25 | 1000 | 1800 | 2200 | 3000 | 1142 | 1098 | 1114
26 | 963 | 1732 | 2115 | 2872 |  |  | 1120
27 | 928 | 1667 | 2034 | 2750 |  |  | 1123.4
28 | 894 | 1604 | 1957 | 2634 |  |  | 1128.1
29 | 862 | 1545 | 1883 | 2522 |  |  | 1132.9
30 | 831 | 1488 | 1812 | 2417 | 1171 | 1117 | 1137.6
35 | 694 | 1235 | 1500 | 1960 | 1200 | 1136 | 1161.5
40 | 583 | 1031 | 1248 | 1597 | 1230 | 1155 | 1185.7
45 | 491 | 865 | 1043 | 1310 | 1261 | 1175 | 1210.2
50 | 416 | 729 | 876 | 1081 | 1291 | 1194 | 1235
55 | 354 | 616 | 738 | 896 | 1322 | 1213 | 1260.1
60 | 302 | 524 | 626 | 746 | 1353 | 1232 | 1285.4
65 | 259 | 447 | 532 | 625 | 1385 | 1252 | 1311.1
70 | 223 | 383 | 454 | 526 | 1417 | 1271 | 1337.1
75 | 192 | 329 | 390 | 444 | 1450 | 1290 | 1363.5
80 | 167 | 284 | 335 | 346 | 1483 | 1309 | 1390.1
85 | 145 | 246 | 289 | 321 | 1516 | 1328 | 1417.1
90 | 127 | 214 | 251 | 275 | 1549 | 1347 | 1444.4
95 | 111 | 187 | 218 | 236 | 1584 | 1366 | 1472
100 | 97 | 163 | 190 | 204 | 1618 | 1385 | 1500
105 | 88 | 143 | 167 | 176 |  |  | 1528.3
110 | 76 | 126 | 146 | 138 | 1688 | 1423 | 1557
115 |  | 111 |  | 120 |  |  | 1586
120 |  | 99 |  | 105 | 1760 | 1461 | 1625.4
125 |  | 88 |  | 92 |  |  |
130 |  | 80 |  | 81 | 1833 | 1498 |
140 |  | 62 |  | 64 | 1909 | 1536 |
150 |  | 50 |  | 50 | 1987 | 1573 |
160 |  |  |  |  | 2066 | 1611 |
170 |  |  |  |  | 2148 | 1648 |
180 |  |  |  |  | 2232 | 1685 |
190 |  |  |  |  |  | 1722 |
200 |  |  |  |  |  | 1758 |
210 |  |  |  |  |  | 1795 |
220 |  |  |  |  |  | 1832 |
230 |  |  |  |  |  | 1868 |
240 |  |  |  |  |  | 1905 |
250 |  |  |  |  |  | 1941 |
260 |  |  |  |  |  | 1977 |
270 |  |  |  |  |  | 2013 |
280 |  |  |  |  |  | 2049 |
290 |  |  |  |  |  | 2085 |
300 |  |  |  |  |  | 2121 |
310 |  |  |  |  |  | 2156 |
320 |  |  |  |  |  | 2191 |
330 |  |  |  |  |  | 2227 |
340 |  |  |  |  |  | 2262 |
350 |  |  |  |  |  | 2297 |
360 |  |  |  |  |  | 2332 |
370 |  |  |  |  |  | 2367 |
380 |  |  |  |  |  | 2401 |
390 |  |  |  |  |  | 2436 |
400 |  |  |  |  |  | 2470 |

Table 2: Specified temperature curves, selectable via the Enum eTemperatureCurve

 | Thermokon Sensor type NTC 1.8 kOhm | Thermokon Sensor type Ni1000 Tk5000
eHVACTemperatureCharacteristic_ | NTC1k8 | Ni1000Tk5000
°C | Ω | Ω
- 50 |  | 790.88
- 40 |  | 830.83
- 30 | 24500 | 871.69
- 20 | 14000 | 913.48
- 10 | 8400 | 956.24
0 | 5200 | 1000
10 | 3330 | 1044.79
20 | 2200 | 1090.65
25 | 1800 | 1113.99
30 | 1480 | 1137.61
40 | 1040 | 1185.71
50 | 740 | 1234.97
60 | 540 | 1285.44
70 | 402 | 1337.14
80 | 306 | 1390.12
90 | 240 | 1444.39
100 | 187 | 1500
110 | 149 | 1556.98
120 | 118 | 1615.36
130 | 95 | 1675.18
140 | 77 | 1736.47
150 | 64 | 1799.26


FB_HVACTemperatureSensor

Application

This function block serves the acquisition and further processing of temperature values for types PT100, PT200, PT1000, NI100, NI120 and NI1000. The FB_HVACTemperatureSensor is matched to the KL320x bus terminals. This bus terminals can be ordered preconfigured or it is possible to adjust the sensor type by software.

VAR_INPUT

      Name                           : Type

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 written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 fault diagnosis, e.g. wire breakage or short circuit.

tTaskCycleTime: Cycle time with which the function block is called. If the 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 measurement signal, so that this can be output at rPresentValue.

VAR_OUTPUT

      Name                      : Type

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 operating 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 then depends on the operating mode eTemperatureSensorMode and is enabled once the error has been rectified and, depending on the operating mode, reset 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 := bErrorCycleTime

bErrorShortCircuit: Short circuit in the connected temperature sensor. After rectification of the error, reset depends on the operating mode.

bErrorBrokenSensor: Wire breakage in the connected temperature sensor. After rectification of the error, reset depends on the operating 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 reset if rPresentValue <= rHighLimit - 1.0 for a period 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 reset if rPresentValue >= rLowLimit + 1.0 for a period of 5 seconds.

bErrorCycleTime: Error caused by an incorrect time input at the input variables tTaskCycleTime and tCtrlCycleTime, which must by reset after correcting the error.

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

VAR_IN_OUT

      Name                            : Type                       Persistent        Default              Range

rOffset                         : REAL;                          X               0.0           -50.0 .. 50.0
rHighLimit                      : REAL;                          X             120.0          -250.0 .. 850.0
rLowLimit                       : REAL;                          X             -60.0          -250.0 .. 850.0
rReplacementValue               : REAL;                          X               0.0          -250.0 .. 850.0
tFilterTime                     : TIME;                          X             t#10s           t#1ms .. t#100s
eTemperatureSensorMode          : E_HVACTemperatureSensorMode;   X               3                 0 .. 3

rOffset: Temperature offset in Kelvin, rPresentValue = (iRawValue / 10.0) + rOffset.
If no correct variable value is present, then the last valid variable value 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 entry.

rHighLimit: Upper limit value; the output bErrorHighLimit is set if rPresentValue >= rHighLimit. rHighLimitmust be larger than rLowLimit.
If no correct variable value is present, then the last valid variable value 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 entry.

rLowLimit: Lower limit value; the output bErrorLowLimit is set if rPresentValue <= rLowLimit.
If no correct variable value is present, then the last valid variable value 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 entry.

rReplacementValue: Replacement value that is output at rPresentValue in case of the error bErrorShortCircuit and bErrorBrokenSensor if the selected operating mode eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue or eHVACTemperatureSensorMode_AutoResetReplacementValue.
If no correct variable value is present, then the last valid variable value 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 entry.

tFilterTime: Filter constant. To avoid large fluctuations and jumps in the measurement signal, the function block is provided with a 2nd order filter. Upon a restart of the controller, or following rectification of the error bErrorShortCircuit or bErrorBrokenSensor, the 2nd order filter is synchronized immediately and additionally after 2 seconds with the present measurement signal, so that the latter is output at rPresentValue. The measurement signal can be synchronized via the input bReset during running operation.
If no correct variable value is present, then the last valid variable value 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 entry.

eTemperatureSensorMode: Enum that specifies the operating mode of the block.
eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue: If bErrorShortCircuit or bErrorBrokenSensor = TRUE, then rPresentValue = rReplacementValue. After rectification of the error, the function block must be reset 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 rectification of the error, it must be reset with a rising edge at the input variable bReset.
eTemperatureSensorMode = eHVACTemperatureSensorMode_AutoResetReplacementValue : If bErrorShortCircuit or bErrorBrokenSensor = TRUE, then rPresentValue = rReplacementValue. The function block resets itself automatically following rectification 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 resets itself automatically following rectification of the error.
If no correct variable value is present, then the last valid variable value 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 entry.


FB_HVACTemperatureSensorEx

Application

This function block is used for recording and subsequent processing of temperature values, e.g. for the sensor types PT100, PT200, PT1000, NI100, NI120, NI1000, NI1000Tk5000. The function block FB_HVACTemperatureSensorExis 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 can, for example, 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 will be TRUE, then is for one PLC cycle rPresentValue = rPresentValueOld. If bErrorSensor is TRUE, the fault has been rectified and bErrorSensor = FALSE, then is for one PLC cycle rPresentValue = rPresentValueOld.

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.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                           : Type

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 internally deallocated.

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:= e HVAC DataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention 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 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 will be TRUE, then is for one PLC cycle rPresentValue = rPresentValueOld.

iRawValue: Raw value of the temperature probe in 1/10 °C from the bus terminal.

byStatusRawValue: Status byte of the temperature probe from the bus terminal. Serves for fault diagnosis, e.g. wire breakage or short circuit. If the KL32xx is set to resistance measurement (ohm) 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

      Name                      : Type

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. rPresentValueOld is the value of rPresentValue that was output in the previous PLC cycle. If bEnable will be TRUE, then is for one PLC cycle rPresentValue = rPresentValueOld. If bErrorSensor is TRUE, the fault has been rectified and bErrorSensor = FALSE, then is for one PLC cycle rPresentValue = rPresentValueOld.
If bErrorSensor = TRUE, the value of rPresentValue depends on mode eTemperatureSensorMode.

bErrorGeneral: The error message bErrorGeneral becomes TRUE if one of the error messages bErrorHighLimit, bErrorLowLimit or bErrorSensor is TRUE . The value of the output variable rPresentValue is then dependent on the operating mode°° eTemperatureSensorMode and is enabled once the error has been rectified and depending on the operating mode eTemperatureSensorMode was 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 rectified, the message is acknowledge 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 rectified, the message is acknowledge 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 rectified, the message is acknowledge either with bReset or automatically, depending on mode eTemperatureSensorMode. If bErrorSensor is TRUE, the fault has been rectified and bErrorSensor = FALSE, then is for one PLC cycle rPresentValue = rPresentValueOld.

bErrorHighLimit: Warning upper limit value exceeded; becomes TRUE if rPresentValue >= rHighLimit. The warning that the upper limit value has been exceeded can only be reset 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; becomes TRUE if rPresentValue <= rLowLimit.°The warning that the lower limit value has been undershot can only be reset 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 block; see description of variables. Once the incorrect parameter specification has been rectified, the message bInvalidParameter is acknowledged either with bReset or automatically, depending on mode eTemperatureSensorMode.

VAR_IN_OUT

      Name                            : Type                       Persistent        Default              Range

rOffset                         : REAL;                          X               0.0
rHighLimit                      : REAL;                          X             120.0
rLowLimit                       : REAL;                          X             -60.0
rReplacementValue               : REAL;                          X               0.0
rSmoothFactor                   : REAL;                          X             100.0                  >= 1.0
eTemperatureSensorMode          : E_HVACTemperatureSensorMode;   X               3                  0 .. 3

rOffset: Temperature compensation in Kelvin, rPresentValue = (iRawValue / 10.0) + rOffset.

rHighLimit: Upper limit value. 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. 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 error bErrorShortCircuit and bErrorBrokenSensor if the selected operating mode eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue or eHVACTemperatureSensorMode_AutoResetReplacementValue.

rSmoothFactor: Smoothing factor for output value rPresentValue.
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 operating mode of the block.
eTemperatureSensorMode = eHVACTemperatureSensorMode_ReplacementValue: If bErrorSensor = TRUE, then rPresentValue = rReplacementValue. After rectification 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 rectification of the error, it must be reset 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 rectification 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 rectification 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.


FB_HVACTemperatureSensorEx

Application

This function block is used for recording and subsequent processing of temperature values, e.g. for the sensor types PT100, PT200, PT1000, NI100, NI120, NI1000, NI1000Tk5000. The function block FB_HVACTemperatureSensorExis adapted to the Bus Terminals KL3201/02/04, KL3208-0010 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 or 1/100°C via the input variable iRawValue and output as a floating-point number via rPresentValue . iRawValue can, for example, be linked directly with the raw temperature value of the following Bus Terminals: KL3201/02/04, KL3208-0010 and KL3228.

The output value rPresentValue depends on the following smoothing function:

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 will be TRUE, then is for one PLC cycle rPresentValue = rPresentValueOld. If bErrorSensor is TRUE, the fault has been rectified and bErrorSensor = FALSE, then is for one PLC cycle rPresentValue = rPresentValueOld.

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, KL3208-0010 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, KL3208-0010 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 udiError.

In contrast to FB_HVACTemperatureSensorEx can be passed to this function module sensors with the temperature raw value 1 / 10 or 1 / 100 ° C.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                           : Type                      Range

eDataSecurityType              : E_HVACDataSecurityType;
bSetDefault                    : BOOL;
bEnable                        : BOOL;
iRawValue                      : INT;
byStatusRawValue               : BYTE;
iConversionFactor              : INT;                      0..1
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 internally deallocated.

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:= e HVAC DataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention 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 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 will be TRUE, then is for one PLC cycle rPresentValue = rPresentValueOld.

iRawValue: Raw value of the temperature probe in 1/10 or 1/100°C from the bus terminal.

byStatusRawValue: Status byte of the temperature probe from the bus terminal. Serves for fault diagnosis, e.g. wire breakage or short circuit. If the KL32xx is set to resistance measurement (ohm) there is no fault diagnosis.

iConversionFactor: Conversion factor for the output variable rPresentValue.

iConversionFactor = 0: rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;

iConversionFactor = 1: rPresentValue := ((iRawValue / 100 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;

If you specify a value of at iConversionFactor outside his range 0 to 1, so 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 from bReset. Depending on mode iTemperatureSensorMode, errors are acknowledged either with bReset or automatically.

VAR_OUTPUT

      Name                      : Type

rPresentValue             : REAL;
bErrorGeneral             : BOOL;
udiError                  : UDINT;
bErrorSensor              : BOOL;
bErrorHighLimit           : BOOL;
bErrorLowLimit            : BOOL;
bInvalidParameter         : BOOL;

rPresentValue: Temperature output variable with two decimal place.
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. rPresentValueOld is the value of rPresentValue that was output in the previous PLC cycle. If bEnable will be TRUE, then is for one PLC cycle rPresentValue = rPresentValueOld. If bErrorSensor is TRUE, the fault has been rectified and bErrorSensor = FALSE, then is for one PLC cycle rPresentValue = rPresentValueOld.
If bErrorSensor = TRUE, the value of rPresentValue depends on mode iTemperatureSensorMode .

bErrorGeneral: The error message bErrorGeneral becomes TRUE if one of the error messages bErrorHighLimit, bErrorLowLimit or bErrorSensor is TRUE . The value of the output variable rPresentValue is then dependent on the operating mode iTemperatureSensorMode and is enabled once the error has been rectified and depending on the operating mode iTemperatureSensorMode was 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 rectified, the message is acknowledge 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 rectified, the message is acknowledge either with bReset or automatically, depending on mode iTemperatureSensorMode.

bErrorSensor: Becomes TRUE if byError.5/bErrorShortCircuit or byError.6/bErrorBrokenSensor is TRUE. Once the fault has been rectified, the message is acknowledge either with bReset or automatically, depending on mode iTemperatureSensorMode. If bErrorSensor is TRUE, the fault has been rectified and bErrorSensor = FALSE, then is for one PLC cycle rPresentValue = rPresentValueOld.

bErrorHighLimit: Warning upper limit value exceeded; becomes TRUE if rPresentValue >= rHighLimit. The warning that the upper limit value has been exceeded can only be reset 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; becomes TRUE if rPresentValue <= rLowLimit.°The warning that the lower limit value has been undershot can only be reset 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 you specify a value of at iConversionFactor outside his range 0 to 1, so this is signaled by bErrorConversionFactor = TRUE. The message is not mandatory acknowledgment by removing the cause.

bInvalidParameter: Indicates that there is an incorrect parameter to one of the variables rHighLimit, rLowLimit, rSmoothFactor or iTemperatureSensorMode . An incorrect parameter specification does not lead to a standstill of the block; see description of variables. Once the incorrect parameter specification has been rectified, the message bInvalidParameter is acknowledged either with bReset or automatically, depending on mode iTemperatureSensorMode .

VAR_IN_OUT

      Name                            : Type                       Persistent        Default              Range

rOffset                         : REAL;                          X               0.0
rHighLimit                      : REAL;                          X             120.0
rLowLimit                       : REAL;                          X             -60.0
rReplacementValue               : REAL;                          X               0.0
rSmoothFactor                   : REAL;                          X             100.0                  >= 1.0
iTemperatureSensorMode          : INT;                           X               3                  0 .. 3

rOffset: Temperature compensation in Kelvin.

iConversionFactor = 0: rPresentValue := ((iRawValue / 10 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;

iConversionFactor = 1: rPresentValue := ((iRawValue / 100 + rOffset) - rPresentValueOld) / rSmoothFactor + rPresentValueOld;

rHighLimit: Upper limit value. 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. 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 error bErrorShortCircuit and bErrorBrokenSensor if the selected operating mode iTemperatureSensorMode = 0 or 2.

rSmoothFactor: Smoothing factor for output value rPresentValue.
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: Sets the operating mode of the block.
iTemperatureSensorMode = 0: If bErrorSensor = TRUE, then rPresentValue = rReplacementValue. After rectification 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 rectification of the error, it must be reset 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 rectification 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 rectification of the error.
If an incorrect variable value is present at iTemperatureSensorMode , the default value is used. bInvalidParameter is set in the case of an incorrect parameter specification.


FB_BAREnergyLevel

Application

The function block serves the adaptation of the energy output according to the requirement of the building. The room usage is defined by the room management system. The longer a building or room is not used, the further the energy level can be lowered. The functionblock selects the energy level. This current energy level is transferred to the room temperature control.

Protection:

This operating mode is activated in the case of long absence times e.g. during works holidays or also when a window is open. The energy level is very low and serves only to protect the building from damage caused by frost or overheating.

Economy:

The Economy energy level is for an unused room that will only be occupied again in a few hours. Economy mode is activated, for example, at night by a time scheduler.

PreComfort:

The Pre-comfort energy level is for an unused room which, however, can be occupied again shortly. It is often activated by a time scheduler.

Comfort:
If the room is occupied, it is in Comfort mode. Comfort mode can be activated by a time scheduler or directly by presence recognition.

VAR_INPUT

 Name                                : Type

eDataSecurityType                   : E_HVACDataSecurityType;
bSetDefault                         : BOOL;
bEnable                             : BOOL;
bWindow                             : BOOL;
bProtection                         : BOOL;
bEconomy                            : BOOL;
bPreComfort                         : BOOL;
bComfort                            : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Warning A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE

bWindow: This input is connected to the window contact. The window is OPEN if bWindow = TRUE. The window is CLOSED if bWindow = FALSE.

bProtection: This input enables the Protection mode. The Protection mode is active if bProtection=TRUE.

bEconomy: This input enables the Economy. The Economy mode is active if bEconomy =TRUE.

bPreComfort: This input enables PreComfort. The PreComfort mode is active if bPreComfort = TRUE

bComfort: If the room is occupied, this input enables Comfort mode.

VAR_OUTPUT

 Name                          : Type

eEnergyLevel                  : E_BAREnergyLevel;
bStateProtection              : BOOL;
bStateEconomy                 : BOOL;
bStatePreComfort              : BOOL;
bStateComfort                 : BOOL;

eEnergyLevel: This output contains the current energy level.

bStateProtection: The state of the input bProtection is transferred to the outside in the mode eBAREnergyLevel_AUTO_I and eBAREnergyLevel_AUTO_II.

bStateEconomy: The state of the input bEconomy is transferred to the outside in the mode eBAREnergyLevel_AUTO_I and eBAREnergyLevel_AUTO_II.

bStatePreComfort: The state of the input bPreComfort is transferred to the outside in the mode eBAREnergyLevel_AUTO_I and eBAREnergyLevel_AUTO_II.

bStateComfort: The state of the input bPComfort is transferred to the outside in the mode eBAREnergyLevel_AUTO_I and eBAREnergyLevel_AUTO_II..

VAR_IN_OUT

 Name                          : Type                      Persistent    Default
eCtrlMode                     : E_BAREnergyLevel;            X          eBAREnergyLevel_AUTO_I

eCtrlMode: With this ENUM the mode can be preselected by the building management system.


FB_BARFanCoil

Application

This function block has three stages with the equivalent switch hysteresis.This hysteresis is the same for all 3 stages. With the deviation of room temperature actual value and room temperature set value the drive can be set gradual. Further on with the input iStageManual resp. bStageUp or bStageDownit a manual override of the stage control is possible. The input udiSecMINPowerOnTime sets the minimum power-on time, it is valid for all stages.

VAR_INPUT

      Name                                         : Type

eDataSecurityType                            : E_HVACDataSecurityType;
bSetDefault                                  : BOOL;
bEnable                                      : BOOL;
eCtrlFct                                     : E_BARCtrlFct;
rSetpoint                                    : ST_BARSetpointRoom;
rRoomTemp                                    : REAL;
bStageUp                                     : BOOL;
bStageDown                                   : BOOL;
iStageManual                                 : INT;
bReset                                       : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: If the variable bEnable TRUE, the functionblock in enabled. If FALSE no stage is active.

eCtrlFct: This input is connected to the output eCtrlFct of FB_BARFctSelection. This information is important. It shows if the system is in heating or cooling mode. In automatic mode the stages are only controlled if e.g. according to deviation the demand of heating is active and the system is in heating mode. Or according to deviation the demand for cooling is active and the system is in cooling mode.

rSetpoint: Structure that contains the set values of the single energy level.

rRoomTemp: Input for room temperature.

bStageUp: Local setting of stage, gradual up.

bStageDown: Local setting of stage, gradual down.

iStageManual: This input sets the manual stage.

iStageManual: = 0 is equivalent to stage OFF
iStageManual: = 1 is equivalent to stage AUTO
iStageManual: = 2 is equivalent to stage01 active
iStageManual: = 3, is equivalent to stage02 active
iStageManual: = 4, is equivalent to stage03 active

bReset: Acknowledge input in case of failure or wrong parameter.

VAR_OUTPUT

Name                          : Type
bStageOff                     : BOOL;
bStageAuto                    : BOOL;
bStage01                      : BOOL;
bStage02                      : BOOL;
bStage03                      : BOOL;
bFanCoilActive                : BOOL;
bPresence                     : BOOL;
byState                       : BYTE;
byError                       : BYTE;
udiSecRT_MINPowerOnTime       : UDINT;
udiRT_TimePeriod              : UDINT;
bInvalidParameter             : BOOL;

bStageOff: TRUE, stages are switched off.

bStageAuto: TRUE, stage control in automatic mode.

bStage01: TRUE, stage01 active.

bStage02: TRUE, stage02 active.

bStage03: TRUE, stage03 active.

bFanCoilActive: TRUE, if one of three stages is active. This output is used for enabling controller to avoid heating resp. cooling accumulation.

bPresence: TRUE means that the inputs bStageUp, bStageDown or iStageManual detected presence.

byState: Shows the state of stage control.
byState.0:= block is enabled
byState.3:= manual stage default is active
byState.4:= bReset
byState.5:= stage01 active
byState.6:= stage02 active
byState.7:= stage03 active

byError: Number of errors in byte.
byError.1:= bInvalidParameter

udiSecRT_MINPowerOnTime: Shows the remaining time of minimum power-on time.

udiRT_TimePeriod: Shows the remaining time of manual override.

bInvalidParameter: Shows a wrong input parameter. bInvalidParameter has to be acknowledged with bReset.

VAR_IN_OUT

Name                                   : Type             Persistent      Default
rDeviationXW_Stage01                   : REAL;                X             0.7
rDeviationXW_Stage02                   : REAL;                X             1.7
rDeviationXW_Stage03                   : REAL;                X             2.1
rHysteresisRange                       : REAL;                X             0.2
udiSecMINPowerOnTime                   : UDINT;               X             120    sec
iFctModeFanCoil                        : INT;                 X             3
udiTimePeriod                          : UDINT;               X             60 min

rDeviationXW_Stage01: Limit value of deviation for stage01.

rDeviationXW_Stage02: Limit value of deviation for stage02.

rDeviationXW_Stage03: Limit value of deviation for stage03.

rHysteresisRange: Hysteresis range around limit value.
Example: A limit value of 0.7 and a hysteresis range of 0.2 leads to switch on stage01 for deviation > 0.8.
For a deviation < 0.6 the stage01 is switched off.

udiSecMINPowerOnTime: Minimum power-on time for a stage until it can be switched into another stage or switched off. In seconds (e.g. 120 is equivalent to 120s).

iFctModeFanCoil: With this value the user has the possibility to enable the stage control for heating mode or cooling mode or both. Valid values are 1,2 or 3 other values are not valid and bInvalidParameter is set TRUE.

Cooling | Heating | Value
0 | 1 | 1 (fan control in heating mode active)
1 | 0 | 2 (fan control in cooling mode active)
1 | 1 | 3 (fan control in heating and cooling mode active)

udiTimePeriod: Time period when manual override is active at presence. In minutes.

Image1: Fan control with default parameter


FB_BARFctSelection

Application

The function block enables room heating or room cooling. It can be used for two wire pipe systems (change over) or four wire pipe systems.

Using a four wire pipe system the switch between heating and cooling mode ist done automatically on the basis of comparsion between room temperature set value and room temperature actual value.

Drawing:

Using a two wire pipe system the enabling of heating oder cooling mode is only allowed if heating medium or cooling medium is present.The room temperature control gets this information from the primary installations.

Switching between heating mode and cooling mode can be delayed with a timer for two wire pipe systems as well as four wire pipe systems.For this the input variable udiChangeOverDelay has to be greater than zero.

The following tables describe the relationship between the inputs and the output eCtrlFc of the function block FB_BARFctSelection

Two wire pipe system

bEnable | bPipeSystem | bFeedbHeatMedium | bFeedbCoolMedium | interim Result | bDewPoint | eCtrlFct
0 | 0 | 0 | 0 | OFF | TRUE / FALSE | OFF
1 | 0 | 0 | 0 | Heating | TRUE / FALSE | Heating
1 | 0 | 0 | 1 | Cooling | TRUE | OFF
 |  |  |  |  | FALSE | Cooling
1 | 0 | 1 | 0 | Heating | TRUE / FALSE | Heating
1 | 0 | 1 | 1 | Heating | TRUE / FALSE | Heating

Four wire pipe system

bEnable | bPipeSystem | T_Room < = Tsetpoint | T_Room > Tsetpoint | interim Result | bDewPoint | eCtrlFct
0 | 1 | 0 | 0 | OFF | TRUE / FALSE | OFF
1 | 1 | 0 | 1 | Cooling | TRUE | OFF
 |  |  |  |  | FALSE | Cooling
1 | 1 | 1 | 0 | Heating | TRUE / FALSE | Heating
1 | 1 | 1 | 1 | Heating | TRUE / FALSE | Heating

VAR_INPUT

Name                                         : Type
eDataSecurityType                            : E_HVACDataSecurityType;
bSetDefault                                  : BOOL;
bEnable                                      : BOOL;
bPipeSystem                                  : BOOL;
bFeedbHeatMedium                             : BOOL;
bFeedbCoolMedium                             : BOOL;
bDewPoint                                    : BOOL;
rRoomTemp                                    : REAL;
stSetpoint                                   : ST_BARSetpointRoom;

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.

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

Attention 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 via TRUE. If FALSE the function block ist disabled and eCtrlFct := eHVACCtrlFct_Off.

bPipeSystem: FALSE means a two wire pipe system exists. TRUE means a four wire pipe system exists

bFeedbHeatMedium: Message of energy production resp. delivery that heating medium is available.

bFeedbCoolMedium: Message of energy production resp. delivery that cooling medium is available.

bDewPoint: This input is connected to the dew point sensor. If the input triggers the cooling control function is disabled and eCtrlFct := eHVACCtrlFct_Off is set.

rRoomTemp: This input variable assigns the function block the current room temperature.

stSetpoint: STRUCTURE that contains setpoints of single energy level.

VAR_OUTPUT

Name                          : Type
eCtrlFct                      : E_BARCtrlFct;
uiReqHeating                  : UINT;
uiReqCooling                  : UINT;
udiRT_ChangeOverDelay         : UDINT;

eCtrlFct: This output contains the current control mode.

uiReqHeating: 1: the room/zone requests heating energy. 0: no heating is needed.

uiReqCooling: 1: the room/zone requests cooling energy. 0: no cooling is needed.

udiRT_ChangeOverDelay: Shows the remaining time until the active contol mode is switched.

VAR_IN_OUT

Name                           : Type                        Persistent      Default
uiChangeOverDelay              : UINT;                            x                0

uiChangeOverDelay: Switch time between the control modes in seconds. If the variable >0 the switch time exists. If the variable is 0 there is no switch time between the control mode.


FB_BARSetpointRoom

Application

The functionblock FB_BARSetpointRoom assigns the energy level Protection, Economy, PreComfort and Comfort in each case a setpoint for cooling and heating operation. In conjunction with the functionblock FB_BAREnergyLevel the room temperature control according to room usage and function selection heating or cooling operation the energetic optimal setpoints are assigned.

The resulting setpoint for the different energy level consists of:

1. the base setpoint

2. the local setpoint offset (not for protection setpoints)

3. the central setpoint offset (not for protection setpoints)

The local offset by a room setpoint adjustement and the remote adjustement of the setpoints via building control acts only on the energy level comfort and precomfort.

VAR_INPUT

Name                                         : Type
eDataSecurityType                            : E_HVACDataSecurityType;
bSetDefault                                  : BOOL;
bEnable                                      : BOOL;
rSetpointShiftHeat                           : REAL;
rSetpointShiftCool                           : REAL;
rSetpointShiftUser                           : REAL;
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.

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

Attention 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 via TRUE.

rSetpointShiftHeat: The variable rSetpointShiftHeat is used for adaption of the ComfortHeating setpoint by the building control.

By increasing the ComfortHeating setpoint the ComfortCooling and PreComfortCooling setpoint is increased too.

Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
Base setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftHeat [ K ] | +3 | - | - | - | +3 | +3 | +3 | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 19 | 24 | 27 | 31 | 35 | 40

Decreasing the ComfortHeating setpoint impacts on the ComfortHeating and PreComfortHeating setpoint.
Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
Base setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftHeat [ K ] | -3 | - | - | -3 | -3 | - | - | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 16 | 18 | 24 | 28 | 35 | 40

rSetpointShiftCool: The variable rSetpointShiftCool is used for adaption of the ComfortCooling setpoint by the building control.

By increasing the ComfortCooling setpoint the PreComfortCooling setpoint is also increased.

Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
Base setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftCool [ K ] | +3 | - | - | - | - | +3 | +3 | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 27 | 31 | 35 | 40

Decreasing the ComfortCooling setpoint impacts only on ComfortCooling. The PreComfortCooling setpoint is unchanged.

Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
Base setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftCool [ K ] | -3 | - | - | - | - | -3 | - | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 21 | 28 | 35 | 40

If the setpoint of the energy level PreComfort is shifted above the setpoint of the economy level, the setpoint of the economy level takes the value of the PreComfort level.

Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
BBase setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftCool [ K ] | +8 | - | - | - | - | +8 | +8 | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 32 | 36 | 36 | 40

rSetpointShiftUser: The variable rSetpointShiftUser is used for local setpoint offset by the user.
A positive value of rSetpointShiftUser impacts on the setpoint of ComfortHeating, ComfortCooling and PreComfortCooling.
Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
Base setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftUser [ K ] | +3 | - | - | - | +3 | +3 | +3 | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 19 | 24 | 27 | 31 | 35 | 40

A negative value of rSetpointShiftUser impacts on the setpoint of PreComfortHeating, ComfortHeating and ComfortCooling.
Example:

Energy level |  | ProtectionHeating | EconomyHeating | PreComfortHeating | ComfortHeating | ComfortCooling | PreComfortCooling | EconomyCooling | ProtectionCooling
Base setpoint [ °C ] |  | 12 | 15 | 19 | 21 | 24 | 28 | 35 | 40
SetpointShiftUser [ K ] | -3 | - | - | -3 | -3 | -3 | - | - | -
Resulting setpoint [ °C ] |  | 12 | 15 | 16 | 18 | 21 | 28 | 35 | 40

bReset: Acknowledge input in the event of an error or a false parameter.

VAR_OUTPUT

Name                                  : Type
stSetpoint                            : ST_BARSetpointRoom;
bInvalidParameter                     : BOOL;

stSetpoint: Structure that contains all setpoints for all energy level.

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

Name                                   : Type                        Persistent      Default         Range
rSetpointComfortHeat                   : REAL;                          X              21.0
rSetpointPreComfortHeat                : REAL;                          X              19.0
rSetpointEconomyHeat                   : REAL;                          X              15.0
rSetpointProtectionHeat                : REAL;                          X              12.0
rSetpointComfortCool                   : REAL;                          X              24.0
rSetpointPreComfortCool                : REAL;                          X              28.0
rSetpointEconomyCool                   : REAL;                          X              35.0
rSetpointProtectionCool                : REAL;                          X              40.0

rSetpointComfortHeat: Setpoint for the engergy level for comfort heating.

rSetpointPreComfortHeat: Setpoint for the engergy level for precomfort heating.

rSetpointEconomyHeat: Setpoint for the engergy level for economy heating.

rSetpointProtectionHeat: Setpoint for the engergy level for protection heating.

rSetpointComfortCool: Setpoint for the engergy level for comfort cooling.

rSetpointPreComfortCool: Setpoint for the engergy level for precomfort cooling

rSetpointEconomyCool: Setpoint for the engergy level for economy cooling.

rSetpointProtectionCool: Setpoint for the engergy level for protection cooling


FB_BARPICtrl

Simple PI-controller

This PI-controller doesn't work directly with an amplification factor Kp, but calculates it internal via the so called proportional band (input rXp) in relation to the limits (rYmin and rYmax) of the actuating variable rY.

In- and Outputs

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
bSetDefault       : BOOL;
bEnable           : BOOL;
rW                : REAL;
rX                : REAL;
tTaskCycleTime    : TIME;
uiCtrlCycleCall   : UINT;
bSync             : BOOL;

eDataSecurityType: If eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eDataSecurityType_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: As long as this input is TRUE, the module is active. A FALSE signal on the other hand stops the execution.

rW : desired value

rX : actual value

tTaskCycleTime : cycle time of the task, in which the module is running.

uiCtrlCycleCall : the module's calling time as a multiple of the cycle time
Sample: tTaskCycleTime = 20ms, uiCtrlCycleCall =10 -> the controlling algorithm is called each 200ms. Because of this, the outputs are actualisated just each 200ms too.

bSync : A rising edge at this input sets the (internal) I-fraction in a way, that at the actuating variable's output rSyncValue is released. However if the I-fraction is disabled via tTn=0ms, this command is ignored.

VAR_OUTPUT

rY         : REAL;
rE         : REAL;
bARW       : BOOL;
bMaxLimit  : BOOL;
bMinLimit  : BOOL;
bError     : BOOL;
udiErrorId : UDINT;

rY : actuating variable

rE : control deviation (the calculation depends on the control-direction)

rEMin : the actuating variable's lower limit, which results of the entered proportional band.

rEMax : the actuating variable's upper limit, which results of the entered proportional band.

bARW : Anti-Reset-Windup-Function is active.

bMaxLimit : the actuating variable has reached the upper limit

bMinLimit : the actuating variable has reached the lower limit

bError : this output is set to TRUE, if the entered parameters are wrong.

udiErrorId : contains the error code, if the entered values are wrong. See Error codes.

VAR_IN_OUT

      Name                    : Type        Persistent     Default

bDirection              : BOOL;           X           FALSE
rXp                     : REAL;           X           100.0
tTn                     : TIME;           X           t#30s
rYMin                   : REAL;           X           0.0
rYMax                   : REAL;           X           100.0
rSyncValue              : REAL;           X           0.0

bDirection: With this Parameter the control-direction can be changed. If bDirection is set to TRUE, the controller is set to cooling-mode, if it is set to FALSE the heating-mode is activated.

rXp : proportional band. The proportional band defines the internal proportional-factor (amplification), which has only an effect on the P-part.

tTn : the I-fraction's reset time. Special case: tTn=t#0ms: the I-fraction is deactivated.

rYMin : the actuating variable's lower limit

rYMax : the actuating variable's upper limit

rSyncValue: A rising edge at the input bSetSyncVal sets the output rY to the value, which is entered at rSyncValue. In order to do so, the I-Part will be internally manipulated. If the I-Part is not activated, the D-Part will be changed.

Functional description

Step response - output's Y(t) reaction to a unit step an the input E(t).

Basic Function

A TRUE signal at the input bEnable enables the module. Then the internal controlling algorithm is processed. The input value uiCtrlCycleCall indicates, after what number of PLC cycles the internal controlling algorithm is going to be processed.
If uiCtrlCycleCall =1, a recalculation is executed in each PLC cycle, if it is set to 100, a new calculation is executed only each 100 PLC cycles. The PLC cycle time is part of the calculation of the actuating variable. A wrong input value causes a wrong calculation.
The inputs rW (desired value), rX (actual value), rXp (proportional band) and rTn (reset time) are the input parameters of the PI-controller. Via them the output parameters rY (actuating variable) and rE (control deviation) are evaluated in each calculation cycle. The actuating variable can additionally be limited via the inputs rYMin and rYMax .

Calibration via the Proportional Band

The calibration of the amplification factor Kp is often difficult, because there is no reference to the dimensions of the application. Whereas a heating controller works normally in a two-digit range, a flow rate control can assume values in five-digit ranges. So it is usefull, to choose the Kp-Faktor in a way, that it has a relation to the expected control deviation and changing of the actuating variables. For dimensioning of the Kp-factor you look at the controller's P-part.
For this is true:

  • actuating variable = control deviati on x ampli fication factor → Y=E*K p

this correlation is also true for changes of the control deviation and the actuating variable:

  • change of the actuating variable = change of the control deviation • amplification factor → ΔY=ΔE*K p

relating to the minimal- and maximal value of the actuating variable, Ymin and Ymax:

  • Ymax-Ymin=(E(Ymax)-E(Ymin))*K p

This difference E(Ymax)-E(Ymin) is called Proportional Band (Xp). Reverse the equation looks like this:

  • Kp=(Ymax-Ymin)/X p

The following diagram illustrates the functional relationship:

The proportional band Xp defines the dimension of the control deviation range, which causes a controller output between Ymin and Ymax.
A small Xp causes a high-angled function and therefor a bigger Kp-factor. However the limits of the deviation rangeE(Ymax)-E(Ymin) shift:

Control-direction

If bDirection is set to FALSE, the control-direction will be changed, so a negative control-deviation will cause a positive value at the control-output. This is done by changing the internal calculation of the control-deviation.

bDirection | rE (control-deviation) | control-direction
TRUE | lrX-lrW (actual value-setpoint) | direct (cooling)
FALSE | lrW-lrX (setpoint-actual value) | reverse (heating)

Anti-Reset-Windup (ARW)

If the controller runs in this limitation, the I-fraction is hold internal at the last value. Without this, the I-fraction's values could become huge without resist in case of this limitation, so at first they would have to be eliminated in the case of a controller's effective direction reversal. This function is called "Anti-Reset-Windup" (ARW). If the I-fraction's integration is canceled, the outputbARWis set.

Special Case Tn=0 to switch-off the I-fraction

In the step response diagram above you see, that the I-fraction's influence is the weaker, the bigger the reset time Tn has been set. If the reset time goes to infinity, the I-fraction's influence goes to zero. Reverse a constantly decreasing reset time would nurture the I-fraction, by Tn=0 the actuating variable would go to infinity. This special case is used to switch-off the I-fraction. This is an internal exception, because the reset time directly belongs to the I-fraction and should switch-off the I-fraction via "0-item" metaphorically.

Synchronisation

A rising edge at bSync sets the controller output rY directly to rSyncValue, if the controller has been activated via a TRUE signal at bEnable. If not, the rising edge at bSync is ignored.

Passive-behaviour (bEnable = FALSE or bError = TRUE)

If the controller is wrong parameterized, the execution is stopped, the output bError is set and the corresponding error code is provided to udiErrorID, see Error codes. The Module is also stopped, if the input bEnable is not set. In both cases the outputs are set as follows:

rY | 0.0
rE | 0.0
bARW | FALSE
bMaxLimit | FALSE
bMinLimit | FALSE


Lighting Overview

TS8000 | TwinCAT PLC Lib: HVAC

Lighting functions – overview

The lighting is subdivided into two different function groups, which can be combined to form arbitrary solutions:

  • User functions
  • Actuator functions

The user functions are control and closed loop circuits, which, served by the sensor functions, each output a light value.

FB_BARLightCircuit - simple light switching circuit without dimming function.

FB_BARLightCircuitDim - simple light switching circuit with dimming function.

FB_BARAutomaticLight - presence-controlled automatic light with switch-off delay.

FB_BARStairwellAutomatic - stairwell lighting with early warning sequence.

FB_BARTwilightAutomatic - twilight circuit.

FB_BARDaylightControl - daylight controller without dimming processes

FB_BARConstantLightControl - constant light control with continuous output of analog values.

The group of actuator functions is currently represented by only one function block.

FB_BARLightActuator - output of a preset proportional dimming value via a ramp function. Output is alternatively in percent, INTEGER or BOOL. This function block likewise encompasses a light scene memory of 21 adjustable dimming values.


FB_BARAutomaticLight

Function block for an automatic light circuit as used in corridors or sanitary facilities.

The block knows 3 different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

The automatic light circuit is active in automatic mode (uiLightCtrlMode=0). A rising edge on bSwitch sets the output lrDimValue to the value entered under lrManualDimValue. A falling edge starts the holding time generator. If the holding time uiHoldTime [s] has expired, the output lrDimValue is reset to 0.0.

The sequence can be restarted at any time:

The bSwitch input has no function in the manual modes: if uiLightCtrlMode=1 the output value lrDimValue is set constantly to lrManualDimValue and if uiLightCtrlMode=2 it is set constantly to 0.0.
Changing to manual mode resets any holding time that had started up to that point.

VAR_INPUT

eDataSecurityType   : E_HVACDataSecurityType;
uiLightCtrlMode     : UINT;
bSwitch             : BOOL;

eDataSecurityType:If eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiLightCtrlMode: Operation mode.

  • 0: Automatic mode; the automatic light circuit is active and reacts to the input bSwitch.
  • 1: Manual On; the automatic light circuit is inactive - the output lrDimValue is set constantly to lrManualDimValue.
  • 2: Manual Off; the automatic light circuit is inactive - the output lrDimValue is set constantly to 0.0.

bSwitch: A rising edge switches the light on in automatic mode (uiLightCtrlMode=0), a falling edge starts the holding time generator. This input has no function in manual operating mode (uiLightCtrlMode=1 or 2).

VAR_OUTPUT

lrDimValue          : LREAL;
uiRemainingHoldTime : UINT;
bError              : BOOL;
udiErrorId          : UDINT;

lrDimValue: output dimming value for the lighting in percent.

uiRemainingTimeHold: remaining holding time in seconds. If the light is off or if manual operating mode is active, then this output is "0". With a rising edge on bSwitch in automatic mode, this output initially indicates the complete number of seconds of the holding time (uiHoldTime), in order to illustrate the countdown of the holding time, starting with a falling edge on bSwitch. This output is 0 as long as no countdown of the time is taking place.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiHoldTime       : UINT;
lrOnDimValue     : LREAL;
lrManualDimValue : LREAL;

uiHoldTime: holding time [s] of the automatic light controller after a falling edge on bSwitch.

lrOnDimValue: a dimming value in automatic mode (uiLightCtrlMode=0).

lrManualDimValue: output dimming value in Manual On mode (uiLightCtrlMode=1).


FB_BARConstantLightControl

The constant light control function block controls the lighting when the room is occupied such that the lighting intensity does not fall below a preset minimum. This ensures adequate lighting whilst at the same time minimising energy consumption.

The constant light control is enabled when the room is entered or by a rising edge on the input bPresence. Optionally the constant light control can also be operated by a button. A short pulse on the input bToggle enables the constant light control or switches it off, depending on the current state. If many constant light controllers are to be switched on by a central command, for example on an office floor, this can be realised with the input bCentralOn. A central command to switch off can be connected to the input bCentralOff.

Actuating the button on bToggle for a longer period manually changes the setpoint value for the room brightness. Upon a falling edge on bToggle the current room brightness value is stored as a setpoint value. The rate of change when manually increasing or decreasing the room brightness can be set by means of a parameter.

The manually set setpoint value for the constant light control is retained until the next time the lighting is switched off. On restarting the controller by a rising edge on bPresence, a rising edge on bCentralOn or a pulse on bToggle, the last manually selected setpoint value or the value of uiSetpointlValue is adopted, depending on the setting of the parameter bInitialMode.

In automatic mode the lighting is switched on only if the room brightness lies below an adjustable hysteresis value (uiTargetRange). As the external brightness increases, the constant light controller reduces the artificial light portion until a minimum load control value lrMinDimValue lies at the output of the controller lrDimValue. Subsequently, the controller switches the lighting off following a time delay with the timer uiOffDelay.
The switching on again of the lighting as the external brightness decreases is delayed with the timer uiOnDelay.

In order to avoid unpleasant visible changes in the brightness, the rate of change of the control signal is retarded with the parameter uiControlRampTime.

For maintenance and test purposes the automatic constant light control can be deactivated and the lighting can be switched on and off in manual mode. This deactivates the edge detection at the inputs bCentralOn, bCentralOff and bToggle.

The block knows three different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

Automatic mode

In automatic mode the control can be activated or deactivated in three different ways:

  1. Via the input bSwitch: A short TRUE signal (shorter than uiSwitchOverTime in milliseconds) at bSwitch activates the constant light control if it had been inactive beforehand. Another short signal on bSwitch deactivates the constant light control again. A long TRUE signal on bSwitch switches the block to setpoint value adjustment mode; this is described below.
  2. Via the input bPresence: Switching on via this input must be explicitly enabled by a TRUE signal on bPresenceOnActive (VAR_IN_OUT). A rising edge then activates the control, while a falling edge always deactivates the control independent of the state of bPresenceOnActive.
  3. The control is explicitly switched on and off via TRUE edges on the inputs bCentralOn and bCentralOff, independent of the previous state of the control. These inputs do not have an override function: for example, if switching off has taken place via bCentralOff, bSwitch can be used to switch on again at any time.

The light output value lrDimValue is initially set in the active state to the initial value lrStartDimValue. After that an actual value/setpoint value comparison takes place continuously. If the actual room value uiBrightness [lux] thereby leaves the target range uiTargetRange [lux] around the setpoint value uiSetpointValue [lux], then this is counteracted by dimming the lighting up or down. The control always operates with a constant, parameterisable dimming ramp uiRamptime [s], which indicates the time of a complete dimming process from 0% to 100%. The control target values are likewise constant: 0% for dimming down and 100% for dimming up. In the inactive state the light output value lrDimValue is set to 0.0.

Switch-on and switch-off delay, minimum output value

If the external brightness increases, then less and less artificial light is necessary in order to obtain the desired total brightness. The lighting can be switched off completely if the external brightness is sufficient.
However, switch-on and switch-off processes can be perceived as distracting, as can very low output dimming values. Therefore a switch-on and switch-off delay uiOnDelay/uiOffDelay can be defined in the block around a lower limit value lrMinDimValue. If the internally determined output value sinks below this minimum value, then the output remains at this minimum for the time uiOffDelay [s]. Only after that is 0.0 output at the output lrDimValue. If in the reverse case switching off to 0.0 has taken place, then if artificial light is required this is only switched on after the expiry of uiOnDelay [s] and then to the value lrMinDimValue. The following diagram is intended to clarify the behaviour:

The yellow areas indicate the ranges where the external brightness permits the lighting to be dimmed down; in the blue areas, conversely, the external brightness alone is not sufficient to obtain the desired room brightness. In the white areas the output control value lrDimValue is appropriate for the lighting conditions.

Manual adjustment of the setpoint value

In order to be able to adapt the light control to personal brightness needs, there is an option to increase or decrease the setpoint value. A long TRUE signal on bSwitch (longer than uiSwitchOverTime in milliseconds) switches the block to the dimming mode and the light is dimmed up if it had been dimmed down in the preceding dimming mode and vice versa. If bSwitch resets to FALSE, then the brightness value now measured on uiBrightness is adopted as the new setpoint value to which control is to take place.

Manual operation

The inputs bSwitch, bCentralOn and bCentralOff have no function in the manual operating modes: if uiLightCtrlMode=1 the output value lrDimValue is set constantly to lrManualDimValue and if uiLightCtrlMode=2 it is set constantly to 0.0.
Changing to manual mode resets any control process that had previously started. On re-entering automatic mode the output value is lrDimValue 0.0 and the control must be restarted.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bPresence         : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;
uiBrightness      : UINT; (*lux*)
uiSetpoint        : UINT; (*lux*)

eDataSecurityType:If eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiLightCtrlMode: Operation mode.

  • 0: Automatic mode; the commands bSwitch, bCentralOn and bCentralOff are executable and can be used to switch the controller on and off.
  • 1: Manual On mode; constant light control is inactive – the value lrManualDimValue is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.
  • 2: Manual Off mode; constant light control is inactive – the value 0.0 is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.

bSwitch: Rising edges on this input switch the control on and off alternately. When switching off the output lrDimValue is set to 0.0. This command input is active only in automatic mode (uiLightCtrlMode=0).

bPresence: A continuous TRUE signal on this input activates the control if the presence function is activated by bPresenceOnActive=TRUE (VAR_IN_OUT). Conversely, a falling edge on this input always deactivates the control. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOn: a rising edge on this input switches the control on. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOff: a rising edge on this input switches the control off and sets the output lrDimValue to 0.0. This command input is active only in automatic mode (uiLightCtrlMode=0).

uiBrightness: light actual value [lux].

uiSetpointValue: light setpoint value [lux].

VAR_OUTPUT

lrDimValue              : LREAL;
bControlActive          : BOOL;
bAdjustedSetpointActive : BOOL;
uiAdjustedSetpoint      : UINT;
diActDeviation          : DINT;
bError                  : BOOL;
udiErrorId              : UDINT;

lrDimValue: light output value, 0 to 100%.

bControlActive: This output is TRUE if the function block is in automatic mode and the control is activated. This is intended to serve as an additional feedback signal if switch-on has taken place but the control outputs a light value of lrDimValue=0.0.

bAdjustedSetpointActive: If the control is active and the setpoint value has been manually adjusted (see above), then the state of this output changes to TRUE in order to indicate that the setpoint value on the input uiSetpointValue is no longer active.

uiAdjustedSetpoint: This output indicates the active setpoint value if this has been manually adjusted (bAdjustedSetpointActive = TRUE). This output is set to 0 if no manually adjusted setpoint value is active.

diActDeviation: current control deviation in lux. This output indicates a valid value only if the function block is in automatic mode and activated. Otherwise 0.0 is output.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSwitchOverTime  : UINT;
uiAdjustRampTime  : UINT;
bPresenceOnActive : BOOL;
bInitialMode      : BOOL;
uiTargetRange     : UINT;
uiControlRampTime : UINT;
uiOnDelay         : UINT;
uiOffDelay        : UINT;
lrMinDimValue     : LREAL;
lrMaxDimValue     : LREAL;
lrStartDimValue   : LREAL;
lrManualDimValue  : LREAL;

uiSwitchOverTime: switchover time in milliseconds for the input bSwitch for the recognition of short and long signals. (Short signal: Switch on/off function, long signal: dimming function)

uiAdjustRampTime: ramp time in seconds with which the setpoint value is changed during manual adjustment.

bPresenceOnActive: if this input is TRUE, then the control is activated by a rising edge on bPresence if the function block is in automatic mode (uiLightCtrlMode = 0).

bInitialMode: a TRUE signal on this input makes the function block begin with the setpoint value on uiSetpoint each time it is activated. If on the other hand this input is FALSE, then the setpoint value that was last active – i.e. including manually adjusted setpoint values – is adopted on activation of the function block.

uiTargetRange: target range around the setpoint value in which no further control is to take place.

uiControlRampTime: ramp time in seconds (time required to dim from 0% to 100%).

uiOnDelay: switch-on delay in seconds around the minimum value lrMinDimValue.

uiOffDelay: switch-off delay in seconds around the minimum value lrMinDimValue.

lrMinDimValue: lower limit value for dimming, see introduction.

lrMaxDimValue: upper limit to which the output lrDimValue can be controlled.

lrStartDimValue: value to which the light should jump on activating the control.

lrManualDimValue: output dimming value in Manual On mode (uiLightCtrlMode=1).


FB_BARDaylightControl

Daylight switch. Unlike the constant light control, this automatic switch operates not with dimming values, but merely switches the light on or off depending on the measured brightness.

The block knows three different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

Automatic mode

If the brightness in the room, uiBrightness, falls below the value uiSwitchOnValue [lux] for the time uiOnDelay [s], then the light is switched on. There is now a delay, uiLightOnTime, to allow the lamps reach their full luminosity. The measured brightness in the room – assuming constant external brightness – is then higher than before switching on by the amount of the increase in brightness. Switching the lighting off again makes sense only after the external brightness has significantly increased again. This limit value is calculated from the light switch-on value plus the brightness increase plus the parameter uiSwitchOffOffset. If an increase in the external brightness causes the room brightness to exceed this determined re-switch-off value for the duration of uiOffDelay [s], then the lighting is switched off again.

Manual operation

The inputs bSwitch, bCentralOn and bCentralOff have no function in the manual operating modes: the output value bOn is set to TRUE if uiLightCtrlMode=1 and to FALSE if uiLightCtrlMode=2.
Changing to manual mode resets any control process that had previously started. On re-entering automatic mode the output value bOn is FALSE and the controller must be restarted.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;
uiBrightness      : UINT;

eDataSecurityType:if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiLightCtrlMode: Operation mode.

  • 0: Automatic mode; the commands bSwitch, bCentralOn and bCentralOff are executable and can be used to switch the controller on and off.
  • 1: Manual On mode; constant light control is inactive – the value lrManualDimValue is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.
  • 2: Manual Off mode; constant light control is inactive – the value 0.0 is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.

bSwitch: Rising edges on this input switch the control on and off alternately. When switching off the output lrDimValue is set to 0.0. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOn: a rising edge on this input switches the control on. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOff: a rising edge on this input switches the control off and sets the output lrDimValue to 0.0. This command input is active only in automatic mode (uiLightCtrlMode=0).

uiBrightness: light actual value [lux].

VAR_OUTPUT

lrDimValue          : LREAL;
bOn                 : BOOL;
uiRemainingOnDelay  : UINT;
uiRemainingOffDelay : UINT;
uiPreOnValue        : UINT;
uiLightGain         : UINT;
uiSwitchOffValue    : UINT;
bControlActive      : BOOL;
bError              : BOOL;
udiErrorId          : UDINT;

lrDimValue: in order to keep this function the same as the other light user functions, a light output value exists here too in the form of a floating point number in percent, even though the light is only switched on or off. This means: light off: lrDimValue = 0.0, light on: lrDimValue = 100.0.

bOn: switch output for the lighting.

uiRemainingOnDelay: countdown of the switch-on delay in seconds. This output is 0 as long as no countdown of the time is taking place.

uiRemainingOffDelay: countdown of the switch-off delay in seconds. This output is 0 as long as no countdown of the time is taking place.

uiPreOnValue: measured light value immediately before switching the lighting on. This output is "0" if the controller is switched off or in manual mode.

uiLightGain: calculated brightness increase after switching on the lighting and waiting for the expiry of the waiting period uiFullLightTime. This output is "0" if the controller is switched off or in manual mode.

uiSwitchOffValue: determined re-switch-off value, wherein the measured brightness must be larger. During the waiting phase (uiLightOnTime) this value jumps to 65535 in order to avoid the light switching off during this time. This output is "0" if the controller is switched off or in manual mode.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSwitchOnValue   : UINT;
uiSwitchOffOffset : UINT;
uiLightOnTime     : UINT;
uiOnDelay         : UINT;
uiOffDelay        : UINT;

uiSwitchOnValue: light switch-on value. The lighting is switched on after the expiry of the switch-on delay if the external brightness is lower than this value.

uiSwitchOffOffset: If the light is switched on for the time uiLightOnTime (see above), the light switch-off value is calculated from the currently measured light intensity plus this value.

uiLightOnTime: The lighting does not reach its true switch-on value immediately. In order to judge the increase in light intensity, this time delay in milliseconds is allowed to elapse before the increase and the light switch-off value that depends on it are calculated.

uiOnDelay: Switch-on delay in seconds. Constant switching on and off of the lighting is perceived as very distracting. If the external brightness sinks in such a manner that the constant light control needs to be switched on for support, then this should take place only after this time delay.

uiOffDelay: Switch-off delay in seconds. If the external brightness increases in such a manner that the constant light control needs to be switched off, then this should take place only after this time delay in order to mask out short-term fluctuations.


FB_BARLightActuator

This function block serves to control a conventional light actuator. The outputs cover the value ranges 0 - 100%, 0 - 32767 and On/Off.
On top of that the function block contains a scene memory in which up to 21 different light values can be saved.

In principle the function block passes the values on the input lrTargetValue through to the output lrDimValue. Conversely, a rising edge on the input bCallScene sets the output to the light value that is saved in the scene table arrLightScenes under the index usiSelectedScene. The output bSceneMode then changes to TRUE. If the scene index usiSelectedScene changes, then the newly selected scene value is adopted only on another rising edge on bCallScene. The scene mode is quit again by a change of value on the input lrTargetValue or a rising edge on bStopScene. The output bSceneMode goes back to FALSE and the output lrDimValue once again follows the input lrTargetValue. A TRUE signal on bSaveScene saves the current light output value into the scene table arrLightScenes under the index usiSelectedScene.

The light output value lrDimValue always follows the target values specified to it via a ramp. As in the case of the user function FB_BARLightCircuitDim, this is defined by a ramp time – in this case uiSecDimTime – which indicates the time interval in seconds that the light output value should require in order to change by 100%.

Since the photosensor function block FB_BARLightCircuitDim also contains a ramp function for presetting the target value, the light actuator function described here is called the "secondary dimtime" - uiSecDimTime.
If the two have different values, then the longer ramp time is always the relevant one:

Example 1:

In this constellation the function block FB_BARLightCircuitDim will change its output value lrDimValue from 0% to 100% in 10 s. However, the function block FB_BARLightActuator can follow these continuously changing setpoint values only with a ramp time of 20 s (related to a change from 0% to 100%). Therefore this is ultimately the resulting ramp time.

Example2:

Conversely the function block FB_BARLightActuator could follow much faster here with a ramp time of 10 s. However, since the dimming function block FB_BARLightCircuitDim presets its setpoint values in this example only with a ramp time of 20s, this longer time is also relevant in this case.
It must be noted in this example that a short button press on the function block FB_BARLightCircuitDim immediately changes the output lrDimValue to the internally-saved value (see FB_BARLightCircuitDim). Hence, the ramp time on the FB_BARLightActuator is then relevant.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
lrTargetValue     : LREAL;
usiSelectedScene  : USINT;
bCallScene        : BOOL;
bStopScene        : BOOL;
bSaveScene        : BOOL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

lrTargetValue: target value of the light output in 0 to 100%;

usiSelectedScene: selected lighting scene, 0 to 20;

bCallScene: sets the output value, controlled by a ramp, to the light value entered in the index usiSelectedScene (arrLightScenes).

bStopScene: resets the output value to the value lrTargetValue. The change is likewise controlled by a ramp.

bSaveScene: saves the current light value at the output lrDimvalue in the light value table arrLightScenes under the index usiSelectedScene.

VAR_OUTPUT

lrDimValue : LREAL;
iDimValue  : INT;
bOn        : BOOL;
bSceneMode : BOOL;
bError     : BOOL;
udiErrorId : UDINT;

lrDimValue: output light value in 0 to 100%.

iDimValue: output light value in 0 to 32767.

bOn: output light status: lrDimmValue=0.0 => bOn=FALSE - lrDimmValue>0.0 => bOn=TRUE.

bSceneMode: the function block presently outputs a scene value and not the value lrTargetValue on the input.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSecDimTime   : UINT; (*Dim time to increase the light actuator function from 0% to 100%*)
arrLightScenes : ARRAY[0..20] OF LREAL;

uiSecDimTime: ramp time in seconds. This is the time that the light actuator function requires in order to regulate from 0 to 100%.

arrLightScenes: table of saved light values.


FB_BARLightCircuit

This block represents a simple light circuit without a dimming function.

The block knows three different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

In automatic mode (uiLightCtrlMode=0) the function block can be controlled via the inputs bSwitch, bCentralOff and bCentralOn. A rising edge on bCentralOff switches the output lrDimValue to 0.0, while a rising edge on bCentralOn sets the output to 100.0. Rising edges on bSwitch make the output lrDimValue change each time between 0.0 and 100.0.

In the manual operating modes the output value lrDimValueOut is set constantly to the value 100.0 if uiLightCtrlMode=1 and constantly to the value 0.0 if uiLightCtrlMode=2.

VAR_INPUT

uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;

uiLightCtrlMode: operation mode.

  • 0: Automatic mode; the output value lrDimmValue can be influenced by the command inputs bSwitch, bCentralOn and bCentralOff
  • 1: Manual On mode; the value 100.0 is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.
  • 2: Manual Off mode; the value 0.0 is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.

bSwitch: rising edges on bSwitch make the output lrDimValue change each time between 0.0 and 100.0.

bCentralOn: switches the output lrDimValueOut to 100.0.

bCentralOff: switches the output lrDimValueOut to 0.0.

Note: All switching commands, bSwitch, bCentralOn and bCentralOff are effective only in automatic mode.

VAR_OUTPUT

lrDimValue  : LREAL;
bLight      : BOOL;
bError      : BOOL;
udiErrorId  : UDINT;

lrDimValue: light output value in percent; 0.0 if the light is switched off and 100.0 if the light is switched on.

bLight: FALSE if lrDimmValue = 0.0, otherwise TRUE.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.


FB_BARLightCircuitDim

This block represents a light circuit with a dimming function.

The block knows three different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

In automatic mode (uiLightCtrlMode=0) the function block can be controlled via the inputs bSwitch, bCentralOff and bCentralOn. Whereas the output lrDimValue is set to 0.0 or to the value reached before the last switch-off by rising edges on bCentralOff and bCentralOn, the behaviour of the input bSwitch depends on the duration of the signal. A short TRUE signal that is shorter than uiSwitchOverTime in milliseconds switches the output lrDimValue. If the output lrDimValue is initially larger than 0.0, then it is switched to 0 and the previous value is saved. If on the other hand it is 0.0, then the output is set to the previously internally saved value. This saved value is set to the maximum value in the switch-on state of the program, see below. Unlike in the case of the inputs bCentralOff and bCentralOn, the falling edge triggers the switching event here. A long TRUE signal on bSwitch starts the dimming process. In principle dimming takes place only between the set minimum and maximum values (lrMinDimValue and lrMaxDimValue). The dimming ramp is defined in seconds by uiRampTime. This dimming time refers to the dimming range from 0 to 100 per cent, even if the limits lrMinDimValue and lrMaxDimValue are set differently. If the output value lrDimmValue reaches one of the limits without bSwitch resetting to FALSE, then it remains there for the time uiCycleDelay in milliseconds, before dimming takes place again to the other limit value.

Exception: A uiCycleDelay value of 0 is not interpreted as an immediate dimming direction reversal, but instead deactivates this. Only another long TRUE signal on bSwitch starts the dimming in the opposite direction.

In the manual operating modes the output value lrDimValueOut is set constantly to the value lrManualDimValue if uiLightCtrlMode=1 and constantly to the value 0.0 if uiLightCtrlMode=2.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiLightCtrlMode: operation mode.

  • 0: Automatic mode; the output value lrDimmValue can be influenced by the command inputs bSwitch, bCentralOn and bCentralOff
  • 1: Manual On mode; the value lrManualDimValue is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.
  • 2: Manual Off mode; the value 0.0 is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.

bSwitch: a short TRUE signal that is shorter than uiSwitchOverTime in milliseconds switches the output lrDimValue. If the output lrDimValue is initially larger than 0.0, then it is switched to 0 and the previous value is saved. If on the other hand it is 0.0, then the output is set to the previously internally saved value. This saved value is set to the maximum value in the switch-on state of the program, see below.
A long TRUE signal that is longer than uiSwitchOverTime in milliseconds starts the dimming process, wherein the dimming direction changes if two long signals follow one another on the input bSwitch.

bCentralOn: switches the output lrDimValueOut to the previously saved (at the last switch-off) dimming value, see bSwitch.

bCentralOff: switches the output lrDimValueOut to 0.0.

Note: All switching commands, bSwitch, bCentralOn and bCentralOff are effective only in automatic mode.

VAR_OUTPUT

lrDimValue  : LREAL;
bLight      : BOOL;
bError      : BOOL;
udiErrorId  : UDINT;

lrDimValue: light output value; can adopt values between lrMinDimValue and lrMaxDimValue, see VAR_IN_OUT, but maximally 0 to 100%.

bLight : FALSE if lrDimmValue = 0.0, otherwise TRUE.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSwitchOverTime : UINT;
uiDimRampTime    : UINT;
uiCycleDelay     : UINT;
lrMinDimValue    : LREAL;
lrMaxDimValue    : LREAL;
lrManualDimValue : LREAL;

uiSwitchOverTime: switching time in milliseconds from button to dimming mode.

uiDimRampTime: ramp time in seconds (time required to dim from 0% to 100%).

uiCycleDelay: switching time in milliseconds of the automatic change between dimming up and dimming down. The automatic change is inactive if this value is zero.

lrDimMinValue: minimum light value in % that can be reached by dimming.

lrDimMaxValue: maximum light value in %.

lrManualDimValue: output dimming value in Manual On mode (uiLightCtrlMode=1).

.


FB_BARStairwellAutomatic

Function block for a stairwell light circuit.

The block knows 3 different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

The stairwell control is active in automatic mode (uiLightCtrlMode=0) . A rising edge on bSwitch initially only switches the light on (output bOn). A falling edge starts the holding time generator. If the holding time uiHoldTime [s] has expired, a flashing sequence with a number of flash pulses programmable by uiNumberPulses begins as a warning of the impending switch-off. These pulses have an on-time of uiPulseTimeOn [ms] and an off-time of uiPulseTimeOff [ms].

The sequence can be restarted at any time:

The bSwitch input has no function in the manual modes: the output value bOn is set constantly to TRUE if uiLightCtrlMode=1 and constantly to FALSE if uiLightCtrlMode=2.
Changing to manual mode resets any lighting sequence that had started up to that point.

VAR_INPUT

eDataSecurityType   : E_HVACDataSecurityType;
uiLightCtrlMode     : UINT;
bSwitch             : BOOL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiLightCtrlMode: operation mode.

  • 0: Automatic mode; the stairwell light circuit is active and reacts to the input bSwitch.
  • 1: Manual On mode; the stairwell circuit is inactive - the output bOn is set constantly to TRUE.
  • 2: Manual Off mode; the stairwell circuit is inactive - the output bOn is set constantly to FALSE.

bSwitch: A rising edge switches the light on in automatic mode (uiLightCtrlMode=0), a falling edge starts the holding time generator. This input has no function in manual operating mode (uiLightCtrlMode=1 or 2).

VAR_OUTPUT

lrDimValue          : LREAL;
bOn                 : BOOL;
uiRemainingHoldTime : UINT;
bError              : BOOL;
udiErrorId          : UDINT;

lrDimValue: In order to keep this function the same as the other light user functions, a light output value exists here too in the form of a floating point number in percent, even though the light is only switched on or off. This means: light off: lrDimValue = 0.0, light on: lrDimValue = 100.0.

bOn: switch output for the lighting.

uiRemainingTimeHold: remaining holding time in seconds. If the light is off or if manual operating mode is active, then this output is "0". With a rising edge on bSwitch in automatic mode, this output initially indicates the complete number of seconds of the holding time (uiHoldTime), in order to illustrate the countdown of the holding time, starting with a falling edge on bSwitch. This output is 0 as long as no countdown of the time is taking place.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiHoldTime      : UINT;
uiPulseTimeOn   : UINT;
uiPulseTimeOff  : UINT;
uiNumberPulses  : UINT;

uiHoldTime: holding time [s] of the stairwell controller after a falling edge on bSwitch.

uiPulseTimeOn: ON-time of the early warning pulses in milliseconds.

uiPulseTimeOff: OFF-time of the early warning pulses in milliseconds.

uiNumberPulses: number of early warning pulses.


FB_BARTwilightAutomatic

Automatic twilight function

The block knows three different modes, which can be set via the input uiLightCtrlMode:

  • Automatic mode
  • Manual On mode
  • Manual Off mode

Automatic mode

In automatic mode a rising edge on bSwitch activates the automatic twilight function, if it had been inactive beforehand. A further edge on bSwitch deactivates the automatic twilight function again. The automatic function is explicitly switched on and off with bCentralOn and bCentralOff, independent of the previous state of the automatic function. If the automatic twilight function is activated, then the function block switches the output lrDimValue to the switch-on value lrDimValueOn when the brightness falls below a switch-on threshold value uiSwitchOnValue for an entered delay time uiOnDelay. Conversely, if a switch-off threshold value uiSwitchOffValue is exceeded for an entered time delay uiOffDelay, then the output is switched to the value lrDimValueOff. In the inactive state the light output value lrDimValue is set to 0.0.

Manual operation

The inputs bSwitch, bCentralOn and bCentralOff have no function in the manual operating modes: if uiLightCtrlMode=1 the output value lrDimValue is set constantly to lrManualDimValue and if uiLightCtrlMode=2 it is set constantly to 0.0.

Switch-on and switch-off delay

The switch-on and switch-off delays written in automatic mode are always run through irrespective of the state of the automatic function (active or inactive) and the operating mode, i.e. the timers are not reset by these operating states.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;
uiBrightness      : UINT;

eDataSecurityType:if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiLightCtrlMode: operation mode.

  • 0: Automatic mode; the commands bSwitch, bCentralOn and bCentralOff are executable and can be used to switch the automatic twilight function on and off.
  • 1: Manual On mode; automatic twilight function is inactive – the value lrManualDimValue is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.
  • 2: Manual Off mode; automatic twilight function is inactive – the value 0.0 is output without a delay at the output lrDimValueOut, all other command inputs are ineffective.

bSwitch: rising edges on this input switch the automatic twilight function on and off alternately. When switching off the output lrDimValue is set to 0.0. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOn: a rising edge on this input switches the automatic twilight function on. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOff: a rising edge on this input switches the automatic twilight function off and sets the output lrDimValue to 0.0. This command input is active only in automatic mode (uiLightCtrlMode=0).

uiBrightness: light actual value [lux].

VAR_OUTPUT

lrDimValue          : LREAL;
uiRemainingOnDelay  : UINT;
uiRemainingOffDelay : UINT;
bControlActive      : BOOL;
bError              : BOOL;
udiErrorId          : UDINT;

lrDimValue: light output value, 0 to 100%.

uiRemainingOnDelay: countdown of the switch-on delay in seconds. This output is 0 as long as no countdown of the time is taking place.

uiRemainingOffDelay: countdown of the switch-off delay in seconds. This output is 0 as long as no countdown of the time is taking place.

bControlActive: this output is TRUE if the function block is in automatic mode and the automatic twilight function is activated. This is intended to serve as an additional feedback signal if switch-on has taken place but the controller outputs a light value of lrDimValue=0.0.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

Note If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSwitchOnValue  : UINT;
uiSwitchOffValue : UINT;
uiOnDelay        : UINT;
uiOffDelay       : UINT;
lrDimOnValue     : LREAL;
lrDimOffValue    : LREAL;
lrManualDimValue : LREAL;

uiSwitchOnValue: switch-on threshold value. This is compared with the brightness value at the input uiBrightness. This value must be greater than the output threshold value uiSwitchOffValue.

uiSwitchOffValue: switch-off threshold value. This is compared with the brightness value at the input uiBrightness.

uiOnDelay: switch-on delay in seconds.

uiOffDelay: switch-off delay in seconds.

lrDimOnValue: switch-on light value in %.

lrDimOffValue: switch-off light value in %.

lrManualDimValue: output dimming value in Manual On mode (uiLightCtrlMode=1).


Shading Overview

TS8000 | TwinCAT PLC Lib: HVAC


Sunprotection Overview

TS8000 | TwinCAT PLC Lib: HVAC


Sun protection: basic principles and definitions

The direct incidence of daylight is regarded as disturbing by persons in rooms. On the other hand, however, people perceive natural light to be more pleasant in comparison with artificial light. Two options for glare protection are to be presented here:

  • Louvre adjustment
  • Height adjustment

Louvre adjustment

A louvered blind that can be adjusted offers the option of intelligent sun protection here. The position of the louvres is cyclically adapted to the current position of the sun, so that no direct daylight enters through the blinds, but as much diffuse daylight can be utilised as possible.

The illustration shows that diffuse light can still enter from underneath, whereas no further direct daylight, or theoretically only a single ray, can enter. The following parameters are necessary for the calculation of the louvre angle:

  • the current height of the sun (angle of elevation)
  • the position of the sun, i.e. the azimuth angle
  • the facade orientation
  • the width of the louvres
  • the spacing of the louvres

The effective angle of elevation is calculated from the first three of the parameters listed above:

If the facade orientation and the position of the sun (azimuth) are equal, then the effective angle is equal to the current angle of elevation.

However, if the sunlight falls at an angle onto the facade as seen from the sun direction, the effective angle is larger for the same angle of elevation.

The following three pictures illustrate the relationship between the effective angle of elevation and the dimensions of the blind and how the resulting louvre angle λ changes:

Height adjustment

With a high position of the sun at midday, the direct rays of sunlight do not penetrate into the full depth of the room. If direct rays of sunlight in the area of the window sill are regarded as uncritical, the height of the sun protection can be adapted automatically in such a way that the rays of sunlight only ever penetrate into the room up to an uncritical depth.

In order to be able to calculate at any time the appropriate blind height that guarantees that the incidence of sunlight does not exceed a certain value, the following values are necessary.

Required for the calculation of the respective blind height:

  • Height of the sun (elevation)
  • Window height
  • Distance between the window and the floor

The following illustration shows where these parameters are to be classified:

Influence of the facade inclination

In both of the methods of sun protection described, it was assumed that the facade and thus the windows are perpendicular to the ground. In the case of an inclined facade, however, the incidence of light changes such that this influence will also be taken into account. The facade inclination is defined as follows:


Shading correction: basic principles and definitions

The shading correction can be used in conjunction with the automatic sun function or louvre adjustment. The function checks whether a window or a window group that is assigned to a room, for example, is temporarily placed in the shade by surrounding buildings or parts of its own building. Sun shading for windows that stand in the shadow of surrounding buildings or trees is not necessary and may even be disturbing under certain circumstances. On the basis of data entered regarding the facade and its surroundings, the shading correction determines which parts of the front are in the shade. Hence, it is then possible to decide whether the sun protection should be active for individual windows or window groups.
Apart from the current position of the sun, the shading of the individual windows depends on three things:

  • the orientation of the facade
  • the position of the windows
  • the positioning of the shading objects

The following illustrations are intended to describe these interrelationships and to present the parameters to be entered.

Orientation of the facade

Observation from above

For the pure observation of the shadow thrown on the facade, a two-dimensional coordinate system is ultimately required, therefore the x and y axis were placed on the facade. The zero point is thereby at the bottom left on the base, as if one were regarding the facade from the front. For the calculation of the shading objects the Z component is then also added. Its axis points from away the facade and has the same zero point as the X and Y axis.

The horizontal position of the sun (azimuth angle)in the northern hemisphere is by definition measured from the north. The facade orientation is likewise related to north, wherein the following applies to the line of sight from a window in the facade:

Line of sight | Facade orientation
North | β=0°
East | β=90°
South | β=180°
West | β=270°

The course of the sun in the southern hemisphere is different. The sun rises in the east as well. but at noon it is located in the north. Thus the definition of the facade-orientation is changed as well:

Line of sight | Facade orientation
South | β=0°
East | β=90°
North | β=180°
West | β=270°

All further explanations in this chapter are referring to the characteristics of the northern hemisphere. For the the subsequent parameterization of the shading-correction (FB_BARShadingCorrection / FB_BARShadingCorrectionSouth) only the facade-orientation is important, which can be taken from the above mentioned tables for either the northern or southern hemisphere.

The following two illustrations are intended to further clarify the position of the point of origin P0 as well as the orientation of the coordinate system:

Observation from the side

The angle of elevation (height of the sun) can be represented using this illustration: by definition this is 0° at sunrise (horizontal incidence of light) and can reach maximally 90°, but this applies only to places within the Tropic of Cancer and the Tropic of Capricorn.

Observation from the front

Here, the position of the point of origin, P0, at the bottom left base point of the facade is once more very clear. Beyond that the X-Y orientation is illustrated, which is important later for the entry of the window elements.

Position of the windows

The position of the windows is defined by the specification of their bottom left corner in relation to the facade coordinate system. Since a window lies flat on the facade, the entry is restricted to the X and Y coordinates.

The width and height must additionally be specified.

The position of each window corner on the facade is determined internally from the values entered. A window is considered to be in the shade if all corners lie in the shade.

Positioning of the shading objects

When describing the shading objects, distinction is made between angular objects (building, column) and objects that are approximately spherical (e.g. trees). Angular objects can be categorised according to the shadow they cast into square, shadow-casting facades, wherein one must consider which ones cast the main shadows over the course of the day:

Morning/midday

In the morning and at midday, the shadows are mainly cast by the sides S1 and S4; S2 und S3 need not be considered if they are not higher.

Afternoon / evening

In the afternoon and in the evening too, the total shade can be determined alone by the observation of S1 and S2. In this case, therefore, it is sufficient to specify S1 and S2 as shadow-casters. The entry is made on the basis of the four corners or their coordinates in relation to the zero point of the facade:

In this sketch only the upper points, P2 and P3, are illustrated due to the plan view. The lower point P1 lies underneath P2 and P4 lies underneath P3.

The input of shadow-casting ball elements is done by entering the centre of the ball and its radius:

Ball elements

A "classification" of the ball element as in the case of the angular building is of course unnecessary, since the shadow cast by a ball changes only its direction, but not its size.


FB_BARBlindPositionEntry

This block serves for the input of interpolation points for the function block FB_BARSunProtectionEx, if this should be operated in the height positioning mode with the help of a table, see E_BARPosMode.

In addition to the operating modes "Fixed shutter height" and "Maximum incidence of light", the function block FB_BARSunProtectionEx also offers the possibility to control the shutter height in relation to the position of the sun by means of table entries. By entering several interpolation points, the shutter height relative to the respective sun position is calculated by linear interpolation. However, since incorrectly entered values can lead to malfunctions in FB_BARSunProtectionEx , this block is to be preceded by the function block FB_BARBlindPositionEntry. Four interpolation points can be parameterised on this block, whereby a missing entry is evaluated as a zero entry.
The function block does not sort the values entered independently, but instead ensures that the positions of the sun entered in the respective interpolation points are entered in ascending order. Unintentional erroneous entries are noticed faster as a result.
The selected values for rSunElevation1 to rSunElevation4 must also be unique; for example, they may not be:
[rSunElevation1 = 10; uiBlindPosition1 = 50] and at the same time [rSunElevation2 = 10; uiBlindPosition2 = 30].
This would mean that there would be two different target values for one and the same value, which does not allow a unique functional correlation to be established.
On top of that the entries for the position of the sun and shutter height must lie within the valid range. Mathematically this means that the following conditions must be satisfied:

  • rSunElevation1 < rSunElevation2 < rSunElevation3 < rSunElevation4 - (values ascending and unequal)
  • 0 ≤rSunElevation≤ 90 (in degrees - range of validity of source values)
  • 0 ≤uiBlindPosition≤ 100 (in percent - range of validity of target values)

The function block checks the values entered for these conditions and outputs an error code if they are not satisfied. In addition, the output bValid is set to FALSE.
Furthermore the function block independently ensures that the boundary areas are filled out: Internally a further interpolation point is setup at rSunElevation = 0 with uiBlindPosition1 and a further one above rSunElevation4 at rSunElevation = 90 with uiBlindPosition4. This ensures that a sensible target value exists for all valid input values 0 ≤rSunElevation≤without the user having to assign an entry for rSunElevation = 0 and rSunElevation = 90:

The actual number of interpolation points transferred to the function block FB_BARSunProtectionEx thus increases to 6, see ST_BARBlindPositionTable.

The interpolation of the values takes place in the glare protection block.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bSetDefault        : BOOL;

eDataSecurityType: If eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eDataSecurityType_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.

VAR_OUTPUT

bValid               : BOOL;
uiErrorId            : UDINT;
stBlindPositionTable : ST_BARBlindPositionTable;

bValid: this output will be TRUE as long as the entries correspond to the criteria listed above.

uiErrorId: contains the error code, if the entries should not correspond to the criteria listed above. See Error codes.

stBlindPositionTable : Transfer structure of the interpolation points, see ST_BARBlindPositionTable.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

rSunElevation1   : REAL;;
uiBlindPosition1 : UINT;
rSunElevation2   : REAL;
uiBlindPosition2 : UINT;
rSunElevation3   : REAL;
uiBlindPosition3 : UINT;
rSunElevation4   : REAL;
uiBlindPosition4 : UINT;

rSunElevation1: sun position of the 1st interpolation point (0° to 90°).

uiBlindPosition1: blind position (closing degree) of the 1st interpolation point (0% to 100%).

rSunElevation2: sun position of the 2nd interpolation point (0° to 90°).

uiBlindPosition2: blind position (closing degree) of the 2nd interpolation point (0% to 100%).

rSunElevation3: sun position of the 3rd interpolation point (0° to 90°).

uiBlindPosition3: blind position (closing degree) of the 3rd interpolation point (0% to 100%).

rSunElevation4: sun position of the 4th interpolation point (0° to 90°).

uiBlindPosition4: blind position (closing degree) of the 4th interpolation point (0% to 100%).


FB_BARDelayedHysteresis

This function block represents a threshold switch for brightness. The switch-on and switch-off behaviour can additionally be delayed.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
uiBrightness       : UINT;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

uiBrightness: external brightness in lux.

VAR_OUTPUT

bOut       : BOOL;
bError     : BOOL;
udiErrorId : UDINT;

bOut: binary delayed output of the threshold switch

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiOnValue  : UINT;
uiOffValue : UINT;
uiOnDelay  : UINT;
uiOnDelay  : UINT;

uiOnValue: switch-on threshold value in lux. This must be larger than the switch-off threshold value usiOffValue.

uiOffValue: switch-off threshold value in lux. This must be smaller than the switch-on threshold value usiOnValue.

uiOnDelay: switch-on delay in seconds.

uiOffDelay: switch-off delay in seconds.


FB_BARFacadeElementEntry

This function block serves the administration of all facade elements (windows) in a facade, which are saved globally in a list of facade elements. It is intended to facilitate the input of the element information - also with regard to the use of the target visualisation. A schematic representation of the objects with description of the coordinates is shown in Shading correction: principles and definitions.

The facade elements are declared in the global variables as a two-dimensional field above the window columns and rows:

      VAR_GLOBAL
     arrFacadeElement : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;
END_VAR

Each individual element arrFacadeElement carries the information for one facade element (ST_BARFacadeElement). The information includes the group affiliation, the dimensions (width, height) and the coordinates of the corners. The block thereby accesses this field directly via the IN-OUT variable arrFacadeElement.

Note: The fact that the coordinates of corners 2 to 4 are output values arises from the fact that they are formed from the input parameters and are to be available for use in a visualisation:

All data in metres!

lrCorner2X = lrCorner1X
lrCorner2Y = lrCorner1Y + lrWindowHeight (window height)
lrCorner3X = lrCorner1X + lrWindowWidth (window width)
lrCorner3Y = lrCorner2Y
lrCorner4X = lrCorner1X + lrWindowWidth (window width)
lrCorner4Y = lrCorner1Y

The function block is used in three steps:

  • Read
  • Change
  • Write

Read

With the entries in iColumn and iRow the corresponding element is selected from the list arrFacadeElement[iColumn,iRow]. A rising edge on bRead reads the following data from the list element:

  • usiGroup Group membership,
  • lrCorner1X X-coordinate of corner 1 in metres
  • lrCorner1Y Y-coordinate of corner 1 in metres
  • lrWindowWidth Window width in metres
  • lrWindowHeight Window height in metres

These are then assigned to the corresponding input variables of the block, which uses them to calculate the coordinates of corners 2-4 as output variables in accordance with the correlation described above. It is important here that the input values are not overwritten in the reading step. Hence, all values can initially be displayed in a visualisation.

Change

In a next program step the listed input values can then be changed. The values entered are constantly checked for plausibility. The output bValid indicates whether the values are valid (bValid=TRUE). If this is not the case, a corresponding error code is output at the output udiErrorId. See also below "Errors (bValid=FALSE)".

Write

The parameterised data are written to the list element with the index nId upon a rising edge on bWrite, regardless of whether they represent valid values or not. Therefore the element structure ST_BARFacadeElement also contains a plausibility bit, bValue, that relays precisely this information to the function block FB_BARShadingCorrection / FB_BARShadingCorrectionSouth and prevents incorrect calculations there.

Error (bValid=FALSE)

The function block FB_BARShadingCorrection / FB_BARShadingCorrectionSouth, which judges whether all windows in a group are shaded, will only perform its task if all windows in the examined group have valid entries.
This means:

  • usiGroup must be greater than 0
  • lrCorner1X must be greater than or equal to 0.0
  • lrCorner1Y must be greater than or equal to 0.0
  • lrWindowWidth must be greater than 0
  • lrWindowHeight must be greater than 0

If one of these criteria is not fulfilled, then this is interpreted as an incorrect input and bValid is set to FALSE at the block output of FB_BARFacadeElementEntry as well as in the window element ST_BARFacadeElement.
If on the other hand all entries of a facade element are zero, it is regarded as a valid, deliberately omitted facade element:

In the case of a facade of 6x4 windows, the elements window (2,1), window (3,5) and window (4,4) would be empty elements here.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
iColumn            : INT;
iRow               : INT;
bWrite             : BOOL;
bRead              : BOOL;
usiGroup           : USINT;
lrCorner1X         : LREAL;
lrCorner1Y         : LREAL;
lrWindowWidth      : LREAL;
lrWindowHeight     : LREAL;

iColumn: column index of the selected component on the facade. This refers to the selection of a field element of the array stored in the IN-OUT variable arrFacadeElement.

iRow: ditto Row index. iRow and iColumn may not be zero! This arises from the field definition, see above.

bRead: with a rising edge on this input, the information from the selected element arrFacadeElement [iColumn,iRow] is read into the function block and assigned to the input variables usiGroup to rWindowHeight. This gives rise to the output variables rCorner2X to rCorner4Y. If data are already present on the inputs usiGroup to rWindowHeight at time of reading, then the data previously read are immediately overwritten with these data.

bWrite: A rising edge writes both the entered values and the calculated values into the selected field element arrFacadeElement [iColumn,iRow].

usiGroup: group membership.

lrCorner1X: X-coordinate of corner 1 in metres.

lrCorner1Y: Y-coordinate of corner 1 in metres.

lrWindowWidth: window width in metres.

lrWindowHeight: window height in metres.

VAR_OUTPUT

lrCorner2X : LREAL;
lrCorner2Y : LREAL;
lrCorner3X : LREAL;
lrCorner3Y : LREAL;
lrCorner4X : LREAL;
lrCorner4Y : LREAL;
bValid     : BOOL;
udiErrorId : UDINT;

lrCorner2X: determined X-coordinate of corner 2 of the window in metres. See "Note" above.

lrCorner2Y: determined Y-coordinate of corner 2 of the window in metres. See "Note" above.

lrCorner3X: determined X-coordinate of corner 3 of the window in metres. See "Note" above.

lrCorner3Y: determined Y-coordinate of corner 3 of the window in metres. See "Note" above.

lrCorner4X: determined X-coordinate of corner 4 of the window in metres. See "Note" above.

lrCorner4Y: determined Y-coordinate of corner 4 of the window in metres. See "Note" above.

bValid: result check for the entered values.

udiErrorId: contains the error code if the values entered are not OK. See Error codes.

VAR_IN_OUT

arrFacadeElement : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;

arrFacadeElement: List of facade elements.


FB_BARReadFacadeElementList

With the help of this function block, data for facade elements (windows) can be imported from a pre-defined Excel table in csv format into the list of facade elements. In addition the imported data are checked for plausibility and errors are written to a log file.

VAR_INPUT

bStart    : BOOL;
sDataFile : STRING;
sLogFile  : STRING;
sNetId    : STRING;

bStart: a TRUE edge on this input starts the reading process.

sDataFile: contains the path and file name for the data file to be opened. This must have been saved in Excel as file type "CSV (comma-separated values) (*.csv)". If the file is opened with a simple text editor, then the values must be displayed separated by semicolons. Example of an entry: sDataFile:= 'C:\Projekte\FacadeElements.csv'

sLogFile: ditto Log file for the accumulating errors. This file is overwritten each time the function block is activated, so that only current errors are contained.

sNetId: a string can be entered here with the AMS Net ID of the TwinCAT computer on which the files are to be written/read. If it is to be run on the local computer, an empty string can be entered.

Note: The data can be saved only on the control computer itself and on the computers that are connected by ADS to the control computer. Links to local hard disks in this computer are possible, but not to connected network hard drives.

VAR_OUTPUT

bBusy              : BOOL;
bError             : BOOL;
udiErrorId         : UDINT;
uiAmountOfSetsRead : UINT;

bBusy: this output is TRUE as long as elements are being read from the file.

bError: this output is switched to TRUE if the parameters entered are erroneous or if an error has occurred while writing to or reading from the file.

udiErrorId: contains the error code of the error that occurred last. See Error codes or ADS_Error codes.

uiAmountOfSetsRead: number of data sets read

VAR_IN_OUT

arrFacadeElement : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;

arrFacadeElement: List of facade elements.

Excel table

The following example shows the Excel table with the entries of the window elements.
All text fields are freely writeable; important are the green marked fields, wherein each line of a data set is marked there.
The following rules are to be observed:

  • A data set must always start with a '@'.
  • The indices IndexColumn and IndexRow must lie within the defined limits, see List of facade elements. These indices directly describe the facade element in the list arrFacadeElements to which the data from the set are saved.
  • Window width and window height must be greater than zero
  • The corner coordinates P1x and P1y must be greater than or equal to zero.
  • Each window element must be assigned to a group from 1 to 255.
  • For system-related reasons the total size of the table may not exceed 65534 bytes.
  • This must have been saved in Excel as file type "CSV (comma-separated values) (*.csv)".

It is not necessary to describe all window elements that would be possible by definition or declaration. Before the new list is read in, the function block deletes the entire old list in the program. All elements that are not described by entries in the Excel table then have pure zero entries and are thus marked as non-existent and also non-evaluable, since the function block for shading correction, FB_BARSunProtectionEx, does not accept elements with the group entry '0'.

Log file

Each time the reading function block is restarted, the log file is rewritten and the old contents are deleted. If there is no log file, it will be automatically created first. The log file then contains either an OK message or a list of all errors that have occurred. Errors connected with the opening, writing or closing of the log file itself cannot be written at the same time. Therefore the output udiErrorId of the reading function block must also always be observed, since it displays the last error code. Since the log file is always closed last during the reading process, a corresponding alarm is ensured in the event of an error.

Program Example

In this example the variable bInit is initially set to TRUE when the PLC starts. Hence, the input bStart on the function block fbReadFacadeElementList receives a once-only rising edge that triggers the reading process. The file "FacadeElements.csv" is read, which is located in the folder "C:\Projects\". The log file "Logfile.txt" is then saved in the same folder. If this log file does not yet exist it will be created, otherwise the existing contents are overwritten. Reading and writing take place on the same computer on which the PLC is located. This is defined by the input sNetID = '' (=local). All data are written to the list arrFacadeElement declared in the program. The output bBusy is TRUEs as long as reading and writing are taking place. The error that occurred last is indicated on udiErrorId; bError is then TRUE. The number of data lines found and read is indicated on uiAmountOfSetsRead for checking purposes.

The errors marked were "built into" the following Excel list. This gives rise to the log file shown:

The first error is in data set 2 and is an index error, since "0" is not permitted.
The next error in data set 6 was found after validation of the data with the internally used function block FB_BARShadingObjectsEntry and was therefore provided in greater detail with an error number, which is explained in greater detail under error codes. The third and the fourth errors likewise occurred after the internal validation. Important here it that the data set numbers (in this case 22 and 24) do not go by the numbers entered in the list, but by the actual sequential numbers: only 30 data sets were read in here.


FB_BARReadShadingObjectsList

With the help of this function block, data for shading objects can be imported from a pre-defined Excel table in csv format into the list of shading objects. In addition the imported data are checked for plausibility and errors are written to a log file.

VAR_INPUT

bStart    : BOOL;
sDataFile : STRING;
sLogFile  : STRING;
sNetId    : STRING;

bStart: a TRUE edge on this input starts the reading process.

sDataFile: contains the path and file name for the data file to be opened. This must have been saved in Excel as file type "CSV (comma-separated values) (*.csv)". If the file is opened with a simple text editor, then the values must be displayed separated by semicolons. Example of an entry: sDataFile:= 'C:\Projekte\ShadingObjects.csv'

sNetId: a string can be entered here with the AMS Net ID of the TwinCAT computer on which the files are to be written/read. If it is to be run on the local computer, an empty string can be entered.

Note: The data can be saved only on the control computer itself and on the computers that are connected by ADS to the control computer. Links to local hard disks in this computer are possible, but not to connected network hard drives.

VAR_OUTPUT

bBusy              : BOOL;
bError             : BOOL;
udiErrorId         : UDINT;
uiAmountOfSetsRead : UINT;

bBusy: This output is TRUE as long as elements are being read from the file.

bError: This output is switched to TRUE if the parameters entered are erroneous or if an error has occurred while writing to or reading from the file.

udiErrorId: Contains the error code of the error that occurred last. See Error codes or ADS_Error codes.

uiAmountOfSetsRead: number of data sets read.

VAR_IN_OUT

arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;

arrShadingObject: List of shading objects.

Excel table

The following example shows the Excel table with the entries of the window elements.
All text fields are freely writeable; important are the green marked fields, wherein each line of a data set is marked there. The columns G to J have a different meaning depending on whether the type square or ball is concerned. The columns K to M are to be left empty in the case of balls. With regard to the square coordinates, only the relevant data are entered and the remainder are internally calculated, see FB_BARShadingObjectsEntry.
The following rules are to be observed:

  • A data set must always start with a '@'.
  • The monthly entries may not be 0 or greater than 12, otherwise all combinations are possible.
    Examples:
    Start=1, End=1: shading in January.
    Start=1, End=5: shading from the beginning of January to the end of May.
    Start=11, End=5: shading from the beginning of November to the end of May (the following year).
  • Window width and window height must be greater than zero
  • The z-coordinates P1z and P3z or Mz must be greater than zero.
  • The radius must be greater than zero.
  • For system-related reasons the total size of the table may not exceed 65534 bytes.
  • This must have been saved in Excel as file type "CSV (comma-separated values) (*.csv)".

Is not necessary to describe all shading objects that are possible per facade. Only those contained in the list ultimately take effect.

Log file

Each time the reading function block is restarted, the log file is rewritten and the old contents are deleted. If there is no log file, it will be automatically created first. The log file then contains either an OK message or a list of all errors that have occurred. However, errors connected with the opening, writing or closing of the log file itself cannot be written at the same time. Therefore the output udiErrorId of the reading function block must also always be observed, since it displays the last error code. Since the log file is always closed last during the reading process, a corresponding alarm is ensured in the event of an error.

Program Example

In this example the variable bInit is initially set to TRUE when the PLC starts. Hence, the input bStart on the function block fbReadShadingObjectsList receives a once-only rising edge that triggers the reading process. The file "ShadingObjects.csv" is read, which is located in the folder "C:\Projects\". The log file "Logfile.txt" is then saved in the same folder. If this log file does not yet exist it will be created, otherwise the existing contents are overwritten. Reading and writing take place on the same computer on which the PLC is located. This is defined by the input sNetID = '' (=local). All data are written to the list arrShadingObject declared in the program. The output bBusy is TRUEs as long as reading and writing are taking place. The error that occurred last is indicated on udiErrorId; bError is then TRUE. The number of data lines found and read is indicated on uiAmountOfSetsRead for checking purposes.

The errors marked were built into the following Excel list. This gives rise to the log file shown:

The first error is in data set 3 and is a type error, since "2" is not defined.
The next error in data set 6 was found after validation of the data with the internally used function block FB_BARShadingObjectsEntry and was therefore provided in greater detail with an error number, which is explained in greater detail under error codes. The third error likewise occurred after the internal validation. Important here it that the data set number (in this case 11) does not go by the number entered in the list, but by the actual sequential number: only 16 data sets were read in here.


FB_BARShadingCorrection

Function block for the shading evaluation of a window group on a facade.

This function block is valid for the northern hemisphere only. The equivalent valid for the southern hemisphere is the function block FB_BARShadingCorrectionSouth.

The function block FB_BARShadingCorrection calculates whether a window group lies in the shadow of surrounding objects. The result, which is output at the output bGroupNotShaded, can be used to judge whether sun shading makes sense for this window group.
The function block thereby accesses two lists, which are to be defined:

  • The data of the elements (window) of the facade in which the group to be regarded is located. This list of facade elements is accessed via the IN-OUT variable arrFacadeElement, which itself is globally defined.
  • The parameters that describe the shading elements that are relevant to the facade on which the window group is located. This list of shading objects is likewise globally defined. The IN-OUT variable arrShadingObject accesses it directly.

On the basis of the facade orientation (lrFacadeOrientation), the direction of the sun (lrAzimuth) and the height of the sun (lrElevation), a calculation can be performed for each corner of a window to check whether this lies in a shaded area. A window group is considered to be completely shaded if all corners are shaded.

The facade orientation is related to north, wherein the following applies to the line of sight from a window in the facade:

Line of sight | Facade orientation
North | β=0°
East | β=90°
South | β=180°
West | β=270°

The function block performs its calculations only if the sun is actually shining on the facade. If one regards the drawing presented in the introduction, then this is the case if the following is true:

Facade orientation < azimuth angle < facade orientation + 180°

Beyond that a calculation is also unnecessary if the sun has not yet risen, i.e. the height of the sun (elevation) lies below 0°. In both cases the output bFacadeSunlit is set to FALSE.

VAR_INPUT

eDataSecurityType   : E_HVACDataSecurityType;
stTimeAct           : TIMESTRUCT;
lrAzimuth           : LREAL;
lrElevation         : LREAL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

stTimeAct: entry of the current time in GMT (Greenwich Mean Time).

rAzimuth: sun direction in degrees at the time of observation.

rElevation: sun elevation in degrees at the time of observation.

VAR_OUTPUT

bGroupNotShaded : BOOL;
bFacadeSunlit   : BOOL;
bError          : BOOL;
udiErrorId      : UDINT;

bGroupNotShaded: is TRUE as long as the window group is not calculated as shaded.

bFacadeSunlit: this output is set to TRUE if the sun is shining on the facade. See description above.

bError: this output is set to TRUE if an error is detected during the execution of the function block.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

arrFacadeElement     : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;
arrShadingObject     : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;
lrFacadeOrientation : LREAL;
usiGroupID           : USINT;

arrFacadeElement: List of facade elements.

arrShadingObject: List of shading objects.

lrFacadeOrientation: Facade orientation, see illustration above.

usiGroupId: window group regarded. The group 0 is reserved here for unused window elements, see FB_BARFacadeElementEntry. A 0-entry would lead to an error output (bError=TRUE). The function block is then not executed any further and bGroupNotShaded is set to FALSE.


FB_BARShadingCorrectionSouth

Function block for the shading evaluation of a window group on a facade.

This function block is valid for the southern hemisphere only. The equivalent valid for the northern hemisphere is the function block FB_BARShadingCorrection.

The function block FB_BARShadingCorrectionSouth calculates whether a window group lies in the shadow of surrounding objects. The result, which is output at the output bGroupNotShaded, can be used to judge whether sun shading makes sense for this window group.
The function block thereby accesses two lists, which are to be defined:

  • The data of the elements (window) of the facade in which the group to be regarded is located. This list of facade elements is accessed via the IN-OUT variable arrFacadeElement, which itself is globally defined.
  • The parameters that describe the shading elements that are relevant to the facade on which the window group is located. This list of shading objects is likewise globally defined. The IN-OUT variable arrShadingObject accesses it directly.

On the basis of the facade orientation (lrFacadeOrientation), the direction of the sun (lrAzimuth) and the height of the sun (lrElevation), a calculation can be performed for each corner of a window to check whether this lies in a shaded area. A window group is considered to be completely shaded if all corners are shaded.

The facade orientation is related to south, wherein the following applies to the line of sight from a window in the facade:

Line of sight | Facade orientation
South | β=0°
East | β=90°
North | β=180°
West | β=270°

The function block performs its calculations only if the sun is actually shining on the facade. If one regards the drawing presented in the introduction, then this is the case if the following is true:

Facade orientation < azimuth angle < facade orientation + 180°

Beyond that a calculation is also unnecessary if the sun has not yet risen, i.e. the height of the sun (elevation) lies below 0°. In both cases the output bFacadeSunlit is set to FALSE.

VAR_INPUT

eDataSecurityType   : E_HVACDataSecurityType;
stTimeAct           : TIMESTRUCT;
lrAzimuth           : LREAL;
lrElevation         : LREAL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

stTimeAct: entry of the current time in GMT (Greenwich Mean Time).

rAzimuth: sun direction in degrees at the time of observation.

rElevation: sun elevation in degrees at the time of observation.

VAR_OUTPUT

bGroupNotShaded : BOOL;
bFacadeSunlit   : BOOL;
bError          : BOOL;
udiErrorId      : UDINT;

bGroupNotShaded: is TRUE as long as the window group is not calculated as shaded.

bFacadeSunlit: this output is set to TRUE if the sun is shining on the facade. See description above.

bError: this output is set to TRUE if an error is detected during the execution of the function block.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

arrFacadeElement     : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;
arrShadingObject     : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;
lrFacadeOrientation : LREAL;
usiGroupID           : USINT;

arrFacadeElement: List of facade elements.

arrShadingObject: List of shading objects.

lrFacadeOrientation: Facade orientation, see illustration above.

usiGroupId: window group regarded. The group 0 is reserved here for unused window elements, see FB_BARFacadeElementEntry. A 0-entry would lead to an error output (bError=TRUE). The function block is then not executed any further and bGroupNotShaded is set to FALSE.


FB_BARShadingObjectsEntry

This function block serves for the administration of all shading elements in a facade, which is globally saved in a list of shading elements. It is intended to facilitate the input of the element information - also with regard to the use of the target visualisation. A schematic representation of the objects with description of the coordinates is shown in Shading correction: principles and definitions.

The shading elements are declared in the global variable:

      VAR_GLOBAL
     arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;
END_VAR

Each individual element arrShadingObject[1] to arrShadingObject[iShadingObjects] carries the information for one shading element (ST_BARShadingObject). This information consists of the selected type of shading (square or ball) and the respectively associated coordinates. In the case of a square these are the corners (lrP1x, lrP1y, lrP1z), (lrP2x, lrP2y, lrP2z),(lrP3x, lrP3y, lrP3z) and (lrP4x, lrP4y, lrP4z), and in the case of a ball the centre (lrMx, lrMy, lrMz) and the radius lrRadius. In addition, the phase of the shading can be defined via the inputs usiBeginMonth and usiEndMonth, which is important in the case of objects such as trees that bear no foliage in winter.

The function block thereby directly accesses the field of this information via the IN-OUT variable arrShadingObject.

Note: The fact that the square coordinates lrP2x, lrP2z, lrP4x, lrP4y and lrP4z are output values arises from the fact that they are formed from the input parameters:

      lrP2x = lrP1x; lrP2z = lrP1z;
lrP4x = lrP3x; lrP4y = lrP1y; lrP4z =
lrP3z;

That limits the input of a square to the extent that the lateral edges stand vertically on the floor (lrP2x = lrP1x and lrP4x = lrP3x), that the square has no inclination (lrP2z = lrP1z and lrP4z = lrP3z) and can only have a different height "upwards", i.e. in the positive y-direction (lrP4y = lrP1y).

The function block is used in three steps:

  • Read
  • Change
  • Write

Read

With the entry to iId the appropriate element is selected from the list arrShadingObject, [iId]. A rising edge on bRead reads the data. These values are assigned to the input and output variables of the function block. This concerns the input values lrP1x, lrP1y, lrP1z, lrP2y, lrP3x, lrP3y, lrP3z, lrMx, lrMy, lrMz and rRadius and the object enumerator eType and the output values lrP2x, lrP2z, lrP4x, lrP4y, and lrP4z. It is important here that the input values are not overwritten in the reading step. Hence, all values can initially be displayed in a visualisation.

Change

In a next program step the listed input values can then be changed. If the use of a square is preselected via the value "eObjectTypeTetragon" at the input eType, then the output values lrP2x, lrP2z, lrP4x, lrP4y and lrP4z result from the square coordinates entered, see above.

The values entered are constantly checked for plausibility. The output bValid indicates whether the values are valid (bValid=TRUE). If this is not the case, a corresponding error code is output at the output udiErrorId.
If a square is defined, then only the inputs lrP1x, lrP1y, lrP1z, lrP2y, lrP3x, lrP3y and lrP3z need to be described; the inputs lrMx, lrMy, lrMz and lrRadius do not need to be linked. In case of a ball definition, only lrMx, lrMy, lrMz and lrRadius need to be described and the square coordinates can remain unlinked.

The parameterised data are written to the list element with the index iId upon a rising edge on bWrite, regardless of whether they represent valid values or not. Therefore the element structure ST_BARShadingObject also contains a plausibility bit, bValid, that relays precisely this information to the function block FB_BARShadingCorrection / FB_BARShadingCorrectionSouth and prevents incorrect calculations there.

This approach is to be regarded only as a proposal. It is naturally also possible to parameterise the function block quite normally in one step and to write the values entered to the corresponding list element with a rising edge on bWrite.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
iId                : INT;
bRead              : BOOL;
bWrite             : BOOL;
lrP1x              : LREAL;
lrP1y              : LREAL;
lrP1z              : LREAL;
lrP2y              : LREAL;
lrP3x              : LREAL;
lrP3y              : LREAL;
lrP3z              : LREAL;
lrMx               : LREAL;
lrMy               : LREAL;
lrMz               : LREAL;
lrRadius           : LREAL;
usiBeginMonth      : USINT;
usiEndMonth        : USINT;
eType              : E_BARShadingObjectType;

iId: index of the selected element. This refers to the selection of a field element of the array saved in the IN-OUT variable arrShadingObject. iId may not be zero! This results from the field definition, arrShadingObject: ARRAY[1..iShadingObjects] OF ST_BARShadingObject;

bRead: With a rising edge on this input the information of the selected element, arrShadingObject [iId], is read into the function block and assigned to the input variables lrP1x to eType as well as the output variables lrP2x to lrP4z. If data are already present on the inputs lrP1x to eType at this time, then the data previously read are immediately overwritten with these data.

bWrite: A rising edge writes the values on the inputs rP1x to eType as well as the values determined and assigned to the outputs lrP2x to lrP4z into the selected field element arrShadingObject [iId].

lrP1x: X-coordinate of point 1 of the shading element (square) in metres.

lrP1y: Y-coordinate of point 1 of the shading element (square) in metres.

lrP1z: Z-coordinate of point 1 of the shading element (square) in metres.

lrP2y: Y-coordinate of point 2 of the shading element (square) in metres.

lrP3x: X-coordinate of point 3 of the shading element (square) in metres.

lrP3y: Y-coordinate of point 3 of the shading element (square) in metres.

lrP3z: Z-coordinate of point 3 of the shading element (square) in metres.

lrMx: X-coordinate of the centre of the shading element (ball) in metres.

lrMy: Y-coordinate of the centre of the shading element (ball) in metres.

lrMz: Z-coordinate of the centre of the shading element (ball) in metres.

lrRadius: radius of the shading element (ball) in metres.

usiBeginMonth: beginning of the shading period (number of month).

usiEndMonth: end of the shading period (number of month).

eType: selected type of element: square or ball. See E_BARShadingObjectType.

Remark about the shading period:

The monthly entries may not be 0 or greater than 12, otherwise all combinations are possible.
Examples:
Start=1, End=1: shading in January.
Start=1, End=5: shading from the beginning of January to the end of May.
Start=11, End=5: shading from the beginning of November to the end of May (the following year).

VAR_OUTPUT

lrP2x       : LREAL;
lrP2z       : LREAL;
lrP4x       : LREAL;
lrP4y       : LREAL;
lrP4z       : LREAL;
bValid     : BOOL;
udiErrorId : UDINT;

lrP2x: determined X-coordinate of point 2 of the shading element (square) in metres. See "Note" above.

lrP2z: determined Z-coordinate of point 2 of the shading element (square) in metres. See "Note" above.

lrP4x: determined X-coordinate of point 4 of the shading element (square) in metres. See "Note" above.

lrP4y: determined Y-coordinate of point 4 of the shading element (square) in metres. See "Note" above.

lrP4z: determined Z-coordinate of point 4 of the shading element (square) in metres. See "Note" above.

bValid: Result of the plausibility check for the values entered. With respect to a square it is required that the internal angle is 360° and that the points lie in one plane and in front of the facade regarded. In the case of a ball the centre must likewise lie in front of the facade and the radius must be greater than zero.

udiErrorId: contains the error code, if the entries should not correspond to the criteria mentioned. See Error codes.

VAR_IN_OUT

arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;

arrShadingObject : List of shading objects. Values are persistently saved.


FB_BARSunblindActuator

This function block serves to position a blind via two outputs: drive up and drive down. The blind can be driven to any desired (height) position and louvre angle via the positioning telegram stSunblind. On top of that, the positioning telegram stSunblind also contains manual commands with which the blind can be moved individually to certain positions. These manual commands are controlled by the function block FB_BARSunblindSwitch.

For driving-times longer than 65s the function-block FB_BARSunblindActuatorEx has to be used.

Structure of the blind positioning telegram stSunblind.
TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

The current height position and the louvre angle are not read in by an additional encoder, but determined internally by the travel time of the blind. The calculation is based on the following drive profile (regarded from the highest and lowest position of the blind):

Downward drive profile:

More detailed explanations of the terms "backlash" and "turning" are given here in the downward movement:

The blind normally describes its downward movement with the louvre low point directed outwards, as in fig. 3.
If the blind is in an initial position with the low point directed inwards (i.e. after the conclusion of an upward movement), then a certain time elapses after a new downward movement begins before the louvres start to turn from the "inward low point" to the "outward low point". During this time the louvre angle does not change; the blind only drives downward (fig.1 and fig. 2). This time is an important parameter for the movement calculation and is entered in the function block in ms under uiBacklashTimeDown. Since it is not known at an arbitrary point after a blind movement of an arbitrary length whether part of the backlash has already been travelled, the most secure way to measure the backlash of the downward movement or its travel time is when the blind has initially been driven fully upward. A further important parameter is the time interval of the subsequent turning of the louvres from the "Inward low point" to the "Outward low point". This time is to be entered as uiTurningTimeDown in ms in the function block.

Upward travel profile:

More detailed explanations of the terms "backlash" and "turning" are given here in the upward movement:

The circumstances are similar to the downward movement described above: The blind normally describes its upward movement with the louvre low point directed inwards, as in fig. 3.
If the blind is in an initial position with the low point directed outwards (i.e. after the conclusion of a downward movement), then a certain time elapses after a new upward movement begins before the louvres start to turn from the "Outward low point" to the "Inward low point". During this time the louvre angle does not change; the blind only drives upward (fig. 1 and fig. 2). This time is also an important parameter for the movement calculation and is entered in the function block in ms under uiBacklashTimeUp. Since it is not known at an arbitrary point after a blind movement of an arbitrary length whether part of the backlash has already been travelled, the most secure way to measure the backlash of the upward movement or its travel time is when the blind has initially been driven fully downward. A further important parameter is the time interval of the subsequent turning of the louvres from the "Outward low point" to the "Inward low point". This time is to be entered as uiTurningTimeUp in ms in the function block.

Parameterisation

For the calculation of the (height) position and the louvre angle, the following times now have to be determined for both the upward and downward movement:

  • the travel time of the backlash (uiBacklashTimeUp / uiBacklashTimeDown in ms)
  • the turning duration (uiTurningTimeUp / uiTurningTimeDown in ms)
  • the total travel time (uiTotalUpTime / uiTotalDownTime in ms)

Furthermore the following are required for the calculation:

  • the total extended blind height (uiBlindHeight in mm)
  • the highest louvre angle after turning upwards (iAngleLimitUp in degrees)
  • the lowest louvre angle after turning downwards (iAngleLimitDown in degrees)

The louvre angle λ is defined by a notional straight line through the end points of the louvre to the horizontal.

Functioning

The function block fundamentally controls the blind via the information from the positioning telegram stSunblind. If automatic mode is active (bManualMode=FALSE), then the current position and louvre angle are always driven to, wherein changes are immediately accounted for. The height positioning takes priority: First the entered height and afterwards the louvre angle are driven to. For reasons of the simplicity the position error due to the angle movement is disregarded. In manual mode (bManualMode=TRUE) the commands bManUp and bManDown control the blind.

Referencing

Secure referencing is ensured if the blind is driven upward for longer than its complete drive-up time. The position is then in any case "0" and the louvre angle is at its maximum. Since blind positioning without an encoder is naturally always susceptible to error, it is important to automatically reference as often as possible: each time the "0" position is to be driven to (the angle is unimportant), the blind initially drives upward quite normally with continuous position calculation. Once the calculated position value of 0% has been reached, the output bBlindUp is kept active until another complete drive-up time + 5 s has elapsed.
For reasons of flexibility there are now two possibilities to interrupt the referencing procedure: Until the calculated 0% position has been reached, a change of position is still accepted and executed; after reaching this 0% position, the manual command "down" can still move the blind differently. These two sensible limitations make it necessary for the user to ensure that the blind is securely referenced as often as possible.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bEnable            : BOOL;
stSunblind         : ST_BARSunblind;

eDataSecurityType:if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: enable input for the function block. As long as this input is TRUE, the actuator function block accepts and executes commands as described above. A FALSE signal on this input resets the control outputs bBlindUp and bBlindDown and the function block remains in a state of rest.

stSunblind: positioning telegram, see ST_BARSunblind.

VAR_OUTPUT

bBlindUp       : BOOL;
bBlindDown     : BOOL;
uiActPosition  : UINT;
uiActAngle     : UINT;
bReferencing   : BOOL;
bBusy          : BOOL;
bError         : BOOL;
udiErrorId     : UDINT;

bBlindUp: control output for blind up.

bBlindDown: control output for blind down.

uiActPosition: current position in percent.

uiActAngle: current louvre angle in degrees.

bReferencing: the blind is in the reference-process, which means, that the output bBlindUp will be set for the complete drive-up time + 5 s. Only the manual command "down" can move the blind in the opposite direction an terminate the reference-mode.

bBusy: a positioning or a referencing procedure is in progress.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiBacklashTimeUp   : UINT;
uiBacklashTimeDown : UINT;
uiTurningTimeUp    : UINT;
uiTurningTimeDown  : UINT;
uiTotalTimeUp      : UINT;
uiTotalTimeDown    : UINT;
uiBlindHeight      : UINT;
iAngleLimitUp      : INT;
iAngleLimitDown    : INT;

uiBacklashTimeUp: time to traverse the backlash in the upward direction in ms.

uiBacklashTimeDown: time to traverse the backlash in the downward direction in ms.

uiTurningTimeUp: time for turning the louvres in the upward direction in ms.

uiTurningTimeDown: time for turning the louvres in the downward direction in ms.

uiTotalTimeUp: complete time for driving up in ms.

uiTotalTimeDown: complete time for driving down in ms.

uiBlindHeight: blind height in mm.

iAngleLimitUp: highest position of the louvres in degrees.

This position is reached, when the blind is completely driven up.

The lamella-angle λ, as described above, is typically greater than 0.

iAngleLimitDown: lowest position of the louvres in degrees.

This position is reached, when the blind is completely driven down.

The lamella-angle λ, as described above, is typically lower than 0.


FB_BARSMISunblindActuator

This block works like the FB_BARSunblindActuator only with the difference that an SMI motor is driven directly.

Required library is the TwinCAT 2 PLC Lib: SMI.

Download PLC export file: FB_BARSMISunblindActuator.zip

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bEnable            : BOOL;
stSunblind         : ST_BARSunblind;
tPositionRead      : TIME;
dwAddr             : DWORD;
eAddrType          : E_SMIAddrType;
dwAddrOption       : DWORD;
dwMasterDevAddr    : DWORD;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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

Attention

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

bEnable: enable input for the function block. As long as this input is TRUE, the actuator function block accepts and executes commands as described above. A FALSE signal on this input lets the function block remain in a state of rest.

stSunblind: positioning telegram, see ST_BARSunblind

tPositionRead: interval in which the current position is read from the SMI motor if positioning commands are processed.

dwAddr: manufacturer code (0-15), address of a device (0-15), bit field (16 bits) for the group addressing or slave ID (32-bit key ID). This input has no meaning if a collective call (broadcast) is sent.

eAddrType: defines whether the dwAddr input is to be evaluated as a manufacturer code, the address of a device, for group addressing or as a slave ID.

dwAddrOption: if the SMI device is addressed by slave ID (eAddrType = eSMIAddrTypeSlaveId), then the manufacturer code must be specified via this input.

dwMasterDevAddr: address (0-15) of the SMI motor of which the current position is to be read when eAddrType != eSMIAddrTypeAddress.

VAR_OUTPUT

uiActPosition  : UINT;
iActAngle      : INT;
bBusy          : BOOL;
bError         : BOOL;
udiErrorId     : UDINT;

uiActPosition: current position in percent.

iActAngle: current louvre angle in degrees.

bBusy: a positioning is in progress.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

wLouvreRange       : WORD;
iAngleLimitUp      : INT;
iAngleLimitDown    : INT;
stCommandBuffer    : ST_SMICommandBuffer;

wLouvreRange: Number of steps of the louvres from "low point inside" to the "low point outside".

iAngleLimitUp: Highest position of the louvres in degrees (-360..360).

iAngleLimitDown: Lowest position of the louvres in degrees (-360..360).

stCommandBuffer: reference to the structure for communication (buffer) with the FB_KL6831KL6841Communication() block.


FB_BARSunblindEvent

This function block serves to preset the position and angle for any desired event. It can be used, for example, in order to drive to a parking position or to drive the blind upward for maintenance.

The function is activated via the input bActivate. If this is the case, then the active flag is set in the positioning telegram (bActive in stSunblind) at the output stSunblind and the values uiPositionEvent for the blind height in % and iAngleEvent for the louvre angle in degrees, which are entered in the In-Out variables, are passed on in this telegram. If the function is no longer active due to the resetting of bActive, then the active flag in the positioning telegram stSunblind is reset and the positions for height and angle are set to "0". If the priority function block is used, then a function with a lower priority can take over the control.

VAR_INPUT

eDataSecurityType   : E_HVACDataSecurityType;
bActivate             : BOOL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bActivate: A TRUE signal on this input activates the function block and transfers the entered setpoint values together with the active flag in the positioning telegram ST_BARSunblind . A FALSE signal resets the active flag again and sets position and angle to zero.

VAR_OUTPUT

stSunblind : ST_BARSunblind;
bActive    : BOOL;

bActive: Corresponds to the Boolean value bActive in the blind telegram ST_BARSunblind and serves merely to indicate whether the function block is sending an active telegram.

stSunblind : Output structure of the blind positions, see ST_BARSunblind

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiPositionPark : UINT;
iAnglePark     : INT;

uiPositionEvent: Height position of the blind in % in case of activation.

iAngleEvent: Louvre angle of the blind in degrees in case of activation.


FB_BARSunblindPrioritySwitch

Priority controller for up to 9 positioning telegrams (stSunblind_Prio1 to stSunblind_Prio9) of the type ST_BARSunblind.

Structure of the blind positioning telegram ST_BARSunblind.

TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

Up to 9 positioning telegrams from different control function blocks can be applied to this function block. The telegram on stSunblind_Prio1 has the highest priority and that on stSunblind_Prio9 the lowest. The active telegram with the highest priority is output at the output stSunblind. "Active" means that the variable bActive is set within the structure of the positioning telegram.

Note: This function block is to be programmed in such a way that one of the applied telegrams is always active. If this is not the case, then an empty telegram is output, i.e. uiPosition=0, iAngle=0, bManUp=FALSE, bManDown=FALSE, bManualMode=FALSE and bActive=FALSE. Since the blind function blocks FB_BARSunblindActuator and FB_BARRollerBlind themselves do not pay attention to the bActive flag, this telegram would thus be evaluated as a command to drive to position "0", i.e. fully open. The absence of an active telegram therefore does not represent a safety risk for the blind.

VAR_INPUT

stSunblind_Prio1  : ST_BARSunblind;
stSunblind_Prio2  : ST_BARSunblind;
stSunblind_Prio3  : ST_BARSunblind;
stSunblind_Prio4  : ST_BARSunblind;
stSunblind_Prio5  : ST_BARSunblind;
stSunblind_Prio6  : ST_BARSunblind;
stSunblind_Prio7  : ST_BARSunblind;
stSunblind_Prio8  : ST_BARSunblind;
stSunblind_Prio9  : ST_BARSunblind;

stSunblind_Prio1..stSunblind_Prio9: Positioning telegrams available for selection. stSunblind_Prio1 has the highest priority and stSunblind_Prio9 the lowest.

VAR_OUTPUT

stSunblind    : ST_BARSunblind;

stSunblind: resulting positioning telegram.


FB_BARRollerBlind

This function block serves to position a blind via two outputs: drive up and drive down. The blind can be driven to any desired (height) position and louvre angle via the positioning telegram stSunblind. On top of that, the positioning telegram stSunblind also contains manual commands with which the blind can be moved individually to certain positions. These manual commands are controlled by the function block FB_BARSunblindSwitch.

Structure of the blind positioning telegram stSunblind.
TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

The current height positionis not read in by an additional encoder, but determined internally by the travel time of the blind.
By distingiushing between a complete time for driving up (udiTotalTimeUp) and a complete time for driving down (udiTotalTimeDown) the different behaviour of driving in both directions has been taken into account.

Functioning

The function block fundamentally controls the blind via the information from the positioning telegram stSunblind. If automatic mode is active (bManualMode=FALSE), then the current position is always driven to, wherein changes are immediately accounted for. In manual mode (bManualMode=TRUE) the commands bManUp and bManDown control the blind.

Referencing

Secure referencing is ensured if the blind is driven upward for longer than its complete drive-up time. The position is then in any case "0" and the louvre angle is at its maximum. Since blind positioning without an encoder is naturally always susceptible to error, it is important to automatically reference as often as possible: each time the "0" position is to be driven to (the angle is unimportant), the blind initially drives upward quite normally with continuous position calculation. Once the calculated position value of 0% has been reached, the output bBlindUp is kept active until another complete drive-up time + 5 s has elapsed.
For reasons of flexibility there are now two possibilities to interrupt the referencing procedure: Until the calculated 0% position has been reached, a change of position is still accepted and executed; after reaching this 0% position, the manual command "down" can still move the blind differently. These two sensible limitations make it necessary for the user to ensure that the blind is securely referenced as often as possible.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bEnable            : BOOL;
stSunblind         : ST_BARSunblind;

eDataSecurityType:if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: enable input for the function block. As long as this input is TRUE, the actuator function block accepts and executes commands as described above. A FALSE signal on this input resets the control outputs bBlindUp and bBlindDown and the function block remains in a state of rest.

stSunblind: positioning telegram, see ST_BARSunblind.

VAR_OUTPUT

bBlindUp       : BOOL;
bBlindDown     : BOOL;
uiActPosition  : UINT;
bReferencing   : BOOL;
bBusy          : BOOL;
bError         : BOOL;
udiErrorId     : UDINT;

bBlindUp: control output for blind up.

bBlindDown: control output for blind down.

uiActPosition: current position in percent.

bReferencing: the blind is in the reference-process, which means, that the output bBlindUp will be set for the complete drive-up time + 5 s. Only the manual command "down" can move the blind in the opposite direction an terminate the reference-mode.

bBusy: a positioning or a referencing procedure is in progress.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

udiTotalTimeUp      : UDINT;
udiTotalTimeDown    : UDINT;

udiTotalTimeUp: complete time for driving up in ms.

udiTotalTimeDown: complete time for driving down in ms.


FB_BARSMIRollerBlind

This block works like the FB_BARRollerBlind only with the difference that an SMI motor is driven directly.

Required library is the TwinCAT 2 PLC Lib: SMI.

Download PLC export file: FB_BARSMISunblindActuator.zip

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bEnable            : BOOL;
stSunblind         : ST_BARSunblind;
tPositionRead      : TIME;
dwAddr             : DWORD;
eAddrType          : E_SMIAddrType;
dwAddrOption       : DWORD;
dwMasterDevAddr    : DWORD;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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

Attention

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

bEnable: enable input for the function block. As long as this input is TRUE, the actuator function block accepts and executes commands as described above. A FALSE signal on this input lets the function block remain in a state of rest.

stSunblind: positioning telegram, see ST_BARSunblind

tPositionRead: interval in which the current position is read from the SMI motor if positioning commands are processed.

dwAddr: manufacturer code (0-15), address of a device (0-15), bit field (16 bits) for the group addressing or slave ID (32-bit key ID). This input has no meaning if a collective call (broadcast) is sent.

eAddrType: defines whether the dwAddr input is to be evaluated as a manufacturer code, the address of a device, for group addressing or as a slave ID.

dwAddrOption: if the SMI device is addressed by slave ID (eAddrType = eSMIAddrTypeSlaveId), then the manufacturer code must be specified via this input.

dwMasterDevAddr: address (0-15) of the SMI motor of which the current position is to be read when eAddrType != eSMIAddrTypeAddress.

VAR_OUTPUT

uiActPosition  : UINT;
bBusy          : BOOL;
bError         : BOOL;
udiErrorId     : UDINT;

uiActPosition: current position in percent.

bBusy: a positioning is in progress.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

stCommandBuffer    : ST_SMICommandBuffer;

stCommandBuffer: reference to the structure for communication (buffer) with the FB_KL6831KL6841Communication() block.


FB_BARSunblindScene

This function block represents an extension of the manual controller FB_BARSunblindSwitch by a scene memory and a call function. Hence, the blind actuators FB_BARSunblindActuator and FB_BARRollerBlind can be controlled in manual operating mode and can also be made to drive to previously saved positions (scenes). Up to 21 scenes can be saved.

Structure of the blind positioning telegram stSunblind.
TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

Mode of operation

This function block controls the blind function blocks FB_BARSunblindActuator and FB_BARRollerBlind in manual mode via the command inputs bSwitchUp and bSwitchDown, wherein bSwitchUp takes priority. The commands are passed on to the respective commands bManUp and bManDown in the positioning telegram. If a command input is activated that is longer than the entered time uiSwitchOverTime (in ms), then the corresponding control command latches. Activating a command input again releases this latch.
A rising edge on bSaveScene saves the current position and louvre angle in the scene selected in usiSelectedScene. This procedure is possible at any time, even during active positioning. The selected scene is called with bInvokeScene, i.e. the saved position and angle values are driven to.

Linking to the blind function block

Like the "normal" manual control function block, FB_BARSunblindSwitch, the scene selection function block can be connected to the blind function block either directly or via an upstream priority controller FB_BARSunblindPrioritySwitch. The connection is made via the positioning telegram stSunblind. Furthermore the scene function block requires the current positions from the blind function block for the reference blind:

Use of a priority controller:

Direct connection:

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bEnable            : BOOL;
usiSelectedScene   : USINT;
bSwitchUp          : BOOL;
bSwitchDown        : BOOL;
bInvokeScene       : BOOL;
bSaveScene         : BOOL;
uiSetpointPosition : UINT;
iSetpointAngle     : INT;

eDataSecurityType:if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: the function block has no function if this input is FALSE. In the positioning telegram, stSunblind , 0 is output for both position and angle – bManualMode and bActive are both FALSE. For a connection with priority controller this means that another functionality takes over control of the blind. Conversely, a direct connection allows the blind to drive directly to the 0 position, i.e. fully up, since the actuator function block does not evaluate the bit bActive itself.

usiSelectedScene: selected scene, which is to be either stored (bSaveScene) or called (bInvokeScene).

bSwitchUp : command input for blind up.

bSwitchDown : command input for blind down.

bInvokeScene : call selected scene.

bSaveScene: save selected scene.

uiSetpointPosition: setpoint position in % that is to be saved in the selected scene. Must be linked to the actual position of the actuator function block FB_BARSunblindActuator or FB_BARRollerBlind of the reference blind in order to be able to save a position that was previously driven to manually.

iSetpointAngle: ditto Louvre angle in degrees.

VAR_OUTPUT

stSunblind              : ST_BARSunblind;
bActive                 : BOOL;
uiPositionActScene      : UINT;
iAnglePositionActScene  : INT;
bError                  : BOOL;
udiErrorId              : UDINT;

stSunblind: positioning telegram, see ST_BARSunblind.

bActive: corresponds to the Boolean value bActive in the blind telegram ST_BARSunblind and serves merely to indicate whether the function block is sending an active telegram.

uiPositionActScene: indicates the saved relative blind height position in % for the currently selected scene.

iAnglePositionActScene: ditto Louvre angle in degrees.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

Note If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSwitchOverTime : UINT;
arrBlindScenes   : ARRAY[0..20] OF ST_BARSunblindScene;

uiSwitchOverTime: time in milliseconds until the corresponding manual command in the positioning telegram stSunblind latches in the case of a continuous active command input.

arrBlindScenes: table with the scene entries of the type ST_BARSunblindScene. Up to 21 scenes can be saved: 0..20.


FB_BARSunblindSwitch

With the help of this function block the blind actuators FB_BARSunblindActuator and FB_BARRollerBlind can be controlled in manual operating mode. The connection takes place via the positioning telegram stSunblind either directly or with an additional priority controller.

Structure of the blind positioning telegram stSunblind.

TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

Operation

This function block controls the blind function blocks FB_BARSunblindActuator and FB_BARRollerBlind in manual mode via the command inputs bSwitchUp and bSwitchDown, wherein bSwitchUp takes priority. The commands are passed on to the respective commands bManUp and bManDown in the positioning telegram. If a command input is activated that is longer than the entered time uiSwitchOverTime (in ms), then the corresponding control command latches. Activating a command input again releases this latch.

Linking to the blind function block

The manual control function block can be connected to the blind function block either directly or via an upstream priority controller FB_BARSunblindPrioritySwitch. The connection is made via the positioning telegram stSunblind.

Use of a priority controller:

Direct connection:

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
bEnable           : BOOL;
bSwitchUp         : BOOL;
bSwitchDown       : BOOL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: The function block has no function if this input is FALSE. In the positioning telegram, stSunblind , 0 is output for both position and angle – bManualMode and bActive are both FALSE. For a connection with priority controller this means that another functionality takes over control of the blind. Conversely, a direct connection allows the blind to drive directly to the 0 position, i.e. fully up, since the actuator function block does not evaluate the bit bActive itself.

bSwitchUp : command input for blind up.

bSwitchDown : command input for blind down.

VAR_OUTPUT

stSunblind : ST_BARSunblind;
bActive    : BOOL;

stSunblind: positioning telegram, see ST_BARSunblind.

bActive: corresponds to the Boolean value bActive in the blind telegram ST_BARSunblind and serves merely to indicate whether the function block is sending an active telegram.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiSwitchOverTime : UINT;

uiSwitchOverTime: time in milliseconds until the corresponding manual command in the positioning telegram stSunblind latches in the case of a continuous active command input.


FB_BARSunblindThermoAutomatic

This function block controls the blind in relation to the temperature inside the room if the room is unoccupied.
The objective is to block radiant heat when cooling and to increase the input of heat by opening the blinds when heating.

The thermo-automatic function is active only if there is sufficient sunshine and the room concerned is unoccupied. To this end, the external brightness value uiBrightness [lux] must have exceeded the activation limit value uiBrightnessActivateValue for the time uiActivateDelay (in seconds) and the presence input bPresence must be FALSE. The automatic function is deactivated again if either presence is signalled (bPresence = TRUE) or the external brightness value uiBrightness falls below the value uiBrightnessDeactivateValue for the time uiDeactivateDelay.

A structure of the type ST_BARSetpointRoom, which carries the information about the temperature switching points for the air conditioning of the room, is to be applied at the input stBARSetpointRoom:

TYPE ST_BARSetpointRoom :
STRUCT
     stBARSetpointRoom_BMS             : LREAL:= 22.5;
     stBARSetpointRoom_ComfortHeat     : LREAL:= 21.0;
     stBARSetpointRoom_PreComfortHeat  : LREAL:= 19.0;
     stBARSetpointRoom_EconomyHeat     : LREAL:= 15.0;
     stBARSetpointRoom_ProtectionHeat  : LREAL:= 12.0;
     stBARSetpointRoom_ComfortCool     : LREAL:= 24.0;
     stBARSetpointRoom_PreComfortCool  : LREAL:= 28.0;
     stBARSetpointRoom_EconomyCool     : LREAL:= 35.0;
     stBARSetpointRoom_ProtectionCool  : LREAL:= 40.0;
END_STRUCT
END_TYPE

Once activated, the thermo-automatic function distinguishes between three cases:

  • Remain in the current position if the room temperature rActRoomTemperature lies between the values stBARSetpointRoom_ComfortHeat and stBARSetpointRoom_ComfortCool.
  • Heating case if the room temperature rActRoomTemperature falls below the value stBARSetpointRoom_ComfortHeat.
  • Cooling case if the room temperature rActRoomTemperature exceeds the value stBARSetpointRoom_ComfortCool.

Once the heating or the cooling case has been reached, the thermo-automatic function remembers this until it becomes inactive itself once again due to renewed presence detection or insufficient external brightness (see above).
In both cases, however – heating or cooling – the mechanism operates like a on-off controller.

Heating case

In the heating case, the blind drives to the heating position uiPositionHeatingMode and iAngleHeatingMode if the room temperature falls below the lower limit value. If the room temperature exceeds the upper limit value, then the blind drives to the cooling position uiPositionCoolingMode and iAngleCoolingMode.
The upper limit value is selectable by the parameter bComfortCoolingAsSwitchPointHeating [BOOL]; the lower limit value is not selectable:

 | bComfortCoolingAsSwitchPointHeating = FALSE | bComfortCoolingAsSwitchPointHeating = TRUE
upper limit value | stBARSetpointRoom_PreComfortCool | stBARSetpointRoom_ComfortCool
lower limit value | stBARSetpointRoom_ComfortHeat | stBARSetpointRoom_ComfortHeat

Diagram

Cooling case

In the cooling case the blind drives to the cooling position uiPositionCoolingMode and iAngleCoolingMode if the room temperature exceeds the upper limit value. If the room temperature falls below the lower limit, then the blind drives to the heating position uiPositionHeatingMode and iAngleHeatingMode.
The lower limit value is selectable by the parameter bComfortHeatingAsSwitchPointCooling [BOOL]; the upper limit value is not selectable:

 | bComfortHeatingAsSwitchPointCooling = FALSE | bComfortHeatingAsSwitchPointCooling = TRUE
upper limit value | stBARSetpointRoom_ComfortCool | stBARSetpointRoom_ComfortCool
lower limit value | stBARSetpointRoom_PreComfortHeat | stBARSetpointRoom_ComfortHeat

Diagram

A lower average room temperature is obtained by selecting the Precomfort Cool value instead of the Comfort Cool value as the upper hysteresis point. This could be perceived as more pleasant when re-entering the room.

VAR_INPUT

eDataSecurityType    : E_HVACDataSecurityType;
bEnable              : BOOL;
uiBrightness: UINT;
bPresence            : BOOL;
lrActRoomTemperature : LREAL;
stBARSetpointRoom    : ST_BARSetpointRoom;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: The function block has no function if this input is FALSE. In the positioning telegram stSunblind , 0 is output for both position and angle and bActive is FALSE. This means that another function takes over control of the blind via the priority controller.

uiBrightness: external brightness in lux.

bPresence: the automatic function is active only if the room is unoccupied, since otherwise the sun shading takes priority. If this input is FALSE, the room is considered to be unoccupied and the thermo-automatic function is active. A TRUE-signal on bPresence deactivates the thermo-automatic function immediately.

lrActRoomTemperature: input for the room temperature in °C.

stBARSetpointRoom: structure of the type ST_BARSetpointRoom, which contains the information about the temperature switching points for the air conditioning of the room, see above.

VAR_OUTPUT

stSunblind                        : ST_BARSunblind;
bActive                           : BOOL;
uiRemainingTimeActivate           : UINT;
uiRemainingTimeDeactivate         : UINT;
bHeating                          : BOOL;
bCooling                          : BOOL;
lrUpperSwitchPointHeating         : LREAL;
lrLowerSwitchPointHeating         : LREAL;
lrUpperSwitchPointCooling         : LREAL;
lrLowerSwitchPointCooling         : LREAL;
bError                            : BOOL;
udiErrorId                        : UDINT;

stSunblind: output structure of the blind positions, see ST_BARSunblind.

bActive: corresponds to the Boolean value bActive in the blind telegram ST_BARSunblind and serves merely to indicate whether the function block is sending an active telegram.

uiRemainingTimeActivate: the thermo-automatic function is active if no presence is detected AND the brightness lies above the limit value uiBrightnessActivateValue for the time uiActivateDelay (switching delay). This output indicates the remaining duration of the switching delay in seconds. This output is 0 as long as no countdown of the time is taking place.

uiRemainingTimeDeactivate: the thermo-automatic function is not active if presence is detected OR if the brightness lies below the limit value uiBrightnessDeactivateValue for the time uiDeactivateDelay (switching delay). This output indicates the remaining duration of the switching delay in seconds. This output is 0 as long as no countdown of the time is taking place.

bHeating: indicates whether the heating case is active.

bCooling: indicates whether the cooling case is active.

lrUpperSwitchPointHeating: indicates the selected upper switch point in heating mode at which the blind is driven to the position uiPositionCoolingMode for cooling. This is either stBARSetpointRoom_ComfortCool or stBARSetpointRoom_PreComfortCool, depending on the preselection (see diagrams above).

lrLowerSwitchPointHeating: indicates the lower switch point in heating mode at which the blind is driven to the position uiPositionHeatingMode for heating. This is permanently set as the value stBARSetpointRoom_ComfortHeat (see diagrams above).

lrUpperSwitchPointCooling: indicates the selected upper switch point in cooling mode at which the blind is driven to the position uiPositionCoolingMode for cooling. This is permanently set as the value stBARSetpointRoom_ComfortCool (see diagrams above).

lrLowerSwitchPointCooling: indicates the selected lower switch point in cooling mode at which the blind is driven to the position uiPositionHeatingMode for heating. This is either stBARSetpointRoom_ComfortHeat or stBARSetpointRoom_PreComfortHeat, depending on the preselection (see diagrams above).

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

Note If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change in the value of this reference variable is persistently saved in the function block and written back to the reference variable after a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiBrightnessActivateValue           : UINT;(*lux*)
uiBrightnessDeactivateValue         : UINT;(*lux*)
uiActivateDelay                     : UINT;(*sec*)
uiDeactivateDelay                   : UINT;(*sec*)
bComfortHeatingAsSwitchPointCooling : BOOL;
bComfortCoolingAsSwitchPointHeating : BOOL;
uiPositionHeatingMode               : UINT;
iAngleHeatingMode                   : INT;
uiPositionCoolingMode               : UINT;
iAngleCoolingMode                   : INT;

uiBrightnessActivateValue / uiActivateDelay: activation limit value. The thermo-automatic function is active only if the external brightness is adequate. Otherwise there would be no radiant heat from the sun which could be utilised or which would need to be blocked. If the external brightness uiBrightness [lux] exceeds the value uiBrightnessActivateValue [lux] for the time uiActivateDelay [s], then the automatic function becomes active if in addition no presence is detected (bPresence = FALSE).

uiBrightnessDeactivateValue / uiDeactivateDelay: deactivation limit value of the brightness: if the external brightness uiBrightness [lux] falls below the value uiBrightnessDeactivateValue [lux] for the time uiDeactivateDelay [s], then the automatic function becomes inactive. The value uiBrightnessDeactivateValue must be smaller than the value uiBrightnessActivateValue. Otherwise an error is output.

bComfortHeatingAsSwitchPointCooling: if this input is TRUE, then the value stBARSetpointRoom_ComfortHeat is considered to be the lower value in cooling mode from which the blinds are opened again. If the input is set to FALSE, then the value stBARSetpointRoom_PreComfortHeat applies (see introductory description).

bComfortCoolingAsSwitchPointHeating: if this input is TRUE, then the value stBARSetpointRoom_ComfortCool is considered to be the upper value in heating mode from which the blinds are closed again. If the input is set to FALSE, then the value stBARSetpointRoom_PreComfortCool applies (see introductory description).

uiPositionHeatingMode: height position of the blind in % in the heating case (intended heat irradiation). The following applies for the height position: 0% = fully open, 100% = fully closed.

iAngleHeatingMode: louvre angle of the blind in degrees in the heating case (intended heat irradiation).

uiPositionCoolingMode: height position of the blind in % in the cooling case (sun protection). The following applies for the height position: 0% = fully open, 100% = fully closed. The value of the height position must be higher than in the heating case, i.e. the blind must be closed more in the cooling case than in the heating case. Otherwise the supply of heat from the sun cannot be meaningfully controlled according to the above description. In this case an error is output.

iAngleCoolingMode: louvre angle of the blind in degrees in the cooling case (sun protection).


FB_BARSunblindTwilightAutomatic

This function block controls the blind if the external brightness has fallen below a limit value.

The automatic twilight function operates with both a value hysteresis and a temporal hysteresis: If the external brightness value usiBrightness [lux] falls below the value usiActivateValue [lux] for the time uiActivateDelay [s], then the function block is active and will supply the blind positions uiPositionActiveMode (height in %) and uiAngleActiveMode (louvre angle in degrees), which are specified on the IN-OUT variables, at the output in the position telegram stSunblind. Conversely, if the external brightness exceeds the value usiDeactivateValue [lux] for the time uiDeactivateDelay [s], then the automatic function is no longer active. The active flag in the positioning telegram stSunblind is reset and the positions for height and angle are set to "0". A function with a lower priority can then take over control.

VAR_INPUT

eDataSecurityType    : E_HVACDataSecurityType;
bEnable              : BOOL;
uiBrightness         : UINT;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: The function block has no function if this input is FALSE. In the positioning telegram stSunblind , 0 is output for both position and angle and bActive is FALSE. This means that another function takes over control of the blind via the priority controller.

uiBrightness: external brightness in lux.

VAR_OUTPUT

stSunblind                : ST_BARSunblind;
bActive                   : BOOL;
uiRemainingTimeActivate   : UINT;
uiRemainingTimeDeactivate : UINT;
bError                    : BOOL;
udiErrorId                : UDINT;

stSunblind: output structure of the blind positions, see ST_BARSunblind.

bActive: corresponds to the Boolean value bActive in the blind telegram ST_BARSunblind and serves merely to indicate whether the function block is sending an active telegram.

uiRemainingTimeActivate: indicates the time remaining in seconds until the activation of the automatic function after falling below the switch value usiActivateValue. This output is 0 as long as no countdown of the time is taking place.

uiRemainingTimeDeactivate: indicates the time remaining in seconds until the deactivation of the automatic function after the switch value usiDeactivateValue has been exceeded. This output is 0 as long as no countdown of the time is taking place.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

Note If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiActivateValue      : UINT;
uiDeactivateValue    : UINT;
uiActivateDelay      : UINT;
uiDeactivateDelay    : UINT;
uiPositionActiveMode : UINT;
iAngleActiveMode     : INT;

uiActivateValue: activation limit value in lux.

uiDeactivateValue: deactivation limit value in lux.

uiActivateDelay: activation delay in seconds.

uiDeactivateDelay: deactivation delay in seconds.

uiPositionActiveMode: height position of the blind in % if the automatic twilight function is active.

iAngleActiveMode: louvre angle of the blind in degrees if the automatic twilight function is active.


FB_BARSunblindWeatherProtection

The weather protection has the highest priority in the blind controller (see overview) and is intended to ensure that the blind is not damaged by ice or wind.

The task of the automatic weather protection function is to protect the blind against two impending dangers and, in order to do so, to drive it to a safe position:

  • Icing up: impending icing up is detected when the measured outside temperature rOutsideTemperature falls below the frost limit value rFrostTemperature while at the same time rain is detected on bRainSensor. This event is saved internally and remains active until it is ensured that the ice has melted again. In addition, the outside temperature must have exceeded the frost limit value for the entered deicing time uiDeiceTime (in minutes). For safety reasons the icing event is persistently saved, i.e. also beyond a PLC failure. Thus, if the controller fails during the icing up or deicing period, the blind is considered to be newly iced up when then the controller restarts and the deicing timer starts from the beginning again.
  • Storm: if the measured wind velocity lies above the value rWindSpeedStormUpcoming for the time uiDelayStormUpcoming [s], then it is assumed that a storm is directly impending. Only if the wind velocity falls below the value rWindSpeedStormAbating for the time uiDelayStormAbating [s] is the storm considered to have abated and the driving of the shutter considered to be safe. For safety reasons the storm event is also persistently saved. Thus, if the controller fails during a storm, the storm abating timer is started again from the beginning when the controller is restarted.

In both cases of danger the blind is driven to the protection position specified by uiPositionProtection (height position in percent) and iAngleProtection (louvre angle in degrees).

VAR_INPUT

eDataSecurityType    : E_HVACDataSecurityType;
bEnable              : BOOL;
lrWindSpeed          : LREAL;
lrOutsideTemperature : LREAL;
bRainSensor          : BOOL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_Persistent, the persistent VAR_IN_OUT variables of the function block are stored in the flash of the computer if a value changes. To this end the function block FB_HVACPersistentDataHandling must be instanced once in the main program, which is called cyclically. Otherwise the instanced FB will not be internally enabled.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: the function block has no function if this input is FALSE. In the positioning telegram stSunblind , 0 is output for both position and angle and bActive is FALSE. This means that another function takes over control of the blind via the priority controller.

lrWindSpeed: wind speed. The unit of entry is arbitrary, but it is important that no value is smaller than 0 and that the values become larger with increasing speed.

rOutsideTemperature: outdoor temperature in degrees Celsius.

bRainSensor: input for a rain sensor.

VAR_OUTPUT

stSunblind                  : ST_BARSunblind;
bIceAlarm                   : BOOL;
udiRemainingTimeIceAlarm    : UDINT;
bStormAlarm                 : BOOL;
uiRemainingTimeStormDetect  : UINT;
uiRemainingTimeStormAlarm   : UINT;
bError                      : BOOL;
udiErrorId                  : UDINT;

stSunblind: output structure of the blind positions, see ST_BARSunblind.

bActive: corresponds to the Boolean value bActive in the blind telegram ST_BARSunblind and serves merely to indicate whether the function block is sending an active telegram.

bIceAlarm: indicates the icing up alarm.

udiRemainingTimeIceAlarm: in the case of impending icing up (bIceAlarm=TRUE), this second counter is set to the deicing time. As soon as the temperature lies above the frost point entered (rFrostTemperature), the remaining number of seconds until the 'all-clear' signal is given (bIceAlarm=FALSE) are indicated here. This output is 0 as long as no countdown of the time is taking place.

bStormAlarm: indicates the storm alarm.

uiRemainingTimeStormDetect: in an uncritical case this second counter constantly indicates the alarm delay time uiDelayStormUpcoming. If the measured wind force rWindSpeed lies above the activation limit value rWindSpeedStormUpcoming, then the seconds until the alarm is given are counted down. This output is 0 as long as no countdown of the time is taking place.

uiRemainingTimeStormAlarm: as soon as the storm alarm is initiated, this second counter initially constantly indicates the deactivation time delay of the storm alarm uiDelayStormAbating. If the measured wind force rWindSpeed falls below the deactivation limit value rWindSpeedStormAbating, then the seconds remaining until the 'all-clear' signal is given (bStormAlarm=FALSE) are counted down. This output is 0 as long as no countdown of the time is taking place.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

Note If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change in the value of this reference variable is persistently saved in the function block and written back to the reference variable after a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

lrFrostTemperature       : LREAL;
lrWindSpeedStormUpcoming : LREAL;
lrWindSpeedStormAbating  : LREAL;
uiDeiceTime              : UINT;
uiDelayStormUpcoming     : UINT;
uiDelayStormAbating      : UINT;
uiPositionProtection     : UINT;
iAngleProtection         : INT;

lrFrostTemperature: icing up temperature limit value in degrees Celsius. This value may not be greater than 0. Otherwise an error is output.

lrWindSpeedStormUpcoming: wind speed limit value for the activation of the storm alarm. This value may be not smaller than 0 and must lie above the value for the deactivation. Otherwise an error is output. The unit of entry must be the same as that of the input rWindSpeed. A value greater than this limit value triggers the alarm after the entered time uiDelayStormUpcoming.

lrWindSpeedStormAbating: wind speed limit value for the deactivation of the storm alarm. This value may be not smaller than 0 and must lie below the value for the activation. Otherwise an error is output. The unit of entry must be the same as that of the input rWindSpeed. A value smaller than or equal to this limit value resets the alarm after the entered time uiDelayStormAbating.

uiDeiceTime: time until the deicing of the blind after icing up (in minutes). After that the icing up alarm is reset.

uiDelayStormUpcoming: time delay in seconds until the storm alarm is triggered.

uiDelayStormUpcoming: time delay in seconds until the storm alarm is reset.

uiPositionProtection: height position of the blind in % in the case of protection.

iAngleProtection: louvre angle of the blind in degrees in the case of protection.


FB_BARSunProtectionEx

Function block for the control of glare protection with the aid of a louvered blind.

The function block FB_BARSunProtectionEx enables glare protection in two ways that operate in parallel:

  • Louvre adjustment, so that the direct incident light cannot quite enter through the lowered part of the blind.
  • Control of the blind height, with three different options (adjustable via the enumerator on ePositioningMode):
    1) Fixed blind height, i.e. no change (preset).
    2) Blind height in relation to the position of the sun, defined via a table (stBlindPosTable), see also description of the function block FB_BARBlindPositionEntry.
    3) Maximum desired incidence of light.

On the basis of the parameters entered, which are described further below, the function block calculates the necessary louvre angle and blind position and transfers them to the output structure stSunblind. Of course, the output does not take place continuously, since a constant blind movement would be perceived as extremely distracting. The interval in seconds at which new position values are to be output can be set on the input uiPositioningInterval.
However, the shading criteria must always be fulfilled between two positioning times: no direct light may enter through the louvres and the desired incidence of light must remain limited by the blind height, if one initially assumes that the blind height is controlled via the mode "maximum desired incidence of light". Therefore two blind and louvre positions are internally calculated: those for the current switching point and those for the next. The position in which the blind is more closed is then the valid position.

The positioning in intervals starts precisely when the following three conditions are satisfied:

  • the input bEnable must be TRUE.
  • the function block must not be in an error state due to incorrect parameterisation (bError=TRUE).
  • the sun must have risen, i.e. the height of the sun (elevation) must be greater than 0°. This is an internal safety query, since the limitation to at least 0° should actually be done by the user by programming the input bEnable; see overview of automatic sun protection (shading correction).

If these three conditions are not satisfied, then the active bit (bActive) is set to FALSE, the shutter height to 0% and the louvre angle to 0% in the positioning structure.

VAR_INPUT

eDataSecurityType      : E_HVACDataSecurityType;
bEnable                : BOOL;
stTimeAct              : TIMESTRUCT;
stBlindPositionTable   : ST_BARBlindPositionTable;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: If this input is set to FALSE the positioning is inactive, i.e. the active bit (bActive) is reset in the positioning structure stSunblind of the type ST_BARSunblind and the function block itself remains in a standstill mode. If on the other hand the function block is activated, then the active bit is TRUE and the function block outputs its control values (uiShutterHeight, iLouvreAngle) in the positioning structure at the appropriate times.

stTimeAct: entry of the current time in GMT (Greenwich Mean Time).

stBlindPositionTable: table of 6 interpolation points, 4 of which are parameterisable, from which a blind position is then given in relation to the position of the sun by linear interpolation. Valid if ePositioningMode = ePosModeFixed (see enumerator E_BARPosMode). See FB_BARBlindPositionEntry for further description.

VAR_OUTPUT

stSunblind    : ST_BARSunblind;
bError        : BOOL;
udiErrorId    : UDINT;

stSunblind: output structure of the blind positions, see ST_BARSunblind.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

Note If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiPositioningInterval  : UINT;
lrDegreeOfLongitude    : LREAL;
lrDegreeOfLatitude     : LREAL;
lrFacadeOrientation   : LREAL;
lrFacadeAngle          : LREAL;
uiLouvreWidth          : UINT;
uiLouvreSpacing        : UINT;
uiFixedShutterHeight   : UINT;
uiMaxLightIncidence    : UINT;
uiWindowHeight         : UINT;
uiWindowDistanceFloor  : UINT;
ePositioningMode       : E_BARPOSMODE;

uiPositioningInterval: Positioning interval in seconds – time interval between two outputs of blind positions. Valid range: 1s to 7200s.

lrDegreeOfLongitude: Longitude in degrees. Valid range: -180°..180°.

lrDegreeOfLatitude: Latitude in degrees. Valid range: -90°..90°.

lrFacadeOrientation: Facade orientation in degrees:

The facade-orientation for the northern hemisphere (view out of the window) is defined as follows:

Line of sight | Facade orientation
North | β=0°
East | β=90°
South | β=180°
West | β=270°

For the southern hemisphere however it is:

Line of sight | Facade orientation
South | β=0°
East | β=90°
North | β=180°
West | β=270°

lrFacadeAngle: Facade inclination in degrees. See facade inclination.

uiLouvreWidth: Width of the louvres in mm, see sketch.

uiLouvreSpacing: Louvre spacing in mm, see sketch.

uiFixedShutterHeight: Fixed (constant) blind height [0 to 100%]. Valid if ePositioningMode = ePosModeFixed (see enumerator E_BARPosMode).

uiMaxLightIncidence: Maximum desired incidence of light in mm measured from the outside of the wall (see height adjustment). With the aid of the parameters uiWindowHeight and uiWindowDistanceFloor, a calculation is performed in relation to the position of the sun to determine how high the blind must be so that the incidence of light does not exceed the value uiMaxLightIncidence. Valid if ePositioningMode = ePosModeMaxIncidence (see enumerator E_BARPosMode).

uiWindowHeight: Window height in mm for the calculation of the blind height if the mode "maximum desired incidence of light" is selected.

uiWindowDistanceFloor: Distance between the floor and the window sill in mm for the calculation of the blind height if the mode "maximum desired incidence of light" is selected.

ePositioningMode: Selection of the positioning mode, see enumerator E_BARPosMode.


FB_BARWithinRangeAzimuth

This function block checks whether the current azimuth angle (horizontal position of the sun) lies within the limits entered. As can be seen in the overview, the function block provides an additionally evaluation as to whether the sun shading of a window group should be activated. Therefore the observations in the remainder of the text always apply to one window group.

A smooth facade is always irradiated by the sun at an azimuth angle of Facade orientation-90° to Facade orientation+90°.

If the facade has lateral projections, however, this range is limited. This limitation can be checked with the help of this function block. However, the position of the window group on the facade also plays a role. If it lies centrally, this gives rise to the following situation (the values are only examples):

The values change for a group at the edge:

The beginning of the range rBeginRange may thereby be larger than the end rEndRange; it is then regarded beyond 0°:

Example:

lrAzimuth | 10.0°
lrBeginRange | 280.0°
lrEndRange | 20.0°
bOut : | TRUE

However, the range regarded may not be greater than 180° or equal to 0° – this would be unrealistic. Such entries result in an error on the output bError – the test output bOut is then additionally set to FALSE.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
lrAzimuth          : LREAL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

lrAzimuth: Current azimuth angle.

VAR_OUTPUT

bOut       : BOOL;
bError     : BOOL;
udiErrorId : UDINT;

bOut: binary delayed output of the threshold switch

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

lrBeginRange : LREAL;
lrEndRange   : LREAL;

lrBeginRange : beginning of the range in degrees.

lrEndRange: end of the range in degrees.


FB_BARWithinRangeElevation

This function block checks whether the current angle of elevation (vertical position of the sun) lies within the limits entered. As can be seen in the overview, the function block provides an additionally evaluation as to whether the sun shading of a window group should be activated. Therefore the observations in the remainder of the text always apply to one window group.

A normal vertical facade is irradiated by the sun at an angle of elevation of 0° to maximally 90°.

If the facade has projections, however, this range is limited. This limitation can be checked with the help of this function block. However, the position of the window group on the facade also plays a role. If it lies in the lower range, this gives rise to the following situation (the values are only examples):

The values change for a group below the projection:

The lower observation limit, rLowLimit, may thereby not be greater than or equal to the upper limit, rHighLimit. Such entries result in an error on the output bError – the test output bOut is then additionally set to FALSE.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
lrElevation        : LREAL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

lrElevation: current angle of elevation in degrees.

VAR_OUTPUT

bOut       : BOOL;
bError     : BOOL;
udiErrorId : UDINT;

bOut: binary delayed output of the threshold switch

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

lrLowLimit   : LREAL;
lrHighLimit  : LREAL;

lrLowLimit: lower limit value in degrees.

lrHighLimit: upper limit value in degrees.


Example FB_BARSunblindSwitch

TS8000 | TwinCAT PLC Lib: HVAC

Program example FB_BARSunblindSwitch

This example is intended to show how a possible activation (input bEnable) of the manual blind controller might look. The input and output variables (bordered) have the following meaning:

tAutoResetTime : time after which the activation is to be automatically reset.

bSwitchUp : blind up switch.

bSwitchDown : blind down switch.

bPauseClock : pause signal from the property, e.g. lunch break: 12:00 - 13: 00. bPauseClock = TRUE: pause.

bPresenceDetection: occupied signal from the room in which the blinds are controlled. bPresenceDetection= TRUE: room is occupied.

uiSwitchOverTime: time in milliseconds until the corresponding manual command latches with a continuous command input.

stSunblind: positioning telegram, see ST_BARSunblind. For further linking to a priority selection, see FB_BARSunblindPrioritySwitch.

Functioning

If one of the blind buttons bSwitchUp or bSwitchDown is actuated, the output of the flip-flop will initially be set to TRUE, but only if there is currently no pause signal applied (bPauseClock) or if the room is currently occupied (bPresenceDetection). The bEnable input of the function block fbBARSunblindSwitch is thus TRUE, which activates it. The respective switch signal that has led to the activation can be passed on directly by the function block in the command telegram stSunblind.
At the same time a TRUE signal is applied to the input of the switch-off delay tofAutoResetTimer and its output Q is set directly to TRUE. On releasing the blind switch the switch-off delay is started, and after the expiry of tAutoResetTime the output Q is reset to FALSE. This falling edge is in turn recognised by ftAutoResetTimer and a trigger pulse is sent that resets the flip-flop. The activation input bEnable is thus FALSE once again and the function block fbBARSunblindSwitch is passive.

If this function block is linked via the command telegram to a priority selection FB_BARSunblindPrioritySwitch, then the telegram will be passed through there to the next priority:


E_BARCtrlFct

TYPE E_BARCtrlFct:
(
     eBARCtrlFct_Off             := 0,
     eBARCtrlFct_Heating         := 1,
     eBARCtrlFct_Cooling         := 2
);
END_TYPE

eBARCtrlFct_Off: Function selection OFF acitve.

eBARCtrlFct_Heating: Function selection for heating operation active.

eBARCtrlFct_Cooling: Function selection for cooling operation active.


E_BAREnergyLevel

TYPE E_BAREnergyLevel:
(
     eBAREnergyLevel_AUTO_I         := 0,
     eBAREnergyLevel_Protection     := 1,
     eBAREnergyLevel_Economy        := 2,
     eBAREnergyLevel_PreComfort     := 3,
     eBAREnergyLevel_Comfort        := 4,
     eBAREnergyLevel_AUTO_II        := 5
);
END_TYPE

eBAREnergyLevel_AUTO_I: Automatic-mode-I means, in this mode a switch to a higher enery level is possible if the upper energy level are already TRUE. In the mode the state of the inputs bProtection, bEconomy, bPreComfort and bComfort are evaluated for the selection of the energy level.

eBAREnergyLevel_Protection: In this mode which is manually operated by the building management system, the room/zone/range held in protection. This mode is only building protection mode.

eBAREnergyLevel_Economy: In this mode which is manually operated by the building management system, the room/zone/range held in Economy. This mode is set for longer periods of absence or at night.

eBAREnergyLevel_PreComfort: In this mode which is manually operated by the building management system, the room/zone/range held in PreComfort. This mode is set for shorter periods of absence

eBAREnergyLevel_Comfort: In this mode which is manually operated by the building management system, the room/zone/range held in the Comfort. This mode is set for periods of absence.

eBAREnergyLevel_AUTO_II: Automatic-mode-II means, in case of presence detection, this mode switches from energy level Protection, Economy or PreComfort directly to energy level Comfort.
See diagram


E_BARPosMode

Enumerator for the definition of the positioning mode.

TYPE E_BARPosMode :
(
     ePosModeFixed := 0,
     ePosModeTable,
     ePosModeMaxIncidence
);
END_TYPE

ePosModeFixed: The blind height adopts a fixed value, which is set (in %) via the uiFixedShutterHeight value on the function block FB_BARSunProtectionEx;

ePosModeTable: the height positioning takes place with the help of a table of 6 interpolation points, 4 of which are parameterisable. A blind position in relation to the position of the sun is then calculated from these points by linear interpolation. See FB_BARBlindPositionEntry for further description.

ePosModeMaxIncidence: the positioning takes place with specification of the maximum desired incidence of light.


E_BARShadingObjectType

Enumerator for selection of shading object type.

TYPE E_BARShadingObjectType :
(
     eObjectTypeTetragon  := 0,
     eObjectTypeGlobe     := 1
);
END_TYPE

eObjectTypeTetragon: Object type is a tetragon.

eObjectTypeGlobe: Object type is a globe.


E_HVACDataSecurityType

Enumeration for defining the saving of entered parameters.

TYPE E_HVACDataSecurityType :
(
eDataSecurityType_Persistent := 0,
eDataSecurityType_Idle       := 1
);
END_TYPE

eDataSecurityType_Persistent: the parameters entered are persistently saved after each change. The values are available on the input or output variables following a restart.

eDataSecurityType_Idle: the values are not saved. Following a restart only default values – if existent – are available.


ST_BARBlindPositionTable

Structure of the interpolation point entries for the height adjustment of the blind.

TYPE ST_BARBlindPositionTable:
STRUCT
     lrSunElevation   : ARRAY[0..5] OF LREAL;
     uiBlindPosition  : ARRAY[0..5] OF UINT;
     bValid           : BOOL;
END_STRUCT
END_TYPE

lrSunElevation / uiBlindPosition: The 6 interpolation points that are transferred, wherein the array elements 0 and 5 represent the automatically generated edge elements mentioned above.

bValid: validity flag for the function block FB_BARSunProtectionEx. It is set to TRUE by the function block FB_BARBlindPositionEntry if the data entered correspond to the validity criteria described.


ST_BARCorner

Information about window corners

TYPE ST_BARCorner :
STRUCT
     lrX      : LREAL;
     lrY      : LREAL;
     bShaded  : BOOL;
END_STRUCT
END_TYPE

lrX: X-coordinate of the window (on the facade).

lrY: Y-coordinate of the window (on the facade).

bShaded: information as to whether this corner is in the shade: bShaded=TRUE: corner is in the shade.


ST_BARFacadeElement

List entry for a facade element (window).

TYPE ST_BARFacadeElement :
STRUCT
     usiGroup       : USINT;
     lrWindowWidth  : LREAL;
     lrWindowHeight : LREAL;
     stCorner       : ARRAY [1..4] OF ST_BARCorner;
     bValid         : BOOL;
END_STRUCT
END_TYPE

usiGroup: group membership of the element

lrWindowWidth: width of the window.

lrWindowHeight: height of the window.

stCorner: coordinates of the window corners and information as to whether this corner point is in the shade; see ST_BARCorner.

bValid: plausibility of the data entered: bValid=TRUE: Data are plausible.


ST_BARSetpointRoom

TYPE ST_BARSetpointRoom :
STRUCT
  stBARSetpointRoom_ComfortHeat       : REAL:= 21.0;
  stBARSetpointRoom_PreComfortHeat    : REAL:= 19.0;
  stBARSetpointRoom_EconomyHeat       : REAL:= 15.0;
  stBARSetpointRoom_ProtectionHeat    : REAL:= 12.0;
  stBARSetpointRoom_ComfortCool       : REAL:= 24.0;
  stBARSetpointRooom_PreComfortCool   : REAL:= 28.0;
  stBARSetpointRoom_EconomyCool       : REAL:= 35.0;
  stBARSetpointRoom_ProtectionCool    : REAL:= 40.0;
END_STRUCT
END_TYPE

The values in the structure are defined with the preset values.


ST_BARShadingObject

List entry for a shading object.

TYPE ST_BARShadingObject :
STRUCT
     lrP1x          : LREAL;
     lrP1y          : LREAL;
     lrP1z          : LREAL;
     lrP2x          : LREAL;
     lrP2y          : LREAL;
     lrP2z          : LREAL;
     lrP3x          : LREAL;
     lrP3y          : LREAL;
     lrP3z          : LREAL;
     lrP4x          : LREAL;
     lrP4y          : LREAL;
     lrP4z          : LREAL;
     lrMx           : LREAL;
     lrMy           : LREAL;
     lrMz           : LREAL;
     lrRadius       : LREAL;
     usiBeginMonth  : USINT;
     usiEndMonth    : USINT;
     eType          : E_BARShadingObjectType;
     bValid         : BOOL;
END_STRUCT
END_TYPE

lrP1x .. lrP4z: corner coordinates. Of importance only if the element is a square.

lrMx .. lrMz: centre coordinates. Of importance only if the element is a ball.

lrRadius: radius of the ball. Of importance only if the element is a ball.

usiBeginMonth: beginning of the shading period (number of month).

usiEndMonth: end of the shading period (number of month).

eType: object type, see E_BARShadingObjectType.

bValid: plausibility of the data: bValid=TRUE: Data are plausible.

Remark about the shading period:

The monthly entries may not be 0 or greater than 12, otherwise all combinations are possible.
Examples:
Start=1, End=1: shading in January.
Start=1, End=5: shading from the beginning of January to the end of May.
Start=11, End=5: shading from the beginning of November to the end of May (the following year).


ST_BARSunblind

Structure of the blind positioning telegram.

TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

uiPosition: transferred blind height in %.

iAngle: transferred louvre position in degrees.

bManUp: manual command: blind up.

bManDown: manual command: blind down.

bManualMode: TRUE: manual mode is active.

FALSE: automatic mode is active.

bActive: The sender of the telegram is active. This bit is evaluated only by the priority controller FB_BARSunblindPrioritySwitch. The blind actuators FB_BARSunblindActuator and FB_BARRollerBlind ignore it.


ST_BARSunblindScene

Table entry for a blind scene.

TYPE ST_BARSunblindScene:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
END_STRUCT
END_TYPE

uiPosition: blind height in %.

iAngle: louvre position in degrees.


List of facade elements

The data of all windows (facade elements) per facade are saved within the program in a field of structural elements of the type ST_BARFacadeElement.
The declaration is global, since the administration block FB_BARFacadeElementEntry as well as the shading correction FB_BARShadingCorrection / FB_BARShadingCorrectionSouth access this field directly by input/output variable:

VAR_GLOBAL
     arrFacadeElement : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;
END_VAR

The variables iColumnsPerFacade and iRowsPerFacade thereby define the upper limit of the available elements and are to be globally declared as constants:

VAR_GLOBAL CONSTANT
     iRowsPerFacade    : INT :=10;
     iColumnsPerFacade : INT :=20;
END_VAR


Shading correction: List of shading elements

TS8000 | TwinCAT PLC Lib: HVAC

List of shading elements

The shading elements per facade are saved within the program in a field of structure elements of the type ST_BARShadingObject.
The declaration is global, since the administration block FB_BARShadingObjectsEntry as well as the shading correction FB_BARShadingCorrection / FB_BARShadingCorrectionSouth access this field directly by input/output variable:

VAR_GLOBAL
     arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;
END_VAR

The variable iShadingObjects thereby represents the upper limit of the available elements and is to be globally defined as a constant:

VAR_GLOBAL CONSTANT
     iShadingObjects  : INT := 20;
END_VAR


Error Codes

udiErrorId (hex) | udiErrorId (dec) | Error
0x0 | 0 | No error.
0x8001 | 32769 | FB_BARBlindPositionEntry : values for rSunElevation are not ascending or unequal
0x8002 | 32770 | FB_BARBlindPositionEntry : values for rSunElevation are not within the valid range from 0° to 90°
0x8003 | 32771 | FB_BARBlindPositionEntry : values for uiBlindPosition are not within the valid range from 0% to 100%
0x8004 | 32772 | FB_BARSunProtectionEx : the duration of the positioning interval is zero or exceeds 7200 s.
0x8005 | 32773 | FB_BARSunProtectionEx : the longitude entered is not within the valid range from -180° to 180°.
0x8006 | 32774 | FB_BARSunProtectionEx : the latitude entered is not within the valid range from -90° to 90°.
0x8007 | 32775 | FB_BARSunProtectionEx: the value for the louvre spacing (uiLouvreSpacing) is greater than or equal to the value for the louvre width (uiLouvreWidth).
0x8008 | 32776 | FB_BARSunProtectionEx : the "Values valid" bit (bValid) in the stBlindPositionTable positioning table is not set - invalid values, see FB_BARBlindPositionEntry.
0x8009 | 32777 | FB_BARSunProtectionEx : the value entered for the fixed shutter height (uiFixedShutterHeight) exceeds 100%
0x801A | 32778 | FB_BARSunProtectionEx : the value entered for the window height is zero
0x801B | 32779 | FB_BARSunProtectionEx : the value entered for the louvre spacing is zero
0x801C | 32780 | FB_BARSunProtectionEx : the value entered for the louvre width is zero
0x801D | 32781 | FB_BARShadingObjectsEntry: the sum of the angles of the square is not 360°. This means that the corners are not in the order P1, P2, P3 and P4 but rather P1, P3, P2 and P4. This results in a crossed-over square.
0x801E | 32782 | FB_BARShadingObjectsEntry: the corners of the square are not on the same level.
0x801F | 32783 | FB_BARShadingObjectsEntry: the z-component of P1 is less than zero. This corner would thus lie behind the facade.
0x8010 | 32784 | FB_BARShadingObjectsEntry: the z-component of P3 is less than zero. This corner would thus lie behind the facade.
0x8011 | 32785 | FB_BARShadingObjectsEntry: P1 is equal to P2. The object entered is thus not a square.
0x8012 | 32786 | FB_BARShadingObjectsEntry: P1 is equal to P3. The object entered is thus not a square.
0x8013 | 32787 | FB_BARShadingObjectsEntry: P1 is equal to P4. The object entered is thus not a square.
0x8014 | 32788 | FB_BARShadingObjectsEntry: P2 is equal to P3. The object entered is thus not a square.
0x8015 | 32789 | FB_BARShadingObjectsEntry: P2 is equal to P4. The object entered is thus not a square.
0x8016 | 32790 | FB_BARShadingObjectsEntry: P3 is equal to P4. The object entered is thus not a square.
0x8017 | 32791 | FB_BARShadingObjectsEntry: the radius entered is zero
0x8018 | 32792 | FB_BARShadingObjectsEntry: the z-component of the ball centre is less than zero. This point would thus lie behind the facade.
0x8019 | 32793 | FB_BARFacadeElementEntry: the group index is 0, but at the same time another entry of the facade element is not zero. Only if all entries of a facade element are zero is it considered to be a valid, deliberately omitted facade component, otherwise it is interpreted as an incorrect entry.
0x801A | 32794 | FB_BARFacadeElementEntry: the X-component of the first corner (Corner1) is less than zero.
0x801B | 32795 | FB_BARFacadeElementEntry: the Y-component of the first corner (Corner1) is less than zero.
0x801C | 32796 | FB_BARFacadeElementEntry: the window width is less than or equal to zero.
0x801D | 32797 | FB_BARFacadeElementEntry: the window height is less than or equal to zero.
0x801E | 32798 | FB_BARDelayedHysteresis : the switch-on value bOnValue is smaller than the switch-off value bOffValue.
0x801F | 32799 | FB_BARWithinRangeAzimuth : the beginning of the range rBeginRange and the end of the range rEndRange are the same.
0x8020 | 32800 | FB_BARWithinRangeAzimuth : one of the range limits entered is greater than 360° or less than 0°
0x8021 | 32801 | FB_BARWithinRangeAzimuth : the range entered is greater than 180°.
0x8022 | 32802 | FB_BARWithinRangeElevation : the lower limit value rLowLimit entered is greater than or equal to the upper limit value rHighLimit.
0x8023 | 32803 | FB_BARWithinRangeElevation : the upper limit value rHighLimit is greater than 90° or the lower limit value rLowLimit is less than 0°.
0x8024 | 32804 | FB_BARShadingObjectsEntry: the number of the month when shading begins or when shading ends is zero or greater than 12.
0x8025 | 32805 | FB_BARShadingObjectsEntry: index error! iId lies outside the permissible limits 1..iShadingObjects. See list of shading elements.
0x8026 | 32806 | FB_BARSunblindActuator / FB_BARSunblindActuatorEx : the shutter height entered is 0.
0x8027 | 32807 | FB_BARSunblindActuator / FB_BARSunblindActuatorEx : the entire "Up" travel time (uiTotalTimeUp) or the total "Down" travel time (uiTotalTimeDown) is 0 ms.
0x8028 | 30808 | FB_BARSunblindActuator / FB_BARSunblindActuatorEx : the louvre "Up" turning time (uiTurningTimeUp) or the louvre "Down" turning time (uiTurningTimeDown) is 0 ms.
0x8029 | 32809 | FB_BARSunblindActuator / FB_BARSunblindActuatorEx : the upper louvre angle limit value (iAngleLimitUp) is smaller than or equal to the lower louvre angle limit value (iAngleLimitDown)
0x802A | 32810 | FB_BARSunblindScene: the selected scene number exceeds the maximum number of 20.
0x802B | 32811 | FB_BARSunblindThermoAutomatic: the preset room temperature values are in the wrong order.
0x802C | 32812 | FB_BARSunblindThermoAutomatic: the brightness activation limit value is smaller than or equal to the deactivation limit value.
0x802D | 32813 | FB_BARSunblindThermoAutomatic: the blind position (height in %) of the heating mode is greater than or equal to that of the cooling mode.
0x802E | 32814 | FB_BARSunblindTwilightAutomatic: the brightness limit value for the activation of the automatic twilight function is greater than or equal to the deactivation value.
0x802F | 32815 | FB_BARSunblindWeatherProtection : the frost limit value is greater than 10 °C.
0x8030 | 32816 | FB_BARSunblindWeatherProtection : the limit value for the activation of the storm alarm is smaller than or equal to the deactivation value.
0x8031 | 32817 | FB_BARSunblindWeatherProtection : the input of wind force limit values of less than 0 is not permissible.
0x8032 | 32818 | FB_BARShadingCorrection / FB_BARShadingCorrectionSouth: the group index is 0. This index is intended only for facade components that are to be marked as non-existent, for example if windows are omitted from an even facade grid or if a door is installed instead of a window.
0x8033 | 32819 | FB_BARShadingCorrection / FB_BARShadingCorrectionSouth: a window element in the selected group is marked as invalid (bValid=FALSE).
0x8034 | 32820 | FB_BARFacadeElementEntry: index error! iColumn or iRow lies outside the permissible limits 1..iColumnsPerFacade or 1..iRowsPerFacade respectively. See list of facade elements.
0x8035 | 32821 | FB_BARSunProtectionEx : the Facade inclination (lrFacadeAngle) entered is not within the valid range from -90° to 90°.
0x8036 | 32822 | FB_BARSunblindActuator / FB_BARSunblindActuatorEx :one of the backlash-times (uiBacklashTimeUp) or (uiBacklashTimeDown) is 0ms.
0x8037 | 32823 | FB_BARRollerBlind : the entire "Up" travel time (udiTotalTimeUp) or the total "Down" travel time (udiTotalTimeDown) is 0 ms.
0x8038 | 32824 | FB_BARSMISunblindActuator: Value of wLouvreRange can not be 0.
0x8039 | 32825 | FB_BARSMISunblindActuator: Ratio of wLouvreRange / (iAngleLimitUp + iAngleLimitDown) must be greater 0.
0x803A.. 0x80FF | 32826.. 33023 | reserved for shading function blocks
0x8100 | 33024 | FB_BARLightCircuit: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x8101 | 33025 | FB_BARLightCircuitDim: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x8102 | 33026 | FB_BARLightCircuitDim: the lower limit value, lrMinDimValue, is less than zero or greater than 100%.
0x8103 | 33027 | FB_BARLightCircuitDim: the upper limit value, lrMaxDimValue, is less than zero or greater than 100%.
0x8104 | 33028 | FB_BARLightCircuitDim: the lower limit value, lrMinDimValue, is greater than the upper limit value, lrMaxDimValue.
0x8105 | 33029 | FB_BARLightCircuitDim: the value for "Manual On", lrManualDimValue, is less than zero or greater than 100%.
0x8106 | 33030 | FB_BARAutomaticLight: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x8107 | 33031 | FB_BARAutomaticLight: the value for "Manual On", lrManualDimValue, is less than zero or greater than 100%.
0x8108 | 33032 | FB_BARAutomaticLight: the light switch-on value, lrOnDimValue, is less than zero or greater than 100%.
0x8109 | 33033 | FB_BARStairwellAutomatic: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x810A | 33034 | FB_BARTwilightAutomatic: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x810B | 33035 | FB_BARTwilightAutomatic: the value for "Manual On", lrManualDimValue, is less than zero or greater than 100%.
0x810C | 33036 | FB_BARTwilightAutomatic: the ON value for the automatic function, lrDimOnValue, is less than zero or greater than 100%.
0x810D | 33037 | FB_BARTwilightAutomatic: the OFF value for the automatic function, lrDimOffValue, is less than zero or greater than 100%.
0x810E | 33038 | FB_BARTwilightAutomatic: the switch-on threshold value, uiSwitchOnValue, is greater than or equal to the switch-off threshold value, uiSwitchOffValue.
0x810F | 33039 | FB_BARDaylightControl: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x8110 | 33040 | FB_BARConstantLightControl: the operating mode, uiLightCtrlMode, is greater than 2. However, only 0, 1 or 2 is permitted.
0x8111 | 33041 | FB_BARConstantLightControl: the lower limit value, lrMinDimValue, is less than zero or greater than 100%.
0x8112 | 33042 | FB_BARConstantLightControl: the upper limit value, lrMaxDimValue, is less than zero or greater than 100%.
0x8113 | 33043 | FB_BARConstantLightControl: the lower limit value, lrMinDimValue, is greater than the upper limit value, lrMaxDimValue.
0x8114 | 33044 | FB_BARConstantLightControl: the starting value of the controller, lrStartDimValue, is less than zero or greater than 100%.
0x8115 | 33045 | FB_BARConstantLightControl: the value for "Manual On", lrManualDimValue, is less than zero or greater than 100%.
0x8116.. 0x81FF | 33046.. 33279 | reserved for lighting function blocks
0x8200 | 33280 | FB_BARPICtrl: The activation-cyclenumber uiCtrlCycleCall is equal to zero.
0x8201 | 33281 | FB_BARPICtrl: The proportional band rXp equal to zero.
0x8202 | 33282 | FB_BARPICtrl: The lower limit of the control-value rYMin, is greater than or equal to the upper limit rYMax.
0x8203 | 33283 | FB_BARPICtrl: The task-cycletime tTaskCycleTime is set to 0.
0x8204 | 33284 | FB_HVACOptimizedOn: The outsude-temperature-values rOutsideTemp[i] of the temperature-change-function stTempChangeFunction are not in a rising order or two values are equal.
0x8205 | 33285 | FB_HVACOptimizedOn: One or more values of the temperature-change-function stTempChangeFunction are greater than the upper limit rMaxTempChange.
0x8206 | 33286 | FB_HVACOptimizedOn: One or more values of the temperature-change-function stTempChangeFunction are lower than the lower limit rMinTempChange.
0x8207 | 33287 | FB_HVACOptimizedOn: The control-input eCtrlFct is neither set to heating nor cooling (eBARCtrlFct_Heating oder eBARCtrlFct_Cooling).
0x8208 | 33288 | FB_HVACOptimizedOff: One or more values of the temperature-change-function stTempChangeFunction are greater than the upper limit rMaxTempChange.
0x8209 | 33289 | FB_HVACOptimizedOff: One or more values of the temperature-change-function stTempChangeFunction are greater than the upper limit rMaxTempChange.
0x820A | 33290 | FB_HVACOptimizedOff: One or more values of the temperature-change-function stTempChangeFunction are lower than the lower limit rMinTempChange.
0x820B | 33291 | FB_HVACOptimizedOff: The control-input eCtrlFct is neither set to heating nor cooling (eBARCtrlFct_Heating oder eBARCtrlFct_Cooling).
0x820C | 33292 | FB_HVACTempChangeFunctionEntry: The outsude-temperature-values rOutsideTemp[i] of the temperature-change-function stTempChangeFunction are not in a rising order or two values are equal.
0x8C00.. 0x8CFF | 35840.. 36095 | See SMI error codes. Substract from the error code the value 0x0C00 to get the SMI-specific error code.


FB_HVAC2PointCtrl

Application

This function block represents a 2-point controller. The controller is enabled via bEnable = TRUE and is then active.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
rW                        : REAL;
rX                        : REAL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The controller is enabled via a TRUE and is then active.

rW: The set value is transferred with the rW variable.

rX: The actual value of the control loop is transferred with the rX variable.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

bOut                      : BOOL;
bInvalidParameter         : BOOL;

bOut: Switching output of the two-point controller.

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

VAR_IN_OUT

      Name                      : Type            Persistent       Default            Range

rHighLimit                : REAL;               X              0.0             0 .. 32767
rLowLimit                 : REAL;               X              0.0             0 .. 32767
bDirection                : BOOL;               X              FALSE
tDelayOn                  : TIME;               X              t#0s
tDelayOff                 : TIME;               X              t#0s

rHighLimit: Upper limit of the control deviation.

rLowLimit: Lower limit of the control deviation.

bDirection: The control direction of the controller is determined by bDirection. FALSE = heating mode; TRUE = cooling mode.

tDelayOn: Switch-on delay

tDelayOff: Release delay

Timing characteristics

Figure 1:

Curve of switching output bOut for a two-point controller in relation to the upper/lower limits of the control deviation, with no switch-on or release delay.

Figure 2:

Curve of switching output bOut for a two-point controller in relation to the upper limit rHighLimit = 3 and the lower limit rLowLimit = 8 with a switch-on delay of tDelayOn = 4s and a release delay of tDelayOff = 6s.


FB_HVACI_CtrlStep

Application

The function block serves the sequential control of power generators.

In conjunction with the power range table FB_HVACPowerRangeTable, the power step controller can be used for the stepped control of several heating boilers, refrigerating machines or recooling plants.

Switching up or down to the next higher or next lower power step respectively takes place via an integral (rW - rX) and a time delay. First of all, the actual temperature value rX must have exceeded or fallen below a threshold value rW_High / rW_Low. Subsequently, the integral starts. If the upper or lower limit value (rIntegralHigh / rIntegralLow) is reached on the output rI_Ctrl, then a timing element is started upon whose expiry (udiSecRT_DelayHigh / udiSecRT_DelayLow)the output iStep is incremented or decremented; see Program flowchart

An integration time setting of udiSecTiHigh/udiSecTiLow = 60 seconds means that the I-transfer element changes by one Kelvin per minute. In the case of a control deviation of rE = 5, the output of the I-transfer element rI_Ctrl has the value 5 after one minute.

Example:
bDirection = FALSE; udiSecTiLow = 60; rE = 2; rIntegralLow = 10
For the remaining control deviation of 2 and the lower integral limit of 10, rI_Ctrl = rIntegralLow after 5 minutes . The consequence of this is that a timing element with the delay time udiSecDelayLow is started. After its expiry (udiSecRT_DelayHigh / udiSecRT_DelayLow),the output iStep isincremented by 1 and the I-transfer element and the time delays are reset.
iStep is set to 1 for one PLC cycle if bEnable =TRUE, bError =FALSE, eCtrlMode = eHVACCtrlMode_Auto AND iNumberOfStepInProfile > 0.

Conditions

The I-transfer element is released, if

bEnable = TRUEAND NOT bError AND eCtrlMode = eHVACCtrlMode_Auto AND NOT bBlock
(
(rX >= rW_High AND ((iStep > 0 ANDNOT bDirection) OR (iStep < iNumberOfStepInProfile AND bDirection))
OR
(rX < rW_Low AND ((iStep < iNumberOfStepInProfile ANDNOT bDirection) OR (iStep > 0 AND bDirection))
)

. If rI_Ctrl =rIntegralHigh / rIntegralLow, then the timing elements of the delay times udiSecDelayHigh / udiSecDelayLow are activated. After the expiry of the delay times udiSecRT_DelayHigh / udiSecRT_DelayLow, the steps of the power step sequence are controlled as follows:

iStep = iStep + 1 if

(rX < rW_Low AND iStep < iNumberOfStepInProfile ANDNOT bDirection)
OR
(rX >= rW_High AND iStep < iNumberOfStepInProfile AND bDirection)

iStep = iStep - 1 if

(rX < rW_Low AND iStep > 0 AND bDirection)
OR
(rX >= rW_High AND iStep > 0 ANDNOT bDirection)

The I-transfer element and the internal time delays (udiSecDelayLow, udiSecDelayHigh) are reset after each change of iStep.

Transfer function of the I-transfer element (I_Ctrl)

Program flowchart

Program flowchart

Behaviour of the different variables

The figure shows when each variable is used and how.

Application example

The application example shows the function block FB_HVACI_CtrlStep in conjunction with the power range table FB_HVACPowerRangeTable. The example is available in the programming languages ST and CFC. The program example P_CFC_I_CtrlStep.PRG in CFC is in the folder Language CFC > Controller; the program example P_ST_I_CtrlStep.PRG in ST is in the folder Language Structure Text > Controller.

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                        : Type                       Range

eDataSecurityType           : E_HVACDataSecurityType;
bSetDefault                 : BOOL;
bEnable                     : BOOL;
rW                          : REAL;
rX                          : REAL;
eCtrlMode                   : E_HVACCtrlMode;
iManualStep                 : INT;                       0..iNumberOfStepInProfile
bStepUp                     : BOOL;
bStepDown                   : BOOL;
bDirection                  : BOOL;
iNumberOfStepInProfile      : INT;                       0..g_iMaxNumberOfSteps
bBlock                      : 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.

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 via TRUE. If bEnable = FALSE, then iStep is set constantly to 0. The check of the variable iNumberOfStepInProfile remains active. If an error occurs, it is displayed with bError = TRUE and can be acknowledged with bReset once the fault has been rectified.

rW: The set value is transferred with the rW variable.

rX: The variable rX is used to transfer the actual value.

eCtrlMode: Enum that specifies the mode of operation of the function block. If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual AND iNumberOfStepInProfile > 0, then the value of the output iStep can be specified via iManualStep. On starting the PLC, eCtrlMode = eHVACCtrlMode_Auto.

iManualStep: If the operating mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUEAND bError = FALSEAND iNumberOfStepInProfile > 0, then the value of the output iStep can be specified via iManualStep. The input range of iManualStep can be 0 at the least and the value of iNumberOfStepInProfile at the most.

bStepUp: If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=FALSE, then the value of the output iStep can be incremented by 1 by a rising edge on the input bStepUp. This can be repeated until iStep = iNumberOfStepInProfile.

bStepDown: If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=FALSE, then the value of the output iStep can be decremented by 1 by a rising edge on the input bStepDown. This can be repeated until iStep = 0.

bDirection: bDirection determines the direction of action of the function block. FALSE = heating mode; TRUE = cooling mode

iNumberOfStepInProfile: Number of steps in the power step sequence. iNumberOfStepInProfile can be 0 at the least and the value of g_iMaxNumberOfSteps at the most. If the limit values are not adhered to, an error is output and displayed by bError = TRUE and iStep becomes = 0.

bBlock: Using the input variable bBlock, the controller of the function block can either be released or the output iStep is set to the value to the variable iNumberOfStepInProfile.

If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=FALSE, then the I-transfer element and the internal timing elements are released for the control of the output iStep.

If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=TRUE, then the I-transfer element and the internal timing elements are blocked and iStep = iNumberOfStepInProfile.

bReset: Input for acknowledgement of the faults once they have been rectified. Internally the system responds to a rising edge.

VAR_OUTPUT

      Name
                       : Type         Range                          Comment

iStep                  : INT;         0..iNumberOfStepInProfile
rI_Ctrl                : REAL;
rE                     : REAL;
rW_High                : REAL;
rW_Low                 : REAL;
b_rW_High              : BOOL;
b_rW_Low               : BOOL;
udiSecRT_DelayHigh     : UDINT;                                      Second Remaining Time Delay High
udiSecRT_DelayLow      : UDINT;                                      Second Remaining Time Delay Low
bError                 : BOOL;
eErrorCode             : E_HVACErrorCodes;

iStep: The output variable iStep indicates the step in a power step sequence. On starting the function block, iStep = 1 if bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_Auto AND iNumberOfStepInProfile > 0. iStep can reach the value of iNumberOfStepInProfile at the most and can be 0 at the least.

The value of iStep can be specified manually via iManualStep if bEnable = TRUE, bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual.

The value of iStep can be incremented or decremented via the input variables bStepUp / bStepDown if bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_Auto AND bBlock = FALSE.

If bEnable = TRUE,
bError = FALSE,
eCtrlMode = eHVACCtrlMode_Auto AND bBlock = FALSE and the value of iStep has changed,
then the delay timing elements and the I-transfer element are
reset.

If bEnable = TRUE,
bError = FALSE,
eCtrlMode = eHVACCtrlMode_Auto, bBlock =
FALSEAND iNumberOfStepInProfile  > 0, the output of the I-transfer
element rI_Ctrl =rIntegralHigh or  rIntegralLow and
one of the delay times tRemainingTimeDelayHigh /
tRemainingTimeDelayLow =T#0s,
then the output iStep is controlled as follows:

iStep = iStep + 1 if

(rX < rW_Low AND iStep < iNumberOfStepInProfile ANDNOT bDirection)
OR
(rX >= rW_High AND iStep < iNumberOfStepInProfile AND bDirection) ist.

iStep = iStep - 1 if

(rX < rW_Low AND iStep > 0 AND bDirection)
OR
(rX >= rW_High AND iStep > 0 ANDNOT bDirection) ist, siehe Programmablaufplan

If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=TRUE, then the I-transfer element and the internal timing elements are blocked and iStep = iNumberOfStepInProfile.

rI_Ctrl: Output of the I-transfer element.
If rI_Ctrl >= rIntegralHigh or rIntegralLow and tRemainingTimeDelayHigh or tRemainingTimeDelayLow = T#0s, then the number of steps is incremented or decremented by 1 via iStep. Subsequently, the I-transfer element and the timing elements for stepping up or down are reset, so that stepping up or down is restarted, see Program flowchart.

rE: Control deviation with which the internal I-transfer element works: rE = rW - rX

rW_High: rW_High := rW + rHysteresisHigh – upper set value limit which, when exceeded by rX, causes the I-transfer element to be activated first, followed by the timing element of the delay time udiSecDelayHigh; see Application or Behaviour of different variables.

rW_Low: rW_Low := rW - rHysteresisLow – lower set value limit which, when undercut by rX, causes the I-transfer element to be activated first, followed by the timing element of the delay time udiSecDelayLow; see Application or Behaviour of different variables.

b_rW_High: b_rW_High goes TRUE if rX > rW_High.

b_rW_Low: b_rW_Low goes TRUE if rX < rW_Low.

udiSecRT_DelayHigh: Remaining time of the delay time udiSecDelayHigh.

udiSecRT_DelayLow: Remaining time of the delay time udiSecDelayLow.

bError: This output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfStepInProfile. iStep is set constantly to 0 and the Enum eErrorCode indicates the error code. Once the fault has been rectified the bError message must be acknowledged with bReset.

eErrorCode: Supplies the error number when the bError output is set. The following error can occur in this function block: eHVACErrorCodes_InvalidParam_NumberOfStepInProfile

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_Error_iNumberOfStepInProfil =32

VAR_IN_OUT

      Name               : Type       Persistent       Default        Range

rHysteresisHigh    : REAL;          X                5.0
rHysteresisLow     : REAL;          X                5.0
udiSecDelayHigh    : UDINT;         X                300s     0..g_udiMaxSec
udiSecDelayLow     : UDINT;         X                300s     0..g_udiMaxSec
udiSecTiHigh       : UDINT;         X                 60s     0..g_udiMaxSec
udiSecTiLow        : UDINT;         X                 60s     0..g_udiMaxSec
rIntegralHigh      : REAL;          X               15.0
rIntegralLow       : REAL;          X               15.0

rHysteresisHigh: Positive value of the upper limit of the control deviation; see Application or Behaviour of different variables. rW_High := rW + rHysteresisHigh

rHysteresisLow: Positive value of the lower limit of the control deviation; see Application or Behaviour of different variables. rW_Low := rW - rHysteresisLow

udiSecDelayHigh: Delay time after whose expiry iStep is incremented or decremented; see Application or Behaviour of different variables.

udiSecDelayLow: Delay time after whose expiry iStep is incremented or decremented; see Application or Behaviour of different variables.

udiSecTiHigh: Integration time for the upper limit of the I-transfer element in seconds; see Application or Behaviour of different variables. udiSecTiHigh must be > 0. Otherwise the default value or the last valid variable value is used internally.

udiSecTiLow: Integration time for the lower limit of the I-transfer element in seconds; see Application or Behaviour of different variables. udiSecTiLow must be > 0. Otherwise the default value or the last valid variable value is used internally.

rIntegralHigh: Positive value for the upper limit at which the integration of the I-transfer element is stopped (ARW measure, anti-reset-windup) and one of the delay times starts; see Application or Behaviour of different variables.

rIntegralLow: Positive value for the lower limit at which the integration of the I-transfer element is stopped (ARW measure, anti-reset-windup) and one of the delay times starts; see Application or Behaviour of different variables.


FB_HVACI_CtrlStepEx

Application

The function block serves the sequential control of power generators. The difference compared with the FB_HVACI_CtrlStep lies in it that iStep's value is provided when uploading the function block about the variable iStartStep.

In conjunction with the power range table FB_HVACPowerRangeTable, the power step controller can be used for the stepped control of several heating boilers, refrigerating machines or recooling plants.

Switching up or down to the next higher or next lower power step respectively takes place via an integral (rW - rX) and a time delay. First of all, the actual temperature value rX must have exceeded or fallen below a threshold value rW_High / rW_Low. Subsequently, the integral starts. If the upper or lower limit value (rIntegralHigh / rIntegralLow) is reached on the output rI_Ctrl, then a timing element is started upon whose expiry (udiSecRT_DelayHigh / udiSecRT_DelayLow)the output iStep is incremented or decremented; see Program flowchart

An integration time setting of udiSecTiHigh/udiSecTiLow = 60 seconds means that the I-transfer element changes by one Kelvin per minute. In the case of a control deviation of rE = 5, the output of the I-transfer element rI_Ctrl has the value 5 after one minute.

Example:
bDirection = FALSE; udiSecTiLow = 60; rE = 2; rIntegralLow = 10
For the remaining control deviation of 2 and the lower integral limit of 10, rI_Ctrl = rIntegralLow after 5 minutes . The consequence of this is that a timing element with the delay time udiSecDelayLow is started. After its expiry (udiSecRT_DelayHigh / udiSecRT_DelayLow),the output iStep isincremented by 1 and the I-transfer element and the time delays are reset.
iStep is set to iStartStep for one PLC cycle if bEnable =TRUE, bError =FALSE, eCtrlMode = eHVACCtrlMode_Auto AND iNumberOfStepInProfile > 0.

Conditions

The I-transfer element is released, if

bEnable = TRUEAND NOT bError AND eCtrlMode = eHVACCtrlMode_Auto AND NOT bBlock
(
(rX >= rW_High AND ((iStep > 0 ANDNOT bDirection) OR (iStep < iNumberOfStepInProfile AND bDirection))
OR
(rX < rW_Low AND ((iStep < iNumberOfStepInProfile ANDNOT bDirection) OR (iStep > 0 AND bDirection))
)

. If rI_Ctrl =rIntegralHigh / rIntegralLow, then the timing elements of the delay times udiSecDelayHigh / udiSecDelayLow are activated. After the expiry of the delay times udiSecRT_DelayHigh / udiSecRT_DelayLow, the steps of the power step sequence are controlled as follows:

iStep = iStep + 1 if

(rX < rW_Low AND iStep < iNumberOfStepInProfile ANDNOT bDirection)
OR
(rX >= rW_High AND iStep < iNumberOfStepInProfile AND bDirection)

iStep = iStep - 1 if

(rX < rW_Low AND iStep > 0 AND bDirection)
OR
(rX >= rW_High AND iStep > 0 ANDNOT bDirection)

The I-transfer element and the internal time delays (udiSecDelayLow, udiSecDelayHigh) are reset after each change of iStep.

Transfer function of the I-transfer element (I_Ctrl)

Program flowchart

Program flowchart

Behaviour of the different variables

The figure shows when each variable is used and how.

Application example

The application example shows the function block FB_HVACI_CtrlStep in conjunction with the power range table FB_HVACPowerRangeTable. The example is available in the programming languages ST and CFC. The program example P_CFC_I_CtrlStep.PRG in CFC is in the folder Language CFC > Controller; the program example P_ST_I_CtrlStep.PRG in ST is in the folder Language Structure Text > Controller.

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                        : Type                       Range

eDataSecurityType           : E_HVACDataSecurityType;
bSetDefault                 : BOOL;
bEnable                     : BOOL;
rW                          : REAL;
rX                          : REAL;
iStartStep                  : INT;                       0..iNumberOfStepInProfile
eCtrlMode                   : E_HVACCtrlMode;
iManualStep                 : INT;                       0..iNumberOfStepInProfile
bStepUp                     : BOOL;
bStepDown                   : BOOL;
bDirection                  : BOOL;
iNumberOfStepInProfile      : INT;                       0..g_iMaxNumberOfSteps
bBlock                      : 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.

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 via TRUE. If bEnable = FALSE, then iStep is set constantly to 0. The check of the variable iNumberOfStepInProfile remains active. If an error occurs, it is displayed with bError = TRUE and can be acknowledged with bReset once the fault has been rectified.

rW: The set value is transferred with the rW variable.

rX: The variable rX is used to transfer the actual value.

iStartStep: iStep is set to iStartStep for one PLC cycle if bEnable =TRUEand bError =FALSE.

eCtrlMode: Enum that specifies the mode of operation of the function block. If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual AND iNumberOfStepInProfile > 0, then the value of the output iStep can be specified via iManualStep. On starting the PLC, eCtrlMode = eHVACCtrlMode_Auto.

iManualStep: If the operating mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUEAND bError = FALSEAND iNumberOfStepInProfile > 0, then the value of the output iStep can be specified via iManualStep. The input range of iManualStep can be 0 at the least and the value of iNumberOfStepInProfile at the most.

bStepUp: If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=FALSE, then the value of the output iStep can be incremented by 1 by a rising edge on the input bStepUp. This can be repeated until iStep = iNumberOfStepInProfile.

bStepDown: If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=FALSE, then the value of the output iStep can be decremented by 1 by a rising edge on the input bStepDown. This can be repeated until iStep = 0.

bDirection: bDirection determines the direction of action of the function block. FALSE = heating mode; TRUE = cooling mode

iNumberOfStepInProfile: Number of steps in the power step sequence. iNumberOfStepInProfile can be 0 at the least and the value of g_iMaxNumberOfSteps at the most. If the limit values are not adhered to, an error is output and displayed by bError = TRUE and iStep becomes = 0.

bBlock: Using the input variable bBlock, the controller of the function block can either be released or the output iStep is set to the value to the variable iNumberOfStepInProfile.

If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=FALSE, then the I-transfer element and the internal timing elements are released for the control of the output iStep.

If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=TRUE, then the I-transfer element and the internal timing elements are blocked and iStep = iNumberOfStepInProfile.

bReset: Input for acknowledgement of the faults once they have been rectified. Internally the system responds to a rising edge.

VAR_OUTPUT

      Name
                       : Type         Range                          Comment

iStep                  : INT;         0..iNumberOfStepInProfile
rI_Ctrl                : REAL;
rE                     : REAL;
rW_High                : REAL;
rW_Low                 : REAL;
b_rW_High              : BOOL;
b_rW_Low               : BOOL;
udiSecRT_DelayHigh     : UDINT;                                      Second Remaining Time Delay High
udiSecRT_DelayLow      : UDINT;                                      Second Remaining Time Delay Low
bError                 : BOOL;
eErrorCode             : E_HVACErrorCodes;

iStep: The output variable iStep indicates the step in a power step sequence. On starting the function block, iStep = iStartStep if bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_Auto AND iNumberOfStepInProfile > 0. iStep can reach the value of iNumberOfStepInProfile at the most and can be 0 at the least.

The value of iStep can be specified manually via iManualStep if bEnable = TRUE, bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual.

The value of iStep can be incremented or decremented via the input variables bStepUp / bStepDown if bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_Auto AND bBlock = FALSE.

If bEnable = TRUE,
bError = FALSE,
eCtrlMode = eHVACCtrlMode_Auto AND bBlock = FALSE and the value of iStep has changed,
then the delay timing elements and the I-transfer element are
reset.

If bEnable = TRUE,
bError = FALSE,
eCtrlMode = eHVACCtrlMode_Auto, bBlock =
FALSEAND iNumberOfStepInProfile  > 0, the output of the I-transfer
element rI_Ctrl =rIntegralHigh or  rIntegralLow and
one of the delay times tRemainingTimeDelayHigh /
tRemainingTimeDelayLow =T#0s,
then the output iStep is controlled as follows:

iStep = iStep + 1 if

(rX < rW_Low AND iStep < iNumberOfStepInProfile ANDNOT bDirection)
OR
(rX >= rW_High AND iStep < iNumberOfStepInProfile AND bDirection) ist.

iStep = iStep - 1 if

(rX < rW_Low AND iStep > 0 AND bDirection)
OR
(rX >= rW_High AND iStep > 0 ANDNOT bDirection) ist, siehe Programmablaufplan

If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bBlock=TRUE, then the I-transfer element and the internal timing elements are blocked and iStep = iNumberOfStepInProfile.

rI_Ctrl: Output of the I-transfer element.
If rI_Ctrl >= rIntegralHigh or rIntegralLow and tRemainingTimeDelayHigh or tRemainingTimeDelayLow = T#0s, then the number of steps is incremented or decremented by 1 via iStep. Subsequently, the I-transfer element and the timing elements for stepping up or down are reset, so that stepping up or down is restarted, see Program flowchart.

rE: Control deviation with which the internal I-transfer element works: rE = rW - rX

rW_High: rW_High := rW + rHysteresisHigh – upper set value limit which, when exceeded by rX, causes the I-transfer element to be activated first, followed by the timing element of the delay time udiSecDelayHigh; see Application or Behaviour of different variables.

rW_Low: rW_Low := rW - rHysteresisLow – lower set value limit which, when undercut by rX, causes the I-transfer element to be activated first, followed by the timing element of the delay time udiSecDelayLow; see Application or Behaviour of different variables.

b_rW_High: b_rW_High goes TRUE if rX > rW_High.

b_rW_Low: b_rW_Low goes TRUE if rX < rW_Low.

udiSecRT_DelayHigh: Remaining time of the delay time udiSecDelayHigh.

udiSecRT_DelayLow: Remaining time of the delay time udiSecDelayLow.

bError: This output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfStepInProfile. iStep is set constantly to 0 and the Enum eErrorCode indicates the error code. Once the fault has been rectified the bError message must be acknowledged with bReset.

eErrorCode: Supplies the error number when the bError output is set. The following error can occur in this function block: eHVACErrorCodes_InvalidParam_NumberOfStepInProfile

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_Error_iNumberOfStepInProfil =32

VAR_IN_OUT

      Name               : Type       Persistent       Default        Range

rHysteresisHigh    : REAL;          X                5.0
rHysteresisLow     : REAL;          X                5.0
udiSecDelayHigh    : UDINT;         X                300s     0..g_udiMaxSec
udiSecDelayLow     : UDINT;         X                300s     0..g_udiMaxSec
udiSecTiHigh       : UDINT;         X                 60s     0..g_udiMaxSec
udiSecTiLow        : UDINT;         X                 60s     0..g_udiMaxSec
rIntegralHigh      : REAL;          X               15.0
rIntegralLow       : REAL;          X               15.0

rHysteresisHigh: Positive value of the upper limit of the control deviation; see Application or Behaviour of different variables. rW_High := rW + rHysteresisHigh

rHysteresisLow: Positive value of the lower limit of the control deviation; see Application or Behaviour of different variables. rW_Low := rW - rHysteresisLow

udiSecDelayHigh: Delay time after whose expiry iStep is incremented or decremented; see Application or Behaviour of different variables.

udiSecDelayLow: Delay time after whose expiry iStep is incremented or decremented; see Application or Behaviour of different variables.

udiSecTiHigh: Integration time for the upper limit of the I-transfer element in seconds; see Application or Behaviour of different variables. udiSecTiHigh must be > 0. Otherwise the default value or the last valid variable value is used internally.

udiSecTiLow: Integration time for the lower limit of the I-transfer element in seconds; see Application or Behaviour of different variables. udiSecTiLow must be > 0. Otherwise the default value or the last valid variable value is used internally.

rIntegralHigh: Positive value for the upper limit at which the integration of the I-transfer element is stopped (ARW measure, anti-reset-windup) and one of the delay times starts; see Application or Behaviour of different variables.

rIntegralLow: Positive value for the lower limit at which the integration of the I-transfer element is stopped (ARW measure, anti-reset-windup) and one of the delay times starts; see Application or Behaviour of different variables.


FB_HVACPIDCtrl

Application

The PID controller is a standard controller for heating and air conditioning applications. It can be used to control temperatures, pressures, volumetric flows or air humidity. The values of Ti and Tv can be set to zero. This allows a P, PI, or PD controller characteristic to be set. The controller has an ARW function (Anti-Reset-Windup). This prevents continuous integration in the event of a perpetual pending control deviation.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rW                       : REAL;
rX                       : REAL;
tTaskCycleTime           : TIME;
tCtrlCycleTime           : TIME;
eCtrlMode                : E_HVACCtrlMode;
rYManual                 : REAL;
rInitialValue            : REAL;
bResetController         : BOOL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: Input variable for enabling the controller. The controller is enabled if bEnable = TRUE.

rW: The set value is transferred to the controller with the variable rW.

rX: rX acquires the actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

eCtrlMode: The operating mode is selected via this Enum.

rYManual: The controller output rY can be oversteered for test purposes. The set value of rYManual will be found at the controller output in manual operating mode.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue. The initial values are adopted on a rising edge at the controller enable input bEnable.
0 = start with the value zero at output rY
<>0 = Start with the value of rInitialValue

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                    : Type

rY                      : REAL;
rXW                     : REAL;
bMaxLimit               : BOOL;
bMinLimit               : BOOL;
bActive                 : BOOL;
bARWactive              : BOOL;
eState                  : E_HVACState;
bError                  : BOOL;
eErrorCode              : E_HVACErrorCodes;
bInvalidParameter       : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation.

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                    : Type        Persistent     Default        Range

rDeadRange              : REAL;           X            0.0         0 .. 32767
bDirection              : BOOL;           X           FALSE
rKp                     : REAL;           X            1.0      0.01 .. 100
tTi                     : TIME;           X           t#30s
tTv                     : TIME;           X            t#0s
tTd                     : TIME;           X            t#0s
rYMin                   : REAL;           X            0.0         0 .. 32767
rYMax                   : REAL;           X          100.0         0 .. 32767

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal rY. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal rY is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

bDirection: The control direction of the controller can be changed with the parameter bDirection. If bDirection is TRUE, then the direct control direction is active for cooling operation of the controller. If bDirection is FALSE, then the indirect control direction is active for heating operation of the controller.

rKp: Proportional factor amplification

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rYMin / rYMax: Limit the operating range of the controller. Several other function blocks, e.g. sequencers, require a symmetrical control range (-100 to +100). In the case of a cascade structure, the operating range of the master controller determines the set value of the slave controller. For example, 15° to 25° as the limitation of the supply air set value for an exhaust/supply air cascade control.


FB_HVACPIDCtrl_Ex

Universal PID-controller.

In- and Outputs

VAR_INPUT

      Name                    : Type

eDataSecurityType       : E_HVACDataSecurityType;
bSetDefault             : BOOL;
bEnable                 : BOOL;
rW                      : REAL;
rX                      : REAL;
tTaskCycleTime          : TIME;
uiCycleCall             : UINT;
bSetSyncValue           : BOOL;

eDataSecurityType: If eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eDataSecurityType_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: A TRUE-signal at this input activates the controller.
In the moment of enabling the controller, the control-output will react immeadiately to the control-deviation without a synchronization to a specific value.

rW : Setpoint-value.

rX : Actual value.

tTaskCycleTime: Task-cycle time with which the function block is called. A wrong entry will result in wrong calculations of the PID-algorithm.

uiCycleCall: This enty specifies how often the controller is processed: eg. a 5 means, that the controller is called every 5th PLC-cycle. This entry can be used to save resources, on the other hand an entry too high makes the controller more inaccurate. A missing or "0"-entry will be internally corrected to "1" = every cycle".

bSetSyncValue: A rising edge at this input sets the output rY to the value, which is entered at rSyncValue (VAR_IN_OUT). In order to do so, the I-Part will be internally manipulated. If the I-Part is not activated, the D-Part will be changed.

VAR_OUTPUT

      Name                    : Type

rY                      : REAL;
rXW                     : REAL;
bMaxLimit               : BOOL;
bMinLimit               : BOOL;
bDecLimit               : BOOL;
bIncLimit               : BOOL;
bActive                 : BOOL;
bARWactive              : BOOL;
b2Ptactive              : BOOL;
bError                  : BOOL;
eErrorCode              : E_HVACErrorCodes;

rY: Control-value, which is limited by rYMin and rYMax (VAR_IN_OUT).

rXW: Control-deviation (the calculation depends on the control-direction)

bMaxLimit: The control-value has reached its upper limit.

bMinLimit: The control-value has reached its lower limit.

bDecLimit: The decreasing-slope of the control-value has reached its upper limit, which is entered at tMaxToMin (VAR_IN_OUT).

bIncLimit : The increasing-slope of the control-value has reached its upper limit, which is entered at tMinToMax (VAR_IN_OUT).

bActive : The controller is active, wich means, that it is enabled (bEnable = TRUE) and not in an error-state (bError = FALSE).

bARWactive : The Anti-Reset-Windup-function is active.

b2Ptactive : Two-position-controller-mode is active.

bError : This output is set to TRUE, when the controller is in an error-state due to wrong parameters.

eErrorCode : Contains the specific errorcode, see E_HVACErrorCodes.

VAR_IN_OUT

      Name                    : Type        Persistent     Default

rDeadRange              : REAL;           X            0.0
rSyncValue              : REAL;           X            0.0
bDirection              : BOOL;           X           FALSE
rKp                     : REAL;           X            1.0
tTi                     : TIME;           X           t#30s
tTv                     : TIME;           X            t#0s
tTd                     : TIME;           X            t#0s
rYMin                   : REAL;           X            0.0
rYMax                   : REAL;           X          100.0
tMinToMax               : TIME;           X            t#0s
tMaxToMin               : TIME;           X            t#0s

rDeadRange: In order to avoid needless switching of the actuators, such as valves, a so called dead-range can be defined. If the control-deviation is within the range of -rDeadRange/2 ... +rDeadRange/2 the controller stopps calculating the output rY. The bigger the dead-range, the longer the control-value is frozen.

rSyncValue: A rising edge at the input bSetSyncVal sets the output rY to the value, which is entered at rSyncValue. In order to do so, the I-Part will be internally manipulated. If the I-Part is not activated, the D-Part will be changed.

bDirection: With this Parameter the control-direction can be changed. If bDirection is set to TRUE, the controller is set to cooling-mode, if it is set to FALSE the heating-mode is activated. See control-direction.

rKp: Propportional-constant (Amplification). The amplification has only an effect on the P-Part.

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integral component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rYMin / rYMax: Limitation of the output. With these both parameters the output-range of rY can be defined. rYMin thas to be lower than rYMax.

tMinToMax : Limitation of the increasing slope of the control-output. tMinToMax in seconds defines the time for a change from rYMin to rYMax.

tMaxToMin : Limitation of the decreasing slope of the control-output. tMaxToMin in seconds defines the time for a change from rYMax to rYMin.

Functional description

Passive-behaviour (bEnable = FALSE or bError = TRUE)

The outputs are set in the followiog scheme:

rY | 0,0
rXW | 0,0
bMaxLimit | FALSE
bMinLimit | FALSE
bDecLimit | FALSE
bIncLimit | FALSE
bActive | FALSE
bARWactive | FALSE
b2Ptactive | FALSE
In case of an error the output bError is set to TRUE - eErrorCode displays the actual errorcode. The internal values for the P-, I-, and D-part are set to "0", as well as the repective values for the previous cycle. Thus the controller can restart "clean" without any past values.

Aktive-behaviour (bEnable = TRUE and bError = FALSE)

As already mentioned, the I- and the D-part are calculated without any past-values in the first cycle after activation. A TRUE-signal at bSetSyncValue sets the control-output rY to rSyncValue by changing the internal I-Part, so the PID-Addition results in the desired value. If the I-Part is disabled, the D-Part will be changed. If bEnable and bSetSyncValue are set at the same time, this can be used to define an initial value for starting the controller. Internally only rising edges at the input bSetSyncValue will be recognized - in order to synchronize another time, bSetSyncValue has to be set to FALSE before.

If the I-Part is active, the controller will freeze its internal value, if the output rY reaches beyond the defined limits. This method is called "Anti Reset Windup" and prevents the I-Part from drifting too much, if the control-deviation causes the output to exceed its limits. This way, when the deviation has normal values again, the controller is able to quickly react again without working off an I-Part, which got needlessly too high.

Control-direction

If bDirection is set to FALSE, the control-direction will be changed, so a negative control-deviation will cause a positive value at the control-output. This is done by changing the internal calculation of the control-deviation.

bDirection | rE (control-deviation) | control-direction
TRUE | lrX-lrW (actual value-setpoint) | direct (cooling)
FALSE | lrW-lrX (setpoint-actual value) | reverse (heating)

Anti-Reset-Windup when reaching the minimum or maximum limit of the control value

If the controller reaches its upper limit at the control-output and the deviation remains still positive, the I-part would increase as long as the deviation remains positiv and not equal to zero. The same goes for for reaching the minimum output while still having a negative deviation. In both cases it is possible that dhe I-Part will needlessly grow much too high - positively or negatively. When the deviation changes, this big I-part has to be worked off before the control-output will show changes within its limits again which slows down the controller. On order to prevent the controller from accumulating high I-values, this part will be frozen when

  • the deviation is bigger than zero and the contoller has reached its upper limit
  • the deviation is lower than zero and the contoller has reached its lower limit

When the mentioned freezing conditions are not fulfilled any more, the calculation of the control-output will be resumed.
The output lrY will be synchronized to the limit, where it has remained earlier by manipulating the I-part, in order to prevent it from jumping into the controlling range lrMin..lrMax.

Slope-Limitation

If the controller is reacting to fast, the actuator, eg. a valve, may not be able to follow, which can result in a swinging system. This can be prevented by limitating the slope of the control-output. In order to do so, the I-part of the controller will only be allowed to increase/decrease as much per PLC-cycle as the actuator is able to follow.

The following two parameters have to be entered - a zero-entry deactivates the slope-limitation:

tMinToMax : Slope-limitation for increasing the control-output: tMinToMax in seconds referring to a change from rYMin to rYMax.

tMaxToMin : Slope-limitation for decreasing the control-output: tMinToMax in seconds referring to a change from rYMax to rYMin.

With these values it is possible to calculate the allowed change per PLC-Cycle.

Deadrange

If the setpoint is finally reached, the actual value may still swing around it, which causes swinging at the control-output and constant movement at the actuator. This can be surpressed by defining a deadrange around the setpoint. If the absolute value of the control-deviation is smaller than half of the defined rDeadRange, the P- I- and D-Part will be frozen and not calculated any more until the deviation gets above 0,5*rDeadRange again.

A zero-entry at this input deactivates the deadrange.

Two-position-control-mode

If the parameters rKp, tTn, tTv and tTd are set to 0.0 resp. t#0s, the controller has two-position-control-behaviour. The deadrange mentioned above now defines the hysteresis.

The controller will switch to the maximum-output rYMax, if the deviation rXW is greater than half of the hysteresis rDeadRange and will switch to its minimum output, if the deviation falls below the negative half of the hysteresis rDeadRange :

The different calculations of the control-deviation (direct or reverse control) will result in the following switching-behaviour referring to the actual value rX:

  • direct control (cooling): control deviation = actual value - setpoint rXW = rX-rW

  • reverse control (heating): control deviation = setpoint - actual value rXW = rW-rX


FB_HVACPowerRangeTable

Application

This function block represents a power range table and serves the sequential control of power generators such as boilers or refrigeration machines. The power steps are determined by the upstream controller FB_HVACI_Ctrl_Step and transferred to the power range table via the input iStep.

All information or parameters relevant to system control are summarised in the power range table ARRAY arrPowerRangeTable. The power range table is a two-dimensional array with the structure ST_HVACPowerRange. The power range table can be compared to a normal table. An individual element is clearly designated by naming line and column. The columns are marked by the field range 1 to g_iMaxNumberOfProfiles. This range is called the profile and is addressed via the input variable iProfile. The field range 0 to g_iMaxNumberOfSteps represents the lines. This range is called the step and is addressed via the input variable iStep.

The power range table consists of 16 profiles. Each profile can have up to 33 steps, from 0 to 32. Each individual step contains the parameter structure ST_HVACPowerRange needed for system control. The parameters indicated here are transferred via the output structures stI_Ctrl and stAggregate1-6 to the function block FB_HVACI_CtrlStep for controlling the steps and to the function blocks for energy generation.

The number of steps in a profile is indicated by the output variableiNumberOfStepInProfile.The number depends on the entries in the power range table and on the specification in the selected profileiCurrentProfile. The selected profile is checked internally from step 1 up to the step in which all variables of the structure ST_HVACPowerRange have the value 0. iNumberOfStepInProfile is always intended only for the specified profile. iNumberOfStepInProfile can thus be used to limit the steps in a profile for other function blocks such as for the input iNumberOfStepInProfile of FB_HVACI_CtrlStep, which could control the individual steps of the FB_HVACPowerRangeTable via its output iStep. The step 0 is not taken into account when evaluating the number of steps via iNumberOfStepInProfile, because the power generators are switched off in this step; it can be considered to be a standby step. The values of the variables of the output structures stAggregate1-6 then output the value 0. In the standby step, the parameters required for starting the power step sequence of the energy generators are transferred to the upstream controller FB_HVACI_Ctrl_Step via the output structure stI_Ctrl.

Table example for the power range table arrPowerRangeTable

A unit is assigned to each power step within a profile (table columns).
Hence, the order is specified in which the power generators are switched on or off within a sequence.
The power of the units is specified as 0 to 6 in the case of stepped power generators or 0 to 100% in the case of constant power generators.
After switching to a higher or lower power step, the integral portion of the upstream function block FB_HVACI_Ctrl_Step is re-initialised. The current values for the step-up and step-down integrals are then transferred to the controller by means of the structure stI_Ctrl.
It is possible to switch to a different profile for a change of order of the units within the sequence. By skilfully entering different orders of the units in the profiles, it is possible to react with the utmost flexibility to all requirements with regard to the control of power generators.
The switching of the power profiles (iCurrentProfile) usually takes place on the basis of time or operating hours so that all power generators in a plant are utilised evenly.
In the case of power generators with different rated outputs, the power profile is changed in relation to the load.

If a unit within a generator group is faulty, it is possible to switch to a profile in which the faulty generator is placed at the end of the power order.

The power range table shows three power profiles. The order of the power generators is entered in each power profile.

Profile 1:
In profile 1, unit 1 is switched to the first power step in power step 1. In the second power step, unit 2 is added with its first power step.

Profile 2:
In profile 2, unit 3 is switched to the first power step in power step 1. In the second power step, unit 3 is switched in its second power step. In the third power step, unit 1 is added with its first power step.

Profile 3:
In profile 3, unit 5 is switched to the first power step in power step 1. In the second power step, unit 4 is added with its first power step. In the third power step, unit 3 is added with its first power step.

By skilful arrangement of the power profiles, it is possible to react to faults in individual units, the operating-hour dependent change of order or the load-optimised change of power orders.

The relationship between the power range table arrPowerRange and the output structures stAggregate1-6 and stI_Ctrl is to be described in greater detail on the basis of the table example:

  1. The column iCurrentProfile = 1 is intended to represent the 1st profile of the power range table arrPowerRange. In this profile the output iNumberOfStepInProfile has the value 2, because no variable value in the structure ST_HVACPowerRange (marked red) is greater than 0 in the line iCurrentStep = 3.
    If one assumes that the current power step iCurrentStep has the value 2, then the variable values are output as follows on the output structures:

    arrPowerRangeTable[iCurrentProfile,iCurrentStep];

    stAggregate1.iAggregateStep :=arrPowerRangeTable[1,1].iAggregateStep;
    stAggregate1.rY_Max     := arrPowerRangeTable[1,1].rY_Max;
    stAggregate1.rY_Min     :=arrPowerRangeTable[1,1].rY_Min;
    stAggregate1.bBlock     := arrPowerRangeTable[1,1].bBlock;

    stAggregate2.iAggregateStep :=arrPowerRangeTable[1,2].iAggregateStep;
    stAggregate2.rY_Max     := arrPowerRangeTable[1,2].rY_Max;
    stAggregate2.rY_Min     :=arrPowerRangeTable[1,2].rY_Min;
    stAggregate2.bBlock     := arrPowerRangeTable[1,2].bBlock;

    stI_Ctrl.rIntegralHigh := arrPowerRangeTable[1,2].rIntegralHigh;
    stI_Ctrl.rIntegralLow := arrPowerRangeTable[1,2].rIntegralLow;
    stI_Ctrl.udiSecDelayHigh :=arrPowerRangeTable[1,2].udiSecDelayHigh;
    stI_Ctrl.udiSecDelayLow :=arrPowerRangeTable[1,2].udiSecDelayLow;

    Contents of the output structures stAggregate1, stAggregate2 and stI_Ctrl. The variables of the output structures stAggregate3-6 have the value 0.

    stAggregate1.iAggregateStep := 1;
    stAggregate1.rY_Max     := 0;
    stAggregate1.rY_Min := 0;
    stAggregate1.bBlock := FALSE;

    stAggregate2.iAggregateStep :=1;
    stAggregate2.rY_Max     := 0;
    stAggregate2.rY_Min     :=0;
    stAggregate2.bBlock     := TRUE;

    stI_Ctrl.rIntegralHigh := 10;
    stI_Ctrl.rIntegralLow := 10;
    stI_Ctrl.udiSecDelayHigh :=300;
    stI_Ctrl.udiSecDelayLow :=300;

  2. The column iCurrentProfile = 2 represents the 2nd profile of the power range table arrPowerRange. In this profile the output iNumberOfStepInProfile has the value 3, because no variable value in the structure ST_HVACPowerRange (marked red) is greater than 0 in the line iCurrentStep = 4.
    If one assumes that the current power step iCurrentStep has the value 3, then the variable values are output as follows on the output structures:

    arrPowerRangeTable[iCurrentProfile,iCurrentStep];

    stAggregate1.iAggregateStep :=arrPowerRangeTable[2,3].iAggregateStep;
    stAggregate1.rY_Max     := arrPowerRangeTable[2,3].rY_Max;
    stAggregate1.rY_Min     :=arrPowerRangeTable[2,3].rY_Min;
    stAggregate1.bBlock     := arrPowerRangeTable[2,3].bBlock;

    stAggregate3.iAggregateStep :=arrPowerRangeTable[2,2].iAggregateStep;
    stAggregate3.rY_Max     := arrPowerRangeTable[2,2].rY_Max;
    stAggregate3.rY_Min     :=arrPowerRangeTable[2,2].rY_Min;
    stAggregate3.bBlock     := arrPowerRangeTable[2,2].bBlock;

    stI_Ctrl.rIntegralHigh := arrPowerRangeTable[2,3].rIntegralHigh;
    stI_Ctrl.rIntegralLow := arrPowerRangeTable[2,3].rIntegralLow;
    stI_Ctrl.udiSecDelayHigh :=arrPowerRangeTable[2,3].udiSecDelayHigh;
    stI_Ctrl.udiSecDelayLow :=arrPowerRangeTable[2,3].udiSecDelayLow;

    Contents of the output structures stAggregate1, stAggregate3 and stI_Ctrl. The variables of the output structures stAggregate2 and stAggregate4-6 have the value 0.

    stAggregate1.iAggregateStep :=1;
    stAggregate1.rY_Max     := 0;
    stAggregate1.rY_Min     :=0;
    stAggregate1.bBlock     := FALSE;

    stAggregate3.iAggregateStep :=2;
    stAggregate3.rY_Max     := 60;
    stAggregate3.rY_Min     :=30;
    stAggregate3.bBlock     := FALSE;

    stI_Ctrl.rIntegralHigh := 8;
    stI_Ctrl.rIntegralLow := 8;
    stI_Ctrl.udiSecDelayHigh :=23;
    stI_Ctrl.udiSecDelayLow :=123;

  3. The column iCurrentProfile = 3 represents the 3rd profile of the power range table arrPowerRange. In this profile the output iNumberOfStepInProfile has the value 3, because no variable value in the structure ST_HVACPowerRange (marked red) is greater than 0 in the line iCurrentStep = 4.
    If one assumes that the current power step iCurrentStep has the value 3, then the variable values are output as follows on the output structures:

    arrPowerRangeTable[iCurrentProfile,iCurrentStep];

    stAggregate3.iAggregateStep :=arrPowerRangeTable[3,3].iAggregateStep;
    stAggregate3.rY_Max     := arrPowerRangeTable[3,3].rY_Max;
    stAggregate3.rY_Min     :=arrPowerRangeTable[3,3].rY_Min;
    stAggregate3.bBlock     := arrPowerRangeTable[3,3].bBlock;

    stAggregate4.iAggregateStep :=arrPowerRangeTable[3,2].iAggregateStep;
    stAggregate4.rY_Max     := arrPowerRangeTable[3,2].rY_Max;
    stAggregate4.rY_Min     :=arrPowerRangeTable[3,2].rY_Min;
    stAggregate4.bBlock     := arrPowerRangeTable[3,2].bBlock;

    stAggregate5.iAggregateStep :=arrPowerRangeTable[3,1].iAggregateStep;
    stAggregate5.rY_Max     := arrPowerRangeTable[3,1].rY_Max;
    stAggregate5.rY_Min     :=arrPowerRangeTable[3,1].rY_Min;
    stAggregate5.bBlock     := arrPowerRangeTable[3,1].bBlock;

    stI_Ctrl.rIntegralHigh := arrPowerRangeTable[3,3].rIntegralHigh;
    stI_Ctrl.rIntegralLow := arrPowerRangeTable[3,3].rIntegralLow;
    stI_Ctrl.udiSecDelayHigh :=arrPowerRangeTable[3,3].udiSecDelayHigh;
    stI_Ctrl.udiSecDelayLow :=arrPowerRangeTable[3,3].udiSecDelayLow;

    Contents of the output structures stAggregate3, stAggregate4,stAggregate5 and stI_Ctrl.. The variables of the output structures stAggregate1, stAggregate2 and stAggregate6 have the value 0.

    stAggregate3.iAggregateStep :=1;
    stAggregate3.rY_Max     := 0;
    stAggregate3.rY_Min     :=0;
    stAggregate3.bBlock     := FALSE;

    stAggregate4.iAggregateStep :=1;
    stAggregate4.rY_Max     := 0;
    stAggregate4.rY_Min     :=0;
    stAggregate4.bBlock     := TRUE;

    stAggregate5.iAggregateStep :=1;
    stAggregate5.rY_Max     := 0;
    stAggregate5.rY_Min     :=0;
    stAggregate5.bBlock     := FALSE;

    stI_Ctrl.rIntegralHigh := 7;
    stI_Ctrl.rIntegralLow := 7;
    stI_Ctrl.udiSecDelayHigh :=400;
    stI_Ctrl.udiSecDelayLow :=200;

Output structure stI_Ctrl adjusted to the example

Output structures stAggregate1-6 adjusted to the example

Application example

The application example shows the function block FB_HVACPowerRangeTable in conjunction with the I-transfer element FB_HVACI_CtrlStep. The example is illustrated in the programming languages ST and CFC. The program example P_CFC_I_CtrlStep.PRG for the programming language CFC is located in the folder Language CFC > Controller; the program example P_ST_I_CtrlStep.PRG for the programming language ST is located in the folder Language Structured Text >Controller.

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name
      : Type                            Range

eDataSecurityType             : E_HVACDataSecurityType;
bEnable                       : BOOL;
iNumberOfProfiles             : INT;
iProfile                      : INT;
iStep                         : INT;
eCtrlModeProfile              : E_HVACCtrlMode;
iManualProfile                : INT;
eCtrlModeStep                 : E_HVACCtrlMode;
iManualStep                   : INT;
iNumberOfAggregates           : INT;
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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then all output variables and output structures are set constantly to 0. The checking of the variables iNumberOfProfiles, iProfile, iStep, iNumberOfStepInProfile, iNumberOfAggregates, arrPowerRangeTable[X,X].iAggregate, arrPowerRangeTable[X,X].iAggregateSteps, arrPowerRangeTable[X,X].rY_Max, arrPowerRangeTable[X,X].rY_Min, arrPowerRangeTable[iP,iS].udiSecDelayHigh, and arrPowerRangeTable[iP,iS].udiSecDelayLow remains active. If an error occurs, it is displayed with bError = TRUE and can be acknowledged with bReset once the fault has been rectified.

iNumberOfProfiles: The number of parameterised profiles in the power range table arrPowerRangeTable. The indication of the number of profiles must not be lower than g_iMinNumberOfProfiles and must not be greater than g_iMaxNumberOfProfiles. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

iProfile: Indicates the current profile with which the function block from the power range table arrPowerRangeTable [iCurrentProfile, iCurrentStep] is working. If eCtrlModeProfile = eHVACCtrlMode_Auto, then iCurrentProfile = iProfile. The indication of the profile must not be lower than g_iMinNumberOfProfiles and must not be greater than iNumberOfProfiles. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

iStep: Indicates the current step with which the function block from the power range table arrPowerRangeTable[iCurrentProfile, iCurrentStep] is working. If eCtrlModeStep = eHVACCtrlMode_Auto, then iCurrentStep = iStep. The indication of the steps must not be smaller than g_iMinNumberOfSteps and must not be greater than iNumberOfStepInProfile. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

eCtrlModeProfile: The input variable via which the specification of the profile from the power range table arrPowerRangeTable[iCurrentProfile, iCurrentStep] is indicated is decided via this enum. If eCtrlModeProfile = eHVACCtrlMode_Auto, then iCurrentProfile = iProfile. If eCtrlModeProfile = eHVACCtrlMode_Manual, then iCurrentProfile = iManualProfile.

iManualProfile: Indicates which profile from the power range table arrPowerRangeTable[iCurrentProfile, iCurrentStep] is in use. If eCtrlModeProfile = eHVACCtrlMode_Manual, then iCurrentProfile = iManualProfile. The indication of the profile must not be lower than g_iMinNumberOfProfiles and must not be greater than iNumberOfProfiles. Otherwise iManualProfile is set internally to g_iMinNumberOfProfiles if it is lower than g_iMinNumberOfProfiles or to iNumberOfProfiles if it is greater than iNumberOfProfiles.

eCtrlModeStep: The input variable via which the specification of the steps from the power range table arrPowerRangeTable[iCurrentProfile, iCurrentStep] is indicated is decided via this enum. If eCtrlModeStep = eHVACCtrlMode_Auto, then iCurrentStep = iStep. If eCtrlModeStep = eHVACCtrlMode_Manual, then iCurrentStep = iManualStep.

iManualStep: Indicates which step from the power range table arrPowerRangeTable[iCurrentProfile, iCurrentStep] is in use. If eCtrlModeStep = eHVACCtrlMode_Manual, then iCurrentStep = iManualStep. The indication of the steps must not be smaller than g_iMinNumberOfSteps and must not be greater than iNumberOfStepInProfile. Otherwise iManualStep is set internally to g_iMinNumberOfSteps if less than g_iMinNumberOfProfiles or to iNumberOfStepInProfile if greater than iNumberOfStepInProfile.

iNumberOfAggregates: iNumberOfAggregates specifies the number of units in the power generator sequence. For example, if iNumberOfAggregates = 4, then the parameters from the array arrPowerRangeTable are written to the output structures stAggregate1-4, depending on the specification of iCurrentStep/iCurrentProfile. The specification must not be smaller than g_iMinNumberOfAggregates and must not be greater than g_iMaxNumberOfAggregates. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

bReset: Input for acknowledgement of the faults once they have been rectified. Internally the system responds to a rising edge.

VAR_OUTPUT

      Name                        : Type

bEnablePowerRangeTable      : BOOL;
iNumberOfStepInProfile      : INT;
iCurrentProfile             : INT;
iCurrentStep                : INT;
stI_Ctrl                    : ST_HVACI_Ctrl;
stAggregate1                : ST_HVACAggregate;
stAggregate2                : ST_HVACAggregate;
stAggregate3                : ST_HVACAggregate;
stAggregate4                : ST_HVACAggregate;
stAggregate5                : ST_HVACAggregate;
stAggregate6                : ST_HVACAggregate;
bError                      : BOOL;
eErrorCode                  : E_HVACErrorCodes;
iErrorPosArrayProfile       : INT;
iErrorPosArrayStep          : INT;

bEnablePowerRangeTable: Indicates that the function block is released. bEnablePowerRangeTable is TRUE if bEnable =TRUEAND bError =FALSE.

iNumberOfStepInProfile: Indicates the number of parameterised steps from the specified profile iCurrentProfile of the power range table arrPowerRangeTable. Each individual step contains the parameter structure ST_HVACPowerRange needed for system control. Each profile can have up to 33 steps. The field for the steps in the power range table arrPowerRangeTable begins with 0 and ends with 32. The number of parameterised steps in a profile iNumberOfStepInProfile is determined from step 1 upwards to step 32. The counting of the parameterised steps ends in the step in which all variables of the parameter structure ST_HVACPowerRange have the value 0. The minimum value that iNumberOfStepInProfile can have is 1 and the maximum is 32. Step 0 is not taken into account, because the power generators are switched off in this step. The step can be considered to be a standby step. The values of the variables of the output structures stAggregate1-6 then output the value 0. In the standby step, the parameters responsible for starting the power step sequence of the energy generators are transferred to the upstream controller FB_HVACI_Ctrl_Step via the output structure stI_Ctrl.

iNumberOfStepInProfile can be used to limit the steps for other function blocks, such as for the input iNumberOfStepInProfile of the function block FB_HVACI_CtrlStep. In turn, the output variable iStep of FB_HVACI_CtrlStep can be used to specify the step of the power range table FB_HVACPowerRangeTable via the input iStep.

iCurrentProfile: Indicates the current profile with which the function block from the power range table arrPowerRangeTable [iCurrentProfile, iCurrentStep] is working. The indication depends on the input variables iProfile, iManualProfile and eCtrlModeProfile. If eCtrlModeProfile = eHVACCtrlMode_Auto, then iCurrentProfile = iProfile. If eCtrlModeProfile = eHVACCtrlMode_Manual, then iCurrentProfile = iManualProfile.

iCurrentStep: Indicates the current power step with which the function block from the power range table arrPowerRangeTable[iCurrentProfile,iCurrentStep] is working. The most current step is always the highest step viewed from 1 upward. The indication depends on the input variables iStep, iManualStep and eCtrlModeStep. If eCtrlModeStep = eHVACCtrlMode_Auto, then iCurrentStep = iStep. If eCtrlModeStep = eHVACCtrlMode_Manual, then iCurrentStep = iManualStep.

stI_Ctrl: Output structure of the parameter ST_HVACI_Ctrl for the function block FB_HVACI_CtrlStep.
The values adopted by the variables of the output structure stI_Ctrl from the power range table arrPowerRangeTable depend on the selected profile and the current step. If the selected profile iCurrentProfile = 2 and the step iCurrentStep = 3, then the contents of the following variables from the power range table are written to the structure stI_Ctrl:

stI_Ctrl.rIntegralHigh := arrPowerRangeTable[iCurrentProfile,iCurrentStep].rIntegralHigh;
stI_Ctrl.rIntegralLow := arrPowerRangeTable[iCurrentProfile,iCurrentStep].rIntegralLow;
stI_Ctrl.udiSecDelayHigh :=arrPowerRangeTable[iCurrentProfile,iCurrentStep].udiSecDelayHigh;
stI_Ctrl.udiSecDelayLow :=arrPowerRangeTable[iCurrentProfile,iCurrentStep].udiSecDelayLow;

stI_Ctrl.rIntegralHigh := arrPowerRangeTable[2,3].rIntegralHigh;
stI_Ctrl.rIntegralLow := arrPowerRangeTable[2,3].rIntegralLow;
stI_Ctrl.udiSecDelayHigh :=arrPowerRangeTable[2,3].udiSecDelayHigh;
stI_Ctrl.udiSecDelayLow :=arrPowerRangeTable[2,3].udiSecDelayLow;

stI_Ctrl.rIntegralHigh: Positive value for the upper limit at which the integration of the I-transfer element is stopped.

stI_Ctrl.rIntegralLow: Positive value for the lower limit at which the integration of the I-transfer element is stopped.

stI_Ctrl.udiSecDelayHigh: Delay time after whose expiry the I-transfer element is activated.

stI_Ctrl.udiSecDelayLow: Delay time after whose expiry the I-transfer element is activated.

stAggregate1-6: Output structures of the parameter ST_HVACAggregate for controlling units 1 to 6. iNumberOfAggregates specifies the number of units in the power generator sequence. The values adopted by the variables of the output structures stAggregate1-6 from the power range table arrPowerRangeTable depend on the selected profile and the current step. If the selected profile iCurrentProfile = 8 and the step iCurrentStep = 5, then it is crucial that the variable arrPowerRangeTable[8,5].iAggregate has the value 1. The values parameterised in the power range table are then output via the output structure stAggregate1.

stAggregate1.rY_Max := arrPowerRangeTable[iCurrentProfile,iCurrentStep].rY_Max;
stAggregate1.rY_Min :=arrPowerRangeTable[iCurrentProfile,iCurrentStep].rY_Min;
stAggregate1.iAggregateStep :=arrPowerRangeTable[iCurrentProfile,iCurrentStep].iAggregateStep;
stAggregate1.bBlock := arrPowerRangeTable[iCurrentProfile,iCurrentStep].bBlock;

stAggregate1.rY_Max := arrPowerRangeTable[8,5].rY_Max;
stAggregate1.rY_Min :=arrPowerRangeTable[8,5].rY_Min;
stAggregate1.iAggregateStep :=arrPowerRangeTable[8,3].iAggregateStep;
stAggregate1.bBlock := arrPowerRangeTable[8,5].bBlock;

If the value of the variable arrPowerRangeTable[8,3].iAggregate is also 1, then the values of the highest power step iCurrentStep = 5 are written to the corresponding output structure stAggregate1, because arrPowerRangeTable[8,5].iAggregate is also 1 here. Only if iCurrentStep = 3 does this mean that following values are output via the output structure stAggregate1:

stAggregate1.rY_Max := arrPowerRangeTable[8,3].rY_Max;
stAggregate1.rY_Min :=arrPowerRangeTable[8,3].rY_Min;
stAggregate1.iAggregateStep :=arrPowerRangeTable[8,3].iAggregateStep;
stAggregate1.bBlock := arrPowerRangeTable[8,3].bBlock;

If iCurrentStep = 4 and arrPowerRangeTable[8,4].iAggregate = 2, then this means that the following values are output via the output structures stAggregate1 and stAggregate2:

stAggregate2.rY_Max := arrPowerRangeTable[8,4].rY_Max;
stAggregate2.rY_Min :=arrPowerRangeTable[8,4].rY_Min;
stAggregate2.iAggregateStep :=arrPowerRangeTable[8,4].iAggregateStep;
stAggregate2.bBlock := arrPowerRangeTable[8,4].bBlock;

stAggregate1.rY_Max := arrPowerRangeTable[8,3].rY_Max;
stAggregate1.rY_Min :=arrPowerRangeTable[8,3].rY_Min;
stAggregate1.iAggregateStep :=arrPowerRangeTable[8,3].iAggregateStep;
stAggregate1.bBlock := arrPowerRangeTable[8,3].bBlock;

bError: This output indicates with a TRUE that there is an error. The execution of the function block is stopped. The eErrorCode enum indicates the error number.
Once the fault has been rectified the bError message must be acknowledged with bReset.

eErrorCode: Supplies the error number when the output bError is set.

The following errors can occur in this function block:

eHVACErrorCodes_InvalidParam_iStep: Error when checking the specified steps. The value of iStep must be greater than or equal to g_iMinNumberOfSteps or smaller than or equal to iNumberOfStepInProfile.

eHVACErrorCodes_InvalidParam_iNumberOfStepInProfile: Error when checking the number of profiles, whether each of the specified profiles has parameterised steps. The profiles are checked in step 0. If none of the variable values of the structure ST_HVACPowerRange there is larger than 0, then there is an error.
The variable iErrorPosArrayProfile indicates the incorrect profile in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile;

eHVACErrorCodes_InvalidParam_iNumberOfAggregates: Error when checking the specified number of units. The value of iNumberOfAggregates must be smaller than g_iMinNumberOfAggregates and larger than g_iMaxNumberOfAggregates.

eHVACErrorCodes_InvalidParam_iAggregateSteps: Error when checking the specified steps for the unit. The value of arrPowerRangeTable[x1,x2].iAggregateStep must be greater than or equal to g_iAggregateMinNumberOfSteps and smaller than or equal to g_iAggregateMaxNumberOfSteps.
The variables iErrorPosArrayProfile and iErrorPosArrayStep indicate the incorrect place in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile; x2 = iErrorPosArrayStep

eHVACErrorCodes_InvalidParam_iNumberOfProfiles: Error when checking the number of profiles. The value of iNumberOfProfiles must be greater than or equal to g_iMinNumberOfProfiles and smaller than or equal to g_iMaxNumberOfProfiles.

eHVACErrorCodes_InvalidParam_iProfile: Error when checking the specified profiles. The value of iProfile must be greater than or equal to g_iMinNumberOfProfiles and smaller than or equal to iNumberOfProfiles.

eHVACErrorCodes_InvalidParam_rY_Max: Error when checking arrPowerRangeTable[x1,x2].rY_Max. The value of arrPowerRangeTable[x1,x2].rY_Max must be greater than or equal to g_rYMin and smaller than or equal to g_rYMax. In addition, arrPowerRangeTable[x1,x2].rY_Max must be greater then arrPowerRangeTable[x1,x2].rY_Min.
The variables iErrorPosArrayProfile and iErrorPosArrayStep indicate the incorrect place in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile; x2 = iErrorPosArrayStep

eHVACErrorCodes_InvalidParam_rY_Min: Error when checking arrPowerRangeTable[x1,x2].rY_Min. The value of arrPowerRangeTable[x1,x2].rY_Min must be greater than or equal to g_rYMin and smaller than or equal to g_rYMax.
The variables iErrorPosArrayProfile and iErrorPosArrayStep indicate the incorrect place in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile; x2 = iErrorPosArrayStep

eHVACErrorCodes_InvalidParam_iAggregate: Error when checking the specified units. The value of arrPowerRangeTable[x1,x2].iAggregate must be greater than or equal to g_iMinNumberOfAggregates and smaller than or equal to g_iMaxNumberOfAggregates.
The variables iErrorPosArrayProfile and iErrorPosArrayStep indicate the incorrect place in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile; x2 = iErrorPosArrayStep

eHVACErrorCodes_InvalidParam_udiSecDelayUp: Error when checking arrPowerRangeTable[x1,x2].udiSecDelayUp. The value of arrPowerRangeTable[x1,x2].udiSecDelayUp must not be larger than g_udiMaxSec.
The variables iErrorPosArrayProfile and iErrorPosArrayStep indicate the incorrect place in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile; x2 = iErrorPosArrayStep

eHVACErrorCodes_InvalidParam_udiSecDelayDown: Error when checking arrPowerRangeTable[x1,x2].udiSecDelayDown. The value of arrPowerRangeTable[x1,x2].udiSecDelayDown must not be larger than g_udiMaxSec.
The variables iErrorPosArrayProfile and iErrorPosArrayStep indicate the incorrect place in the power range table arrPowerRangeTable[x1,x2]: x1 = iErrorPosArrayProfile; x2 = iErrorPosArrayStep

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_InvalidParam_iStep = 31
eHVACErrorCodes_InvalidParam_iNumberOfStepInProfil = 32
eHVACErrorCodes_InvalidParam_iNumberOfAggregates = 33
eHVACErrorCodes_InvalidParam_iAggregateSteps = 34
eHVACErrorCodes_InvalidParam_iNumberOfProfiles = 35
eHVACErrorCodes_InvalidParam_iProfile = 36
eHVACErrorCodes_InvalidParam_iAggregate = 39
eHVACErrorCodes_InvalidParam_udiSecDelayUp = 40
eHVACErrorCodes_InvalidParam_udiSecDelayDown = 41

iErrorPosArrayProfile: The variable iErrorPosArrayProfile indicates the profile in which the incorrect place in the power range table arrPowerRangeTable[iErrorPosArrayProfile, iErrorPosArrayStep] is to be found.
If iErrorPosArrayProfile > 0, then one of the following errors is present on eErrorCode:
- eHVACErrorCodes_InvalidParam_iNumberOfStepInProfile
- eHVACErrorCodes_InvalidParam_iAggregateSteps
- eHVACErrorCodes_InvalidParam_iAggregate
- eHVACErrorCodes_InvalidParam_udiSecDelayUp
- eHVACErrorCodes_InvalidParam_udiSecDelayDown

The exact position of the step can be determined with the aid of the variable iErrorPosArrayStep.

Example 1 for the localisation of an error:
The following values are present on the output variables:

bError = TRUE ;
eErrorCode = eHVACErrorCodes_InvalidParam_iNumberOfStepInProfile;
iErrorPosArrayProfile = 2;

No variable value of the structure ST_HVACPowerRange in profile 2 in step 0 of the power range table arrPowerRangeTable[2,x] is greater than 0. iErrorPosArrayStep is not taken into account with this error.

Example 2 for the localisation of an error:
The following values are present on the output variables:

bError = TRUE ;
eErrorCode = eHVACErrorCodes_InvalidParam_iAggregateSteps;
iErrorPosArrayProfile = 2;
iErrorPosArrayStep = 3;

There is an incorrect value on the following variable in the power range table arrPowerRangeTable:

arrPowerRangeTable[2,3].iAggregateStep

iErrorPosArrayStep: If iErrorPosArrayProfile > 0, then the variable iErrorPosArrayStep indicates the step in the profile in which the incorrect place in the power range table is to be found.

Example for the localisation of an error:
The following values are present on the output variables:

bError = TRUE ;
eErrorCode = eHVACErrorCodes_InvalidParam_iAggregate;
iErrorPosArrayProfile = 5;
iErrorPosArrayStep = 15;

There is an incorrect value on the following variable in the power range table arrPowerRangeTable:

arrPowerRangeTable[5,15].iAggregate

VAR_IN_OUT

      Name                      : Type                                                                                       Persistent

arrPowerRangeTable        : ARRAY [1..g_iMaxNumberOfProfiles,0..g_iMaxNumberOfSteps] OF ST_HVACPowerRange;                 X

arrPowerRangeTable: All information or parameters relevant to plant control are summarised in the power range table arrPowerRangeTable. The power range table is a two-dimensional field (array) with the structure ST_HVACPowerRange. The power range table can be compared to a normal table in that the horizontal entries are called lines and the vertical entries columns. An individual element is thus clearly designated by naming line and column. The field range 1 to g_iMaxNumberOfProfiles of the power range table would be the vertical part, i.e. the columns. This range is called the profile and iCurrentProfile indicates which profile is being addressed. The field range 0 to g_iMaxNumberOfSteps is regarded as the horizontal part, i.e. the lines. This range is called the step and iCurrentStep indicates which step is being addressed.

The power range table consists of 16 profiles. Each profile can have up to 33 steps. Each individual step contains the parameter structure ST_HVACPowerRange needed for system control. The parameters specified here are transferred via the output structures stI_Ctrl to the function block FB_HVACI_CtrlStep for controlling the steps and via stAggregate1-6 to the function blocks for energy generation.

The number of steps in a profile is indicated by the output variable iNumberOfStepInProfile. The number depends on the entries in the power range table and on the selected profile iCurrentProfile. The selected profile is checked internally in the block from step 1 up to the step in which all variables of the structure ST_HVACPowerRange have the value 0. iNumberOfStepInProfile is always intended only for the specified profile. Each profile can have up to 33 steps from 0 to 32; step 0 is not taken into account when evaluating the number of steps via iNumberOfStepInProfile.

Structure ST_HVACPowerRange

arrPowerRangeTable[x,x].iAggregate: Parameter that specifies to which output structure stAggregate1-6 of the function block FB_HVACPowerRangeTable the variables rY_Min, rY_Max, iAggregateStep and bBlock are written.

arrPowerRangeTable[x,x].iAggregateStep:Parameter that specifies the step in which the addressed unit should be fixed or should regulate; see bBlock.
iAggregateStep is output via the structure stAggregateX.

arrPowerRangeTable[x,x].rY_Max: Parameter specification for constant units. rY_Max is output via the structure stAggregateX.

arrPowerRangeTable[x,x].rY_Min: Parameter specification for constant units. rY_Min is output via the structure stAggregateX.

arrPowerRangeTable[x,x].rIntegralHigh: Positive value for the upper limit at which the integration of the I-transfer element is stopped; see the VAR_IN_OUT-Variable rIntegralHigh in the FB_HVACI_CtrlStep.
rIntegralHigh is output via the structure stI_Ctrl.

arrPowerRangeTable[x,x].rIntegralLow : Positive value for the lower limit at which the integration of the I-transfer element is stopped; see the VAR_IN_OUT-Variable rIntegralHigh in the FB_HVACI_CtrlStep.
rIntegralLow is output via the structure stI_Ctrl.

arrPowerRangeTable[x,x].udiSecDelayHigh: Delay time after whose expiry the I-transfer element is activated; see the VAR_IN_OUT-Variable udiSecDelayHigh in the FB_HVACI_CtrlStep.
udiSecDelayHigh is output via the structure stI_Ctrl.

arrPowerRangeTable[x,x].udiSecDelayLow: Delay time after whose expiry the I-transfer element is activated; see the VAR_IN_OUT-Variable udiSecDelayHigh in the FB_HVACI_CtrlStep.
udiSecDelayLow is output via the structure stI_Ctrl.

arrPowerRangeTable[x,x].bBlock: If bBlock = FALSE, then the addressed unit is fixed in the specified step via iAggregateStep. If bBlock = TRUE, then the control of the addressed unit is released from the off step (0) to the specified step via iAggregateStep.
bBlock is output via the structure stAggregateX.


Introduction – sequence controller

In heating, ventilation and air-conditioning systems, it is often the case that several actuators, working in a so-called controller sequence, are used in order to achieve a control variable. In the air conditioning system shown below, four actuators are involved in the regulation of the supply air temperature. A dedicated sequence controller is instanced for each of these actuators in the HVAC library. During active control only one of these sequence controllers is active. The other, non-active controllers fix their control signal so that it is energetically optimal for the tempering of the supply air temperature. Depending on the control direction of the individual controller, this means either the maximum or the minimum for the control variable rY.

If the effect of the active actuator (controller) is not sufficient when reaching a limit position, the active controller switches to the adjacent controller to the left or right in the controller sequence. This then takes over control. The previously active controller remains at the limit position of rYmax or rYmin, depending on the direction of control.
This is repeated with the remaining actuators until the set value or the left or right end of the sequence is reached.

In the sequence of the illustrated air conditioning system, all actuators that influence the control variable are shown from left to
right. At the far left is the actuator that enables the greatest possible reduction of the control variable; at the far right is the actuator that effects the greatest possible increase of the control variable.

Actuators that should drive in parallel or in opposite directions, e.g. outside air and circulating air flaps (HS2) are implemented once only. The individual actuators can have a positive control direction (more actuation results in a larger control variable, e.g. a heater) or a negative control direction (more actuation results in a smaller control variable, e.g. a cooler). Some actuators, e.g. a circulating air flap (HS1 & HS2), change their control direction during operation.

Example: Supply air temperature regulation in an air conditioning system with an air cooler, a heat recovery unit, a mixed air plates and an pre-heater, as shown in the diagram above.

iMyNumberInSequence

1. KS1 cooler 1
2. HS1 heat recovery 2
3. HS2 mixed air plates 3
4. HS3 pre-heater 4

Each sequence controller is given the total number of controllers in the sequence.
Four in this case. The PLC variable is called iNumberOfSequences in the function blocks. In addition each function block is given its own number. In the sequence iMyNumberInSequence. The controllers are numbered from left to right in ascending order. Hence each controller knows which position it occupies within the sequence. The outer sequence controllers know that switching to a further sequence controller should not take place in the event of a residual control deviation.

In the example, the controller FB_HVACPIDEnergyRecovery would commence control with the heat recovery unit in the event of the control variable being too small. All other actuators are closed. If the maximum or minimum position of the heat recovery unit has been reached, the controller switches to the flap controller FB_HVACPIDMixedAir. As a result the parameter e HVACSequenceCtrlMode is raised to 3. If the control effect has still not been achieved and the mixed air flap has reached its limit (e.g. minimum outside air rate), the mixed air controller raises the value of e HVACSequenceCtrlMode to 4. As a result the pre-heater or rather the sequence controller FB_HVACPIDPreHeating is activated. If the control variable is too high, the sequence is reversed until the cooler is activated by means of FB_HVACPIDCooling being enabled.

If the control variable is at the lower or upper limit of a controller, the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadRange.

Table of operating modes

A further special feature of the sequence controller is its control by the Enum E_HVACSequenceCtrlMode
 Not only is the controller enabled by the Enum E_HVACSequenceCtrlMode, it also transmits the operating mode of the air conditioning system to the controller blocks in the sequence. Depending on the operating modes, each sequence controller hence reacts specially to the Enum E_HVACSequenceCtrlMode as illustrated in the table.

Value of: E_HVACSequenceCtrlMode | 0 (Stop) | 1 (On) | 2 (night cooling) | 3 (support operation) | 4 (overheating control) | 5 (night cooling and overheating control)
FB_HVACMasterSequenceCtrl Master controller | disabled 0 % | Enable | disabled 0 % | Enable rY=Supply air max. temp. | Enable rY=Supply air min. temp. | Enable rY=Supply air min. temp.
FB_HVACPIDPreHeating Pre-heater | disabled 0 % | Enable | disabled 0 % | Enable 0 % - 100 % | disabled 0 % | disabled 0 %
FB_HVACPIDReHeating Re-heater | disabled 0 % | Enable | disabled 0 % | disabled 0 % | disabled 0 % | disabled 0 %
FB_HVACPIDCooling Cooler | disabled 0 % | Enable | disabled 0 % | disabled 0 % | Enable 0 % - 100 % | Enable 0 % - 100 %
FB_HVACPIDEnergyRecovery Heat recovery | disabled 0 % | Enable | disabled 0 % | disabled 0 % | disabled 0 % | disabled 0 %
FB_HVACPIDMixedAir Mixed air flaps | disabled 0 % | Enable | max. outside air rate 100 % | 0 % air circulation only | 0 % air circulation only | max. outside air rate 100 %


FB_HVAC2PointCtrlSequence

Application

This function block represents a 2-point sequence controller. It is used for sequential staged control of discontinuous units. If can be used for cascades of vessels and in sequences of refrigerating machines or recooling towers for controlling the power stages. For each power stage an instance of the function block is used.

FB_HVAC2PointCtrlSequence can be used in a control sequence with other sequence controllers from TcHVAC.lib.

Depending on the application several actuators (stages) are used for reaching a controlled variable, which operate in a so-called control sequence. In the control sequence shown below four stages are enabled via the respective output bOut = TRUE of FB_HVAC2PointCtrlSequence. With active control only one of the 2-point sequence controllers is active at a time. The outputs of the non-active 2-point sequence controller are fixed. This means that depending on the control direction bDirection of the individual controller; bOut is either TRUE or FALSE.

If the effect of the active stage is insufficient when switched on, the active 2-point controller switches to the next 2-point controller in the controller sequence (to the left right or left) via iCurrentSequence, which will then take over control of the stages. The previously active controller remains in the end position bOut = TRUE or FALSE, depending on the control direction.

Transfer function of the internal I-transfer element

Through an internal AND link of the I-transfer element consisting of (tCtrl_I_Ti_HighLimit, tCtrl_I_Ti_LowLimit, rCtrl_I_HighLimit, rCtrl_I_LowLimit, st2PointCtrlSequence.rCtrl_I_Out) and the delay times tDelayIncreaseSequence/tDelayDecreaseSequence switching in the control sequence to the right or left is controlled via iCurrentSequence. The active sequence controller is indicated via bActiveCtrl = TRUE (iCurrentSequence = iMyNumberInSequence).

The I-transfer element and the timing elements for the delay times tDelayIncreaseSequence/tDelayDecreaseSequence are activated if

bActiveCtrl = TRUEAND
( (*Decrease*)
(
rX > st2PointCtrlSequence.rW_Max AND ((iMyNumberInSequence <= 1) = FALSE) AND
(
(bDirection = TRUEAND bOut = TRUE) OR
(bDirection = FALSEAND bOut = FALSE)
)
)
OR
( (*Increase*)
rX < st2PointCtrlSequence.rW_Min AND((iMyNumberInSequence >= iNumberOfSequences) = FALSE) AND
(
(bDirection = FALSEAND bOut = TRUE) OR
(bDirection = TRUEAND bOut = FALSE)
)
)
)

Once the I-transfer element (st2PointCtrlSequence.rCtrl_I_out output of the internal I-transfer element) AND the timing elements for the delay times tDelayIncreaseSequence/tDelayDecreaseSequence have been activated, switching in the control sequence to the right or left via iCurrentSequence is controlled as follows:

iCurrentSequence = iCurrentSequence - 1 when st2PointCtrlSequence.rCtrl_I_Out <= st2PointCtrlSequence.rCtrl_I_LowLimit AND st2PointCtrlSequence.tRemainingTimeDecreaseSequence = T#0s.

iCurrentSequence = iCurrentSequence + 1 when st2PointCtrlSequence.rCtrl_I_Out >= st2PointCtrlSequence.rCtrl_I_HighLimit AND st2PointCtrlSequence.tRemainingTimeIncreaseSequence = T#0s.

Behaviour of the outputs of four FB_HVAC2PointCtrlSequence in a control sequence

In the control sequence of four FB_HVAC2PointCtrlSequence controllers shown above there may be no gap in the allocation of iMyNumberInSequence (1,2,3,4) and iNumberOfSequence (4), since otherwise automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence would not work.
If bEnable =FALSEOR bError = TRUEOR (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMS OR eHVAC2PointCtrlMode_On_OP OR eHVAC2PointCtrlMode_Off_BMS OR eHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE . Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

Application example

Download | Benötige Bibliothek
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
e2PointCtrlMode           : E_HVAC2PointCtrlMode;
bDirection                : BOOL;
rW                        : REAL;
rX                        : REAL;
iNumberOfSequences        : INT;                      1..32
iMyNumberInSequence       : INT;                      1..32
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:= e HVAC DataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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 via TRUE. If bEnable = FALSE, the 2-point sequence controller is disabled. Validation of the variables iNumberOfSequences, iMyNumberInSequence, iCurrentSequence and tTi_Ctrl_I is still active. If an error occurs, it is displayed with bError = TRUE and can be acknowledged with bReset once the fault has been rectified.

If bEnable =FALSEOR bError = TRUEOR (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMS OR eHVAC2PointCtrlMode_On_OP OR eHVAC2PointCtrlMode_Off_BMS OR eHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

e2PointCtrlMode: Enum specifying the mode of the 2-point sequence controller. If bEnable = TRUEAND bError = FALSE, the output bOut can be switched on or off directly via the enum. On startup of the PLC e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMS.
Up- or down-switching of the sequence via iCurrentSequence does not depend on mode e2PointCtrlMode of the 2-point sequence controller.

If bEnable =FALSEOR bError = TRUEOR (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMS OR eHVAC2PointCtrlMode_On_OP OR eHVAC2PointCtrlMode_Off_BMS OR eHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

bDirection: bDirection determines the control direction of the internal 2-point controller. FALSE = heating mode; TRUE = cooling mode.

rW: The set value is transferred with the rW variable.

rX: The variable rX is used to transfer the actual value.

iNumberOfSequences: Number of controllers in the sequence. If iNumberOfSequences <= 0 an error is issued and indicated with bError = TRUE. The number of device in a sequence is not exceeded by the active sequence controller via iCurrentSequence.

iMyNumberInSequence: The own number of the 2-point controller in the sequence. If iMyNumberInSequence > iNumberOfSequences OR iMyNumberInSequence <= 0, an error is issued and indicated with bError = TRUE.

bReset: Input for acknowledgement of the faults once they have been rectified. Internally the system responds to a rising edge.

VAR_OUTPUT

      Name                      : Type

bOut                      : BOOL;
bActiveCtrl               : BOOL;
b_rW_Max                  : BOOL;
b_rW_Min                  : BOOL;
rE                        : REAL;
e2PointCtrlState          : E_HVAC2PointCtrlMode;
st2PointCtrlSequence      : ST_HVAC2PointCtrlSequence;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;

bOut: Output of the 2-point sequence controller.

bOut becomes TRUE if

1.
bEnable = TRUEAND bError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMS OR e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
bActiveCtrl = TRUEAND
(
(bDirection = TRUEAND ( rX > st2PointCtrlSequence.rW_Max )) OR ( bDirection = FALSEAND ( rX < st2PointCtrlSequence.rW_Min ))
)

2.
bEnable = TRUEAND bError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMS OR e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
 (
( bDirection = TRUEAND ( iCurrentSequence < iMyNumberInSequence )) OR ( bDirection = FALSEAND ( iCurrentSequence > iMyNumberInSequence ))
)

3.
bEnable = TRUEAND bError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_On_BMS OR e2PointCtrlMode = eHVAC2PointCtrlMode_On_OP )

bOut becomes FALSE if

1.
bEnable = FALSEOR bError = TRUE

2.
bEnable = TRUEAND bError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMS OR e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
bActiveCtrl = TRUEAND
(
( bDirection = TRUEAND ( rX < st2PointCtrlSequence.rW_Min )) OR ( bDirection = FALSEAND ( rX > st2PointCtrlSequence.rW_Max ))
)

3.
bEnable = TRUEAND bError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMS OR e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
 (
( bDirection = TRUEAND ( iCurrentSequence > iMyNumberInSequence )) OR ( bDirection = FALSEAND ( iCurrentSequence < iMyNumberInSequence ))
)

4.
bEnable = TRUEAND bError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Off_BMS OR e2PointCtrlMode = eHVAC2PointCtrlMode_Off_OP )

bActiveCtrl: bActiveCtrl = TRUE indicates that active function block in the sequence. bActiveCtrl becomes TRUE if bEnable = TRUE, bError = FALSEAND iCurrentSequence = iMyNumberInSequence.

b_rW_Max: b_rW_Max becomes TRUE if rX > st2PointCtrlSequence.rW_Max.

b_rW_Min: b_rW_Min becomes TRUE if rX < st2PointCtrlSequence.rW_Min.

rE: Control deviation: rE = rW - rX

e2PointCtrlState: Enum indicating the status of mode e2PointCtrlModeof the 2-point sequence controller

st2PointCtrlSequence: The structure indicates various states, inputs and outputs of the function block. Furthermore the remaining times of the VAR_IN_OUT variables tDelayIncreaseSequence and tDelayDecreaseSequence are output if their function is active. Via st2PointCtrlSequence.rCtrl_I_Out the output signal of the internal I-transfer element is displayed.

st2PointCtrlSequence.tRemainingTimeIncreaseSequence: Remaining time of delay time tDelayIncreaseSequence.

st2PointCtrlSequence.tRemainingTimeDecreaseSequence: Remaining time of delay time tDelayDecreaseSequence.

st2PointCtrlSequence.rX: Status of rX

st2PointCtrlSequence.rW_Max: st2PointCtrlSequence.rW_Max := rW + rW_HighLimit - upper setpoint limit; if rX exceeds this value the internal I-transfer element and the timing elements of the delay times tDelayIncreaseSequence/tDelayDecreaseSequence can be activated or deactivated, see Transfer function of the internal I-transfer element in this document

st2PointCtrlSequence.rW_Min: st2PointCtrlSequence.rW_Min := rW - rW_LowLimit - lower setpoint limit; if rX falls below this value the internal I-transfer element and the timing elements of the delay times tDelayIncreaseSequence/tDelayDecreaseSequence can be activated or deactivated, see Transfer function of the internal I-transfer element in this document

st2PointCtrlSequence.rE: Control deviation: rE = rW - rX

st2PointCtrlSequence.rCtrl_I_HighLimit: Upper limit value at which the integration of the internal I-transfer element is stopped. st2PointCtrlSequence.rCtrl_I_HighLimit = rCtrl_I_HighLimit

st2PointCtrlSequence.rCtrl_I_LowLimit: Lower limit value at which the integration of the internal I-transfer element is stopped. st2PointCtrlSequence.rCtrl_I_Low = rCtrl_I_LowLimit * (-1)

st2PointCtrlSequence.rCtrl_I_Out: Output of the internal I-transfer element.
If st2PointCtrlSequence.rCtrl_I_out = st2PointCtrlSequence.rCtrl_I_HighLimit OR
st2PointCtrlSequence.rCtrl_I_LowLimit AND
 either st2PointCtrlSequence.tRemainingTimeIncreaseSequence OR
st2PointCtrlSequence.tRemainingTimeDecreaseSequence = T#0sAND
bActive = TRUE, the number of the active controller iCurrentSequence is increased or decreased by 1 depending on bDirection.

st2PointCtrlSequence.e2PointCtrlState: see e2PointCtrlState

st2PointCtrlSequence.iNumberOfSequences: see iNumberOfSequences

st2PointCtrlSequence.iMyNumberInSequence: see iNumberOfSequences

st2PointCtrlSequence.iCurrentSequence: see iCurrentSequence

st2PointCtrlSequence.bEnable: see bEnable

st2PointCtrlSequence.bError: see bError

st2PointCtrlSequence.bOut: see bOut

st2PointCtrlSequence.bActiveCtrl: see bActiveCtrl

st2PointCtrlSequence.b_rW_Max: see b_rW_Max

st2PointCtrlSequence.b_rW_Min: see b_rW_Min

bError: The output is TRUE if an error is active and one of the variables iNumberOfSequences, iMyNumberInSequence or iCurrentSequence has an incorrect parameter. Once the fault has been rectified the bError message must be acknowledged with bReset. The eErrorCode enum indicates the error number. If bError is TRUE, output bOut becomes FALSE.

If bEnable =FALSEOR bError = TRUEOR (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMS OR eHVAC2PointCtrlMode_On_OP OR eHVAC2PointCtrlMode_Off_BMS OR eHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

eErrorCode: Supplies the error number when the bError output is set. The following errors may occur in this function block: eHVACErrorCodes_Error_iMyNumberInSequence, eHVACErrorCodes_Error_iNumberOfSequences, eHVACErrorCodes_Error_iCurrentSequences

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_Error_iNumberOfSequences = 27
eHVACErrorCodes_Error_iMyNumberInSequence = 28
eHVACErrorCodes_Error_iCurrentSequences = 29

VAR_IN_OUT

      Name                      : Type            Persistent       Default        Range

rW_HighLimit              : REAL;               X              5.0
rW_LowLimit               : REAL;               X              5.0
tDelayIncreaseSequence    : TIME;               X              T#5m
tDelayDecreaseSequence    : TIME;               X              T#5m
tCtrl_I_Ti_HighLimit      : TIME;               X              T#10m        > T#0s
tCtrl_I_Ti_LowLimit       : TIME;               X              T#10m        > T#0s
rCtrl_I_HighLimit         : REAL;               X              10.0
rCtrl_I_LowLimit          : REAL;               X              -10.0
iCurrentSequence          : INT;                                            0..32

rW_HighLimit: Positive value of the upper control deviation limit. st2PointCtrlSequence.rW_Max =rW_Max := rW + rW_HighLimit

rW_LowLimit: Positive value of the lower control deviation limit. st2PointCtrlSequence.rW_Min =rW_Min := rW - rW_LowLimit

tDelayIncreaseSequence: Delay time after which iCurrentSequence is increased by 1, see Transfer function of the internal I-transfer element in this document

tDelayDecreaseSequence: Delay time after which iCurrentSequence is decreased by 1, see Transfer function of the internal I-transfer element in this document

tCtrl_I_Ti_HighLimit: Integration time for the upper limit of the internal I-transfer element, see Transfer function of the internal I-transfer element in this document. tCtrl_I_Ti_HighLimit must be > T#0s.

tCtrl_I_Ti_LowLimit: Integration time for the lower limit of the internal I-transfer element, see Transfer function of the internal I-transfer element in this document. tCtrl_I_Ti_LowLimit must be > T#0s.

rCtrl_I_HighLimit: Positive value for the upper limit at which the integration of the internal I-transfer element is stopped (ARW measure, anti-reset windup), see Transfer function of the internal I-transfer element in this document

rCtrl_I_LowLimit: Negative value for the lower limit at which the integration of the internal I-transfer element is stopped (ARW measure, anti-reset windup), see Transfer function of the internal I-transfer element in this document

iCurrentSequence: Number of the active controller in the sequence. The number of devices in a sequence iNumberOfSequences is not exceeded by the active sequence controller over iCurrentSequence.
If iCurrentSequence > iNumberOfSequences or iCurrentSequence < 0 an error is indicated with bError = TRUE.
Up- or down-switching of the sequence via iCurrentSequence depending on the control deviation rE takes place if the function block is active in the sequence bActiveCtrl = TRUE.

1. iCurrentSequence = iCurrentSequence - 1 if st2PointCtrlSequence.rCtrl_I_Out >= st2PointCtrlSequence.rLimit_Ctrl_I_Min AND st2PointCtrlSequence.tRemainingTimeDecreaseSequence = T#0sAND bActiveCtrl = TRUE

2. iCurrentSequence = iCurrentSequence + 1 if st2PointCtrlSequence.rCtrl_I_Out >= st2PointCtrlSequence.rLimit_Ctrl_I_Max AND st2PointCtrlSequence.tRemainingTimeIncreaseSequence = T#0sAND bActiveCtrl = TRUE

iCurrentSequence must not be written to continuously from outside in a control sequence in order to ensure the function of the automatic switchover of the controllers from the active controller to the adjacent controller to the right or left in the control sequence. At the start of a control sequence the active sequence controller must be specified. iCurrentSequence must be written for one PLC cycle and must be > 0 and <= iNumberOfSequences.
If bEnable =FALSEOR bError = TRUEOR (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMS OR eHVAC2PointCtrlMode_On_OP OR eHVAC2PointCtrlMode_Off_BMS OR eHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.


FB_HVACBasicSequenceCtrl

Application

Contrary to the sequence controllers FB_HVACPIDCooling, FB_HVACDehumidify, FB_HVACEnergyRecovery, FB_HVACPIDHumidify, FB_HVACPIDMixedAir, FB_HVACPIDPreHeating and FB_HVACPIDReHeating the function block FB_HVACBasicSequenceCtrl has no special system specific extensions or applications. The control direction of the controller is not determined automatically depending on room temperature or outside air like at function blocks for energy recovery or air mixing system. This function block, for example, suits a sequence out of static heating and cooling ceiling in a room automation application.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
rInitialValue            : REAL;
bResetController          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: Input variable for enabling the controller. The controller is enabled if bEnable = TRUE.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

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

eCtrlMode: The operating mode is selected via this Enum.

rYManual: Manual value.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                       : Type

rY                         : REAL;
rXW                        : REAL;
bMaxLimit                  : BOOL;
bMinLimit                  : BOOL;
bActive                    : BOOL;
bARWactive                 : BOOL;
eState                     : E_HVACState;
bError                     : BOOL;
eErrorCode                 : E_HVACErrorCodes;
bInvalidParameter          : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                    : Type              Persistent       Default            Range

rDeadRange              : REAL;                 X              0.0             0 .. 32767
bDirection              : BOOL;                 X              FALSE
rKp                     : REAL;                 X              1.0
tTi                     : TIME;                 X              t#30s
tTv                     : TIME;                 X              t#0s
tTd                     : TIME;                 X              t#0s
rDeadBand               : REAL;                 X              0.0             0 .. 32767
rYMin                   : REAL;                 X              0.0
rYMax                   : REAL;                 X            100.0
iCurrentSequence        : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valve or damper drive, a dead band can be set for the controller output signal rY. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal rY is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

bDirection: The control direction of the controller can be changed with the parameter bDirection. If bDirection is TRUE, then the direct control direction is active for cooling operation of the controller.
If bDirection is FALSE, then the indirect control direction is active for heating operation of the controller.

rKp: Proportional factor amplification

tTi: Integration time. The I-component corrects the residual control deviation following the correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. Additionally the deviation between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Currently active controller in the sequence.


FB_HVACMasterSequenceCtrl

Application

Improved controllability can be achieved with the aid of the exhaust or room temperature cascade control. The master controller measures the room or exhaust temperature and adapts the set value for the supply air temperature to the room conditions. The set value for the supply air is limited by a minimum and a maximum value.

In support operating mode of the air conditioning system (eModeSeqCtrl = eHVACSequenceCtrlMode_FreezeProtection), the value of rYMaxis routed directly through to the output rY.

If overheating control is activated (eModeSeqCtrl = eHVACSequenceCtrlMode_ OverheatingProtection), the value of rYMinis routed directly through to the output rY .

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
bResetController          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: The system operating mode is transferred to the controller with the Enum eModeSeqCtrl.

rX: Acquires the actual value of the control loop.

rW: The set value is transferred to the controller with the variable rW.

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

tCtrlCycleTime: Cycle time with which the control loop is processed. This must be greater than or equal to tTaskCycleTime. The function block uses this input variable to calculate internally whether the state and the output variables have to be updated in the current cycle.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value for the manual operating mode.

bResetController: The internal variables of the PID controller are reset.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rY                        : REAL;
rXW                       : REAL;
bMaxLimit                 : BOOL;
bMinLimit                 : BOOL;
bActive                   : BOOL;
bARWactive                : BOOL;
eState                    : E_HVACState;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;
bInvalidParameter         : BOOL;

rY: Set temperature value for the supply air temperature controller

rXW: Control deviation.

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                      : Type            Persistent       Default       Range

rDeadRange                : REAL;               X              0.0        0 .. 32767
rInitialValue             : REAL;               X              0.0        0 .. 32767
rKp                       : REAL;               X              1.0
tTi                       : TIME;               X              t#30s
tTv                       : TIME;               X              t#0s
tTd                       : TIME;               X              t#0s
rYMin                     : REAL;               X             16.0
rYMax                     : REAL;               X             25.0

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valve or damper drive, a dead band can be set for the controller output signal rY. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal rY is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportional factor amplification.

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.


FB_HVACPIDCooling

PID cooling controller

The control direction of the cooling controller is inverted compared to the heating controller. If the inlet air temperature set value is reduced, the sequence controller raises its control signal. In the operating mode Overheating Control, the cooler regulates the supply air temperature to the minimum. Outside the normal sequence control operation the controller is also activated if overheating control is activated.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
bResetController          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

bSetDefault: If the variable is TRUE, the default-values of the VAR_IN_OUT variables are taken over.

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the air conditioning plant is transmitted to the controller block in the sequence. See also Table of operating modes.

iNumberOfSequences: Number of sequence controller in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rY                        : REAL;
rXW                       : REAL;
bMaxLimit                 : BOOL;
bMinLimit                 : BOOL;
bActive                   : BOOL;
bARWactive                : BOOL;
eState                    : E_HVACState;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;
bInvalidParameter         : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation.

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: E_HVACErrorCodes. See Error codes.

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

VAR_IN_OUT

      Name                    : Type      Persistent       Default

rDeadRange              : REAL;         X              0.0
rInitialValue           : REAL;         X              0.0
rKp                     : REAL;         X              1.0
tTi                     : TIME;         X             t#30s
tTv                     : TIME;         X              t#0s
tTd                     : TIME;         X              t#0s
rDeadBand               : REAL;         X              0.0
rYMin                   : REAL;         X              0.0
rYMax                   : REAL;         X            100.0
iCurrentSequence        : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal rY. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal rY is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportional factor amplification.

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the tTi time is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Number of the active controller from the sequence.


FB_HVACPIDDehumidify

PID dehumidification controller

In order to dehumidify the supply air, it is cooled down by the cooler. The dehumidification is constantly controlled by dosing the coolant at the cooling register with the cooler valve. Two controllers, FB_HVACPIDCooling and FB_HVACPIDDehumidify, act on the cooler valve. First of all the control signal rY is relayed by FB_HVACPIDCooling to the dehumidification sequence controller FB_HVACPIDDehumidify. Inside the FB_HVACPIDDehumidify block, the larger of the two control signals is routed through to the controller output. If the air humidity is too high, the dehumidification controller takes precedence over the cooling controller. However, in order that the correct supply air temperature can still be achieved, the pre-heater is disabled if dehumidification is in operation. The reheater is put into operation in order to reheat the air.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
rYFromPIDCooling          : REAL;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
bResetcontroller          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the air conditioning plant is transmitted to the controller block in the sequence. See also Table operating modes.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

rYFromPIDCooling: In the case of an air conditioning plant with dehumidification, the output of the cooling controller is connected to this input. Inside the function block FB_HVACPIDDehumidify there is a MAX selection that relays the larger of the control signals from the two controllers FB_HVACPIDDehumidify and FB_HVACPIDCooling to the cooler control valve.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rY                        : REAL;
rYDehumidify              : REAL;
rXW                       : REAL;
bMaxLimit                 : BOOL;
bMinLimit                 : BOOL;
bActive                   : BOOL;
bARWactive                : BOOL;
eState                    : E_HVACState;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;
bInvalidParameter         : BOOL;

rY: Control signal output of the PID controller.

rYDehumidify: Control signal output of the dehumidification controller.

rXW: Control deviation.

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                      : Type        Persistent         Default

rDeadRange                : REAL;           X                0.0
rInitialValue             : REAL;           X                0.0
rKp                       : REAL;           X                1.0
tTi                       : TIME;           X                t#30s
tTv                       : TIME;           X                 t#0s
tTd                       : TIME;           X                 t#0s
rDeadBand                 : REAL;           X                0.0
rYMin                     : REAL;           X                0.0
rYMax                     : REAL;           X              100.0
iCurrentSequence          : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal rY. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal rY is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportional factor amplification.

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the tTi time is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Number of the active controller from the sequence.


FB_HVACPIDEnergyRecovery

PID heat recovery controller

One of the special features of the heat recovery controller is the reversal of its control direction depending on the outside temperature and the exhaust air temperature. The enthalpies of the outside air and the exhaust air can be used instead of their temperatures.

If the outside temperature is higher than the exhaust air temperature, the heat recovery system can use the exhaust air or room air, which was cooled with a high expenditure of energy, to cool the outside air. A reduction of the supply air temperature, leads in cooling mode to an increase in the control variable for the heat recovery (curve falls from left to right). If the outside temperature is lower than the exhaust air temperature, the heat recovery system is used to feed the exhaust air heat back to the supply air. The heat recovery system is then in heating mode (curve rises from left to right).

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
rOutsideTemp              : REAL;
rReturnAirTemp            : REAL;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
bResetController          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the VAC system is transmitted to the controller block in the sequence. See also Table operating modes.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

rOutsideTemp: Outside temperature.

rReturnAirTemp: Exhaust air temperature.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rY                        : REAL;
rXW                       : REAL;
bMaxLimit                 : BOOL;
bMinLimit                 : BOOL;
bActive                   : BOOL;
bARWactive                : BOOL;
eState                    : E_HVACState;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;
bInvalidParameter         : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                     : Type      Persistent      Default        Range

rDeadRange               : REAL;         X             0.0         0 .. 32767
rInitialValue            : REAL;         X             0.0         0 .. 32767
rKp                      : REAL;         X             1.0
tTi                      : TIME;         X            t#30s
tTv                      : TIME;         X             t#0s
tTd                      : TIME;         X             t#0s
rDeadBand                : REAL;         X             0.0         0 .. 32767
rYMin                    : REAL;         X             0.0
rYMax                    : REAL;         X           100.0
iCurrentSequence         : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal Y. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal Y is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportional factor amplification

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Number of the active controller from the sequence.


FB_HVACPIDHumidify

Humidity control

Besides the temperature, the humidity of the air is also controlled in some air conditioning systems. Steam humidifiers or air washers are used for humidification. For dehumidification the supply air can be cooled down to the dew point by a cooler. As a result, the moisture in the air condenses on the air cooler. The control of humidification and dehumidification is realized with a sequence comprising a humidification controller and a dehumidification controller.

PID humidification controller

This function block is a special application of a PID controller. The humidity controller is only enabled if the function block input bHumidistat is TRUE.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
bHumidistat               : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
bResetContoller           : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the VAC system is transmitted to the controller block in the sequence. See also Table operating modes.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

bHumidistat: A TRUE on this input enables the humidity control. The hygrostat is connected to this input so that over-humidification cannot occur.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rY                        : REAL;
rXW                       : REAL;
bMaxLimit                 : BOOL;
bMinLimit                 : BOOL;
bActive                   : BOOL;
bARWactive                : BOOL;
eState                    : E_HVACState;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;
bInvalidParameter         : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation.

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                     : Type        Persistent     Default        Range

rDeadRange               : REAL;           X           0.0         0 .. 32767
rInitialValue            : REAL;           X           0.0         0 .. 32767
rKp                      : REAL;           X           1.0
tTi                      : TIME;           X          t#30s
tTv                      : TIME;           X           t#0s
tTd                      : TIME;           X           t#0s
rDeadBand                : REAL;           X           0.0         0 .. 32767
rYMin                    : REAL;           X           0.0
rYMax                    : REAL;           X         100.0
iCurrentSequence         : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal Y. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal Y is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportional factor amplification

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Number of the active controller from the sequence.


FB_HVACPIDMixedAir

PID mixed air chamber controller

One of the special features of the mixed air controller is the reversal of its control direction depending on the outside temperature and the exhaust air temperature. The enthalpies of the outside air and the exhaust air can be used instead of their temperatures.

If the outside temperature is lower than the exhaust air temperature, the air can be used for cooling in the case of high thermal loads inside the building. Hence, the outside air rate increases as the control variable or the supply air temperature set value decreases (curve falls from left to right).

If the outside temperature is higher than the exhaust air temperature, the outside air proportion can be increased in the event of the supply air temperature set value being increased (curve rises from left to right). The outside air temperature is applied to the input variable rOutsideTemp. The variable rReturnAirTemp is for the exhaust air or room temperature. The Night Cooling operating mode (eHVACSequenceCtrlMode_NightCooling)is transmitted to the function block by means of the Enum eModeSeqCtrl. During night cooling the controller is deactivated and 100 % control variable is output at the output rY.Further information on the Summer Night Cooling function can be found under FB_HVACSummerNightCooling .

The maximum and minimum outside air rates can be set with the parameters rYMax and rYMin.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
rOutsideTemp              : REAL;
rReturnAirTemp            : REAL;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
rYMin                     : REAL;
bResetController          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the VAC system is transmitted to the controller blocks in the sequence. See also Table operating modes.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number from the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

rOutsideTemp: Outside temperature

rReturnAirTemp: Exhaust air temperature

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

rYMin: Lower limit of the operating range of the controller.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                     : Type

rY                       : REAL;
rXW                      : REAL;
bMaxLimit                : BOOL;
bMinLimit                : BOOL;
bActive                  : BOOL;
bARWactive               : BOOL;
eState                   : E_HVACState;
bError                   : BOOL;
eErrorCode               : E_HVACErrorCodes;
bInvalidParameter        : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                     : Type        Persistent    Default

rYMax                    : REAL;           X          100.0
rDeadRange               : REAL;           X            0.0
rInitialValue            : REAL;           X            0.0
rKp                      : REAL;           X            1.0
tTi                      : TIME;           X           t#30s
tTv                      : TIME;           X            t#0s
tTd                      : TIME;           X            t#0s
rDeadBand                : REAL;           X            0.0
iCurrentSequence         : INT;

rYMax: Upper limit of the operating range of the controller.

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal Y. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal Y is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportionality factor.

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the tTi time is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integration component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

iCurrentSequence: Number of the active controller from the sequence.


FB_HVACPIDPreHeating

PID pre-heating controller

This function block is a special application of a PID controller.
Besides the PID control algorithm, the block contains the conditions for changing to the sequence of the previous or next sequence controller. A special feature of the pre-heating controller is the input rYDehumidify. As soon as the signal of rYDehumidify is greater than zero, the pre-heater is disabled and the value of iCurrentSequence is increased by one. As a result of this the reheater FB_HVACPIDReHeating is activated in place of the pre-heater. If the value of rYDehumidify returns to zero, the pre-heater is automatically reactivated. Outside the normal sequence control operation the controller is also activated in the case of support operation (freeze protection).

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
eModeSeqCtrl              : E_HVACSequenceCtrlMode;
iNumberOfSequences        : INT;
iMyNumberInSequence       : INT;
rW                        : REAL;
rX                        : REAL;
tTaskCycleTime            : TIME;
tCtrlCycleTime            : TIME;
rYDehumidify              : REAL;
eCtrlMode                 : E_HVACCtrlMode;
rYManual                  : REAL;
rInitialValue             : REAL;
bResetController          : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the VAC system is transmitted to the controller block in the sequence. See also Table operating modes.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

rYDehumidify: In the case of an VAC system with dehumidification, the control variable of the dehumidification controller FB_HVACPIDDehumidify is connected to this input. If the value of rYDehumidify > 0, then the VAR_IN_OUT variable iCurrentSequence will be increased automatically by one. In dehumidification mode the system will thus be switched from the pre-heater FB_HVACPIDPreHeating to the reheater FB_HVACPIDReHeating.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                     : Type

rY                       : REAL;
rXW                      : REAL;
bMaxLimit                : BOOL;
bMinLimit                : BOOL;
bActive                  : BOOL;
bARWactive               : BOOL;
eState                   : E_HVACState;
bError                   : BOOL;
eErrorCode               : E_HVACErrorCodes;
bInvalidParameter        : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                     : Type        Persistent    Default          Range

rDeadRange               : REAL;           X           0.0           0 .. 32767
rKp                      : REAL;           X           1.0
tTi                      : TIME;           X           t#30s
tTv                      : TIME;           X           t#0s
tTd                      : TIME;           X           t#0s
rDeadBand                : REAL;           X           0.0           0 .. 32767
rYMin                    : REAL;           X           0.0
rYMax                    : REAL;           X         100.0
iCurrentSequence         : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal Y. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal Y is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rKp: Proportional factor amplification

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integral component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Number of the active controller from the sequence.


FB_HVACPIDReHeating

PID reheating controller

The reheater is used to reheat the supply air that was cooled down by the cooler for dehumidification. The controller can only be enabled within the normal sequence control operation.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
eModeSeqCtrl             : E_HVACSequenceCtrlMode;
iNumberOfSequences       : INT;
iMyNumberInSequence      : INT;
rW                       : REAL;
rX                       : REAL;
tTaskCycleTime           : TIME;
tCtrlCycleTime           : TIME;
rYDehumidify             : REAL;
eCtrlMode                : E_HVACCtrlMode;
rYManual                 : REAL;
bResetController         : BOOL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

eModeSeqCtrl: Among other things, this Enum enables the controller. In addition, the operating mode of the VAC system is transmitted to the controller blocks in the sequence. See also Table operating modes.

iNumberOfSequences: Number of sequence controllers in the system.

iMyNumberInSequence: The controller’s own number in the sequence.

rW: The set value is transferred to the controller with the variable rW.

rX: Actual value of the control loop.

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

tCtrlCycleTime: The variable tCtrlCycleTime specifies the cycle time with which the PID controller is processed. The shortest possible cycle time is that of the controller. Since the controlled systems in building automation are predominantly slow, the cycle time of the controller can be several times that of the controller cycle time.

rYDehumidify: Constant value.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rYManual: Manual value that is set at the output rY if eCtrlMode = eHVACCtrlMode_Manual.

bResetController: A rising edge on the input bResetController resets the PID controller.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rY                        : REAL;
rXW                       : REAL;
bMaxLimit                 : BOOL;
bMinLimit                 : BOOL;
bActive                   : BOOL;
bARWactive                : BOOL;
eState                    : E_HVACState;
bError                    : BOOL;
eErrorCode                : E_HVACErrorCodes;
bInvalidParameter         : BOOL;

rY: Control signal output of the PID controller.

rXW: Control deviation.

bMaxLimit: The output bMaxLimit is TRUE if the output rY has reached the value rYMax.

bMinLimit: The output bMinLimit is TRUE if the output rY has reached the value rYMin.

bActive: bActive is TRUE if the controller is active and enabled.

bARWactive: bARWactive is TRUE if the integral component of the controller has reached the lower or upper control variable limit.

eState: State of the controller. See E_HVACState.

bError: This output indicates with a TRUE that there is an error.

eErrorCode: Contains the command-specific error code. See E_HVACErrorCodes.

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

VAR_IN_OUT

      Name                      : Type        Persistent    Default      Range

rDeadRange                : REAL;           X          0.0        0 .. 32767
rInitialValue             : REAL;           X          0.0        0 .. 32767
rKp                       : REAL;           X          1.0
tTi                       : TIME;           X         t#30s
tTv                       : TIME;           X          t#0s
tTd                       : TIME;           X          t#0s
rDeadBand                 : REAL;           X          0.0        0 .. 32767
rYMin                     : REAL;           X          0.0
rYMax                     : REAL;           X        100.0
iCurrentSequence          : INT;

rDeadRange: In order to avoid unnecessary driving and hence premature wear of the valves or damper drives, a dead band can be set for the controller output signal Y. This means that a control signal change is only active if the change of value is greater than the dead band. A constant change of the control signal Y is converted to a pulsating drive of the actuator if a dead range is specified. The larger the dead range the larger the pauses and the control signal jumps will be.

rInitialValue: The restart behavior of the controller is influenced by rInitialValue.

rKp: Proportional factor amplification

tTi: Integration time. The I-component corrects the residual control deviation following correction of the P-component. The smaller the time tTi is set, the faster the controller corrects. The control loop becomes unstable if the time is too short. Larger tTi-times must be entered in order to reduce the integral component. The integral action time should be selected to be longer than the stroke time of the valve or damper actuator.

tTv: Rate time. The larger tTv is, the stronger the controller corrects. The control loop becomes unstable if the time is too long. Often in normal building automation applications only a PI controller is used. In this case zero must be entered for tTv.

tTd: Damping time.

rDeadBand: If the control variable is at the lower or upper limit of a controller and the actual value of the control path oscillates around the set value with a small amplitude, frequent switching back and forth between two sequence controllers can be damped by an additional parameter for the switchover. To this end, the difference between the actual and nominal values of the control path is integrated after the sequence controller has reached its lower or upper limit. Switching to the next sequence only takes place if the sum of this integration is greater than the value of rDeadBand (See Example).

rYMin: Lower limit of the operating range of the controller.

rYMax: Upper limit of the operating range of the controller.

iCurrentSequence: Number of the active controller in the sequence.


FB_HVACHeatingCurve

Application

The four-point heating curve serves to determine the setpoint for the feed temperature of a heating circuit, depending on the outside temperature.

FB_HVACHeatingCurve and FB_HVACSetpointHeating requires to be applied together. The reason for this is that the magnitude of the night setback is taken into account by the FB_HVACHeatingCurve function block.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
rOutsideTempDamped       : REAL;
bDayOperation            : BOOL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

rOutsideTempDamped: This input variable transfers the current damped outside temperature to the function block.

bDayOperation: TRUE = day operation, FALSE = night operation.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                    : Type           Range        Unit

rTempSetpoint           : REAL;         0 .. 500      ° C
bInvalidParameter       : BOOL;

rTempSetpoint: The calculated setpoint for the feed temperature.

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                    : Type        Persistent    Default

rMinTemp                : REAL;           X           0.0
rMaxTemp                : REAL;           X         500.0
rNightSetback           : REAL;           X          10.0
rTempSetpoint_Y1        : REAL;           X          20.0
rTempSetpoint_Y2        : REAL;           X          65.0
rTempSetpoint_Y3        : REAL;           X          74.0
rTempSetpoint_Y4        : REAL;           X          80.0
rOutsideTemp_X1         : REAL;           X          20.0
rOutsideTemp_X2         : REAL;           X           0.0
rOutsideTemp_X3         : REAL;           X         -10.0
rOutsideTemp_X4         : REAL;           X         -20.0

rMinTemp: The minimum value for the setpoint of the feed temperature is defined by this variable.

rMaxTemp: The maximum value for the setpoint of the feed temperature is defined by this variable.

rNightSetback: The value for the night cooling is specified by this variable.

rTempSetpoint_Y1 / rOutsideTemp_X1: The course of point 1 of the heating curve is parameterized by this value pair.

rTempSetpoint_Y2 / rOutsideTemp_X2: The course of point 2 of the heating curve is parameterized by this value pair.

rTempSetpoint_Y3 / rOutsideTemp_X3: The course of point 3 of the heating curve is parameterized by this value pair.

rTempSetpoint_Y4 / rOutsideTemp_X4: The course of point 4 of the heating curve is parameterized by this value pair.

Course of the heating characteristic curves

Conditions

The following applies to the input of the values: X1 > X 2 > X3 > X4 and Y1 < Y2 < Y3 <Y4.

Furthermore the minimum value for the setpoint of the feed temperature must be <= rTempSetpoint_Y1 and >= 0. The maximum value for the setpoint of the feed temperature must be >= rTempSetpoint_Y4.

If one of these conditions is not met, the variable bInvalidParameter will be set to TRUE and the default values of the VAR_IN_OUT variables will be adopted.


FB_HVACHeatingCurveEx

Application

The heating curve serves to determine the set value for the flow temperature of a heating circuit, depending on the outside temperature. Compared with the FB_HVACHeatingCurve, the heating curve is shown as a function.

z= 20 - rDesignTemp;

u= 20 - rOutsideTemp;

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
rOutsideTempDamped       : REAL;
bDayOperation            : 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.

Attention 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.

rOutsideTempDamped: This input variable transfers the current damped outside temperature to the function block.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                    : Type                 Unit

rTempSetpoint           : REAL;               ° C
bInvalidParameter       : BOOL;

rTempSetpoint: The calculated set value for the flow temperature.

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                    : Type        Persistent    Default    Range     Unit

rMinTempSetpoint        : REAL;           X          20.0                ° C
rMaxTempSetpoint        : REAL;           X          90.0                ° C
rDesignTemp             : REAL;           X         -16.0                ° C
rSlope                  : REAL;           X           1.0       0..4
rCurve                  : REAL;           X           0.5       0..2

rMinTempSetpoint: The minimum value for the set value of the flow temperature is defined by this variable.

rMaxTempSetpoint: The maximum value for the set value of the flow temperature is defined by this variable.

rDesignTemp: Design temperature for the dimensioning of a heating system. Typical values for Germany lie between -12 [° C] and -16 [° C]

rSlope: Factor for the slope.

rCurve: Factor for the curve.

Course of the heating characteristic curves

Flowtemperature 50 ° C at approx. -9.2 °C

Flowtemperature 50 ° C at approx. -9.4 °C

Flowtemperature 50 ° C at approx. -7.8 °C

Flowtemperature 50 ° C at approx. -8.3 °C

Flowtemperature 60 ° C at approx. 0.2 °C

Flowtemperature 60 ° C at approx. 3.0 °C


FB_HVACOutsideTempDamped

Application

This block calculates the average and damped the outside temperature respectively. The average outside temperature is calculated out off the temperature values at 7:00 am, 2:00 pm and 9:00 pm in automatic mode. The value at 9:00 pm is taken twice for the calculation.

VAR_INPUT

      Name                    : Type

bEnable                 : BOOL;
rOutsideTemp            : REAL;
dtSystemTime            : DT;
bResetInternalValues    : BOOL;
eCtrlMode               : E_HVACCtrlMode;
rManualValue            : REAL;

bEnable: The block will be enabled from the plc program with the input variable bEnable. If bEnable=FALSE the last valid value of the damped outside temperature will be put out.

rOutsideTemp: Input for the actual outside temperature.

dtSystemTime: Input for date and time.

bResetInternalValues: Input to reset the internal saved outside temperatures. After a rest the current outside temperature will be taken over.

eCtrlMode: The operating mode is selected via this Enum. Manual or automatic operating mode.

rManualValue: The manual value is set at the output rOutsideTempDamped if eCtrlMode= eHVACCtlrMode_Manual.

VAR_OUTPUT

      Name                    : Type

rOutsideTempDamped      : REAL;

rOutsideTempDamped: Damped outside temperature.


FB_HVACSetpointHeating

Application

Using this function block a heating circuit can be switched through different operating modes. Depending on the operating mode a corresponding setpoint for controlling the inlet temperature of a static heating circuit is output from the function block. The output bHeating is set or reset depending on the operating mode and the state of the parameters described below.

FB_HVACSetpointHeating and FB_HVACHeatingCurve requires to be applied together. The reason for this is that the magnitude of the night setback is taken into account by the FB_HVACHeatingCurve function block.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
rSetpointIn               : REAL;
rOutsideTempDamped        : REAL;
dtSystemTime              : DT;
bDayOperation             : BOOL;
bFreezeProtec             : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 activated if the variable bEnable is TRUE. If it is FALSE, zero will be output at rSetpointOut and the pump output remains FALSE.

rSetpointIn: In the case of a heating circuit controlled by the room temperature, the value of a room setpoint module is applied at rSetpointIn. If the heating circuit is controlled by the outside temperature, then the setpoint comes from the heating characteristic curve. See FB_HVACHeatingCurve.

rOutsideTempDamped: Short-term fluctuations in the outside temperature must not be allowed to have an unfiltered effect on the setpoint of the inlet temperature. For this reason the outside temperature must not be connected directly, but rather via a damping block. See also FB_HVACOutsideTempDamped regarding this point.

dtSystemtime: This variable transfers the computer system time to the function block.

bDayOperation: The output variable of the time switch program is transferred at this input variable. If bDayOperation is TRUE, then the heating circuit is in day operating mode. The night cooling of the inlet temperature is hence deactivated.

bFreezeProtec: Input to which the frost protection signal is applied.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rSetpointOut              : REAL;
bHeating                  : BOOL;
bReqOutsideTemp           : BOOL;
bReqDate                  : BOOL;
bReqPermanent             : BOOL;
bReqFreezeProtec          : BOOL;
bReqNight                 : BOOL;
bReqDay                   : BOOL;
bInvalidParameter         : BOOL;

rSetpointOut: Setpoint for the inlet temperature control.

bHeating: The output bHeating is set (TRUE) or reset (FALSE) immediately or after a delay, depending on the selected operating mode as well as the switch-on and switch-off delays. The output can be used to enable the controller.

bReqOutsideTemp: The heating circuit is in the operating mode ‘heating period according to outside temperature’.

bReqDate: The heating circuit is in the operating mode ‘heating period according to date’.

bReqPermanent: The heating circuit is in the operating mode ‘heating circuit always on’.

bReqFreezeProtec: The heating circuit is in the operating mode ‘frost protection mode’.

bReqNight: The heating circuit is in the operating mode ‘night operation’.

bReqDay: The heating circuit is in the operating mode ‘day operation’.

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                      : Type                        Persistent      Default      Range         Unit

eSetpointHeatingMode      : E_HVACSetpointHeatingMode;      X             1          0 .. 6
rHeatingLimit             : REAL;                           X            19.0      -60 .. 100      ° C
uiOn_Day                  : UINT;                           X             1
uiOn_Month                : UINT;                           X             9
uiOff_Day                 : UINT;                           X             1
uiOff_Month               : UINT;                           X             5
rFreezeProtecSetpoint     : REAL;                           X             8.0        0 .. 100      ° C
rNightSetback             : REAL;                           X            10.0        0 .. 100      ° C
tDelayHeatingOn           : TIME;                           X            t#0h        0 .. 100       h
tDelayHeatingOff          : TIME;                           X            t#0h        0 .. 100       h

eSetpointHeatingMode: Enum that specifies the operating mode of the heating circuit.

rHeatingLimit: Heating limit. Necessary for the operating modes 'heating period according to outside temperature' and heating period according to date'.

uiOn_Day: Switch-on day of the month. Necessary for the operating mode ‘heating period according to date’.

uiOn_Month: Switch-on month of the year. Necessary for the operating mode ‘heating period according to date’.

uiOff_Day: Switch-off day of the month. Necessary for the operating mode ‘heating period according to date’.

uiOff_Month: Switch-off month of the year. Necessary for the operating mode ‘heating period according to date’.

rFreezeProtecSetpoint: Setpoint for the heating circuit in frost protection mode.

rNightSetback: rNightSetback specifies the value for the night setback in °C. rNightSetback is taken into account in the operating mode eHVACSetpointHeatingMode_OnNight.

tDelayHeatingOn: Time delay for the setting of the output bHeating to TRUE after the damped outside temperature has undershot the heating limit or the date has been reached.

tDelayHeatingOff: Time delay for the resetting of the output bHeating to FALSE after the damped outside temperature has exceeded the heating limit or the date has been reached.


FB_HVACSetpointRamp

Application

The block generates a moving setpoint ramp. This block must be called in every PLC cycle, because the calculation for reaching the final setpoint depends on the TaskTime.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rSetpointIn              : REAL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: Enables the function block.

rSetpointIn: Setpoint to which the output rSetpointOut is regulated, depending on the absolute temperature change rSetpointSlide per time change tRampTime. Each change of the setpoint starts a new calculation of the setpoint to the target value of the ramp. The target value is the current value of rSetpointIn. The start value of the ramp is the last value before the change of rSetpointIn to the new target value; see fig. 1.1.
The value range for rSetpointIn is specified by the parameters rMaxSetpoint and rMinSetpoint.
If no correct variable value is present at rSetpointIn, then the last valid variable value will be taken. If no valid last value exists, operation continues internally with rMinSetpoint. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                     : Type

rSetpointOut             : REAL;
tRemainingTime           : TIME;
bValueReached            : BOOL;
bInvalidParameter        : BOOL;

rSetpointOut: Output of the ramp generator

tRemainingTime: Time duration in which the output rSetpointOut has reached the target value rSetpointIn.

bValueReached: A TRUE at this output indicates that the output rSetpointOut has reached the target value rSetpointIn.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables rSetpointSlide or tRampTime. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                     : Type         Persistent       Default         Range          Unit

rMinSetpoint             : REAL;            X             10.0      -10000 .. 10000
rMaxSetpoint             : REAL;            X             40.0      -10000 .. +10000
rSetpointSlide           : REAL;            X              1.0        0.01 .. 1000       K
tRampTime                : TIME;            X           t#3600s       t#1s .. t#24h

rMinSetpoint/rMaxSetpoint: The value range for rSetpointIn is specified by the parameters rMaxSetpoint and rMinSetpoint.rMaxSetpoint must be greater than rMinSetpoint.
If no correct variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

rSetpointSlide: Absolute temperature change in [Kelvin / tRampTime] with which the output is converted in sliding steps from a lower to a higher value or from a higher to a lower value, see fig. 1.1.
If no correct variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tRampTime: Ramp time during which the final setpoint is reached by steps, depending on the absolute temperature change rSetpointSlide; see fig.1.1.
If no correct variable value is present, then the last valid variable value will be taken. If there is no valid last value, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

Fig. 1.1:


FB_HVACSummerCompensation

Application

This function block is a setpoint generator for the exhaust air temperature or room temperature of an air conditioning system. With the aid of this summer compensation, overly large temperature differences between the outside temperature and the exhaust air/room temperature are avoided. This helps to save energy whilst at the same time increasing comfort.

If the outside temperature increases to the extent that its difference to the current room temperature setpoint is larger than the permissible difference of rSetpointShiftAbsolute, then the setpoint for the room temperature (rSetpointOut) is increased. The permissible difference can be set from 0 to 10 Kelvin.

A check is performed in the function block that the maximum room temperature setpoint is not exceeded, if eSetpointMode:= eHVACSetpointMode_DINLimited.

Example I:

rSetpointIn:= 21 °C

rSetpointExternal:= 2K (i.e. +/- 3K from a potentiometer, it will be ignored because eExternalMode:= eHVACExternalMode_Off is set)

rSetpointShiftAbsolute:= 6 K

rOutsideTemp:= 28 °C

eExternalMode:= eHVACExternalMode_Off

eSetpointMode:= eHVACSetpointMode_DIN

calculated room setpoint (rSetpointOut):= 22

Example II:

rSetpointIn:= 20°C

rSetpointExternal:= -2K (i.e. +/- 3K from a potentiometer)

rSetpointShiftAbsolute:= 6 K

rOutsideTemp:= 28 °C

eExternalMode:= eHVACExternalMode_O n

eSetpointMode:= eHVACSetpointMode_DIN

calculated room setpoint (rSetpointOut):= 20

Example III:

rSetpointIn:= 23 °C

rSetpointExternal:= 3K (i.e. +/- 3K from a potentiometer)

rSetpointShiftAbsolute:= 6 K

rOutsideTemp:= 34 °C

rSetpointHighLimit:= 35 °C

eExternalMode:= eHVACExternalMode_On

eSetpointMode:= eHVACSetpointMode_DINLimited

calculated room setpoint (rSetpointOut):= 31

Example IV:

rSetpointIn:= 24 °C

rSetpointExternal:= 3K (i.e. +/- 3K from a potentiometer)

rSetpointShiftAbsolute):= 6 K

rOutsideTemp:= 36 °C

rSetpointHighLimit:= 30 °C

eExternalMode:= eHVACExternalMode_On

eSetpointMode:= eHVACSetpointMode_DINLimited

calculated room setpoint := 31 °C it will be limited because rSetpointHighLimit is set of 30 °C ==> rSetpointOut:= 30 °C

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
rSetpointIn              : REAL;
rSetpointExternal        : REAL;
rOutsideTemp             : REAL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

rSetpointIn: Input for the room setpoint.

rSetpointExternal: Input for the external setpoint value shift or setpoint value offset, i.e. from a potentiometer.

rOutsideTemp: Input for the outside temperature.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

rSetpointOut              : REAL;
bInvalidParameter         : BOOL;

rSetpointOut: Setpoint for the room.

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                             : Type                 Persistent    Default           Range       Unit

rSetpointHighLimit               : REAL;                    X           35.0           0 .. 100     ° C
rSetpointShiftAbsolute           : REAL;                    X            6.0           0 ..  10       K
eExternalMode                    : E_HVACExternalMode;      X            1
eSetpointMode                    : E_HVACSetpointMode;      X            0

rSetpointHighLimit: Upper limit for the room temperature setpoint.

rSetpointShiftAbsolute: Maximum difference between the outside temperature and the room temperature from which point the summer compensation is active, i.e. the room temperature setpoint is raised. The permissible difference can be set from 0 to 10 Kelvin.

eExternalMode: The activation / deactivation of an external setpoint takes place via the ENUM E_HVACExternalMode.

eHVACExternalMode_Off, means that the external setpoint generator is deactivated.
eHVACExternaMode_On, means that the external setpoint generator is activated.
eHVACExternalMode_ShiftAbsolut, means external setpoint value absolut in ° C

eSetpointMode: Enum that specifies the type of setpoint determination.

This increase of the setpoint in the case of high outside temperatures can be unlimited or limited according to DIN. Selection takes place with the ENUM E_HVACSetpointMode. Besides these two modes for summer compensation it is also possible to specify a fixed setpoint.

  1. According to DIN (eHVACSetpointMode_DIN). The setpoint follows the outside temperature, controlled by a difference.
  2. Limited (eHVACSetpointMode_DINLimited). The setpoint follows the outside temperature, controlled by a difference. However, it is limited. The limit value is rSetpointHighLimit.
  3. Constant (eHVACSetpointMode_ConstantValueBase). The setpoint for the room temperature is specified as a constant value; the outside temperature does not exert any influence. The value of rSetpointIn applies.


FB_HVACAirConditioning2Speed

Application

The function block FB_HVACAirConditioning2Speed controls switching to the second stage of air conditioning systems with two-speed fans. Switching to the second stage via the variable bSpeed2 can be performed either by a timer schedule via the input variable bTimeScheduler or load-dependent via a difference between the set value of the room or exhaust temperature, rSetpoint, and the actual value of the room or exhaust temperature, rActualValue, depending on the time delays tDelayHysteresisOn/tDelayHysteresisOff, the switch-on and release hystereses rHysteresisOn/rHysteresisOff and the setting of the operating mode via the Enum eAirConditioning2SpeedMode.

VAR_INPUT

      Name                            : Type

eDataSecurityType               : E_HVACDataSecurityType;
bSetDefault                     : BOOL;
bEnable                         : BOOL;
bTimeScheduler                  : BOOL;
rSetpoint                       : REAL;
rActualValue                    : REAL;
bReset                          : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled by the PLC program with the input variable bEnable = TRUE . The output variable bSpeed2 is FALSE if the block is not enabled.

bTimeScheduler: Request by a timer program for the second fan speed. If bEnable and bTimeScheduler are TRUE, then bSpeed2 and bRequestScheduler are also TRUE.

rSetpoint: Set value of room or exhaust temperature

rActualValue:Actual value of room or exhaust temperature

bReset: Input for resetting an incorrect parameter entry or an error via a rising edge.

VAR_OUTPUT

      Name                            : Type

bSpeed2                         : BOOL;
bRequestScheduler               : BOOL;
bRequestTemperature             : BOOL;
bInvalidParameter               : BOOL;

bSpeed2: Output for controlling the second fan speed.

bRequestScheduler: Request for the second fan speed via the input variable bTimeScheduler.

bRequestTemperature: Request for the second stage, depending on the load, via a difference between the set value of the room or exhaust temperature, rSetpoint, and the actual value of the room or exhaust temperature, rActualValue, depending on the time delays tDelayHysteresisOn/tDelayHysteresisOff, the switch-on and release hystereses rHysteresisOn/rHysteresisOff and the setting of the operating mode via the Enum eAirConditioning2SpeedMode.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables rHysteresisOn , rHysteresisOff and eAirConditioning2SpeedMode. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                               : Type                                  Persistent    Default         Range

rHysteresisOn                      : REAL;                                      X           5            0-1000
rHysteresisOff                     : REAL;                                      X           1            0-1000
tDelayHyteresisOn                  : TIME;                                      X         t#300s
tDelayHyteresisOff                 : TIME;                                      X         t#300s
eAirConditioning2SpeedMode         : E_HVACAirConditioning2SpeedMode;           X           1

rHysteresisOn: Parameter to switch on the second fan speed via a hysteresis loop, load-dependent, via the output variable bSpeed2 depending on the Enum eAirConditioning2SpeedMode. rHysteresisOn must be larger than rHysteresisOff if the operating mode eAirConditioning2SpeedMode is eHVACAirConditioning2SpeedModeHeatingAndCooling.
If no correct variable value is present, then the last valid variable value, if one exists, will be taken If no valid last value exists, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

rHysteresisOff: Parameter to switch off the second fan speed via a hysteresis loop, load-dependent, via the output variable bSpeed2 depending on the Enum eAirConditioning2SpeedMode.
If no correct variable value is present, then the last valid variable value, if one exists, will be taken If no valid last value exists, operation continues with the default value. If no valid last value exists, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tDelayHysteresisOn: Switch-on delay of the output variable bSpeed2 in the event of a load-dependent request for the second fan speed.

tDelayHysteresisOff: Switch-off delay of the output variable bSpeed2 in the event of a load-dependent request for the second fan speed.

eAirConditioning2SpeedMode: Enum that specifies the load-dependent operating mode for switching on the second fan speed via the output variable bSpeed2.
eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_Off: Operating mode off
eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_Heating: Heating operating mode. This is an air conditioning system with heating operation only.
eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_Cooling: Cooling operating mode. This is an air conditioning system with cooling operation only.
eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_HeatingAndCooling: Heating and cooling operating mode. This is an air conditioning system with heating and cooling operation.

Operating mode eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_Heating

Operating mode eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_Cooling

Operating mode eAirConditioning2SpeedMode = eHVACAirConditioning2SpeedMode_HeatingAndCooling


FB_HVACAlarm

Application

A TRUE on the input bAlarmIn indicates that an alarm signal is present. The alarm is routed through to the output bAlarm only if bAlarmIn is present for longer than the preset time tAlarmDelay. Furthermore, the input bCtrlVoltage must be TRUE in order for an alarm to be announced. Output bAlarm remains set to TRUE until bAlarmIn = FALSE and the alarm is acknowledged by a rising edge on bReset.

VAR_INPUT

      Name                       : Type

eDataSecurityType          : E_HVACDataSecurityType;
bSetDefault                : BOOL;
bAlarmIn                   : BOOL;
bCtrlVoltage               : BOOL;
bReset                     : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bAlarmIn: A TRUE on the input bAlarmIn indicates that an alarm signal is present.

bCtrlVoltage: Via the input bCtrlVoltage a check is made of whether control voltage is present.

bReset: Acknowledge input.

VAR_OUTPUT

      Name                      : Type

bAlarm                    : BOOL;

bAlarm: TRUE if an alarm is announced.

VAR_IN_OUT

      Name                       : Type               Persistent      Default         Range

tAlarmDelay                : TIME;               X             t#10s            t#0s .. t#500s

tAlarmDelay: Delay after the alarm is first announced if, during the preset time, bAlarmIn was constantly present.


FB_HVACAntiBlockingDamper

Application

This function block prevents the blocking of an actuator over long time intervals with an unchanged control value. When activated, the blocking protection forces the actuator to drive from fully closed to fully open.

VAR_INPUT

      Name                      : Type                        Range      Unit

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
bDisable                  : BOOL;
ryDamper                  : REAL;                    0 .. 100     %
dtSystemTime              : DT;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The AntiBlocking function is enabled by the input variable bEnable. If bEnable = FALSE, only the input value will be applied at the output; the AntiBlocking function is not active.

bDisable: Resets the outputs rQDamper, iQDamper and bQAntiBlocking to 0.

ryDamper: Control variable from the controller to the valve, which is fed to the outputs rQDamper and iQDamper. The value must be smaller than 1 % in order for the block to recognize this as standstill time. No standstill time will be determined for a valve with a control variable >= 1 %.

dtSystemTime: System time

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

VAR_IN_OUT

      Name                      : Type                        Persistent      Default         Range      Unit

eAntiBlockingMode         : E_HVACAntiBlockingMode;      X
iHoursDowntime            : INT;                         X                24             0 .. 6000    h
iDayWeekly                : INT;                         X                 6             0 .. 6
iHour                     : INT;                         X                12             0 .. 23      h
iMinute                   : INT;                         X                 0             0 .. 59      min
iLengthImpulse            : INT;                         X               150             0 .. 600     s

eHVACAntiBlockingMode: Enumeration value that indicates the type of Antiblocking-method.

eHVACAntiBlockingMode_Off:= 0 : Off

eHVACAntiBlockingMode_Downtime:= 1 : After the expiry of a standstill time in hours, the Antiblocking-pulse will be routed to the bOut output.

eHVACAntiBlockingMode_Weekly:= 2 : The antib locking pulse is only generated on a certain day of the week and at a certain time, independent of how long the standstill has lasted.

iHoursDowntime: For eHVACAntiBlockingMode_Downtime, the time in hours that the input bIn may not be active before the AntiBlocking-pulse is generated.

iDayWeekly: For eHVACAntiBlockingMode_Weekly, the AntiBlockin- pulse is generated on this day. Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6

iHour: Switch-on time in hours.

iMinute: Switch-on time in minutes.

iLengthImpulse: Switch-on duration in seconds.

VAR_OUTPUT

      Name                     : Type              Range           Unit

rQDamper                 : REAL;            0 .. 100           %
iQDamper                 : INT;             0 .. 32767
bQAntiBlocking           : BOOL;
bInvalidParameter        : BOOL;

rQDamper: This output corresponds to the input value of the control variable. As soon as the input bEnable isTRUE, the Antiblocking-pulse is additionally applied to the output. 100 % is present at the output when the Antiblocking state is reached.

iQDamper: This output behaves like rQDamper, but in order to suit an analogue output it is output as an integer value from 0 - 32767, corresponding to 0 - 100 %.

bQAntiBlocking: This output is independent of the switch-on signal and shows only the Antiblocking-pulse.

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACAntiBlockingPump

Application

This function block relays the switch-on condition for a pump drive and can generate an additional switch-on pulse, depending on the mode and the switch-off time, in order e.g. to prevent the blockage of a pump.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
bDisable                 : BOOL;
bIn                      : BOOL;
dtSystemTime             : DT;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The AntiBlocking function is enabled by the input variable bEnable. If bEnable = FALSE, only the switch-on condition will be applied at the output; the AntiBlocking function is not active.

bDisable: Resets the outputs bOut, bOutAndAntiBlocking and bQAntiBlocking to 0. (See example below)

bIn: Switch-on condition that is relayed to the output bOut.

dtSystemTime: System time

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

VAR_IN_OUT

      Name                    : Type                       Persistent       Default           Range       Unit

eAntiBlockingMode       : E_HVACAntiBlockingMode;        X
iHoursDowntime          : INT;                           X               24             0 .. 6000     h
iDayWeekly              : INT;                           X                6             0 .. 6
iHour                   : INT;                           X               12             0 .. 23       h
iMinute                 : INT;                           X                0             0 .. 59       min
iLengthImpulse          : INT;                           X              150             0 .. 600      s

eHVACAntiBlockingMode: Enumeration value that indicates the type of Antiblocking-method.

eHVACAntiBlockingMode_Off:= 0: Off

eHVACAntiBlockingMode_Downtime:= 1 : After the expiry of a standstill time in hours, the Antiblocking-pulse will be routed to the bOut output.

eHVACAntiBlockingMode_Weekly:= 2 : The antib locking pulse is only generated on a certain day of the week and at a certain time, independent of how long the standstill has lasted.

iHoursDowntime: For eHVACAntiBlockingMode_Downtime, the time in hours that the input bIn may not be active before the AntiBlocking-pulse is generated.

iDayWeekly: For eHVACAntiBlockingMode_Weekly, the AntiBlockin- pulse is generated on this day. Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6

iHour: Switch-on time in hours.

iMinute: Switch-on time in minutes.

iLengthImpulse: Switch-on duration in seconds.

VAR_OUTPUT

      Name                      : Type

bOut                      : BOOL;
bOutAndAntiBlocking       : BOOL;
bQAntiBlocking            : BOOL;
bInvalidParameter         : BOOL;

bOut: TRUE, the request is triggered of the function block FB_HVACCirculationPump. This output corresponds to the switch-on condition independent of the state of the Antiblocking pulse and the input bEnable.

bOutAndAntiBlocking: This output corresponds to the switch-on condition and is dependent upon the state of the Antiblocking-pulse and the inputs bEnable and bDisable. If bEnable = FALSE, then the output corresponds to the output bOut. If bEnable = TRUE, then the output corresponds to the output bOut and is additonally linked via an or with the Antiblocking-pulse.

bQAntiBlocking: TRUE, the request is triggered of the Antiblocking function. This output is independent of the switch-on signal and shows only the Antiblocking-pulse.

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.

Example of a combination of a pump block and the FB_HVACAntiBlocking:

  • The pump output bPump is applied to bIn of the FB_HVACAntiBlocking also without bEnable.

  • If the input bPumpProtec goes to FALSE, bPump is switched off and bDisable becomes active via the message bErrorPumpProtec, so that bOut is switched off.

Example of the control of several pumps via one AntiBlocking instance:

  • Enable fbHVACAntiBlocking via bEnable.

  • Select weekly mode (e.g. Monday at 6.30 pm for 10 secs).


FB_HVACBlink

Application

The function block delivers a flashing sequence at the output bBlink that is dependent on the two adjustable times tTimeOn and tTimeOff.

VAR_INPUT

      Name                    :Type

bEnable                 :REAL;
tTimeOn                 :TIME;
tTimeOff                :TIME;

bEnable: Enables the function block.

tTimeOn: Switch-on duration of the flash pulse, bBlink = TRUE.

tTimeOff: Switch-off duration of the flash pulse, bBlink = FALSE.

VAR_OUTPUT

      Name                    :Type

bBlink                  :BOOL;
tNextSwitching          :TIME;

bBlink: Flash output.

tNextSwitching: Time until the next change of state of the output bBlink.

Behavior of the output value


FB_HVACCmdCtrl_8

Application

With this function block, individual units in a system can be sequentially switched on (bQ_Cmd > bQ1 > bQ2… bQ8) or switched off (bQ8 > bQ7 > bQ6… bQ_Cmd) in a certain order. FB_HVACCmdCtrl_8 can be used as the starting function block of a ventilation system.

An event and a parameter structure with time variables belong to each output. These can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output.

Switch-on condition if bEn and bCmd are TRUE:

Q(n) = Q(n - 1) AND Event(n) AND (DelayOn(n) = 0 AND (MinOff(n) = 0 AND stState.udiStep = n

Example for the output bQ_Cmd

bQ_Cmd = bCmd AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[0] = 0 AND stState.udiStep = 0

Example for the output bQ2

bQ2 = bQ1 AND bEvt2 AND stState.udiSecRT_DelayOn = 0 AND stState[2].udiSecRT_MinOff = 0 AND stState.udiStep = 2

Switch-off condition if bEn is TRUE and bCmd is FALSE:

Q(n) = NOT Q(n + 1) AND (DelayOff(n) = 0 AND (MinOn(n) = 0 AND stState.udiStep = n

Example for the output bQ8

bQ8 = stState.udiSecRT_DelayOff = 0 AND stState[7].udiSecRT_MinOn = 0 AND stState.udiStep = 8

Example for the output bQ_Cmd

      bQ_Cmd = NOT bQ1 AND
stState.udiSecRT_DelayOff = 0 AND stState[0].udiSecRT_MinOn = 0
AND stState.udiStep = 0

Current step

On the basis of the status variable stState.udiStep it is possible to see which step the function block is currently in.

Switch-on and switch-off sequence

If bEn and bCmd are TRUE the switch-on sequence is (bQ_Cmd > bQ1 > bQ2… bQ8). The switch-off sequence (bQ8 > bQ7 > bQ6… bQ_Cmd) is active if bEn = TRUE and bCmd = FALSE.

If an output has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase. In the switch-off sequence, no event (bEvt1-8) has any effect on the switch-off conditions of the outputs.

If the function block is in the switch-off sequence and the switch-on phase is activated by bCmd = TRUE, then the function block starts in step 0 with the switch-on conditions of bQ_Cmd. For the other outputs the minimum switch-on or switch-off times are active until their expiry.

Time responses of an individual step

The diagram shows the time responses of step 1 or the output bQ1.

Application example

The application example shows the function block FB_HVACCmdCtrl_8 in conjunction with FB_HVACPriority_INT_8 as the system initialisation program for a ventilation system. The example AC03_StartAC.PRG can be found in the folder Language CFC > SpecialFunctions > Start.

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type

eDST                      : E_HVACDataSecurityType;
bEn                       : BOOL;
bCmd                      : BOOL;
bEvt1                     : BOOL;
bEvt2                     : BOOL;
bEvt3                     : BOOL;
bEvt4                     : BOOL;
bEvt5                     : BOOL;
bEvt6                     : BOOL;
bEvt7                     : BOOL;
bEvt8                     : BOOL;

eDST: If eDST := 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 eDST:= eHVACDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEn: Enables the function block. The function block is disabled if bEn is FALSE. All outputs go to FALSE and the timers for the switch-on and switch-off delays as well as the minimum switch-on and switch-off times are reset. A collective error message or an emergency stop switch for immediately switching off a system can be connected to the input bEn.

bCmd: The switch-on or switch-off sequence of the function block is defined with bCmd. If bCmd is TRUE, then the function block is in the switch-on sequence of the outputs. The switching on of a system could come, for example, from a timer program. If bCmd is FALSE, then the function block is in the switch-off sequence of the outputs.

bCmd counts as one of the switch-on conditions of bQ_Cmd.

bEvt1: The event bEvt1 counts as one of the switch-on conditions of bQ1. In the switch-on phase of bQ1, the switch-on delay of the output is active only if bEvt1 is TRUE.

Switch-on condition:

bQ1 = bQ_Cmd AND bEvt1 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[1] = 0 AND stState.udiStep = 1

The event bEvt1 has no effect on the switch-off condition of bQ1.

bEvt2: The event bEvt2 counts as one of the switch-on conditions of bQ2. In the switch-on phase of bQ2, the switch-on delay of the output is active only if bEvt2 is TRUE.

Switch-on condition:

bQ2 = bQ1 AND bEvt2 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[2] = 0 AND stState.udiStep = 2

The event bEvt2 has no effect on the switch-off condition of bQ2.

bEvt3: The event bEvt3 counts as one of the switch-on conditions of bQ3. In the switch-on phase of bQ3, the switch-on delay of the output is active only if bEvt3 is TRUE.

Switch-on condition:

bQ3 = bQ2 AND bEvt3 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[3] = 0 AND stState.udiStep = 3

The event bEvt3 has no effect on the switch-off condition of bQ3.

bEvt4: The event bEvt4 counts as one of the switch-on conditions of bQ4. In the switch-on phase of bQ4, the switch-on delay of the output is active only if bEvt4 is TRUE.

Switch-on condition:

bQ4 = bQ3 AND bEvt4 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[4] = 0 AND stState.udiStep = 4

The event bEvt4 has no effect on the switch-off condition of bQ4.

bEvt5: The event bEvt5 counts as one of the switch-on conditions of bQ5. In the switch-on phase of bQ5, the switch-on delay of the output is active only if bEvt5 is TRUE.

Switch-on condition:

bQ5 = bQ4 AND bEvt5 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[5] = 0 AND stState.udiStep = 5

The event bEvt5 has no effect on the switch-off condition of bQ5.

bEvt6: The event bEvt6 counts as one of the switch-on conditions of bQ6. In the switch-on phase of bQ6, the switch-on delay of the output is active only if bEvt6 is TRUE.

Switch-on condition:

bQ6 = bQ5 AND bEvt6 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[6] = 0 AND stState.udiStep = 6

The event bEvt6 has no effect on the switch-off condition of bQ6.

bEvt7: The event bEvt7 counts as one of the switch-on conditions of bQ7. In the switch-on phase of bQ7, the switch-on delay of the output is active only if bEvt7 is TRUE.

Switch-on condition:

bQ7 = bQ6 AND bEvt7 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[7] = 0 AND stState.udiStep = 7

The event bEvt7 has no effect on the switch-off condition of bQ7.

bEvt8: The event bEvt8 counts as one of the switch-on conditions of bQ8. In the switch-on phase of bQ8, the switch-on delay of the output is active only if bEvt8 is TRUE.

Switch-on condition:

bQ8 = bQ7 AND bEvt8 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[8] = 0 AND stState.udiStep = 8

The event bEvt8 has no effect on the switch-off condition of bQ8.

VAR_OUTPUT

      Name             : Type

bQ_Cmd           : BOOL;
bQ1              : BOOL;
bQ2              : BOOL;
bQ3              : BOOL;
bQ4              : BOOL;
bQ5              : BOOL;
bQ6              : BOOL;
bQ7              : BOOL;
bQ8              : BOOL;
stState          : ST_HVACCmdCtrl_8State;

bQ_Cmd: Output to enable a device. If the output bQ_Cmd has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The input variable bCmd and the parameter structure stParamCmd belong to bQ_Cmd. bCmd is one of the switch-on conditions of bQ_Cmd. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ_Cmd = bCmd AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[0] = 0 AND stState.udiStep = 0

Switch-off condition

bQ_Cmd = NOT bQ1 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[0] = 0 AND stState.udiStep = 0

bQ1: Output to enable a device. If the output bQ1 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 1 bEvt1 and the parameter structure stParam1 belong to bQ1. bEvt1 is one of the switch-on conditions of bQ1. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ1 = bEvt1 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[1] = 0 AND stState.udiStep = 1

Switch-off condition

bQ1 = NOT bQ1 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[1] = 0 AND stState.udiStep = 1

bQ2: Output to enable a device. If the output bQ2 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 2 bEvt2 and the parameter structure stParam2 belong to bQ2. bEvt2 is one of the switch-on conditions of bQ2. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ2 = bEvt2 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[2] = 0 AND stState.udiStep = 2

Switch-off condition

bQ2 = NOT bQ2 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[2] = 0 AND stState.udiStep = 2

bQ3: Output to enable a device. If the output bQ3 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 3 bEvt3 and the parameter structure stParam3 belong to bQ3. bEvt3 is one of the switch-on conditions of bQ3. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ3 = bEvt3 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[3] = 0 AND stState.udiStep = 3

Switch-off condition

bQ3 = NOT bQ3 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[3] = 0 AND stState.udiStep = 3

bQ4: Output to enable a device. If the output bQ4 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 4 bEvt4 and the parameter structure stParam4 belong to bQ4. bEvt4 is one of the switch-on conditions of bQ4. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ4 = bEvt4 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[4] = 0 AND stState.udiStep = 4

Switch-off condition

bQ4 = NOT bQ4 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[4] = 0 AND stState.udiStep = 4

bQ5: Output to enable a device. If the output bQ5 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 5 bEvt5 and the parameter structure stParam5 belong to bQ5. bEvt5 is one of the switch-on conditions of bQ5. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ5 = bEvt5 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[5] = 0 AND stState.udiStep = 5

Switch-off condition

bQ5 = NOT bQ5 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[5] = 0 AND stState.udiStep = 5

bQ6: Output to enable a device. If the output bQ6 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 6 bEvt6 and the parameter structure stParam6 belong to bQ6. bEvt6 is one of the switch-on conditions of bQ6. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ6 = bEvt6 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[6] = 0 AND stState.udiStep = 6

Switch-off condition

bQ6 = NOT bQ6 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[6] = 0 AND stState.udiStep = 6

bQ7: Output to enable a device. If the output bQ7 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 7 bEvt7 and the parameter structure stParam7 belong to bQ7. bEvt7 is one of the switch-on conditions of bQ7. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ7 = bEvt7 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[7] = 0 AND stState.udiStep = 7

Switch-off condition

bQ7 = NOT bQ7 AND stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[7] = 0 AND stState.udiStep = 7

bQ8: Output to enable a device. If the output bQ8 has been set in the switch-on sequence, then it remains latched and is only reset in the switch-off phase.

The event 8 bEvt8 and the parameter structure stParam8 belong to bQ8. bEvt8 is one of the switch-on conditions of bQ8. The time variables of the parameter structure can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration for the output. The status of the time responses is indicated with the output structure stState.

Switch-on condition

bQ8 = bEvt8 AND stState.udiSecRT_DelayOn = 0 AND stState.udiSecRT_MinOff[8] = 0 AND stState.udiStep = 8

Switch-off condition

bQ8 = stState.udiSecRT_DelayOff = 0 AND stState.udiSecRT_MinOn[8] = 0 AND stState.udiStep = 8

stState: This structure indicates the remaining time of the switch-on or switch-off delay of the active step and the minimum switch-on and switch-off duration of the outputs.

stState.udiSecRT_DelayOn: In the switch-on phase of the outputs (bCmd = TRUE), the remaining time of the switch-on delay of the current step stState.udiStep is indicated by stState.udiSecRT_DelayOn.

Example: If stState.udiStep = 5, then the function block is in step 5. The time variable of the parameter structure stParam5.udiSecDelayOn is used for the switch-on delay of the output bQ5 and the remaining time is indicated by udiSecRT_DelayOn.

stState.udiSecRT_DelayOff: In the switch-off phase of the outputs (bCmd = FALSE) the remaining time of the switch-off delay of the current step stState.udiStep is indicated by udiSecRT_DelayOff.

Example: If stState.udiStep = 0, then the function block is in step 0. The time variable stParamCmd.udiSecDelayOff is used for the switch-off delay of the output bQ_Cmd and the remaining time is indicated by udiSecRT_DelayOff.

stState.udiStep: Status indicating which step the function block is in.

Examples:

- If stState.udiStep = 0, then the function block is in the switch-on or switch-off sequence of the output bQ_Cmd.

- If stState.udiStep = 1, then the function block is in the switch-on or switch-off sequence of the output bQ1.

- If stState.udiStep = 8, then the function block is in the switch-on or switch-off sequence of the output bQ8.

stState.udiSecRT_MinOn[0..g_iNumOfCmdCtrl_8]: The remaining time of the minimum switch-on duration of the outputs is indicated in the one-dimensional field (Table) stState.udiSecRT_MinOn[0..g_iNumOfCmdCtrl_8]. Following the expiry of the minimum switch-on duration of an output, the output can be switched off in the current step stState.udiStep.

stState.udiSecRT_MinOff[0..g_iNumOfCmdCtrl_8]: The remaining time of the minimum switch-off duration of the outputs is indicated in the one-dimensional field (Table) stState.udiSecRT_MinOff[0..g_iNumOfCmdCtrl_8]. Following the expiry of the minimum switch-off duration of an output, the output can be switched on in the current step stState.udiStep.

VAR_IN_OUT

      Name                : Type                         Persistent

stParamCmd          : ST_HVACCmdCtrl_8Param;           X
stParam1            : ST_HVACCmdCtrl_8Param;           X
stParam2            : ST_HVACCmdCtrl_8Param;           X
stParam3            : ST_HVACCmdCtrl_8Param;           X
stParam4            : ST_HVACCmdCtrl_8Param;           X
stParam5            : ST_HVACCmdCtrl_8Param;           X
stParam6            : ST_HVACCmdCtrl_8Param;           X
stParam7            : ST_HVACCmdCtrl_8Param;           X
stParam8            : ST_HVACCmdCtrl_8Param;           X

stParamCmd: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ_CMD.

stParam1: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ1.

stParam2: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ2.

stParam3: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ3.

stParam4: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ4.

stParam5: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ5.

stParam6: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ6.

stParam7: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ7.

stParam8: The structure contains time variables that can be used to define a switch-on or switch-off delay as well as a minimum switch-on or minimum switch-off duration of the output bQ8.


FB_HVACCmdCtrlSystem1Stage

Application

This function block FB_HVACCmdCtrlSystem1Stage is a system switch. It is used, for example, to switch a single-speed ventilation system to automatic or manual operating mode. In automatic operating mode the system can be controlled via a timer program or via a request from a control panel. The FB_HVACCmdCtrlSystem1Stage function block is active if the input variable bEnable is TRUE and eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
eCtrlModeActuator         : E_HVACActuatorMode;
bExternalRequest          : BOOL;
bTimeScheduler            : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If bEnable = FALSE, then bOn is also FALSE.

eCtrlModeActuator: Enum that specifies the system operating modes Manual, Auto and Off. In the event of an incorrect entry, operation continues internally with the last valid operating mode. This is eHVACActuatorMode_Auto_BMS in the case of a first-time start-up. bInvalidParameter is set in the case of an incorrect parameter entry.

bExternalRequest: External request for the system, e.g. from a control panel via a button or switch.

bTimeScheduler: Request for the system via a timer program.

bReset: Acknowledge input in the event of an error

VAR_OUTPUT

      Name                      : Type

bOn                       : BOOL;
eStateModeActuator        : E_HVACActuatorMode;
bRequestScheduler         : BOOL;
bRequestExternal          : BOOL;
bInvalidParameter         : BOOL;

bOn: This output variable enables the system.

eStateModeActuator: Enum via which the operating mode status of the motor is fed back to the controller.

bRequestScheduler: This output indicates that the system is requested by the input variable bTimeScheduler.

bRequestExternal: This output indicates that the system is requested by the input variable bExternalRequest.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables eCtrlModeActuator, ePlantMode or eExternalRequestMode. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                     : Type                          Persistent    Default

ePlantMode               : E_HVACPlantMode;                  X              0
eExternalRequestMode     : E_HVACExternalRequestMode;        X                 0
tOffDelay                : TIME;                             X           t#30m

ePlantMode: With this enumeration variable various functions of the system can be performed in automatic operating mode, depending on the input variables bExternalRequest and bTimeScheduler.
ePlantMode = eHVACPlantMode_TimeSchedulingOnly: the system is switched on and off exclusively via the input variable bTimeScheduler .
ePlantMode = eHVACPlantMode_TimeScheduling_And_ExternalRequest: the system is switched on if the input variables bTimeScheduler AND bExternalRequest are TRUE.
ePlantMode = eHVACPlantMode_TimeScheduling_Or_ExternalRequest: the system is switched on via the input variable bTimeScheduler OR bExternalRequest.
ePlantMode = eHVACPlantMode_ExternalRequestOnly: the system is switched on and off exclusively via the input variable bExternalRequest.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

eExternalRequestMode: The Enum eExternalRequestMode specifies the functional method of the input variable bExternalRequest in automatic operating mode, depending on the Enum ePlantMode.
eExternalRequestMode = eHVACExternalRequestMode_ButtonOn_Off: the external request is set to TRUE following a rising edge on bExternalRequest. A further rising edge resets the request to FALSE.
eExternalRequestMode = eHVACExternalRequestMode_ButtonOffDelay: following a rising edge on the input variable bExternalRequest,the external request extends or sets the utilization time of the system by the time setting of tOffDelay.
eExternalRequestMode = eHVACExternalRequestMode_SwitchOn_Off: the external request is active if bExternalRequest = TRUE. It is deactivated if bExternalRequest = FALSE.
If an incorrect variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tOffDelay: Time value for the extension of the system utilization time. The extension of the utilization time can only be activated if eModeExternalRequest = 2.

Behavior of the output value


FB_HVACCmdCtrlSystem2Stage

Application

This function block FB_HVACCmdCtrlSystem2Stage is a system switch. It is used, for example, to switch a two-stage ventilation system to automatic or manual operating mode. In automatic operating mode the system can be controlled via a timer program or via the request from a control panel. The FB_HVACCmdCtrlSystem2Stage function block is active if the input variable bEnable is TRUE and eCtrlModeActuator = eHVACActuatorMode_Auto_BMS or eHVACActuatorMode_Auto_OP.

VAR_INPUT

      Name                       : Type

eDataSecurityType          : E_HVACDataSecurityType;
bSetDefault                : BOOL;
bEnable                    : BOOL;
eCtrlModeActuator          : E_HVACActuatorMode;
bExternalRequest1          : BOOL;
bExternalRequest2          : BOOL;
bTimeScheduler1            : BOOL;
bTimeScheduler2            : BOOL;
bReset                     : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE. If bEnable = FALSE, then bOn1 and bOn2 are also FALSE.

eCtrlModeActuator: Enum that specifies the system operating modes Manual, Auto and Off. In the event of an incorrect entry, operation continues internally with the last valid operating mode. This is eHVACActuatorMode_Auto_BMS in the case of a first-time start-up. bInvalidParameter is set in the case of an incorrect parameter entry.

bExternalRequest1: External request for the system in stage 1, e.g. from a control panel via a button or switch.

bExternalRequest2: External request for the system in stage 2, e.g. from a control panel via a button or switch.

bTimeScheduler1: Request for the system in stage 1 via a timer program.

bTimeScheduler2: Request for the system in stage 2 via a timer program.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                       : Type

bOn1                       : BOOL;
bOn2                       : BOOL;
eStateModeActuator         : E_HVACActuatorMode;
bRequestScheduler1         : BOOL;
bRequestScheduler2         : BOOL;
bRequestExternal1          : BOOL;
bRequestExternal2          : BOOL;
bInvalidParameter          : BOOL;

bOn1: The system is enabled for stage 1 by this output variable.

bOn2: The system is enabled for stage 2 by this output variable. If stage 2 is enabled, then stage 1 is automatically also enabled.

eStateModeActuator: Enum via which the operating mode status of the motor is fed back to the controller.

bRequestScheduler1: This output indicates that the system is requested by the input variable bTimeScheduler1.

bRequestScheduler2: This output indicates that the system is requested by the input variable bTimeScheduler2.

bRequestExternal1: This output indicates that the system is requested by the input variable bExternalRequest1.

bRequestExternal2: This output indicates that the system is requested by the input variable bExternalRequest2.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables eCtrlModeActuator, ePlantMode or eExternalRequestMode. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                       : Type                         Persistent         Default

ePlantMode                 : E_HVACPlantMode;                 X                 0
eExternalRequestMode       : E_HVACExternalRequestMode;       X                 0
tOffDelay1                 : TIME;                            X               t#30m
tOffDelay2                 : TIME;                            X               t#30m

ePlantMode: With this enumeration variable various functions of the system can be performed in automatic operating mode, depending on the input variables bExternalRequest1, bExternalRequest2, bTimeScheduler1 and bTimeScheduler2.
ePlantMode = eHVACPlantMode_TimeSchedulingOnly: The system is switched to the respective stage exclusively via the input variables bTimeScheduler1 or bTimeScheduler2.
ePlantMode = eHVACPlantMode_TimeScheduling_And_ExternalRequest: The system is switched to stage 1 if the input variables bTimeScheduler1 AND bExternalRequest1 are both TRUE. If the input variables bTimeScheduler2 AND bExternalRequest2 are both TRUE, the system is switched to stage 2.
ePlantMode = eHVACPlantMode_TimeScheduling_Or_ExternalRequest: The system is switched to the respective stage via the input variables bExternalRequest1, bExternalRequest2, OR bTimeScheduler1, bTimeScheduler2.
ePlantMode = eHVACPlantMode_ExternalRequestOnly: The system is switched to the respective stage exclusively via the input variable bExternalRequest1 or bExternalRequest2.
If an incorrect variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

eExternalRequestMode: The Enum eExternalRequestMode specifies the functional method of the input variables bExternalRequest1 and bExternalRequest2 in automatic operating mode, depending on the Enum ePlantMode.
eExternalRequestMode = eHVACExternalRequestMode_ButtonOn_Off: The external request is set to TRUE following a rising edge on bExternalRequest1 or bExternalRequest2. A further rising edge resets the request to FALSE.
eExternalRequestMode = eHVACExternalRequestMode_ButtonOffDelay. Following a rising edge on the input variable bExternalRequest1 or bExternalRequest2, the external request extends or sets the utilization time of the system in the respective stage by the time setting of tOffDelay1 or tOffDelay2.
eExternalRequestMode = eHVACExternalRequestMode_SwitchOn_Off: The external request is active if bExternalRequest1 or bExternalRequest2 = TRUE. It is deactivated if bExternalRequest1 or bExternalRequest2 = FALSE.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter is set in the case of an incorrect parameter entry.

tOffDelay1: Time value for the extension of the system utilization time in stage 1. The extension of the utilization time can only be activated if eModeExternalRequest = 2.

tOffDelay2: Time value for the extension of the system utilization time in stage 2. The extension of the utilization time can only be activated if eModeExternalRequest = 2.

Behavior of the output value


FB_HVACConvertEnum

Application

This function block converts an Enum into an integer value and vice versa. This conversion is particularly suitable for Enums that are used as VAR_IN_OUT variables on function blocks.

VAR_INPUT

      Name                        : Type

pEnum                       : UDINT;
udiLenEnum                  : UDINT;
pInt                        : UDINT;
udiLenInt                   : UDINT;

pEnum: Address of the Enum to be converted. The address is determined with the ADR operator.

udiLenEnum: Number of bytes of which the data type Enum consists. The number is determined with the SIZEOF operator.

pInt: Address the integer variable to be converted. The address is determined with the ADR operator.

udiLenInt: Number of bytes of which the data type Integer consists. The number is determined with the SIZEOF operator.

VAR_OUTPUT

      Name                        : Type

bError                      : BOOL;
eErrorCode                  : E_HVACErrorCodes;

bError: This output indicates with a TRUE that there is an error. (The number of bytes of which the data types Integer or Enum consist is wrong.)

eErrorCode: Supplies the error number when the output bError is set. The following errors can occur in this function block: eHVACErrorCodes_Error_LEN_Int (43), eHVACErrorCodes_Error_LEN_Enum (44)

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib


FB_HVACEnthalpy

Application

This function block is used to calculate the dew point, the specific enthalpy and the absolute humidity. The temperature, the relative humidity and the barometric pressure are required for calculating these parameters.
The enthalpy is a measure for the energy of a thermodynamic system.

VAR_INPUT

      Name                       : Type                  Unit            Range

rTemperature               : REAL;                 [°C ]
rRelativeHumidity          : REAL;                 [ % ]           1..100
rBarometricPressure        : REAL;                 [hPa]

rTemperature: Input for the temperature value, in °C .

rRelativeHumidity: Input for the relative humidity, in %. The value must equal or greater 1.

rBarometricPressure: Input for the air pressure, in hectopascal.

VAR_OUTPUT

      Name                       : Type                   Unit

rDewPoint                  : REAL;                 [°C ]
rEnthalpy                  : REAL;                 [kJ/kg]
rAbsoluteHumidity          : REAL;                 [kg/kg]
rRho                       : REAL;                 [kg/m³]
rYpsilon                   : REAL;                 [m³/kg]
bInvalidParameter          : BOOL;

rDewPoint: Dew point [°C ].

rEnthalpy: Enthalpy [kJ / kg].

rAbsoluteHumidity: Absolute humidity [kg/kg]. In order to obtain the absolute humidity in [g/kg] the result must be multiplied by 1000.

rRho: Density of humid air, showing the weight of the mass of the mixture in relation to volume. The unit is [ kg mixture / m³ ].

rYpsion: Specific volume per 1 kg of dry air. The unit is [ m³ / kg dry air ].

bInvalidParameter: Set to TRUE if the input variable rRelativeHumidity or rBarometricPressure is less than or equal zero.

Fig. 1 h,x diagram [www.air2000.de]

Sample 1:

      rTemperature:= 20  °C
rRelativeHumidity:=  50 %
rBarometricPressure:= 1013.15 hPa

Results from the FB: rDewPoint:= 9.4 °C
rEnthalpy:= 38.6 kJ/kg
rAbsoluteHumidity:= 0.0072 kg/kg ,
converted in g/kg ==> 7.2 g/kg

Sample 2:

      rTemperature:= 25  °C
rRelativeHumidity:=  60 %
rBarometricPressure:= 1013.15 hPa

Results from the FB: rDewPoint:= 17 °C
rEnthalpy:= 55.6 kJ/kg
rAbsoluteHumidity:= 0.0119 kg/kg ,
converted in g/kg ==> 11.9 g/kg


FB_HVACFixedLimit

Application

This function block represents a limit value switch, whose output signal is switched depending on the time delays tDelayHighLimit / tDelayLowLimit, the mode bModeFixedLimit, the limit values rHighLimit / rLowLimit and the input signal rInputValue.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rInputValue              : REAL;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

bSetDefault: The default values of the VAR_IN_OUT variables are adopted with a rising edge at this input variable.

bEnable: The block is enabled if bEnable = TRUE.

rInputValue: Input signal

bReset: Input for resetting the incorrect parameter entry via a rising edge.

VAR_OUTPUT

      Name                     : Type

bEvent                   : BOOL;
bEdgeHighLimit           : BOOL;
bEdgeLowLimit            : BOOL;
bInvalidParameter        : BOOL;

bEvent: Output signal, which is switched depending on the time delays tDelayHighLimit / tDelayLowLimit, the mode bModeFixedLimit, the input signal rInputValue and the limit values rHighLimit / rLowLimit.

bEdgeHighLimit: Is TRUE for one PLC cycle after the input signal rInputValue has exceeded the variable rHighLimit for the duration of tDelayHighLimit.

bEdgeLowLimit: Is TRUE for one PLC cycle after the input signal rInputValue has undershot the variable rLowLimit for the duration of tDelayLowLimit.

bInvalidParameter: Indicates that an incorrect parameter is present at one of the variables rHighLimit, rLowLimit, tDelayHighLimit or tDelayHighLimit. An incorrect parameter entry does not lead to a standstill of the block; see description of variables. After rectifying the incorrect parameter entry, the message bInvalidParameter must be acknowledged via bReset.

VAR_IN_OUT

      Name                     : Type                 Persistent       Default           Range

bModeFixedLimit          : BOOL;                    X             TRUE
rHighLimit               : REAL;                    X             22.0
rLowLimit                : REAL;                    X             18.0
tDelayHighLimit          : TIME;                    X             t#1s         t#0s .. t#3600s
tDelayLowLimit           : TIME;                    X             t#1s         t#0s .. t#3600s

bModeFixedLimit: If bModeFixedLimit = TRUE then the output variable bEvent becomes TRUE if the input signal rInputValue has exceeded the variable rHighLimit for the duration of tDelayHighLimit. If bEvent = TRUE, then bEdgeHighLimit is set for one PLC cycle. If the input signal rInputValue undershoots the variable rLowLimit for the duration of tDelayLowLimit, then bEvent becomes FALSE and bEdgeLowLimit is set for one PLC cycle.
If bModeFixedLimit = FALSE then the output variable bEvent becomes TRUE if the input signal rInputValue has undershot the variable rLowLimit for the duration of tDelayLowLimit. If bEvent = TRUE, then bEdgeLowLimit is set for one PLC cycle. If the input signal rInputValue exceeds the variable rHighLimit for the duration of tDelayHighLimit, then bEvent becomes FALSE and bEdgeHighLimit is set for one PLC cycle.

rHighLimit: Upper limit value.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

rLowLimit: Lower limit value.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tDelayHighLimit: Switching delay when passing beyond the upper limit.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

tDelayLowLimit: Switching delay when passing beyond the lower limit.
If no correct variable value is present, then the last valid variable value will be taken. If no valid last value exists, operation continues with the default value. bInvalidParameter will be set in the event of an incorrect parameter entry; the function block continues to work normally.

Behavior of the output value


FB_HVACFreezeProtectionHeater

Application

This function block is for the frost protection monitoring of an air heater in an air conditioning system. Frost protection monitoring takes place both on the air side via a frost protection thermostat and on the water side via a temperature sensor in the heater return flow.

The frost protection program is activated if the return flow temperature of the air heater rReturnWaterTemp is lower than the limit value rReturnWaterAlarmLimit or if the input bThermostat is FALSE = error.
For each of these errors, the respective message bAlarmReturnWaterTemp and/or bAlarmThermostat at the output of the function block is TRUE. Similarly, the output bAlarmFrost becomes TRUE and the activation of the frost protection program is indicated by a TRUE at the output variable bFrostProtectionRunning.

In order to avoid the air heater freezing up when the frost protection is activated, the heater pump must be switched on and the heater valve compulsorily opened. In many systems this function is implemented not only on the software side, but for reasons of safety on the hardware side also by means of a relay in the control cabinet. In the normal case the frost protection relay is self-latched, since the frost protection circuit is based on the quiescent current principle. Following an error the frost protection relay is normally brought back to its self-latched state by a reset button on the control cabinet. This function is implemented automatically by means of a short pulse at the output bHardwareReset. The condition for this is that the frost protection thermostat has returned to its normal state, the temperature in the return flow of the heater has reached the value of rReturnWaterNormalLimit and the time tDelayFirstWarning has elapsed.

Once the system has restarted following an automatic reset, the timer tMonitoringAfterReset is started.
If another frost warning occurs during this time, the output bAlarmFrost becomes TRUE again. It is only possible to reset the frost alarm by means of a rising edge at the input bReset.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bThermostat               : BOOL;
rReturnWaterTemp          : REAL;
bCtrlVoltage              : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bThermostat: Signal from the frost protection thermostat. In the normal case TRUE.

rReturnWaterTemp: Water temperature in the return flow of the air heater.

bCtrlVoltage: Control voltage monitor. If control voltage is present bCtrlVoltage = TRUE.

bReset: Input for resetting the error.

VAR_OUTPUT

      Name                      : Type

byState                   : BYTE;
bFrostProtecRunning       : BOOL;
bHardwareReset            : BOOL;
bErrorGeneral             : BOOL;
bAlarmFrost               : BOOL;
bAlarmReturnWaterTemp     : BOOL;
bAlarmThermostat          : BOOL;
byError                   : BYTE;
bInvalidParameter         : BOOL;

byState: Output of the status as a byte.

byState.0 := bFrostProtecRunning;
byState.1 := bHardwareReset;
byState.2 := bThermostat;
byState.7 := bCtrlVoltage;

bFrostProtecRunning: TRUE if the frost protection program is active.

bHardwareReset: Output that indicates with a 1 s pulse that the frost protection relay is self-latched again following an error.

bErrorGeneral: There is a general error.

bAlarmFrost: TRUE if there is a frost warning.

bAlarmReturnWaterTemp: The water temperature limit in the return flow of the air heater was undershot.

bAlarmThermostat: TRUE if there is an error in the frost protection thermostat.

byError: Output of the error as a byte.

byError.1 := bInvalidParameter;
byError.2 := bErrorGeneral;
byError.3 := bAlarmFrost;
byError.4 := bAlarmReturnWaterTemp;
byError.5 := bAlarmThermostat;

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                       : Type           Persistent       Range       Unit

rReturnWaterAlarmLimit     : REAL;              X            0..22       ° C
rReturnWaterNormalLimit    : REAL;              X            0..70       ° C
tDelayHardwareReset        : TIME;              X
tMonitoringAfterReset      : TIME;              X

rReturnWaterAlarmLimit: The frost alarm is activated below the temperature value rReturnWaterAlarmLimit in the return flow of the air heater.

rReturnWaterNormalLimit: The air heater returns to its normal state when the temperature is once again above bReturnWaterNormalLimit
 following the temperature having been undershot.

tDelayHardwareReset: Time that elapses, after input, between the input of the frost error and output of a reset pulse in order to return the system to normal operation.

tMonitoringAfterReset: Monitoring time after the first frost warning.


FB_HVACMux8

Application

This function block serves to interpret the FiFo memory of the FB_HVACRedundancyCtrlEx. The inputs are being mapped to the according outputs via the FiFo table.

If this block e.g. is being used to run rotation spedd controlled fans, the setpoints of a controller cascade can be allocated to the according outputs (fans). The setpoints are being applied to the inputs of the FB_HVACMux8. The processing is carried out with the help of the information out off the FiFo memory (which fan is running and in which order have they been switched on).

Example:

There are 4 fans with frequency converters (SetFC1 - SetFC4). A maximum amount of 3 is allowed to run at the same time. The control range (0 - 300%) is being separeted in 3 setpoints. The output arrFiFo of the FB_HVACRedundancyCtrlEx provides the assignment to the FB_HVACMux8. In the example the array includes: 2,3,0,0,0,0,0,0. The switching order was Q2 and Q3.

VAR_INPUT

      Name                       : Type                               Range

arrFiFo                    : Array[1..8] of INT;           0 - 8
rIn1 - rIn8             : REAL;

arrFiFo: Includes the allocation table. The first value states where the first value will be copied, etc. . Similar values are allowed. When a value is "0" the allocation does not take place.

rIn1 - 8: Setpoints that have to be mapped.

VAR_OUTPUT

      Name                    : Type

rQ1 - rQ8               : REAL;
bErr                  : BOOL;

rQ1 -rQ8: Actuator setpoint, input value according ti Fifo table.

bErr: Range of values in the FiFo table is invalid (valid 0-8).


FB_HVACMUX_INT_16

Application

This function block contains two different types of multiplexers, one each for the operating modes eHVACCtrlMode_Auto and eHVACCtrlMode_Manual. This selection is made with the help of the Enum eCtrlMode.
The following conditions must first be fulfilled for this:

bEnable = TRUEAND bError = FALSE

If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.

If eCtrlMode = eHVACCtrlMode_Manual, the output iValueNumber is determined by the value of the variable iManualValue. The variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account in this operating mode.

The output iValueNumber always indicates the number of the variable iValueX, whose content is output in the output variable iValueOut.

Examples of eCtrlMode = eHVACCtrlMode_Auto

- If bDirection = FALSEAND iNumberOfValues = 12 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues(12) and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.

- If bDirection = TRUEAND iNumberOfValues = 8 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(8) and hence iValueOut = iValue8.

The start behaviour of the outputs iValueNumber and iValueOut is as follows:

- If bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and hence iValueOut = iValue1.

- If bDirection = TRUEAND iNumberOfValues = 12, then iNumberOfValues = 12 and hence iValueOut = iValue12.

Examples of eCtrlMode = eHVACCtrlMode_Manual

- The value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that iValueOut = iValue7.

The start behaviour of the outputs iValueNumber and iValueOut is as follows:

- If iManualValue = 13, then iValueNumber = 13 and hence iValueOut = iValue13.

- If iManualValue = 0, then iValueNumber = 0 and hence iValueOut = 0.

A frequently changing variable may not be applied to the VAR_IN_OUT variables iValue1-16 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables iValue1-16 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
iNumberOfValues           : INT;                      1..16
bEdgeNewValue             : BOOL;
bDirection                : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                      0..16

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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then iValueOut and iValueNumber are set constantly to 0.

iNumberOfValues: Indicates the number of variables iValue1-16 that can be output via iValueOut. If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables iValue1 to iValue8 are then taken into account for the output iValueOut, see Application
iNumberOfValues determines the start behaviour of the outputs iValueOut and iValueNumber, see Application
iNumberOfValues is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.
iNumberOfValues must not fall below 1 and must not exceed 16. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

bEdgeNewValue: If there is a rising edge on bEdgeNewValue, then iValueNumber increments or decrements.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 12 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(12) and hence iValueOut = iValue12.
bEdgeNewValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

bDirection: bDirection determines the direction of action of the function block.
bDirection = FALSE means that iValueNumber is incremented in ascending form from 1 to iNumberOfValues and thus determines the output value iValueOut, see Application
bDirection = TRUE means that iValueNumber is decremented in descending form from iNumberOfValues to 1 and thus determines the output value iValueOut, see Application
bDirection is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

eCtrlMode: The operating mode of the function block is specified by means of this Enum, see Application
If the operating mode eCtrlMode = eHVACCtrlMode_Auto, then the variable iManualValue is not taken into account.
If the operating mode eCtrlMode = eHVACCtrlMode_Manual, then the variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account.

iManualValue: If the operating mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUEAND bError = FALSEAND iManualValue = 15, then iValueNumber = 15. The contents of the variable iValue15 are then output via iValueOut, see Application.
iManualValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual. The value of iValueNumber is determined by iManualValue. iManualValue should lie within the range of 0 to 16. If iManualValue falls below the value 0, then 0 is output via iValueNumber. If iManualValue exceeds the value 16, then 16 is output via iValueNumber. If iManualValue = 0, then iValueNumber = 0 and hence iValueOut = 0.

VAR_OUTPUT

      Name
      : Type              Range

iValueOut                       : INT;
bActive                         : BOOL;
bEdgeNewValueOut                : BOOL;
iValueNumber                    : INT;
bError                          : BOOL;
eErrorCode                      : E_HVACErrorCodes;

iValueOut: The value of the variable iValue1-16 is output via iValueOut.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 12 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(12) and hence iValueOut = iValue12.
If bEnable = TRUEAND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that iValueOut = iValue7.

The start behaviour of the output iValueOut is as follows, if bEnable = TRUEAND bError = FALSEAND

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and iValueOut = iValue1.

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 12, then iNumberOfValues = 12 and iValueOut = iValue12.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 13, then iValueNumber = 13 and iValueOut = iValue13.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto.

2. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewValueOut: Is TRUE for one PLC cycle if bEnable = TRUEAND bError = FALSEAND iValueNumber changes its value.

iValueNumber: The output iValueNumber always indicates the number of the variable iValueX, whose content is output in the output variable iValueOut.
If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.
If eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue.

bError: The output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfValues. iValueOut and iValueNumber are set constantly to 0 and the Enum eErrorCode indicate the error code. The message bError does not have to be acknowledged after rectification of the error.

eErrorCode: Supplies the error number when the output bError is set. The following error can occur in this function block:

eHVACErrorCodes_InvalidParam_iNumberOfValues: There is an incorrect value on iNumberOfValues. iNumberOfValues must not fall below 1 and must not exceed 16.

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_InvalidParam_iNumberOfValues = 42

VAR_IN_OUT

      Name                      : Type            Persistent

iValue1-16                : INT;                X

iValue1-16: The value of the output variable iValueOut is determined by the variables iValue1 to iValue16. If iValueNumber = 6, then iValueOut = iValue6.
If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables iValue1 to iValue8 are then taken into account for the output iValueOut if the operating mode eCtrlMode = eHVACCtrlMode_Auto, see Application


FB_HVACMUX_INT_8

Application

This function block contains two different types of multiplexers, one each for the operating modes eHVACCtrlMode_Auto and eHVACCtrlMode_Manual. This selection is made with the help of the Enum eCtrlMode.
The following conditions must first be fulfilled for this:

bEnable = TRUEAND bError = FALSE

If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.

If eCtrlMode = eHVACCtrlMode_Manual, the output iValueNumber is determined by the value of the variable iManualValue. The variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account in this operating mode.

The output iValueNumber always indicates the number of the variable iValueX, whose content is output in the output variable iValueOut.

Examples of eCtrlMode = eHVACCtrlMode_Auto

- If bDirection = FALSEAND iNumberOfValues = 7 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 4, then iValueOut = iValue4. If iValueNumber = iNumberOfValues(7) and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.

- If bDirection = TRUEAND iNumberOfValues = 8 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 3, then iValueOut = iValue3. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(8) and hence iValueOut = iValue8.

The start behaviour of the outputs iValueNumber and iValueOut is as follows:

- If bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and iValueOut = iValue1.

- If bDirection = TRUEAND iNumberOfValues is = 6, then iNumberOfValues = 6 and iValueOut = iValue6.

Examples of eCtrlMode = eHVACCtrlMode_Manual

- The value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that iValueOut = iValue7.

The start behaviour of the outputs iValueNumber and iValueOut is as follows:

- If iManualValue = 13, then iValueNumber = 13 and iValueOut = iValue13.

- If iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.

A frequently changing variable may not be applied to the VAR_IN_OUT variables iValue1-8 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables iValue1-8 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
iNumberOfValues           : INT;                      1..8
bEdgeNewValue             : BOOL;
bDirection                : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                      0..8

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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then iValueOut and iValueNumber are set constantly to 0.

iNumberOfValues: Indicates the number of variables iValue1-8 that can be output via iValueOut. If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables iValue1 to iValue8 are then taken into account for the output iValueOut, see Application
iNumberOfValues determines the start behaviour of the outputs iValueOut and iValueNumber, see Application
iNumberOfValues is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.
iNumberOfValues must not fall below 1 and must not exceed 8. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

bEdgeNewValue: If there is a rising edge on bEdgeNewValue, then iValueNumber increments or decrements.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 6 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(6) and hence iValueOut = iValue6.
bEdgeNewValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

bDirection: bDirection determines the direction of action of the function block.
bDirection = FALSE means that iValueNumber is incremented in ascending form from 1 to iNumberOfValues and thus determines the output value iValueOut, see Application
bDirection = TRUE means that iValueNumber is decremented in descending form from iNumberOfValues to 1 and thus determines the output value iValueOut, see Application
bDirection is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

eCtrlMode: The operating mode of the function block is specified by means of this Enum, see Application
If the operating mode eCtrlMode = eHVACCtrlMode_Auto, then the variable iManualValue is not taken into account.
If the operating mode eCtrlMode = eHVACCtrlMode_Manual, then the variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account.

iManualValue: If the operating mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUEAND bError = FALSEAND iManualValue = 15, then iValueNumber = 15. The contents of the variable iValue15 are then output via iValueOut, see Application.
iManualValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual. The value of iValueNumber is determined by iManualValue. iManualValue should lie within the range of 0 to 16. If iManualValue falls below the value 0, then 0 is output via iValueNumber. If iManualValue exceeds the value 16, then 16 is output via iValueNumber. If iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.

VAR_OUTPUT

      Name

      : Type              Range

iValueOut                       : INT;
bActive                         : BOOL;
bEdgeNewValueOut                : BOOL;
iValueNumber                    : INT;
bError                          : BOOL;
eErrorCode                      : E_HVACErrorCodes;

iValueOut: The value of the variable iValue1-8 is output via iValueOut.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 7 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(7) and hence iValueOut = iValue7.
If bEnable = TRUEAND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that iValueOut = iValue7.

The start behaviour of the output iValueOut is as follows, if bEnable = TRUEAND bError = FALSEAND

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and iValueOut = iValue1.

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 7, then iNumberOfValues = 7 and iValueOut = iValue7.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 13, then iValueNumber = 13 and iValueOut = iValue13.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto.

2. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewValueOut: Is TRUE for one PLC cycle if bEnable = TRUEAND bError = FALSEAND iValueNumber changes its value.

iValueNumber: The output iValueNumber always indicates the number of the variable iValueX, whose content is output in the output variable iValueOut.
If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.
If eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue.

bError: The output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfValues. iValueOut and iValueNumber are set constantly to 0 and the Enum eErrorCode indicate the error code. The message bError does not have to be acknowledged after rectification of the error.

eErrorCode: Supplies the error number when the output bError is set. The following error can occur in this function block:

eHVACErrorCodes_InvalidParam_iNumberOfValues: There is an incorrect value on iNumberOfValues. iNumberOfValues must not fall below 1 and must not exceed 8.

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_InvalidParam_iNumberOfValues = 42

VAR_IN_OUT

      Name                      : Type            Persistent

iValue1-8                : INT;                X

iValue1-8: The value of the output variable iValueOut is determined by the variables iValue1 to iValue8. If iValueNumber = 6, then iValueOut = iValue6.
If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables iValue1 to iValue8 are then taken into account for the output iValueOut if the operating mode eCtrlMode = eHVACCtrlMode_Auto, see Application


FB_HVACMUX_REAL_16

Application

This function block contains two different types of multiplexers, one each for the operating modes eHVACCtrlMode_Auto and eHVACCtrlMode_Manual. This selection is made with the help of the Enum eCtrlMode.
The following conditions must first be fulfilled for this:

bEnable = TRUEAND bError = FALSE

If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.

If eCtrlMode = eHVACCtrlMode_Manual, the output iValueNumber is determined by the value of the variable iManualValue. The variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account in this operating mode.

The output iValueNumber always indicates the number of the variable rValueX, whose content is output in the output variable rValueOut.

Examples of eCtrlMode = eHVACCtrlMode_Auto

- If bDirection = FALSEAND iNumberOfValues = 12 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then rValueOut = rValue6. If iValueNumber = iNumberOfValues(12) and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.

- If bDirection = TRUEAND iNumberOfValues = 8 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then rValueOut = rValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(8) and hence rValueOut = rValue8.

The start behaviour of the outputs iValueNumber and rValueOut is as follows:

- If bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and hence rValueOut = rValue1.

- If bDirection = TRUEAND iNumberOfValues = 12, then iNumberOfValues = 12 and hence rValueOut = rValue12.

Examples of eCtrlMode = eHVACCtrlMode_Manual

- The value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that rValueOut = rValue7.

The start behaviour of the outputs iValueNumber and rValueOut is as follows:

- If iManualValue = 13, then iValueNumber = 13 and rValueOut = rValue13.

- If iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.

A frequently changing variable may not be applied to the VAR_IN_OUT variables rValue1-16 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables rValue1-16 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
iNumberOfValues           : INT;                      1..16
bEdgeNewValue             : BOOL;
bDirection                : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                      0..16

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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then rValueOut and iValueNumber are set constantly to 0.

iNumberOfValues: Indicates the number of variables rValue1-16 that can be output via rValueOut. If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables rValue1 to rValue8 are then taken into account for the output rValueOut, see Application
iNumberOfValues determines the start behaviour of the outputs rValueOut and iValueNumber, see Application
iNumberOfValues is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.
iNumberOfValues must not fall below 1 and must not exceed 16. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

bEdgeNewValue: If there is a rising edge on bEdgeNewValue, then iValueNumber increments or decrements.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then rValueOut = rValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 12 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then rValueOut = rValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(12) and hence rValueOut = rValue12.
bEdgeNewValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

bDirection: bDirection determines the direction of action of the function block.
bDirection = FALSE means that iValueNumber is incremented in ascending form from 1 to iNumberOfValues and thus determines the output value iValueOut, see Application
bDirection = TRUE means that iValueNumber is decremented in descending form from iNumberOfValues to 1 and thus determines the output value rValueOut, see Application
bDirection is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

eCtrlMode: The operating mode of the function block is specified by means of this Enum, see Application
If the operating mode eCtrlMode = eHVACCtrlMode_Auto, then the variable iManualValue is not taken into account.
If the operating mode eCtrlMode = eHVACCtrlMode_Manual, then the variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account.

iManualValue: If the operating mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUEAND bError = FALSEAND iManualValue = 15, then iValueNumber = 15. The contents of the variable rValue15 are then output via rValueOut, see Application.
iManualValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual. The value of iValueNumber is determined by iManualValue. iManualValue should lie within the range of 0 to 16. If iManualValue falls below the value 0, then 0 is output via iValueNumber. If iManualValue exceeds the value 16, then 16 is output via iValueNumber. If iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.

VAR_OUTPUT

      Name
      : Type              Range

rValueOut                       : REAL;
bActive                         : BOOL;
bEdgeNewValueOut                : BOOL;
iValueNumber                    : INT;
bError                          : BOOL;
eErrorCode                      : E_HVACErrorCodes;

rValueOut: The value of the variable rValue1-16 is output via rValueOut.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then rValueOut = rValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 12 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then rValueOut = rValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(12) and hence rValueOut = rValue12.
If bEnable = TRUEAND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that rValueOut = rValue7.

The start behaviour of the output rValueOut is as follows, if bEnable = TRUEAND bError = FALSEAND

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and rValueOut = rValue1.

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 12, then iNumberOfValues = 12 and rValueOut = rValue12.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 13, then iValueNumber = 13 and rValueOut = rValue13.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto.

2. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewValueOut: Is TRUE for one PLC cycle if bEnable = TRUEAND bError = FALSEAND iValueNumber changes its value.

iValueNumber: The output iValueNumber always indicates the number of the variable rValueX, whose content is output in the output variable rValueOut.
If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.
If eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue.

bError: The output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfValues. rValueOut and iValueNumber are set constantly to 0 and the Enum eErrorCode indicate the error code. The message bError does not have to be acknowledged after rectification of the error.

eErrorCode: Supplies the error number when the output bError is set. The following error can occur in this function block:

eHVACErrorCodes_InvalidParam_iNumberOfValues: There is an incorrect value on iNumberOfValues. iNumberOfValues must not fall below 1 and must not exceed 16.

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_InvalidParam_iNumberOfValues = 42

VAR_IN_OUT

      Name                      : Type            Persistent

rValue1-16                : REAL;               X

rValue1-16: The value of the output variable rValueOut is determined by the variables rValue1 to rValue16. If iValueNumber = 6, then rValueOut = rValue6.
If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables rValue1 to rValue8 are then taken into account for the output rValueOut if the operating mode eCtrlMode = eHVACCtrlMode_Auto, see Application


FB_HVACMUX_REAL_8

Application

This function block contains two different types of multiplexers, one each for the operating modes eHVACCtrlMode_Auto and eHVACCtrlMode_Manual. This selection is made with the help of the Enum eCtrlMode.
The following conditions must first be fulfilled for this:

bEnable = TRUEAND bError = FALSE

If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.

If eCtrlMode = eHVACCtrlMode_Manual, the output iValueNumber is determined by the value of the variable iManualValue. The variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account in this operating mode.

The output iValueNumber always indicates the number of the variable rValueX, whose content is output in the output variable rValueOut.

Examples of eCtrlMode = eHVACCtrlMode_Auto

- If bDirection = FALSEAND iNumberOfValues = 7 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 4, then rValueOut = rValue4. If iValueNumber = iNumberOfValues(7) and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.

- If bDirection = TRUEAND iNumberOfValues = 8 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 3, then rValueOut = rValue3. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(8) and hence rValueOut = rValue8.

The start behaviour of the outputs iValueNumber and rValueOut is as follows:

- If bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and hence rValueOut = rValue1.

- If bDirection = TRUEAND iNumberOfValues is = 6, then iNumberOfValues = 6 and hence rValueOut = rValue6.

Examples of eCtrlMode = eHVACCtrlMode_Manual

- The value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that rValueOut = rValue7.

The start behaviour of the outputs iValueNumber and rValueOut is as follows:

- If iManualValue = 13, then iValueNumber = 13 and rValueOut = rValue13.

- If iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.

A frequently changing variable may not be applied to the VAR_IN_OUT variables rValue1-8 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables rValue1-8 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
iNumberOfValues           : INT;                      1..8
bEdgeNewValue             : BOOL;
bDirection                : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                      0..8

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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then rValueOut and iValueNumber are set constantly to 0.

iNumberOfValues: Indicates the number of variables rValue1-8 that can be output via rValueOut. If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables rValue1 to rValue8 are then taken into account for the output rValueOut, see Application
iNumberOfValues determines the start behaviour of the outputs rValueOut and iValueNumber, see Application
iNumberOfValues is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.
iNumberOfValues must not fall below 1 and must not exceed 8. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.

bEdgeNewValue: If there is a rising edge on bEdgeNewValue, then iValueNumber increments or decrements.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then rValueOut = rValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and rValueOut = rValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 6 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then rValueOut = rValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(6) and rValueOut = rValue6.
bEdgeNewValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

bDirection: bDirection determines the direction of action of the function block.
bDirection = FALSE means that iValueNumber is incremented in ascending form from 1 to iNumberOfValues and thus determines the output value iValueOut, see Application
bDirection = TRUE means that iValueNumber is decremented in descending form from iNumberOfValues to 1 and thus determines the output value rValueOut, see Application
bDirection is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual.

eCtrlMode: The operating mode of the function block is specified by means of this Enum, see Application
If the operating mode eCtrlMode = eHVACCtrlMode_Auto, then the variable iManualValue is not taken into account.
If the operating mode eCtrlMode = eHVACCtrlMode_Manual, then the variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account.

iManualValue: If the operating mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUEAND bError = FALSEAND iManualValue = 15, then iValueNumber = 15. The contents of the variable rValue15 are then output via rValueOut, see Application.
iManualValue is not taken into account in the operating mode eCtrlMode = eHVACCtrlMode_Manual. The value of iValueNumber is determined by iManualValue. iManualValue should lie within the range of 0 to 16. If iManualValue falls below the value 0, then 0 is output via iValueNumber. If iManualValue exceeds the value 16, then 16 is output via iValueNumber. If iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.

VAR_OUTPUT

      Name
      : Type              Range

rValueOut                       : INT;
bActive                         : BOOL;
bEdgeNewValueOut                : BOOL;
iValueNumber                    : INT;
bError                          : BOOL;
eErrorCode                      : E_HVACErrorCodes;

rValueOut: The value of the variable rValue1-8 is output via rValueOut.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber increments. If iValueNumber = 6, then rValueOut = rValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and rValueOut = rValue1.
If bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 7 and there is a rising edge on bEdgeNewValue, then iValueNumber decrements. If iValueNumber = 5, then rValueOut = rValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(7) and rValueOut = rValue7.
If bEnable = TRUEAND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that rValueOut = rValue7.

The start behaviour of the output rValueOut is as follows, if bEnable = TRUEAND bError = FALSEAND

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND iNumberOfValues > 0, then iValueNumber = 1 and rValueOut = rValue1.

- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND iNumberOfValues = 7, then iNumberOfValues = 7 and rValueOut = rValue7.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 13, then iValueNumber = 13 and rValueOut = rValue13.

- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Auto.

2. bEnable = TRUEAND bError = FALSEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewValueOut: Is TRUE for one PLC cycle if bEnable = TRUEAND bError = FALSEAND iValueNumber changes its value.

iValueNumber: The output iValueNumber always indicates the number of the variable rValueX, whose content is output in the output variable rValueOut.
If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection is used to determine whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.
If eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue.

bError: The output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfValues. rValueOut and iValueNumber are set constantly to 0 and the Enum eErrorCode indicate the error code. The message bError does not have to be acknowledged after rectification of the error.

eErrorCode: Supplies the error number when the output bError is set. The following error can occur in this function block:

eHVACErrorCodes_InvalidParam_iNumberOfValues: There is an incorrect value on iNumberOfValues. iNumberOfValues must not fall below 1 and must not exceed 8.

To access the enum error number in the PLC eErrorCode can assigned to a variable of data type WORD.
eHVACErrorCodes_InvalidParam_iNumberOfValues = 42

VAR_IN_OUT

      Name                      : Type            Persistent

rValue1-8                : INT;                X

rValue1-8: The value of the output variable rValueOut is determined by the variables rValue1 to rValue8. If iValueNumber = 6, then rValueOut = rValue6.
If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables rValue1 to rValue8 are then taken into account for the output rValueOut if the operating mode eCtrlMode = eHVACCtrlMode_Auto, see Application


FB_HVACOverwriteAnalog

Application

This function block overrides the input rValueIn in the case that eCtrlMode = eHVACCtrlMode_Manual, and writes the rManualValueIn to the output rValueOut.

VAR_INPUT

      Name                    :Type

rValueIn                :REAL;
eCtrlMode               :E_HVACCtrlMode;
rManualValueIn          :REAL;

rValueIn: Analog input value which is written to rValueOut if eCtlrMode = eHVACCtrlMode_Auto.

eCtrlMode: Enum to choose the operating mode. Hand or automatic mode.

rManualValueIn: Analog manual input value that will be written to the output rValueOut, if eCtrlMode = eHVACCtrlMode_Manual.

VAR_OUTPUT

      Name                    :Type

rValueOut               :REAL;

rValueOut: Analog output value.

.


FB_HVACOverwriteDigital

Application

This function block overrides the condition of the input bIn, in case that eCtrlMode = eHVACCtrlMode_Manual, and writes it to the output bOut

VAR_INPUT

      Name                    :Type

bIn                     :BOOL;
eCtrlMode               :E_HVACCtrlMode;
bManualIn               :BOOL;

bIn: Digital input variable whose condition is written to the output bOut, if eCtlrMode = eHVACCtrlMode_Auto.

eCtrlMode: Enum to choose the operating mode. Hand or automatic mode.

b ManualIn: Digital input variable that will be written to the output bOut, if eCtrlMode = eHVACCtrlMode_Manual.

VAR_OUTPUT

      Name                    :Type

bOut                    :BOOL;

bOut: Digital output variable.

.


FB_HVACPowerMeasurementKL3403

Application

This function block serves to control a 3-phase power measurement terminal (KL/KS3403). The terminal data is read out and all variables that depend on it are derived. The KL3403 Bus Terminal enables the measurement of all relevant electrical data of the supply network. The voltage is measured via the direct connection of L1, L2, L3 and N. The current of the three phases L1, L2 and L3 is fed via simple current transformers. All measured currents and voltages are available as root-mean-square values. In the KL3403 version, the effective power and the energy consumption for each phase are calculated. Through the relationship of the rms values of voltage U * current I and the effective power P, all other information such as apparent power or phase shift angle cos φ can be derived. For each fieldbus, KL3403 provides a comprehensive network analysis and an energy management option. The data is read out in 8 groups one after the other. Dependent values are calculated cyclically. The energy measurement is read out from the terminal as a 32-bit value with the overflow from register 1. The input bDelEnergyConsumption can be used to delete this metered measurand.

Attention The input and output variables wDataL1, wDataL2, wDataL3, bySBL1, bySBL2, bySBL3, byCBL1, byCBL2, byCBL3, iDataOutL1, iDataOutL2 und iDataOutL3 must be link to the busterminal KL3403. These will be used to get all data from busterminal.

The results of the power measurement are available in the output structure ST_HVACPowerMeasurement. The structure is 120 bytes long.

TYPE ST_HVACPowerMeasurement

      Name                                   : Type       Unit        Description

STRUCT
  diIL1, diIL2, diIL3                  : DINT;       A        Ieff current (effective value); resolution: 0.1 A
  diUL1, diUL2, diUL3                  : DINT;       V        Ueff voltage (effective value); resolution: 0.1 V
  diPL1, diPL2, diPL3                  : DINT;      kW        P effective power per phase; resolution: 0.1 kW
  diPg                                 : DINT;      kW        Ptot effective power; resolution: 0.1 kW
  diCosPhiL1, diCosPhiL2, diCosPhiL3   : DINT;                cosPhi power factor per phase; resolution: 0.01
  diCosPhi                             : DINT;                cosPhitot power factor; resolution: 0.01
  diWL1, diWL2, diWL3                  : DINT;      kWh       Energy consumption; resolution: 1 kWh
  diWg                                 : DINT;      kWh       Energy consumption; resolution: 1 kWh
  diImaxL1, diImaxL2, diImaxL3         : DINT;       A        Imax peak current value; resolution: 0.1 A
  diUmaxL1, diUmaxL2, diUmaxL3         : DINT;       V        Umax peak voltage value; resolution: 0.1 V
  diPmaxL1, diPmaxL2, diPmaxL3         : DINT;      kW        Pmax peak effective power value; resolution: 0.1 kW
  diSg                                 : DINT;      kVA       Stot apparent power; resolution: 0.1 kVA
  diQg                                 : DINT;      kvar      Qtot idle power; resolution: 0.1 kvar
  dummy                                : DINT;                Reserve, fills up the structure to 120 bytes
END_STRUCT

VAR_INPUT

      Name                            : Type

wDataL1, wDataL2, wDataL3       : WORD;
bySBL1, bySBL2, bySBL3          : BYTE;
diCurrTransFactor               : DINT;
eModePowerMeasurement           : E_HVACPowerMeasurementMode;
bDelEnergyConsumption           : BOOL;

wDataLx: Input data from the three channels of the KL3403.

bySBLx: Status byte of the three channels of the KL3403. Reports which value can be read via the input (wDataLx).

diCurrTransFactor: Transformation factor of the current transformer, serves to convert the actual strand current and the values associated with it. Independent from terminal device the output for rated value is dec. 1000 (100.0%). The primary transformation factor must be specified.

Example KL3403-0000: Transformer 400/1A follows a diCurrTransFactor of 400. A rated value of max. 1A, follows an output rated value by a internal resolution of 0.001A dec. 1000 (100.0%) * diCurrTransFactor = 400A.

Example KL3403-0010: Transformer 400/5A follows a diCurrTransFactor of 400. A rated value of max. 5A, follows an output rated value by a internal resolution of 0.005A dec. 1000 (100.0%) * diCurrTransFactor = 400A.

eModePowerMeasurement: If the value of this parameter lies between 1 and 8, the automatic read-out of all data is interrupted and only the corresponding parameter is read per cycle.
TYPE E_HVACPowerMeasurementMode :
(
eHVACPowerMeasurementMode_AutoAllValues:= 0,
eHVACPowerMeasurementMode_Current:= 1,
eHVACPowerMeasurementMode_Voltage:= 2,
eHVACPowerMeasurementMode_EffectivePower:= 3,
eHVACPowerMeasurementMode_EnergyConsumption:= 4,
eHVACPowerMeasurementMode_PeakCurrentValue:= 5, 1)
eHVACPowerMeasurementMode_PeakVoltageValue:= 6, 1)
eHVACPowerMeasurementMode_PeakPowerValue:= 7 1)
);
END_TYPE

bDelEnergyConsumption : A rising edge at this input deletes the energy consumption in the EEPROM. The energy consumption is counted in RAM and saved every 15 minutes in the EEPROM.
It is retained there even if the KL3403 is switched off.

1) The minimum and peak values are deleted when the KL3403 is switched off.

VAR_OUTPUT

      Name                                       : Type

bDelEnergyMeasuredValuesBusy               : BOOL;
bError                                     : BOOL;
iErrID                                     : UDINT;
byCBL1, byCBL2, byCBL3                     : BYTE;
iDataOutL1, iDataOutL2, iDataOutL3         : INT;
stQ_PowerMeasurement                       : ST_HVACPowerMeasurement;

bDelEnergyMeasuredValuesBusy : Due to the fact that the measured energy values have to be erased out off the EEPROM, no value will be updated during this time and the flag bDelEnergyMeasuredValuesBusy shows TRUE.

bError : TRUE, when an error occurred in the register communication.

iErrID : Error ID of the register communication

0x100 Timeout Error. The allowed execution time elapsed.
0x200 Parameter Error (e.g. at an incorrect register number).
0x300 The gathered value differs from the written the written value ( write access to this register is possibly not allowed or has failed)

byCBLx: This output serves to choose the desired input value and for the register communication to erase the saved values of energy consumption.

iDataOutL1: This output serves for register communication to erase the saved values of energy consumption.

stQ_PowerMeasurement: The results of the power measurement as an output data structure

The example shows how a KL3403 terminal must be linked to the input and output variables of the PLC:


FB_HVACPowerMeasurementKL3403Ex

Application

This function block serves to control a 3-phase power measurement terminal (KL/KS3403). The terminal data is read out and all variables that depend on it are derived. The KL3403 Bus Terminal enables the measurement of all relevant electrical data of the supply network. The voltage is measured via the direct connection of L1, L2, L3 and N. The current of the three phases L1, L2 and L3 is fed via simple current transformers. All measured currents and voltages are available as root-mean-square values. In the KL3403 version, the effective power and the energy consumption for each phase are calculated. Through the relationship of the rms values of voltage U * current I and the effective power P, all other information such as apparent power or phase shift angle cos φ can be derived. For each fieldbus, KL3403 provides a comprehensive network analysis and an energy management option. The data is read out in 8 groups one after the other. Dependent values are calculated cyclically. The energy measurement is read out from the terminal as a 32-bit value with the overflow from register 1. The input bDelEnergyConsumption can be used to delete this metered measurand.

Attention The input and output variables wDataL1, wDataL2, wDataL3, bySBL1, bySBL2, bySBL3, byCBL1, byCBL2, byCBL3, iDataOutL1, iDataOutL2 und iDataOutL3 must be link to the busterminal KL3403. These will be used to get all data from busterminal.

The results of the power measurement are available in the output structure ST_HVACPowerMeasurementEx.

The difference compared with the previous block FB_HVACPowerMeasurementKL3403 lies in the output format for the results. The results are available in the structure ST_HVACPowerMeasurementEx in LREAL format. The output was extended by the frequencies of the three phases.

TYPE ST_HVACPowerMeasurementEx

      Name                                    : Type       Unit       Description

STRUCT
  fIL1, fIL2, fIL3                              : LREAL;      A         Ieff current (RMS value)
  fIg                                   : LREAL;             A        Total current (RMS value)
  fUL1, fUL2, fUL3                              : LREAL;      V         Ueff tension (RMS value)
  fPL1, fPL2, fPL3                              : LREAL;      kW        P effective power per phase
  fPg                                   : LREAL;      kW        tot effective power
  fCosPhiL1, fCosPhiL2, fCosPhiL3               : LREAL;                cosPhi power factor per phase
  fCosPhi                               : LREAL;                cosPhitot power factor
  fWL1, fWL2, fWL3                              : LREAL;      kWh       energy consumption
  fWg                                   : LREAL;      kWh       energy consumption
  fImaxL1, fImaxL2, fImaxL3                     : LREAL;       A        Imax peak current value
  fUmaxL1, fUmaxL2, fUmaxL3                     : LREAL;       V        Umax peak voltage value
  fPmaxL1, fPmaxL2, fPmaxL3                     : LREAL;      kW        Pmax peak effective power value
  fSg                                   : LREAL;      kVA       Stot apparent power
  fQg                                   : LREAL;      kvar      Qtot reactive power
  fFrequencyL1, fFrequencyL2, fFrequencyL3      : LREAL;       Hz       frequency
END_STRUCT

VAR_INPUT

      Name                            : Type

wDataL1, wDataL2, wDataL3       : WORD;
bySBL1, bySBL2, bySBL3          : BYTE;
diCurrTransFactor               : LREAL;
bDelEnergyConsumption           : BOOL;

wDataLx: Input data from the three channels of the KL3403.

bySBLx: Status byte of the three channels of the KL3403. Reports which value can be read via the input (wDataLx).

diCurrTransFactor: Transformation factor of the current transformer, serves to convert the actual strand current and the values associated with it. Independent from terminal device the output for rated value is dec. 1000 (100.0%). The primary transformation factor must be specified.

Example KL3403-0000: Transformer 400/1A follows a diCurrTransFactor of 400. A rated value of max. 1A, follows an output rated value by a internal resolution of 0.001A dec. 1000 (100.0%) * diCurrTransFactor = 400A.

Example KL3403-0010: Transformer 400/5A follows a diCurrTransFactor of 400. A rated value of max. 5A, follows an output rated value by a internal resolution of 0.005A dec. 1000 (100.0%) * diCurrTransFactor = 400A.

bDelEnergyConsumption : A rising edge at this input deletes the energy consumption in the EEPROM. The energy consumption is counted in RAM and saved every 15 minutes in the EEPROM. It is retained there even if the KL3403 is switched off.

1) The minimum and peak values are deleted when the KL3403 is switched off.

VAR_OUTPUT

      Name                                       : Type

bDelEnergyMeasuredValuesBusy               : BOOL;
bError                                     : BOOL;
iErrID                                     : ULREAL;
byCBL1, byCBL2, byCBL3                     : BYTE;
iDataOutL1, iDataOutL2, iDataOutL3         : INT;
stQ_PowerMeasurementEx                     : ST_HVACPowerMeasurementEx;

bDelEnergyMeasuredValuesBusy: Since the measured energy values are deleted from the internal EEPROM, no value is updated during this time and the flag bDelEnergyMeasuredValuesBusy shows TRUE.

bError: If TRUE, an error has occurred in the register communication.

iErrID: Error ID in the register communication

0x100 Timeout error. The time permitted for execution has been exceeded.
0x200 Parameter error (e.g. an invalid register number).
0x300 The read value differs from the written value (write access to this register may not be enabled or have failed)

byCBLx: This output serves the selection of the desired input value and register communication in order to delete the energy consumption.

iDataOutLx:

stQ_PowerMeasurementEx: The results of the power measurement as an output data structure


FB_HVACPriority_INT_16

Application

This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output iValueOut is controlled via the events occurring at the inputs bEvent1-16, iValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events have a higher priority in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then iValueOut has the value of iValue15.
bDirection = TRUE means that the events have a higher priority in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut has the value of iValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables iValue1-16, whose value is output via iValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then iValueOut = iValue2, see Table 3.

A frequently changing variable may not be applied to the VAR_IN_OUT variables iValue1-16 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables iValue1-16 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Table 1: Prioritisation of events in ascending form from 1 to 16

It can be seen in Table 1 that bDirection = FALSE. This means that the events determine the output value iValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in column 1), then iValueOut = iValue15.

Table 2: Prioritisation of events in descending form from 16 to 1

It can be seen in Table 2 that bDirection = TRUE . This means that the events determine the output value iValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.

Table 3: Multiplexer

If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then iValueOut = 2.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
bEvent1 - bEvent8         : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                     0..16
bDirection                : 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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then iValueOut is set constantly to 0.

eCtrlMode: The operating mode of the function block is specified by means of this Enum.
If eCtrlMode = eHVACCtrlMode_Auto, then the function block represents a prioritisation of events. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto, then the output iValueOut is controlled via the events occurring at the inputs bEvent1-16, iValue1-16 and the direction of action of the prioritisation bDirection, see Table 1 and Table 2
If eCtrlMode = eHVACCtrlMode_Manual, then the function block represents a multiplexer. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual, then the value of the output iValueOut is controlled via iManualValue. If iManualProfile = 5, then iValueOut = iValue5, see Table 3

iManualProfile: If the operating mode eCtrlMode = eHVACCtrlMode_Manual (Multiplexer) AND bEnable = TRUEAND bError = FALSE, then the value of the output iValueOut is controlled via iManualValue. If iManualProfile = 5, then iValueOut = iValue5, see Table 3

bEvent1-16: The output iValueOut is controlled via the events occurring at the inputs bEvent1-16, iValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value iValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then iValueOut = iValue15.
bDirection = TRUE means that the events determine the output value iValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.
The variables bEvent1-16 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

bDirection: The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output iValueOut is controlled via the events occurring at the inputs bEvent1-16, iValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value iValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then iValueOut = iValue15.
bDirection = TRUE means that the events determine the output value iValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.
The variables bEvent1-16 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

VAR_OUTPUT

      Name
      : Type              Range

iValueOut                       : INT;
bActive                         : BOOL;
bEdgeNewEvent                   : BOOL;
iValueNumber                    : INT;

iValueOut: This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output iValueOut is controlled via the events occurring at the inputs bEvent1-16, iValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value iValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then iValueOut = iValue15.
bDirection = TRUE means that the events determine the output value iValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables iValue1-16, whose value is output via iValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then iValueOut = iValue2, see Table 3.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and one of the input variables bEvent1-16 = TRUE.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewEvent: Is TRUE for one PLC cycle if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and the decisive event (bEvent1-16) for controlling the output iValueOut by means of iValue1-16 has changed.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual and with each change of iManualValue.

iValueNumber: The variable iValueNumber indicates the variable from which the value on iValueOut is output. If iValueOut = iValue7, then iValueNumber = 7, see Table 1, Table 2 and Table 3

VAR_IN_OUT

      Name                      : Type            Persistent

iValue1-16                : INT;                X

iValue1-16: The value of the output variable iValueOut is determined by the variables iValue1 to iValue16. iValueOut = iValueX

If the function block is used to prioritise events, then each of the variables iValue1-16 is assigned to an event. iValue1 is assigned to the event bEvent1, iValue2 to the event bEvent2, iValue3 to the event bEvent3, ... and iValue16 to the event bEvent16.

If the function block is used as a multiplexer, then each of the variables iValue1-16 is assigned to the value of iManualValue. If iManualValue = 1, then iValueOut = iValue1. If iManualValue = 2, then iValueOut = iValue2.... If iManualValue = 16, then iValueOut = iValue16.


FB_HVACPriority_INT_8

Application

This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output iValueOut is controlled via the events occurring at the inputs bEvent1-8, iValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events have a higher priority in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then iValueOut has the value of iValue7.
bDirection = TRUE means that the events have a higher priority in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut has the value of iValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables iValue1-8, whose value is output via iValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then iValueOut = iValue2, see Table 3.

A frequently changing variable may not be applied to the VAR_IN_OUT variables iValue1-8 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables iValue1-8 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Table 1: Prioritisation of events in ascending form from 1 to 8

It can be seen in Table 1 that bDirection = FALSE. This means that the events determine the output value iValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in column 1), then iValueOut = iValue7.

Table 2: Prioritisation of events in descending form from 8 to 1

It can be seen in Table 2 that bDirection = TRUE . This means that the events determine the output value iValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.

Table 3: Multiplexer

If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then iValueOut = 2.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
bEvent1 - bEvent8         : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                     0..8
bDirection                : 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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then iValueOut is set constantly to 0.

eCtrlMode: The operating mode of the function block is specified by means of this Enum.
If eCtrlMode = eHVACCtrlMode_Auto, then the function block represents a prioritisation of events. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto, then the output iValueOut is controlled via the events occurring at the inputs bEvent1-8, iValue1-8 and the direction of action of the prioritisation bDirection, see Table 1 and Table 2
If eCtrlMode = eHVACCtrlMode_Manual, then the function block represents a multiplexer. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual, then the value of the output iValueOut is controlled via iManualValue. If iManualProfile = 5, then iValueOut = iValue5, see Table 3

iManualProfile: If the operating mode eCtrlMode = eHVACCtrlMode_Manual (Multiplexer) AND bEnable = TRUEAND bError = FALSE, then the value of the output iValueOut is controlled via iManualValue. If iManualProfile = 5, then iValueOut = iValue5, see Table 3

bEvent1-8: The output iValueOut is controlled via the events occurring at the inputs bEvent1-8, iValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value iValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then iValueOut = iValue7.
bDirection = TRUE means that the events determine the output value iValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.
The variables bEvent1-8 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

bDirection: The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output iValueOut is controlled via the events occurring at the inputs bEvent1-8, iValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value iValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then iValueOut = iValue7.
bDirection = TRUE means that the events determine the output value iValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.
The variables bEvent1-8 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

VAR_OUTPUT

      Name
      : Type              Range

iValueOut                       : INT;
bActive                         : BOOL;
bEdgeNewEvent                   : BOOL;
iValueNumber                    : INT;

iValueOut: This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output iValueOut is controlled via the events occurring at the inputs bEvent1-8, iValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value iValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then iValueOut = iValue7.
bDirection = TRUE means that the events determine the output value iValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables iValue1-8, whose value is output via iValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then iValueOut = iValue2, see Table 3.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and one of the input variables bEvent1-8 = TRUE.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewEvent: Is TRUE for one PLC cycle if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and the decisive event (bEvent1-8) for controlling the output iValueOut by means of iValue1-8 has changed.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual and with each change of iManualValue.

iValueNumber: The variable iValueNumber indicates the variable from which the value on iValueOut is output. If iValueOut = iValue7, then iValueNumber = 7, see Table 1, Table 2 and Table 3

VAR_IN_OUT

      Name                      : Type            Persistent

iValue1-8                : INT;                X

iValue1-8: The value of the output variable iValueOut is determined by the variables iValue1 to iValue8. iValueOut = iValueX

If the function block is used to prioritise events, then each of the variables iValue1-8 is assigned to an event. iValue1 is assigned to the event bEvent1, iValue2 to the event bEvent2, iValue3 to the event bEvent3, ... and iValue8 to the event bEvent8.

If the function block is used as a multiplexer, then each of the variables iValue1-8 is assigned to the value of iManualValue. If iManualValue = 1, then iValueOut = iValue1, if iManualValue = 2, then iValueOut = iValue2, ... and if iManualValue = 8, then iValueOut = iValue8.


FB_HVACPriority_REAL_16

Application

This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled via the events occurring at the inputs bEvent1-16, rValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events have a higher priority in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then rValueOut has the value of rValue15.
bDirection = TRUE means that the events have a higher priority in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut has the value of rValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables rValue1-16, whose value is output via rValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then rValueOut = rValue2, see Table 3.

A frequently changing variable may not be applied to the VAR_IN_OUT variables rValue1-16 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables rValue1-16 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Table 1: Prioritisation of events in ascending form from 1 to 16

It can be seen in Table 1 that bDirection = FALSE. This means that the events determine the output value rValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in column 1), then rValueOut = rValue15.

Table 2: Prioritisation of events in descending form from 16 to 1

It can be seen in Table 2 that bDirection = TRUE . This means that the events determine the output value rValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.

Table 3: Multiplexer

If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then rValueOut = 2.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
bEvent1 - bEvent8         : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                     0..16
bDirection                : 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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then rValueOut is set constantly to 0.

eCtrlMode: The operating mode of the function block is specified by means of this Enum.
If eCtrlMode = eHVACCtrlMode_Auto, then the function block represents a prioritisation of events. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto, then the output rValueOut is controlled via the events occurring at the inputs bEvent1-16, rValue1-16 and the direction of action of the prioritisation bDirection, see Table 1 and Table 2
If eCtrlMode = eHVACCtrlMode_Manual, then the function block represents a multiplexer. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual, then the value of the output rValueOut is controlled via iManualValue. If iManualProfile = 5, then rValueOut = rValue5, see Table 3

iManualProfile: If the operating mode eCtrlMode = eHVACCtrlMode_Manual (Multiplexer) AND bEnable = TRUEAND bError = FALSE, then the value of the output rValueOut is controlled via iManualValue. If iManualProfile = 5, then rValueOut = rValue5, see Table 3

bEvent1-16: The output rValueOut is controlled via the events occurring at the inputs bEvent1-16, rValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value rValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then rValueOut = rValue15.
bDirection = TRUE means that the events determine the output value rValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.
The variables bEvent1-16 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

bDirection: The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled via the events occurring at the inputs bEvent1-16, rValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value rValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then rValueOut = rValue15.
bDirection = TRUE means that the events determine the output value rValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.
The variables bEvent1-16 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

VAR_OUTPUT

      Name
      : Type              Range

rValueOut                       : REAL;
bActive                         : BOOL;
bEdgeNewEvent                   : BOOL;
iValueOut                       : INT;

rValueOut: This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled via the events occurring at the inputs bEvent1-16, rValue1-16 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value rValueOut in ascending form from 1 to 16. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent15 = TRUE (highest occurring event in Table 1 column 1), then rValueOut = rValue15.
bDirection = TRUE means that the events determine the output value rValueOut in descending form from 16 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables rValue1-16, whose value is output via rValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then rValueOut = rValue2, see Table 3.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and one of the input variables bEvent1-16 = TRUE.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewEvent: Is TRUE for one PLC cycle if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and the decisive event (bEvent1-16) for controlling the output rValueOut by means of rValue1-16 has changed.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual and with each change of iManualValue.

iValueNumber: The variable iValueNumber indicates the variable from which the value on rValueOut is output. If rValueOut = rValue7, then iValueNumber = 7, see Table 1, Table 2 and Table 3

VAR_IN_OUT

      Name                      : Type            Persistent

rValue1-16                : REAL;               X

rValue1-16: The value of the output variable rValueOut is determined by the variables rValue1 to rValue16. rValueOut = rValueX

If the function block is used to prioritise events, then each of the variables rValue1-16 is assigned to an event. rValue1 is assigned to the event bEvent1, rValue2 to the event bEvent2, rValue3 to the event bEvent3, ... and rValue16 to the event bEvent16.

If the function block is used as a multiplexer, then each of the variables rValue1-16 is assigned to the value of iManualValue. If iManualValue = 1, then rValueOut = rValue1. If iManualValue = 2, then rValueOut = rValue2.... If iManualValue = 16, then rValueOut = rValue16.


FB_HVACPriority_REAL_8

Application

This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled via the events occurring at the inputs bEvent1-8, rValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events have a higher priority in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then rValueOut has the value of rValue7.
bDirection = TRUE means that the events have a higher priority in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut has the value of rValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables rValue1-8, whose value is output via rValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then rValueOut = rValue2, see Table 3.

A frequently changing variable may not be applied to the VAR_IN_OUT variables rValue1-8 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables rValue1-8 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Table 1: Prioritisation of events in ascending form from 1 to 8

It can be seen in Table 1 that bDirection = FALSE. This means that the events determine the output value rValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in column 1), then rValueOut = rValue7.

Table 2: Prioritisation of events in descending form from 8 to 1

It can be seen in Table 2 that bDirection = TRUE . This means that the events determine the output value rValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.

Table 3: Multiplexer

If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then rValueOut = 2.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type                        Range

eDataSecurityType         : E_HVACDataSecurityType;
bEnable                   : BOOL;
bEvent1 - bEvent8         : BOOL;
eCtrlMode                 : E_HVACCtrlMode;
iManualValue              : INT;                     0..8
bDirection                : 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.

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.

bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then rValueOut is set constantly to 0.

eCtrlMode: The operating mode of the function block is specified by means of this Enum.
If eCtrlMode = eHVACCtrlMode_Auto, then the function block represents a prioritisation of events. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto, then the output rValueOut is controlled via the events occurring at the inputs bEvent1-8, rValue1-8 and the direction of action of the prioritisation bDirection, see Table 1 and Table 2
If eCtrlMode = eHVACCtrlMode_Manual, then the function block represents a multiplexer. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual, then the value of the output rValueOut is controlled via iManualValue. If iManualProfile = 5, then rValueOut = rValue5, see Table 3

iManualProfile: If the operating mode eCtrlMode = eHVACCtrlMode_Manual (Multiplexer) AND bEnable = TRUEAND bError = FALSE, then the value of the output rValueOut is controlled via iManualValue. If iManualProfile = 5, then rValueOut = rValue5, see Table 3

bEvent1-8: The output rValueOut is controlled via the events occurring at the inputs bEvent1-8, rValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value rValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then rValueOut = rValue7.
bDirection = TRUE means that the events determine the output value rValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.
The variables bEvent1-8 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

bDirection: The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled via the events occurring at the inputs bEvent1-8, rValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value rValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then rValueOut = rValue7.
bDirection = TRUE means that the events determine the output value rValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.
The variables bEvent1-8 and bDirection are taken into account only if eCtrlMode = eHVACCtrlMode_Auto.

VAR_OUTPUT

      Name
      : Type              Range

rValueOut                       : REAL;
bActive                         : BOOL;
bEdgeNewEvent                   : BOOL;
iValueNumber                    : INT;

rValueOut: This function block can be used to prioritise events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritise events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled via the events occurring at the inputs bEvent1-8, rValue1-8 and the direction of action of the prioritisation bDirection.
bDirection = FALSE means that the events determine the output value rValueOut in ascending form from 1 to 8. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSEAND bEvent7 = TRUE (highest occurring event in Table 1 column 1), then rValueOut = rValue7.
bDirection = TRUE means that the events determine the output value rValueOut in descending form from 8 to 1. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUEAND bEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables rValue1-8, whose value is output via rValueOut. If bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 2, then rValueOut = rValue2, see Table 3.

bActive: bActive goes TRUE if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and one of the input variables bEvent1-8 = TRUE.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.

bEdgeNewEvent: Is TRUE for one PLC cycle if

1. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Auto and the decisive event (bEvent1-8) for controlling the output rValueOut by means of rValue1-8 has changed.

2. bEnable = TRUEAND eCtrlMode = eHVACCtrlMode_Manual and with each change of iManualValue.

iValueNumber: The variable iValueNumber indicates the variable from which the value on rValueOut is output. If rValueOut = rValue7, then iValueNumber = 7, see Table 1, Table 2 and Table 3

VAR_IN_OUT

      Name                      : Type            Persistent

rValue1-8                : REAL;                X

rValue1-8: The value of the output variable rValueOut is determined by the variables rValue1 to rValue8. rValueOut = rValueX

If the function block is used to prioritise events, then each of the variables rValue1-8 is assigned to an event. rValue1 is assigned to the event bEvent1, rValue2 to the event bEvent2, rValue3 to the event bEvent3, ... and rValue8 to the event bEvent8.

If the function block is used as a multiplexer, then each of the variables rValue1-8 is assigned to the value of iManualValue. If iManualValue = 1, then rValueOut = rValue1. If iManualValue = 2, then rValueOut = rValue2.... If iManualValue = 8, then rValueOut = rValue8.


FB_HVACOptimizedOn

Function block for an optimized switch-on (Prestart Time) of boilers and air-conditioning-systems in connection with Switching-time-modules.

This documentation refers to the heating behaviour. For cooling-systems the module is used analogously.

Calculating the Prestart Time

Commercial and public buildings are usually unlined at night and on weekends, so the boilers are working in a standby-mode. The target of an optimized switch-on is, to start the boiler so early that the building is sufficiently warm at a certain time. This applies in reverse as well for the cooling of a building in summer. However this prestart temperature is not constant, but depends on several factors like outdoor temperature, room temperature difference (actual value - to desired value) and building properties like e. g. the building mass and the heating insulation. To develop a universal formula which is valid for all buildings would be a very complex task, which would fail not only because there would be endless parameters to be entered. Much easier and finally sufficient is a self-learning (adapting) approximation procedure.

The flow temperature of the boiler refers to the outdoor temperature. Therefore there are different heating processes for different outdoor temperatures which meet basically an exponential function:

The flow temperature is significantly higher than the desired room temperature.

To determine the prestart time, the area between the functions of room temperature start value and room temperature target value is assumed linear. So for each outdoor temperature there is a characteristic temperature change ΔT/Δt, which is illustrated here in a dotted line.

The function block FB_HVACOptimizedOn refers with the variable stTempChangeFunction to a table, in which there are 10 outdoor temperatures with their corresponding room temperature changes. With these values you can approximately determine the prestart temperature. Typically this temperature-change-function f(OT) has the following course:

Function values inside these 10 points are determined via equation of line, values outside correspond to the function value f( OT1 ) resp. f(OT10):

  • OT < OT1: f(OT) = f(OT1)
  • OT > OT10: f(OT) = f(OT10)

Thus the prestart time is calculated:

The input and output variables of the module are illustrated in red. The internal flag uiActualPrestartTime which holds always the actual prestart time is illustrated in violet. The output uiPrestartTime corresponds to this flag, but becomes "freezed" during the prestart phase. This will be explained in detail in the following chapter.

Connection of Modules and Prestart Phase

Based on these specifications the module will calculate a prestart time and provide it to the time switch module. If the boiler should have warmed up the buildung at monday morning at 06:00 a.m. and the prestop module calculates at 05:00 a.m. a prestart time of 60 minutes, the boiler will be started immediately. The heating-up behaviour is watched in a reference room during the prestart time phase and the function of the temperature change is corrected.

The prestart module provides a prestart time to the time switch module. If this switches the output bOutput, the prestart module gets informed by its input bSchedulerActive. Then the prestart module starts an internal countdown with the previously output prestart time uiPrestartTime [min]. Either the countdown runs to its end or it is aborted when the desired resp. tolerated room temperature is reached. During the countdown the output bPrestartActive is set. It can be used e. g. for the quickstart of the boiler.
The output uiPrestartTime follows continously the above described calculation - but when a countdown has been started it is kept constant, in order to inhibit a fluctuation in the outdoor temperature to specify a lower prestart time and switch off the boiler.

If the time-switch-module requests an adaption of the prestart-function (rising edge at bWithAdaption, red line) the prestart module will decide after the prestart phase, whether the calculated prestart time has been exact, too short or too long (within a tolerance) and will correct the temperature change. For this the prestart time of the point whose outdoor temperature is nearest to the actual (at start of the countdown) is corrected upward or downward. This process is called "Adaption".

Note: Temperature changes are only corrected, when the outdoor temperature has been within the function range at the beginning of the prestart-phase, see "Adaption".

When adaption is requested, the input bWithAdaption has to be set at the same time as the input bSchedulerActive. For bWithApation a simple trigger impulse is sufficient. When the input bSchedulerActive drops down, a started countdown is immediately aborted. The adaption can be disabled via the input bDisableAdaption. This option should be selected, when the temperature change function should not be changed any more after a sufficient number of adaptions.

The following program flow chart is to illustrate the behaviour, in red you see the input- and output variables of the module:

The internal flag "actual prestart time" is the always actual result of the calculation described obove.

The input bEnable (not described here), sets the module out of function if it is FALSE: the prestart time uiPrestartTime is set "0" and the prestart is not started resp. is immediately reset.

Adaption

When adaption is selected and the prestart phase has ended (countdown = 0 or room temperature is reached) you can have 3 cases:

  1. The countdown has expired a nd the desired room temperature difference is below a tolerance rAdaptionTolerance -> there is no adaption.
  2. The countdown hasn't expired yet but the desired room temperature is reached -> the prestart time uiPrestartTime has been too long.
  3. The countdown has expired but there is a positive temperature difference left -> the prestop time uiPrestartTime was too short.

With help of the expired countdown time and the changing of the room temperature difference the value of Wert ΔT/Δt can be defined again.

  1. no change
  2. too much time has been calculated - new value: "room temperature difference at the start" / "elapsed time until now"
  3. too little time has been calculated - new value: "room temperature difference at the start" - "difference at the end") / "countdown time"

The temperature change function is corrected at the point whose outdoor temperature is closest to the actual at the start of the prestart phase. This point has been saved before the countdown was started (see program flow chart).

The calculated value ΔT/Δt is not necessarily accepted per 100 percent as new value at this point. It is possible to mix up the new value with a quantifier of old and new value. Therefore an adaption factor rAdaptionFactor is used:

With an adaption factor of 100% the new calculated value is accepted completely, with 0% the old value remains.

Note: Because always the prestart time of the closest point is changed, an adaption can only be executed, if the outdoor temperature at the beginning of the prestart phase is within OT1 to OT10.

Input- an Output variables

VAR_INPUT

eDataSecurityType    : E_HVACDataSecurityType;
eCtrlFct             : E_BARCtrlFct;
bEnable              : BOOL;
bSchedulerActive     : BOOL;
bWithAdaption        : BOOL;
bDisableAdaption     : BOOL;
rOutsideTemperature  : REAL;
rRoomTemperature     : REAL;
rRoomSetpointValue   : REAL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention Never connect a cyclic changing variable with the IN_OUT-variable of a function block, if eDataSecurityType:= eDataSecurityType_Persistent. It would cause an early abrasion of the flash memory.

eCtrlFct : eCtrlFct = eBARCtrlFct_Heating defines that it is a usage in heating mode. eCtrlFct = eBARCtrlFct_Cooling defines that it is a usage in cooling mode. Another entry at this input is not permitted and causes an error. These both permitted inputs result in a different calculation of the room-temperature-difference (difference between actual and desired room-temperature).

bEnable : A FALSE-signal at this input disables the optimized turning-on of the connected switching-time-modules. The output of the prestart time is directly set to "0". No countdown is started, no adaption is executed - the module is reset.

bSchedulerActive: A rising edge at this input starts the internal countdown of the prestart time. While the countdown exceeds, the output bPrestartMode is set to TRUE. If the output bSchedulerActive is set to FALSE again during countdown, the countdown is immediately interrupted and the output bPrestartMode is set to FALSE. The countdown is also stopped and bPrestartMode is set to FALSE, if the target room temperature is reached.

bWithAdaption : If this input is set at the same time as bSchedulerActive, an adaption will be executed after the countdown. A trigger impulse together with a rising edge of bSchedulerActive is sufficient. This input can only be used in connection with bSchedulerActive, a single set has no effect.

bDisableAdaption : A TRUE-signal at this input disables the adaption after the countdown.

rOutsideTemperature : outdoor temperature in degree Celsius.

rRoomTemperature : room temperature in degree Celsius.

rRoomSetpointValue : desired value of the room temperature in degree Celsius.

VAR_OUTPUT

uiPrestartTime   : UINT;
bPrestartActive  : BOOL;
udiCountdownTime : UDINT;
bError           : BOOL;
udiErrorID       : UDINT;

uiPrestartTime : output value of the optimized prestart time to the concerning switching time modules in minutes. This value is continously generated of the prestart function which depends on the outdoor temperature. If the input bDisableOptimization is set to TRUE, this output is set to "0".

bPrestartActive : as long as the internal countdown is running and isn't stopped by the exceeding prestart time, reaching the target room temperature or interruption (bSchedulerActive = FALSE), the modul is in the prestart mode. This is displayed by a TRUE-Signal at this output.

udiCountdownTime : this output shows the exceeding of the internal countdowns in seconds. If the module is not in the prestart mode any longer (see bPrestartMode), this output is set to "0".

bError : This output is set to TRUE, if the entered parameter are wrong.

udiErrorId : contains the error code if the entered values are wrong. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiMaxPrestartTime     : UINT;
rAdaptionFactor       : REAL;
rAdaptionTolerance    : REAL;
stTempChangeFunction  : ST_HVACTempChangeFunction;

uiMaxPrestartTime : the prestart times within the temperature change function are changed downwards and upwards by the adaption. Downwards they are limited automatically logical to 0 minutes, upwards you can define the limit in minutes via this input.

rAdaptionFactor : in the adaption step the temperature change ΔT/Δt is calculated for the nearest outdoor temperature point. This is not necessarily accepted per 100 percent as new value at this point. It is possible to mix up the new value with a quantifier of old and new value. The adaption factor rAdaptionFactor (in percent) is the quantifier.

With an adaption factor of 100% the new calculated value is accepted completely, with 0% the old value remains.

rAdaptionTolerance : If adaption is switched-on, the countdown has exceeded and the desired room temperature rRequestedDeviation is reached, no adaption is executed, because the prestart time is exactly sufficient. The value rAdaptionTolerance defines an additional tolerance range: if the actual value is wihin the range rRoomSetpointValue .. rRoomSetpointValue + rAdaptionTolerance, it is considered as the desired value.

stTempChangeFunction : structure variable of type ST_HVACTempChangeFunction, which contains the 10 pairs of values (outdoor temperature, room temperature change). These pairs of values, which have to be - sorted by rising outdoor temperature - entered in the field variable, define the 9 fragment lines of the temperature change function.


FB_HVACOptimizedOff

Function block for an optimized switch-off (PrestopTime) of boilers and air-conditioning-systems in connection with Switching-time-modules.

This documentation refers to the heating behaviour. For cooling-systems the module is used analogously.

Calculating the PrestopTime

Buildings and parts of buildings which are used at a certain and projectable time, e. g. schools and conference rooms, don´t need to be heated for the whole using-time. Because the buildings save thermal energy, it is possible to shut off the heating earlier. The room temperature declines till the end of usage to a lower niveau which is hardly noticed. This is a desired declining to an objective temperature - the difference of declining is an input of the function block and is called rRequestedTempDeviation.

The flow temperature of the boiler refers to the outdoor temperature. Therefore there are different declining processes for different outdoor temperatures which meet basically an exponential function:

To determine the prestop time, the area between the functions of room temperature start value and room temperature target value is assumed linear. So for each outdoor temperatuethere is a characteristic temperature change ΔT/Δt, which is illustrated here in a dotted line.

The function block FB_HVACOptimizedOff refers with the variable stTempChangeFunction to a table, in which there are 10 outdoor temperatures with their corresponding room temperature changes. With these values you can approximately determine the prestop temperature. Typically this temperature-change-function f(OT) has the following course: (the change is positive illustrated):

Function values inside these 10 points are determined via equation of line, values outside correspond to the function value f( OT1 ) resp. f(OT10):

  • OT < OT1: f(OT) = f(OT1)
  • OT > OT10: f(OT) = f(OT10)

Thus the prestop time is calculated:

The input and output variables of the module are illustrated in red. The internal flag uiActualPrestopTime which holds always the actual prestop time is illustrated in violet. The output uiPrestopTime corresponds to this flag, but becomes "freezed" during the prestop phase. This will be explained in detail in the following chapter.

Connection of Modules and Prestop Phase

Based on these specifications the module will calculate a prestop time and provide it to the time switch module. Is the boiler to be switched off e. g. at 08:00 p.m. and the prestop module calculates at 07:00 p.m., that the temperature niveau would need 60 minutes to decline by the desired value rRequestedTempDeviation, the boiler will be shut off immediately. The cool-down behaviour is watched in a reference room during the prestop time phase and the function of the temperature change is corrected.

The prestop module provides a prestop time to the time switch module. If this switches back the output bOutput to FALSE, the prestop module gets informed by its input bSchedulerOff. Then the prestop module starts an internal countdown with the previously output prestop time uiPrestopTime [min]. Either the countdown runs to its end or it is aborted when the desired resp. tolerated room temperature is reached. During the countdown the output bPrestopActive is set.
The output uiPrestopTime follows continously the above described calculation - but when a countdown has been started it is kept constant, in order to inhibit a fluctuation in the outdoor temperature to specify a lower prestop time and turn on the boiler again.

If the time-swicht-module requests an adaption of the prestop-function (rising edge at bWithAdaption, red line), the prestop module will decide after the prestop phase, whether the calculated prestop time has been exact, too short or too long (within a tolerance) and will correct the temperature change. For this the prestop time of the point whose outdoor temperature is nearest to the actual (at start of the countdown) is corrected upward or downward. This process is called "Adaption".

Note: Temperature changes are only corrected, when the outdoor temperature has been within the function range at the beginning of the prestop-phase, see "Adaption".

When adaption is desired, the input bWithAdaption has to be set at the same time as the input bSchedulerOff. For bWithApation a simple trigger impulse is sufficient. When the input bSchedulerOff drops down, a started countdown is immediately aborted. The adaption can be disabled via the input bDisableAdaption. This option should be selected, when the temperature change function should not be changed any more after a sufficient number of adaptions.

The following program flow chart is to illustrate the behaviour, in red you see the input- and output variables of the modul:

The internal flag "actual prestop time" is the always actual result of the calculation described obove.

The input bEnable(not described here), sets the module out of function if it is FALSE: the prestop time uiPrestopTime is set "0" and the prestop is not started resp. is immediately reset.

Adaption

The target of the Adaption is to adapt the temperature change function so exactly, that the desired resp. tolerated declining of temperature rRequestedTempDeviation is reached in the calculated prestop time (in the cooling mode it would be the increase of temperature after shut off of the cooling devices).

When adaption is selected and the prestop phase has ended (countdown = 0 or room temperature is reached) you can have 3 cases:

  1. The countdown has expired a nd the desired declining rRequestedDeviation is reached within an acceptable rAdaptionTolerance -> there is no adaption.
  2. The countdown hasn't expired yet but the desired declining rRequestedDeviation has exceeded -> the prestop time uiPrestopTime has been too long.
  3. The countdown has expired but the desired declining rRequestedDeviation isn't reached yet -> the prestop time uiPrestopTime was too short, the heating can be shut off even earlier.

With the help of the expired countdown time and the changing of the room temperature difference the value of ΔT/Δt can be defined again.

  1. no change
  2. too much time has been calculated - new value: "desired declining rRequestedDeviation" / "elapsed time till now"
  3. too little time has been calculated - new value: "desired declining rRequestedDeviation" / "difference at the end") / "countdown time"

The temperature change function is corrected at the point whose outdoor temperature is closest to the actual at the start of the prestop phase. This point has been saved before the countdown was started (see program flow chart).

The calculated value ΔT/Δt is not necessarily accepted per 100 percent as new value at this point. It is possible to mix up the new value with a quantifier of old and new value. Therefore an adaption factor rAdaptionFactor is used:

With an adaption factor of 100% the new calculated value is accepted completely, with 0% the old value remains.

Note: Because always the prestop time of the nearest point is changed, an adaption can only be executed, if the outdoor temperature at the beginning of the prestop phase is within OT1 to OT10.

Input- and Output variables

VAR_INPUT

eDataSecurityType       : E_HVACDataSecurityType;
eCtrlFct                : E_BARCtrlFct;
bEnable                 : BOOL;
bSchedulerOff           : BOOL;
bWithAdaption           : BOOL;
bDisableAdaption        : BOOL;
rOutsideTemperature     : REAL;
rRoomTemperature        : REAL;
rRequestedTempDeviation : REAL;

eDataSecurityType: if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention Never connect a cyclic changing variable with the IN_OUT-variable of a function block, if eDataSecurityType:= eDataSecurityType_Persistent. It would cause an early abrasion of the flash memory.

eCtrlFct : eCtrlFct = eBARCtrlFct_Heating defines that it is a usage in heating mode. eCtrlFct = eBARCtrlFct_Cooling defines that it is a usage in cooling mode. Another entry at this input is not permitted and causes an error. These both permitted inputs result in a different calculation of the temperature-deviation rRequestedTempDeviation.

bEnable : A FALSE-signal at this input disables the optimized turning-on of the connected switching-time-modules. The output of the prestop time is directly set to "0". No countdown is started, no adaption is executed - the module is reset.

bSchedulerOff : A rising edge at this input starts the internal countdown of the prestop time. While the countdown exceeds, the output bPrestopMode is set to TRUE. If the output bSchedulerOff is set to FALSE again during countdown, the countdown is immediately interrupted and the output bPrestopMode is set to FALSE. The countdown is also stopped and bPrestopMode is set to FALSE, if the target room temperature is reached.

bWithAdaption : If this input is set at the same time as bSchedulerOff, an adaption will be executed after the countdown. A trigger impulse together with a rising edge of bSchedulerOff is sufficient. This input can only be used in connection with bSchedulerOff, a single set has no effect.

bDisableAdaption : A TRUE-signal at this input disables the adaption after the countdown.

rOutsideTemperature : outdoor temperature in degree Celsius.

rRoomTemperature : room temperature in degree Celsius.

rRequestedTempDeviation : tolerated downward temperature deviation (heating mode) or upward (cooling mode) from shut off of the boiler resp. air-conditioning-system till leaving the room.

VAR_OUTPUT

uiPrestopTime    : UINT;
bPrestopActive   : BOOL;
udiCountdownTime : UDINT;
bError           : BOOL;
udiErrorID       : UDINT;

uiPrestopTime : output value of the optimized prestop time to the concerning switching time modules in minutes. This value is continously generated of the prestop function which depends on the outdoor temperature. If the input bDisableOptimization is set to TRUE, this output is set to "0".

bPrestopActive : as long as the internal countdown is running and isn't stopped by the exceeding prestop time, reaching the target room temperature or interruption (bSchedulerOff = FALSE), the modul is in the prestop mode. This is displayed by a TRUE-Signal at this output.

udiCountdownTime : this output shows the exceeding of the internal countdowns in seconds. If the module is not in the prestop mode any longer (see bPrestopMode), this output is set to "0".

bError : This output is set to TRUE, if the entered parameter are wrong.

udiErrorId : contains the error code if the entered values are wrong. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiMaxPrestopTime      : UINT;
rAdaptionFactor       : REAL;
rAdaptionTolerance    : REAL;
stTempChangeFunction  : ST_HVACTempChangeFunction;

uiMaxPrestopTime : the prestop times within the temperature change function are changed downwards and upwards by the adaption. Downwards they are limited automatically logical to 0 minutes, upwards you can define the limit in minutes via this input.

rAdaptionFactor : in the adaption step the temperature change ΔT/Δt is calculated for the nearest outdoor temperature point. This is not necessarily accepted per 100 percent as new value at this point. It is possible to mix up the new value with a quantifier of old and new value. The adaption factor rAdaptionFactor (in percent) is the quantifier.

With an adaption factor of 100% the new calculated value is accepted completely, with 0% the old value remains.

rAdaptionTolerance : If adaption is switched-on, the countdown has exceeded and the desired declining rRequestedDeviation is reached, no adaption is executed, because the prestop time is exactly sufficient. The value rAdaptionTolerance defines an additional tolerance range:

stTempChangeFunction : structure variable of type ST_HVACTempChangeFunction, which contains the 10 pairs of values (outdoor temperature, room temperature change). These pairs of values, which have to be - sorted by rising outdoor temperature - entered in the field variable, define the 9 fragment lines of the temperature change function.


FB_HVACTempChangeFunction

Function block for entering the node points of the prestop function.

To keep the modules FB_HVACOptimizedOn and FB_HVACOptimizedOff clear, they don't contain inputs for the pairs of values for the temperature change function - the modules access the structure variable of the temperature change function via an IN-OUT-variable (ST_HVACTempChangeFunction).

The function block FB_HVACTempChangeFunction enables the description of the structure variable in a clear form and controls if the pairs of values - as demanded - are sorted by rising outdoor temperature and that there are no two points of the same outdoor temperature. In this case there would be a mathematical functional ambigous correlation.

The pairs of values have to be entered at the correspondent inputs rOutsideTemperature_1.. rOutsideTemperature_10 (outdoor temperature) and rRoomTempChange_1..rRoomTempChange_10 (roomtemperature-change). The module controls continously, if the above described demands are fulfilled.

Note: The description of the temperature change function should be done once, to provide basic values to the prestart - / prestop-modules, which are continously upgraded in the course of time.

VAR_INPUT

bWrite             : BOOL;
rOutsideTemp_1     : REAL;
rRoomTempChange_1  : REAL;
rOutsideTemp_2     : REAL;
rRoomTempChange_2  : REAL;
rOutsideTemp_3     : REAL;
rRoomTempChange_3  : REAL;
rOutsideTemp_4     : REAL;
rRoomTempChange_4  : REAL;
rOutsideTemp_5     : REAL;
rRoomTempChange_5  : REAL;
rOutsideTemp_6     : REAL;
rRoomTempChange_6  : REAL;
rOutsideTemp_7     : REAL;
rRoomTempChange_7  : REAL;
rOutsideTemp_8     : REAL;
rRoomTempChange_8  : REAL;
rOutsideTemp_9     : REAL;
rRoomTempChange_9  : REAL;
rOutsideTemp_10    : REAL;
rRoomTempChange_10 : REAL;

bWrite : A rising edge at this input copies the input values in the prestart function.

(rOutsideTemp_1 - rRoomTempChange1) ... (rOutsideTemp_10 - rRoomTempChange10): pairs of values of the prestart function: room temperature change (rRoomTempChange) in degree Kelvin per minute at outdoor temperature (rOutsideTemp) in degree Celsius.

VAR_OUTPUT

bValid                  : BOOL;
udiErrorID              : UDINT;

bValid : this output is set to TRUE, if the entered parameters are not wrong.

udiErrorId : contains the error code, if the entered values are wrong. See Error codes.

VAR_IN_OUT

stTempChangeFunction  : ST_HVACTempChangeFunction;

stTempChangeFunction : structure variable of type ST_HVACTempChangeFunction, which contains the 10 pairs of values (outdoor temperature, room temperature change). These pairs of values, which have to be - sorted by rising outdoor temperature - entered in the field variable, define the 9 fragment lines of the temperature change function.


FB_HVACPWM

Application

This function block creates a PWM signal on the basis of the analog input signal rYIn. Additionally it offers to define a minimum switch -on time.

VAR_INPUT

      Name                     : Type                             Range        Unit

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
rYIn                     : REAL;                          0..100        %
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

bEnable: The block is enabled if bEnable = TRUE.

rYIn: Analog input signal.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                    : Type           Range        Unit

bOut                    : BOOL;
rYOut                   : REAL;         0 .. 100       %
bInvalidParameter       : BOOL;

bOut: PWM-signal.

rYOut: Output of the input signal, e.g. Request from visualization.

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

VAR_IN_OUT

      Name                    : Type        Persistent    Default     Range

tPWMPeriod              : TIME;           X          t#30m
tMINPowerOnTime         : TIME;           X          t#0s

tPWMPeriod: Period of the PWM signal.

tMINPowerOnTime: Minimum switch-on time of the PWM-signal.

Picture 1: A Scope2 record which explain additional the function of the FB. bEnable enabled the block, see section 1, 5.
A change in the input size is taken into account until the next period, see section 2, 3, 4.


FB_HVACStartAirConditioning

Application

The air conditioning system is started up stepwise with the start program FB_HVACStartAirConditioning. The shut-off dampers, the fans, the controller and the limit value monitoring of the analogue inputs are thereby enabled one after the other.

In the case of low outside temperatures below the value of rPreRinseOutsideTemp, the heating coil is initially rinsed through with hot water before the outside and exhaust air dampers are opened. In Air conditioning plants with a temperature sensor in the return flow from the heating coil, the rinsing procedure continues until the temperature rReturnWaterTemp has exceeded the value of the input variable rPreRinseLimitTemp. The outside and exhaust air dampers are opened when the specified temperature in the return flow from the air heater is reached. If the temperature is not exceeded after the timer tPreRinseMaxTime has elapsed, the error is indicated by a TRUE at the output bErrorNoHotWater.

If there is no temperature sensor in the return flow from the heater, a constant of -100 is applied to the input rReturnWaterTemp. The FB_HVACStartAirConditioning function block then knows that the pre-rinse procedure must be executed without return flow monitoring. In this case rinsing continues until the timer tPreRinseMaxTime elapses. Hence, there is no monitoring of the rinsing procedure!

The outside and exhaust air dampers are opened after completion of the pre-rinsing procedure. The output bDampersOpen becomes TRUE as a result.
In order to avoid damage to the air ducts and the dampers, the start-up of the fans is delayed until the feedback ‘Open’ from the dampers is present at the input bDampersFeedbOpen. In addition the timer tDelaySupplyVent must have elapsed. The set time must be longer than the stroke time of the damper drive.
Since this timer is also active when the system is switched off, the ramp-down times of frequency converters must also be taken into account!
The output bErrorDampers becomes TRUE if no feedback is received from the damper drives within the set time. In order to avoid high start-up currents, the switching on of the exhaust fan is delayed by the timer tDelayExhaustVent.

In systems with a mixed air chamber it makes sense to enable the controller only after the supply air temperature rSupplyAirTemp has reached approximately the value of the exhaust air temperature. The maximum deviation is specified by the parameter rDifferenceTemp. In systems without a mixed air system a very large value is simply entered here as a constant, e.g. 100. The controller is then enabled without a delay.

After the timer tDelayLimitCtrl has elapsed, the output bEnableLimitCtrl is enabled and, hence, the limit value monitoring of the analogue inputs is activated.

If the outside temperature lies below the value of rPreRinseOutsideTemp, the value of iCurrentSequence is applied to the output the same as that of iStartSeqWinter. The number of the pre-heater controller must be entered here (see the chapter on sequence controllers). If the outside temperature is higher than rPreRinseOutsideTemp, start-up can commence with the heat recovery unit or the mixed air chamber. Hence, the number of the sequence controller for the mixed air chamber or for the heat recovery unit is entered at the input iStartSeqSummer.

The start-up becomes active in the case of operation requests from the automatic programs, the time switch schedules, summer night cooling, support operation and overheating protection.
In order to activate the sequence controllers, the counter variable eModeSeqCtrl at the output of the function block is set as follows:

TYPE E_HVACSequenceCtrlMode :
(
eHVACSequenceCtrlMode_Stop := 0,
eHVACSequenceCtrlMode_On := 1,
eHVACSequenceCtrlMode_NightCooling := 2,
eHVACSequenceCtrlMode_FreezeProtection := 3,
eHVACSequenceCtrlMode_OverheatingProtection := 4,
eHVACSequenceCtrlMode_NightCoolingAndOverheatingProtection := 5
);
END_TYPE

Requests from all automatic programs are transferred to the system start program via the input variables bTimeScheduler, bNightCooling, bFreezeProtec and bOverHeatingProtec. Requests from retention functions are only applied if there is no request from a time switch program at the input variable bTimeScheduler.

The programs for summer night cooling (bNightCooling), frost protection (bFreezeProtect) and overheating protection (bOverHeatingProtec) are only usable if a room temperature sensor is used in place of an exhaust air temperature sensor. For reasons of safety the frost protection takes precedence over the overheating protection and summer night cooling.

Since summer night cooling can take place as forced ventilation with fans or as convection ventilation without fans, the command from the program FB_HVACSummerNightCooling is transferred with the counter variable E_HVACConvectionMode. This output must be applied to the input variable eConvection.

A collection of all air conditioning system error messages that lead to the system switching off is applied to the input bEmergencyStop.

When the air conditioning system is switched off, the order of the switch-on steps is reversed.

- Deactivate limit monitoring at the analogue inputs
- Deactivate the controllers (reset iCurrentSequence to 0)
- Switch off the fans
- Close the dampers after the timer tDelaySupplyVent has elapsed.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
iStartSeqWinter           : INT;
iStartSeqSummer           : INT;
bTimeScheduler            : BOOL;
bNightCooling             : BOOL;
bFreezeProtec             : BOOL;
bOverHeatingProtec        : BOOL;
rOutsideTemp              : REAL;
rReturnWaterTemp          : REAL;
rSupplyAirTemp            : REAL;
rReturnAirTemp            : REAL;
bDampersFeedbOpen         : BOOL;
bEmergencyStop            : BOOL;
bReset                    : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out of the flash memory.

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

iStartSeqWinter: The number of the sequence controller for the pre-heater must be entered here.

iStartSeqSummer: The number of the sequence controller for the mixed air chamber or for the heat recovery unit must be entered here.

bTimeScheduler: Input for the timer switch command.

bNightCooling: Input for the night cooling function.

bFreezeProtec: Input for the frost protection function.

bOverHeatingProtec: Input for the overheating protection function.

rOutsideTemp: Input for the outside temperature.

rReturnWaterTemp: Input for the water temperature from the return flow of the air heater.

rSupplyAirTemp: Input for the inlet air temperature.

rReturnAirTemp: Input for the room temperature or the exhaust air temperature.

bDampersFeedbOpen: Input for the feedback from the dampers.

bEmergencyStop: A collection of all air conditioning plant error messages that lead to the system switching off can be applied to this input.

bReset: Input for resetting the error.

VAR_OUTPUT

      Name                      : Type

eModeSeqCtrl              : E_HVACSequenceCtrlMode;
bPreRinse                 : BOOL;
bDampersOpen              : BOOL;
bSupplyVentilation        : BOOL;
bExhaustVentilation       : BOOL;
bStartPIDControllers      : BOOL;
bEnableLimitCtrl          : BOOL;
bErrorGeneral             : BOOL;
bErrorNoHotWater          : BOOL;
bErrorDampers             : BOOL;
byError                   : BYTE;
bInvalidParameter         : BOOL;

eModeSeqCtrl: Enum that informs of operation requests.

bPreRinse: TRUE if the pre-rinsing procedure is active.

bDampersOpen: If TRUE, then the outside and exhaust air dampers are open.

bSupplyVentilation: Switches on the supply air fan if TRUE.

bExhaustVentilation: Switches on the exhaust air fan if TRUE.

bStartPIDControllers: Enables the controllers.

bEnableLimitCtrl: After the timer tDelayLimitCtrl has elapsed, the output bEnableLimitCtrl is enabled and, hence, the limit value monitoring of the analogue inputs is activated.

bErrorGeneral: There is a general error.

bErrorNoHotWater: Is set to TRUE if the rinsing procedure has ended and the set temperature in the return flow has not been reached.

bErrorDampers: There is an error in the dampers.

byError: Output of the error as a byte.

byError.1:= bInvalidParameter;
byError.2:= bErrorGeneral;
byError.3:= bErrorNoHotWater;
byError.4:= bErrorDampers;

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                      : Type                   Persistent     Default       Unit

eConvection               : E_HVACConvectionMode;      X            1
tDelaySupplyVent          : TIME;                      X           t#120s
tDelayExhaustVent         : TIME;                      X           t#5s
tDelayTempCtrl            : TIME;                      X           t#10s
rDifferenceTemp           : REAL;                      X            5.0          K
tDelayLimitCtrl           : TIME;                      X           t#360s
rPreRinseOutsideTemp      : REAL;                      X           10.0          K
rPreRinseLimitTemp        : REAL;                      X           30.0          K
tPreRinseMaxTime          : TIME;                      X           t#300s
iCurrentSequence          : INT;                       X

eConvection: ENUM via which summer night cooling can take place as forced ventilation with fans or as convection ventilation without fans.

TYPE E_HVACConvectionMode :
(
eHVACConvectionMode_WithFan := 0,
eHVACConvectionMode_WithoutFan := 1
);
END_TYPE

tDelaySupplyVent: Time delay that delays the start-up of the supply air fans.

tDelayExhaustVent: Time delay that delays the start-up of the exhaust air fans.

tDelayTempCtrl: Time delay for the controller.

rDifferenceTemp: The controller is enabled if the difference between the room temperature and the supply air temperature is smaller than rDifferenceTemp.

tDelayLimitCtrl: Time delay before limit monitoring of the temperature sensors is enabled. See the variable bEnableLimitCtrl in FB_HVACTemperature regarding this point.

rPreRinseOutsideTemp: Outside temperature below which the air conditioning plant should start up with the pre-rinsing of the heater coil.

rPreRinseLimitTemp: Temperature of the return flow from the heater coil that must be reached in order to end the pre-rinsing procedure and continue with the opening of the dampers.

tPreRinseMaxTime: Maximum duration of the pre-rinsing procedure.

iCurrentSequence: The starting controller at controller enablement is specified here. The value is written by the start program in one cycle only, since afterwards in system operation this parameter must be freely writeable again for the switching on or off of the sequence controllers.


FB_HVACSummerNightCooling

Application

With this function block, rooms that were heated up on the day before can be cooled down during the night using cool outside air. The summer night cooling function serves to improve the quality of the air and to save electrical energy. Electrical energy for cooling is saved during the first hours of the next summer day.

The start conditions for the summer night cooling are defined by parameterising the FB_HVACSummerNightCooling function block. The block can be used to open motor-driven windows or to switch air conditioning systems to summer night cooling mode outside their normal hours of operation. Summer night cooling mode is active if the output variable bOn is TRUE.

The following conditions must be met for activation of summer night cooling:
- bEnable = TRUE
- rOutsideTemp > (rMinimumOutsideTemp + 0.2K)
- ((rRoomTemp - rOutsideTemp) > rDifferOutsideRoomTempOn)
 - ((rRoomTemp - rSetpointRoomTemp) > rDifferRoomSetpointTemp)
- The system time dtSystemtime must be within the timeframe todStartTime and 12:00

For the deactivation of summer night cooling bOn = FALSE it is sufficient if one of the following condition is met:
- bEnable = FALSE
 - (rOutsideTemp < (rMinimumOutsideTemp - 0.2K))
- ((rRoomTemp - rOutsideTemp) < rDifferOutsideRoomTempOff)
- The system time dtSystemtime is outside the timeframe between todStartTime and 12:00
- Summer night cooling was active for the maximum time tMaxRuntime within the timeframe between todStartTime and 12:00. Summer night cooling can be switched on several times within this timeframe.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
rOutsideTemp              : REAL;
rRoomTemp                 : REAL;
rSetpointRoomTemp         : REAL;
dtSystemTime              : DT;
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:= e HVAC DataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Attention 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 block is enabled by the PLC program with the input variable bEnable.

rOutsideTemp: Input for the outside temperature.

rRoomTemp: Input for the room temperature.

rSetpointRoomTemp: Set value of the room temperature

dtSystemTime: This variable transfers the computer system time to the function block.

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                      : Type

bOn                       : BOOL;
bInvalidParameter         : BOOL;

bOn: If bOn = TRUE summer night cooling is active.
The following conditions must be met for activation of summer night cooling:
bEnable = TRUEAND rOutsideTemp > (rMinimumOutsideTemp + 0.2K) AND ((rRoomTemp - rOutsideTemp) > rDifferOutsideRoomTempOn) AND
((rRoomTemp - rSetpointRoomTemp) > rDifferRoomSetpointTemp) AND the system time dtSystemtime must be within the timeframe todStartTime and 12:00.

For the deactivation of summer night cooling bOn = FALSE it is sufficient if one of the following condition is met:
bEnable = FALSEOR (rOutsideTemp < (rMinimumOutsideTemp - 0.2 K)) OR ((rRoomTemp - rOutsideTemp) < rDifferOutsideRoomTempOff) OR the system time dtSystemtime lies outside the timeframe between todStartTime and 12:00 OR summer night cooling was active for the maximum time tMaxRuntime within the timeframe between todStartTime and 12:00. Summer night cooling can be switched on several times within this timeframe.

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be aknowledged with bReset.

VAR_IN_OUT

      Name                      : Type            Persistent       Default        Range

rMinimumOutsideTemp       : REAL;             X            10.0°C          4.0 .. 100.0
rDifferOutsideRoomTempOn  : REAL;             X             5.0°C          0.0 .. 100.0
rDifferOutsideRoomTempOff : REAL;             X             2.0°C          0.0 .. 100.0
rDifferRoomSetpointTemp   : REAL;             X             2.0°C          0.0 .. 100.0
todStartTime              : TOD;              X           TOD#02:00          0 .. 24
tMaxRuntime               : TIME;             X             T#20m             > T#0s

rMinimumOutsideTemp: If the outside temperature rOutsideTemp falls below the limit value (rMinimumOutsideTemp - 0.2 K), the summer night cooling function is disabled, i.e. bOn = FALSE. If the outside temperature rOutsideTemp exceeds the limit value (rMinimumOutsideTemp + 0.2 K), one of the conditions for activation of summer night cooling(bOn = TRUE) is met.

rMinimumOutsideTemp must be within the specified range.
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.

rDifferOutsideRoomTempOn: The difference rRoomTemp - rOutsideTemp must be greater than the absolute value of rDifferOutsideRoomTempOn to meet one of the conditions for activation of summer night cooling (bOn = TRUE).
((rRoomTemp - rOutsideTemp) > rDifferOutsideRoomTempOn)

rDifferOutsideRoomTempOn must be 0.4 K higher than rDifferOutsideRoomTempOff. Furthermore rDifferOutsideRoomTempOn must be within its specified range.
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.

rDifferOutsideRoomTempOff: The difference rRoomTemp - rOutsideTemp must be less than the absolute value of rDifferOutsideRoomTempOff for summer night cooling to be disabled (bOn = FALSE).
((rRoomTemp - rOutsideTemp) < rDifferOutsideRoomTempOff)

rDifferOutsideRoomTempOff must be 0.4 K lower than rDifferOutsideRoomTempOn. Furthermore rDifferOutsideRoomTempOff must be within its specified range.
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.

rDifferRoomSetpointTemp: The room temperature must exceed the room temperature setpoint by this value to meet one of the conditions for activation of summer night cooling (bOn = TRUE).
((rRoomTemp - rSetpointRoomTemp) > rDifferRoomSetpointTemp)

rDifferRoomSetpointTemp must be within its specified range.
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.

todStartTime: Start time for the timeframe within summer night cooling can be activated. The timeframe for enabling summer night cooling starts with todStartTime and ends at 12:00.

todStartTime must be within its specified range.
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.

tMaxRuntime: Maximum runtime of the summer night cooling function within the timeframe between todStartTime and 12:00. Summer night cooling can be switched on several times within this timeframe, but the total time cannot exceed tMaxRuntime.

tMaxRuntime must be greater than T#0s.
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.


FB_HVACSummerNightCoolingEx

Application

With this function block, rooms that were heated up on the day before can be cooled down during the night using cool outside air. The summer night cooling function serves to improve the quality of the air and to save electrical energy. Electrical energy for cooling is saved during the first hours of the next summer day.

The start conditions for the summer night cooling are defined by parameterising the FB_HVACSummerNightCooling function block. The block can be used to open motor-driven windows or to switch air conditioning systems to summer night cooling mode outside their normal hours of operation. Summer night cooling mode is active if the output variable bOn is TRUE.

The following conditions must be met for activation of summer night cooling:
- bEnable = TRUE
- rOutsideTemp > (rMinimumOutsideTemp + 0.2K); the value 0.2K is an internal constant of the function block.
- (rRoomTemp - rOutsideTemp) > rDifferOutsideTempRoomTempOn
 - (rRoomTemp - rSetpointRoomTemp) > rDifferRoomTempSetpointRoomTempOn
- udiSecRT_MaxRuntime > 0

For the deactivation of summer night cooling bOn = FALSE it is sufficient if one of the following condition is met:
- bEnable = FALSE
 - rOutsideTemp < (rMinimumOutsideTemp - 0.2K); the value 0.2K is an internal constant of the function block.
- (rRoomTemp - rOutsideTemp) < rDifferOutsideTempRoomTempOff
-udiSecRT_MaxRuntime = 0

Attention Summer night cooling can be switched on and off several times within the time udiSecMaxRuntime. Once udiSecRT_MaxRuntime has elapsed the summer night cooling function can only be reactivated if bEnable is FALSE for at lease one PLC cycle. The function block and the summer night cooling function can be enabled via a timer.

Program flowchart

Application example

The application example shows the function block FB_HVACSummerNightCoolingEx in conjunction with the weekly timer FB_HVACScheduler1ch. The example is available in the programming languages ST and CFC. The programming example P_CFC_SummernightCoolingEx.PRG in the programming language CFC can be found in folder Language CFC > SpecialFunctions, the programming example P_ST_SummernightCoolingEx.PRG in the programming language ST in folder Language Structured Text > SpecialFunctions.

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bEnable                   : BOOL;
rOutsideTemp              : REAL;
rRoomTemp                 : REAL;
rSetpointRoomTemp         : REAL;
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.

Attention 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 block is enabled by the PLC program with the input variable bEnable. Once the time udiSecMaxRuntime has elapsed the summer night cooling function can only be reactivated if bEnable is FALSE for at lease one PLC cycle. The function block could be enabled via a timer.

rOutsideTemp: Input for the outside temperature.

rRoomTemp: Input for the room temperature

rSetpointRoomTemp: Set value of the room temperature

bReset: Acknowledge input in the event of an error.

VAR_OUTPUT

      Name                                     : Type

bOn                                      : BOOL;
bStateDifferOutsideTempMinOutsideTemp    : BOOL;
rStateDifferOutsideTempMinOutsideTemp    : REAL;
bStateDifferRoomTempOutsideTemp          : BOOL;
rStateDifferRoomTempOutsideTemp          : REAL;
bStateDifferRoomTempSetpointRoomTemp     : BOOL;
rStateDifferRoomTempSetpointRoomTemp     : REAL;
udiSecRT_MaxRuntime                      : UDINT;
bInvalidParameter                        : BOOL;

bOn: If bOn = TRUE summer night cooling is active.

The following conditions must be met for activation of summer night cooling:
- bEnable = TRUE
- rOutsideTemp > (rMinimumOutsideTemp + 0.2K); the value 0.2K is an internal constant of the function block.
- (rRoomTemp - rOutsideTemp) > rDifferOutsideTempRoomTempOn
 - (rRoomTemp - rSetpointRoomTemp) > rDifferRoomTempSetpointRoomTempOn
- udiSecRT_MaxRuntime > 0

For the deactivation of summer night cooling bOn = FALSE it is sufficient if one of the following condition is met:
- bEnable = FALSE
 - rOutsideTemp < (rMinimumOutsideTemp - 0.2K); the value 0.2K is an internal constant of the function block.
- (rRoomTemp - rOutsideTemp) < rDifferOutsideTempRoomTempOff
- udiSecRT_MaxRuntime = 0

bStateDifferOutsideTempMinOutsideTemp: Status indicator. bStateDifferOutsideTempMinOutsideTemp is TRUE if rOutsideTemp > (rMinimumOutsideTemp + 0.2). bStateDifferOutsideTempMinOutsideTemp is FALSE if rOutsideTemp < (rMinimumOutsideTemp - 0.2).

rStateDifferOutsideTempMinOutsideTemp: Value of the difference rOutsideTemp - rMinimumOutsideTemp

bStateDifferRoomTempOutsideTemp: Status indicator. bStateDifferRoomTempOutsideTemp is TRUE if (rRoomTemp - rOutsideTemp) > rDifferOutsideTempRoomTempOn . bStateDifferRoomTempOutsideTemp is FALSE if (rRoomTemp - rOutsideTemp) < rDifferOutsideTempRoomTempOff.

rStateDifferRoomTempOutsideTemp: Value of the difference rRoomTemp - rOutsideTemp

bStateDifferRoomTempSetpointRoomTemp: Status indicator. bStateDifferRoomTempSetpointRoomTemp is TRUE if (rRoomTemp - rSetpointRoomTemp) > rDifferRoomTempSetpointRoomTempOn . bStateDifferRoomTempSetpointRoomTemp is FALSE if (rRoomTemp - rSetpointRoomTemp) <= rDifferRoomTempSetpointRoomTempOn.

rStateDifferRoomTempSetpointRoomTemp: Value of the difference rRoomTemp - rSetpointRoomTemp

udiSecRT_MaxRuntime: Remaining summer night cooling time. If udiSecRT_MaxRuntime = 0 the summer night cooling function can only be reactivated if bEnable is FALSE for at lease one PLC cycle

bInvalidParameter: Indicates that there is an incorrect input parameter. bInvalidParameter must be acknowledged with bReset.

VAR_IN_OUT

      Name                                  : Type          Persistent       Default             Range

rMinimumOutsideTemp                   : REAL;             X             10.0°C          4.0 .. 100.0
rDifferOutsideTempRoomTempOn          : REAL;             X              5.0°C          0.0 .. 100.0
rDifferOutsideTempRoomTempOff         : REAL;             X              2.0°C          0.0 .. 100.0
rDifferRoomTempSetpointRoomTempOn     : REAL;             X              2.0°C          0.0 .. 100.0
udiSecMaxRuntime                      : UDINT;            X              180

rMinimumOutsideTemp: If the outside temperature rOutsideTemp falls below the limit value (rMinimumOutsideTemp - 0.2 K), the summer night cooling function is disabled, i.e. bOn = FALSE. If the outside temperature rOutsideTemp exceeds the limit value (rMinimumOutsideTemp + 0.2 K), one of the conditions for activation of summer night cooling(bOn = TRUE) is met.

rMinimumOutsideTemp must be within the specified range.
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.

rDifferOutsideTempRoomTempOn: The difference rRoomTemp - rOutsideTemp must be greater than the amount of rDifferOutsideTempRoomTempOn to meet one of the conditions for activation of summer night cooling (bOn = TRUE).
((rRoomTemp - rOutsideTemp) > rDifferOutsideRoomTempOn)

rDifferOutsideRoomTempOn must be 0.4 K higher than rDifferOutsideRoomTempOff. Furthermore rDifferOutsideRoomTempOn must be within its specified range.
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.

rDifferOutsideTempRoomTempOff: The difference rRoomTemp - rOutsideTemp must be less than the amount of rDifferOutsideTempRoomTempOff for summer night cooling to be disabled (bOn = FALSE).
((rRoomTemp - rOutsideTemp) < rDifferOutsideRoomTempOff)

rDifferOutsideRoomTempOff must be 0.4 K lower than rDifferOutsideRoomTempOn. Furthermore rDifferOutsideRoomTempOff must be within its specified range.
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.

rDifferRoomTempSetpointRoomTempOn: The room temperature must exceed the room temperature setpoint by this value to meet one of the conditions for activation of summer night cooling (bOn = TRUE).
((rRoomTemp - rSetpointRoomTemp) > rDifferRoomSetpointTemp)

rDifferRoomSetpointTemp must be within its specified range.
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.

udiSecMaxRuntime: Maximum runtime of the summer night cooling function. Summer night cooling can be switched on and off several times within the time. The remaining summer night cooling time is indicated via the variable udiSecRT_MaxRuntime.

udiSecMaxRuntime must be greater than 0.
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.


FB_HVACTimeCon

Application

This function block converts a TIME variable tTime to the three UDINT variables udiSec, udiMin and udiHour, which indicate seconds, minutes and hours. This conversion is reversible, so that a TIME variable can be formed from seconds, minutes and hours.

VAR_IN_OUT

      Name            : Type           Range

udiSec          : UDINT;         0..59
udiMin          : UDINT;         0..59
udiHour         : UDINT;         0..1191
tTime           : TIME;          T#0s..T#71519m59s

udiSec: Variable indicating seconds

udiMin: Variable indicating minutes

udiHour: Variable indicating hours

tTime: Variable of type time

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib


FB_HVACTimeConSec

Application

This function block converts a TIME variable tTime into an UDINT variable udiSec, which indicates seconds. This conversion is reversible, so that a TIME variable can be formed from seconds.

VAR_IN_OUT

      Name            : Type       Range

udiSec          : UDINT;     0..4294967
tTime           : TIME;

udiSec: Variable indicating seconds

tTime: Variable of type time

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib


FB_HVACTimeConSecMs

Application

This function block converts a TIME variable tTime into the UDINT variables udiSec and udiMs, which indicates seconds. This conversion is reversible, so that a TIME variable can be formed from seconds and milliseconds.

VAR_IN_OUT

      Name            : Type       Range

udiMs           : UDINT;     0..999
udiSec          : UDINT;     0..4294966
tTime           : TIME;      T#0s..T#71582m46s999ms

udiSec: Variable indicating milliseconds

udiSec: Variable indicating seconds

tTime: Variable of type time

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib


FB_HVACWork

Application

This function block serves the recording of the operating hours and the switch-on cycles. Furthermore it is possible to report specified operating times being reached.

Recording of operating hours

As soon as the input bOn reports operation, the operating time is recorded with an internal resolution of 1 sec. The output is in the form of a real value in hours to two decimal places (1/100 h). If no system time with second resolution is available, or if this is disrupted, the clock input bSysTakt1Hz is used instead after 2 sec. Triggering takes place on a rising edge at this input. The variant with the system time is more exact than the variant with the clock generator on account of the possibility of synchronization via the network.

Every rising edge at bOn is counted as a switch-on cycle and is available at the output as iCount.

VAR_INPUT

      Name                      : Type

eDataSecurityType         : E_HVACDataSecurityType;
bSetDefault               : BOOL;
bOn                       : BOOL;
bResetHours               : BOOL;
bResetCount               : BOOL;
dtSystemtime              : DT;
bStartWarnLevel           : BOOL;
bStartAlarmLevel          : BOOL;
bSysTakt1Hz               : BOOL;
bReset                    : BOOL;
Attention If E_HVACDataSecurityType := eHVACDataSecurityType_Persistent has been selected, the procedure deviates from the standard. After a change, the data is not written to the flash memory with a delay equivalent to g_tHVACWriteBackupDataTime (default t#5s), but only once per hour. This serves to protect the flash memory, as otherwise all persistent data would be written to it every 5 sec if the operating hour counter were to be running. Besides the four variables of type VAR_IN_OUT, the outputs rHours and iCount are also saved.

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

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

bOn: Operation signal; the operating time is totalled up as long as the signal is present. The rising edge is counted as the switch-on cycle.

bResetHours: A rising edge sets the operating hours counter to 0.

bResetCount: A rising edge sets the switch-on cycle counter to 0.

dtSystemtime: System time with seconds display.

bStartWarnLevel: A rising edge at the input resets the output bQWarnLevel and restarts the time measurement for this.

bStartAlarmLevel: A rising edge at the input resets the output bQAlarmLevel and restarts the time measurement for this.

bSysTakt1Hz: 1 Hz clock signal as a replacement for dtSystemTime; if dtSystemTime is not available, or does not change its value for longer than 2 sec, then the clock signal is used as a replacement.

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

VAR_IN_OUT

      Name                     : Type          Persistent     Default         Range        Unit

uiWarnLevel              : UINT;             X            0            0 .. 50000     h
uiAlarmLevel             : UINT;             X            0            0 .. 50000     h
bEnableWarnLevel         : BOOL;             X          FALSE
bEnableAlarmLevel        : BOOL;             X          FALSE

uiWarnLevel: Number of operating hours after which a warning is output. Upon a rising edge at the input bStartWarnLevel the current operating hours count is added to the value uiWarnLevel and saved as an absolute operating time. As soon as the operating hours counter has reached this value and the signal is enabled via bEnableWarnLevel, the output bQWarnLevel is set to TRUE.

uiAlarmLevel: Number of operating hours after which an alarm is output. Upon a rising edge at the input bStartAlarmLevel the current operating hours count is added to the value uiAlarmLevel and saved as an absolute operating time. As soon as the operating hours counter has reached this value and the signal is enabled via bEnableAlarmLevel, the output bQAlarmLevel is set to TRUE.

bEnableWarnLevel: Enables the output bQWarnLevel.

bEnableAlarmLevel: Enables the output bQAlarmLevel.

VAR_OUTPUT

      Name                 : Type

rHours               : REAL;
uiCount              : UINT;
bQAlarmLevel         : BOOL;
bQWarnLevel          : BOOL;
bInvalidParameter    : BOOL;

rHours: Operating hours with a resolution of 1/100 hours (internally with 1 s).

uiCount: Switch-on cycle counter.

bQAlarmLevel: Operating hours counter has reached the alarm level.

bQWarnLevel: Operating hours counter has reached the warning level.

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACScheduler1ch

Application

This function block is a weekly time switch with one time switch channel. Any desired combination of days of the week can be assigned to the time switch channel. The time switch channel can be defined for one-shot or recurring events. Besides the switching signal, the switch-on and switch-off edges plus the next switch-on or switch-off time as a countdown are available as outputs. The data of the time switch channel is transferred as a reference. The block is therefore able to check the data for changes and to save it as persistent data. After booting, the data is at disposal of the building control system again. The switch-on and switch-off points can be specified to the exact second via the variables tiOn_ss and tiOff_ss of the respective time channel.

If the input variable bEnable is FALSE, then the output variable bOutput is FALSE. Futhermore the time switching channel stTimeChannel are active.

VAR_INPUT

      Name                : Type                      Range       Unit

eDataSecurityType   : E_HVACDataSecurityType;
bSetDefault         : BOOL;
bEnable             : BOOL;
dtSystemTime        : DT;
uiOffsetBefore      : UINT;                    0 .. 240     min
bReset              : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 by the variable bEnable. If bEnable = FALSE there is no switching at the output bOutput.

dtSystemTime: The variable dtSystemTime transfers the computer system time to the timer switch program.

uiOffsetBefore: The switch-on time is brought forward by this number of minutes. This function is useful for the time-optimized switching on of heating circuits. A maximum of 240 min, i.e. 4 hours, may be entered. If the resulting switch-on time is before midnight on the previous day, then midnight will be chosen as the switch-on time. The switch-off time is not affected.

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

Example 1:

Switch-on period from 1:30 to 5:30; uiOffsetBefore has the value 150 min. The switch-on time is brought forward by only 90 minutes to 0:00.

Example 2:

Switch-on period from 13:30 to 17:30; uiOffsetBefore has the value 150 min. The switch-on time is brought forward by 150 minutes to 11:00.

VAR_IN_OUT

      Name              : Type                             Description

stTimeChannel     : ST_HVACTimeChannel;          (*1 timer switch channel *)

stScheduleWeekly: It is possible to generate 1 switch-on time per day of the week with the variable stScheduleWeekly.

      Name                      : Type     Persistent   Default      Range     Unit

TYPE ST_HVACTimeChannel:
    STRUCT
         uiOn_hh          : UINT;        X          0                0 .. 23     h      (* Hour value of the switch-on time on the day *)
        uiOn_mm          : UINT;        X          0           0 .. 59     min    (* Minute value of the switch-on time on the day *)
         uiOn_ss          : UINT;        X          0              0 .. 59     s      (* Second value of the switch-on time on the day *)
         uiOff_hh         : UINT;        X          0                 0 .. 23     h      (* Hour value of the switch-off time on the day *)
         uiOff_mm         : UINT;        X          0                 0 .. 59     min    (* Minute value of the switch-off time on the day *)
         uiOff_ss         : UINT;        X          0            0 .. 59     s      (* Second value of the switch-off time on the day *)
         bEnable          : BOOL;        X        FALSE                           (* Enables this time channel *)
         bAllDays         : BOOL;        X        FALSE                           (* Selects switch-on on all days *)
         bMonday          : BOOL;        X        FALSE                           (* -----------------------------------------------  *)
         bTuesday         : BOOL;        X        FALSE                           (*                                                  *)
         bWednesday       : BOOL;        X        FALSE                           (*                                                  *)
         bThursday        : BOOL;        X        FALSE                           (* Selects switch-on on the respective day of the week *)
         bFriday          : BOOL;        X        FALSE                           (*                                                  *)
         bSaturday        : BOOL;        X        FALSE                           (*                                                  *)
         bSunday          : BOOL;        X        FALSE                           (*  ------------------------------------------------*)
         bResetAfterOn    : BOOL;        X        FALSE                           (* Deletes the Enable after the switching cycle is complete *)
         bQ               : BOOL;                                                 (* Result of the time channel *)

   END_STRUCT
END_TYP

Special notes regarding time input

The following applies:

  • Switch-on time 00:00:00: switch-on begins at 0:00 on the selected day.
  • Switch-off time 00:00:00: switch-off takes place at 23:59:59 on the selected day.

The following applies:

If the switch-on time is later than the switch-off time, the switch-on period is extended through midnight into the next day, regardless of whether the next day is selected.

This setting produces:

For each instance of the function block FB_HVACScheduler1ch it is necessary to create a structure variable of type ST_HVACTimeChannel, which is transferred as a reference (VAR_IN_OUT).

Example:

VAR_GLOBAL
        stTimeChannel : ST_HVACTimeChannel;
END_VAR

Within the weekly planner each timer switch channel is enabled via the variable bEnable (On/Off). If bEnable = FALSE, then the timer switch channel is deactivated and the times entered have no effect. If bAllDays (Mon-Sun) = TRUE, then the times set in uiOn_hh, uiOn_mm, uiOff_hh and uiOff_mm apply to all days of the week from Monday to Sunday. If bAllDays is FALSE, then the days of the week can be selectively assigned to a timer switch channel using the variables bMonday to bSunday. For one-shot events, the variable bResetAfterOn (non-recurring) is activated. After the time set in this channel has elapsed, the entries created under uiOn_hh, uiOn_mm, uiOff_hh, uiOff_mm and the days of the week are retained. However, the variable bEnable (On/Off) is reset to FALSE. In this manner a one-shot event can be defined once and reactivated whenever it is required.

Visualization template for the Target VISU with one timer switch channel: P_Scheduler1ch.ZIP

VAR_OUTPUT

      Name                     : Type       Range       Unit        Description

bOutput                  : BOOL;
bEdgeOn                  : BOOL;
bEdgeOff                 : BOOL;
tNextOn                  : TIME;    0 .. 10080   min       (* Next switch-on time, max.7 days * 24 h * 60 min = 10080 *)
tNextOff                 : TIME;    0 .. 1440    min       (* Next switch-off time, max.same day 24 h * 60 min = 1440 *)
bInvalidParameter        : BOOL;

bOutput: Is TRUE if one of the timer switch channels has switched on.

bEdgeOn: Is TRUE for one PLC cycle after bOutput switches on.

bEdgeOff: Is TRUE for one PLC cycle after bOutput switches off.

tNextOn: Time until the next switch-on of the timer switch program. Maximum value 10080 minutes (1 week).

tNextOff: Time until the next switch-off of the timer switch program. Maximum forecast until midnight .

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACScheduler7ch

Application

This function block is a weekly time switch with seven time switch channels. Any desired combination of days of the week can be assigned to any time switch channel. The time switch channels can be defined for non-recurring or recurring events. Besides the switching signal, the switch-on and switch-off edges plus the next switch-on or switch-off time as a countdown are available as outputs. The data of the time switch channels is transferred as a reference. The block is therefore able to check the data for changes and to save it as persistent data. After booting, the data is at disposal of the building control system again. The switch-on and switch-off points can be specified to the exact second via the variables tiOn_ss and tiOff_ss of the respective time channel.

If the input variable bEnable is FALSE, then the output variable bOutput is FALSE. Futhermore the time switching channels arrTimeChannel are active.

VAR_INPUT

      Name                : Type                     Range      Unit

eDataSecurityType   : E_HVACDataSecurityType;
bSetDefault         : BOOL;
bEnable             : BOOL;
dtSystemTime        : DT;
uiOffsetBefore      : UINT;                   0 .. 240    min
bReset              : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 by the variable bEnable. If bEnable = FALSE there is no switching at the output bOutput.

dtSystemTime: The variable dtSystemTime transfers the computer system time to the time switch program.

uiOffsetBefore: The switch-on time is brought forward by this number of minutes. This function is useful for the time-optimized switching on of heating circuits. A maximum of 240 min, i.e. 4 hours, may be entered. If the resulting switch-on time is before midnight on the previous day, then midnight will be chosen as the switch-on time. The switch-off time is not affected.

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

Example 1:

Switch-on period from 1:30 to 5:30; uiOffsetBefore has the value 150 min. The switch-on time is brought forward by only 90 minutes to 0:00.

Example 2:

Switch-on period from 13:30 to 17:30; uiOffsetBefore has the value 150 min. The switch-on time is brought forward by 150 minutes to 11:00.

VAR_IN_OUT

      Name              : Type                                       Description

arrTimeChannel    : ARRAY[1..7] OF ST_HVACTimeChannel;       (* 7 timer switch channels *)

arrScheduleWeekly: The variable arrScheduleWeekly is an array with 7 declarations of the structure variable ST_HVACTimeChannel. It is possible to generate 1 switch-on time per day of the week with the 7 channels.

      Name                      : Type       Persistent     Default        Range      Unit

TYPE ST_HVACTimeChannel:
    STRUCT
         uiOn_hh          : UINT;          X            0           0 .. 23      h       (* Hour value of the switch-on time on the day *)
         uiOn_mm          : UINT;          X            0           0 .. 59      min     (* Minute value of the switch-on time on the day *)
         uiOn_ss          : UINT;          X            0           0 .. 59      s       (* Second value of the switch-on time on the day *)
         uiOff_hh         : UINT;          X            0           0 .. 23      h       (* Hour value of the switch-off time on the day *)
         uiOff_mm         : UINT;          X            0           0 .. 59      min     (* Minute value of the switch-off time on the day *)
         uiOff_ss         : UINT;          X            0           0 .. 59      s       (* Second value of the switch-off time on the day *)
         bEnable          : BOOL;          X          FALSE                              (* Enables this time channel *)
         bAllDays         : BOOL;          X          FALSE                              (* Selects switch-on on all days *)
         bMonday          : BOOL;          X          FALSE                              (* ----------------------------------------------- *)
         bTuesday         : BOOL;          X          FALSE                              (*                                                 *)
         bWednesday       : BOOL;          X          FALSE                              (*                                                 *)
         bThursday        : BOOL;          X          FALSE                              (* Selects switch-on on the respective day of the week *)
         bFriday          : BOOL;          X          FALSE                              (*                                                 *)
         bSaturday        : BOOL;          X          FALSE                              (*                                                 *)
         bSunday          : BOOL;          X          FALSE                              (* ------------------------------------------------*)
         bResetAfterOn    : BOOL;          X          FALSE                              (* Deletes the Enable after the switching cycle is complete *)
         bQ               : BOOL;                                                        (* Result of the time channel *)
    END_STRUCT
END_TYP
Special notes regarding time input

The following applies:

  • Switch-on time 00:00:00: switch-on begins at 0:00 on the selected day.
  • Switch-off time 00:00:00: switch-off takes place at 23:59:59 on the selected day.

The following applies:

If the switch-on time is later than the switch-off time, the switch-on period is extended through midnight into the next day, regardless of whether the next day is selected.

This setting produces:

For each instance of the function block FB_HVACSchedulerWeekly it is necessary to create an array of type ST_HVACTimeChannel. The size of the array must be 7, since the function block processes a total of 7 weekly time switch cycles and expects these as a reference (VAR_IN_OUT).

Example

VAR_GLOBAL
        arrTimeChannel : ARRAY[1..7] OF ST_HVACTimeChannel;
END_VAR

Within the weekly planner each time switch channel is enabled via the variable bEnable (On/Off). If bEnable = FALSE, then the time switch channel is deactivated and the times entered have no effect. If bAllDays (Mon-Sun) = TRUE, then the times set in uiOn_hh, uiOn_mm, uiOff_hh and uiOff_mm apply to all days of the week from Monday to Sunday. If bAllDays is FALSE, then the days of the week can be selectively assigned to a time switch channel using the variables bMonday to bSunday. For one-shot events, the variable bResetAfterOn (non-recurring) is activated. After the time set in this channel has elapsed, the entries created under uiOn_hh, uiOn_mm, uiOff_hh, uiOff_mm and the days of the week are retained. However, the variable bEnable (On/Off) is reset to FALSE. In this manner a one-shot event can be defined once and reactivated whenever it is required.

Example

Monday switched on from 07:20 until 17:30

Tuesday switched on from 16:40 until 00:00

Wednesday switched on from 00:00 until 23:59:59 (around the clock – 24 hours!)

Thursday switched on from 15:00 until 03:00 Friday morning, non-recurring!

Friday Time switch channel not activated, always switched off!

VAR_OUTPUT

      Name                   : Type       Range        Unit         Description

bOutput                : BOOL;
bEdgeOn                : BOOL;
bEdgeOff               : BOOL;
tNextOn                : TIME;     0 .. 10080    min         (* Next switch-on time, max.7 days * 24 h * 60 min = 10080 *)
tNextOff               : TIME;     0 .. 1440     min         (* Next switch-off time, max.same day 24 h * 60 min = 1440 *)
bInvalidParameter      : BOOL;

bOutput: Is TRUE if one of the time switch channels has switched on.

bEdgeOn: Is TRUE for one PLC cycle after bOutput switches on.

bEdgeOff: Is TRUE for one PLC cycle after bOutput switches off.

tNextOn: Time until the next switch-on of the time switch program. Maximum value 10080 minutes (1 week).

tNextOff: Time until the next switch-off of the time switch program. Maximum forecast until midnight .

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACScheduler7TCHandling

Application

This function block can be used to select and modify an individual line from the data array of a weekly timer. In this way it is easily possible to edit the datasets with a visualisation that only offers a low graphic resolution, without having to show all the data of the array.
The dataset from arr7TimeChannel with index iCurrChannelNumber is copied to data structure stCurrChannel . Modifications of the data in structure stCurrChannel take effect immediately and are transferred to array arr7TimeChannel.

VAR_INPUT

      Name              : Type                      Range       Unit

bGoChannelUp       : BOOL;
bGoChannelDown  : BOOL;

bGoChannelUp: A positive edge shifts the focus to the next higher index in the data array arr7TimeChannel.

bGoChannelDown: A positive edge shifts the focus to the next lower index in the data array arr7TimeChannel.

VAR_IN_OUT

      Name                    : Type                     Range              Description

arr7TimeChannel            : ARRAY[1..7] OF ST_HVACTimeChannel;       (* 7 datasets of the timer switch channel *)
stCurrChannel           : ST_HVACTimeChannel;                       (* data for the dataset selected for the visualisation *)
iCurrChannelNumber      : INT;                                   (* selection index for arr7TimeChannel         *)
iNumOfChannelsToUse     : INT;                   1..7           (* limiter if not all datasets from arr7TimeChannel are to be used *)

arr7TimeChannel : Dataset array for timer switch FB_HVACScheduler7CH.

stCurrChannel: Includes the content of the dataset from array arr7TimeChannel, which is selected via the variable iCurrChannelNumber.

iCurrChannelNumber : Index for array arr7TimeChannel .

iNumOfChannelsToUse : Maximum permitted index for iCurrChannelNumber


FB_HVACScheduler28ch

Application

This function block is a weekly time switch with 28 time switch channels. Any desired combination of days of the week can be assigned to any time switch channel. The time switch channels can be defined for non-recurring or recurring events. Besides the switching signal, the switch-on and switch-off edges plus the next switch-on or switch-off time as a countdown are available as outputs. The data of the time switch channels is transferred as a reference. The block is therefore able to check the data for changes and to save it as persistent data. After booting, the data is at disposal of the building control system again. The switch-on and switch-off points can be specified to the exact second via the variables tiOn_ss and tiOff_ss of the respective time channel.

If the input variable bEnable is FALSE, then the output variable bOutput is FALSE. Futhermore the time switching channels arrTimeChannel are active.

VAR_INPUT

      Name                : Type                      Range         Unit

eDataSecurityType   : E_HVACDataSecurityType;
bSetDefault         : BOOL;
bEnable             : BOOL;
dtSystemTime        : DT;
uiOffsetBefore      : UINT;                    0 .. 240     min
bReset              : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 by the variable bEnable. If bEnable = FALSE there is no switching at the output bOutput.

dtSystemTime: The variable dtSystemTime transfers the computer system time to the time switch program.

uiOffsetBefore: The switch-on time is brought forward by this number of minutes. This function is useful for the time-optimized switching on of heating circuits. A maximum of 240 min, i.e. 4 hours, may be entered. If the resulting switch-on time is before midnight on the previous day, then midnight will be chosen as the switch-on time. The switch-off time is not affected.

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

Example 1

Switch-on period from 1:30 to 5:30; uiOffsetBefore has the value 150 min. The switch-on time is brought forward by only 90 minutes to 0:00.

Example 2

Switch-on period from 13:30 to 17:30; uiOffsetBefore has the value 150 min. The switch-on time is brought forward by 150 minutes to 11:00.

VAR_IN_OUT

      Name                : Type                                    Description

arrTimeChannel      : ARRAY[1..28] OF ST_HVACTimeChannel;    (* 28 timer switch channels *)

arrTimeChannel: The variable arrTimeChannel is an array with 28 declarations of the structure variable ST_HVACTimeChannel. It is possible to generate up to 3 switch-on times per day of the week with the 28 channels.

      Name                      : Type      Persistent    Default       Range        Unit

TYPE ST_HVACTimeChannel:
    STRUCT
         uiOn_hh          : UINT;         X           0           0 .. 23       h     (* Hour value of the switch-on time on the day *)
         uiOn_mm          : UINT;         X           0           0 .. 59       min   (* Minute value of the switch-on time on the day *)
         uiOn_ss          : UINT;         X           0           0 .. 59       s     (* Second value of the switch-on time on the day *)
         uiOff_hh         : UINT;         X           0           0 .. 23       h     (* Hour value of the switch-off time on the day *)
         uiOff_mm         : UINT;         X           0           0 .. 59       min   (* Minute value of the switch-off time on the day *)
         uiOff_ss         : UINT;         X           0           0 .. 59       s     (* Second value of the switch-off time on the day *)
         bEnable          : BOOL;         X         FALSE                              (* Enables this time channel *)
         bAllDays         : BOOL;         X         FALSE                             (* Selects switch-on on all days *)
         bMonday          : BOOL;         X         FALSE                             (* ----------------------------------------------- *)
         bTuesday         : BOOL;         X         FALSE                             (*                                           *)
         bWednesday       : BOOL;         X         FALSE                             (*                                           *)
         bThursday        : BOOL;         X         FALSE                             (* Selects switch-on on the respective day of the week *)
         bFriday          : BOOL;         X         FALSE                             (*                                           *)
         bSaturday        : BOOL;         X         FALSE                             (*                                              *)
         bSunday          : BOOL;         X         FALSE                             (* ------------------------------------------------*)
         bResetAfterOn    : BOOL;         X         FALSE                             (* Deletes the Enable after the switching cycle is complete *)
         bQ               : BOOL;                                                     (* Result of the time channel *)
    END_STRUCT
END_TYP
Special notes regarding time input

The following applies:

  • Switch-on time 00:00:00: switch-on begins at 0:00 on the selected day.
  • Switch-off time 00:00:00: switch-off takes place at 23:59:59 on the selected day.

The following applies:

If the switch-on time is later than the switch-off time, the switch-on period is extended through midnight into the next day, regardless of whether the next day is selected.

This setting produces:

For each instance of the function block FB_HVACScheduler28ch it is necessary to create an array of type ST_HVACTimeChannel. The size of the array must be 28, since the function block processes a total of 28 weekly time switch cycles and expects these as a reference (VAR_IN_OUT).

Example
VAR_GLOBAL
        arrTimeChannel : ARRAY[1..28] OF ST_HVACTimeChannel;
END_VAR

Within the weekly planner each time switch channel is enabled via the variable bEnable (On/Off). If bEnable = FALSE, then the time switch channel is deactivated and the times entered have no effect. If bAllDays (Mon-Sun) = TRUE, then the times set in uiOn_hh, uiOn_mm, uiOff_hh and uiOff_mm apply to all days of the week from Monday to Sunday. If bAllDays is FALSE, then the days of the week can be selectively assigned to a time switch channel using the variables bMonday to bSunday. For one-shot events, the variable bResetAfterOn (non-recurring) is activated. After the time set in this channel has elapsed, the entries created under uiOn_hh, uiOn_mm, uiOff_hh, uiOff_mm and the days of the week are retained. However, the variable bEnable (On/Off) is reset to FALSE. In this manner a one-shot event can be defined once and reactivated whenever it is required.

Example

Monday switched on from 07:20 until 17:30

Tuesday switched on from 16:40 until 00:00

Wednesday switched on from 00:00 until 23:59:59 (around the clock – 24 hours!)

Thursday switched on from 15:00 until 03:00 Friday morning, non-recurring!

Friday Time switch channel not activated, always switched off!

VAR_OUTPUT

      Name                   : Type       Range      Unit         Description

bOutput                : BOOL;
bEdgeOn                : BOOL;
bEdgeOff               : BOOL;
tNextOn                : TIME;    0 .. 10080   min       (* Next switch-on time, max.7 days * 24 h * 60 min = 10080 *)
tNextOff               : TIME;    0 .. 1440    min       (* Next switch-off time, max.same day 24 h * 60 min = 1440 *)
bInvalidParameter      : BOOL;

bOutput: Is TRUE if one of the time switch channels has switched on.

bEdgeOn: Is TRUE for one PLC cycle after bOutput switches on.

bEdgeOff: Is TRUE for one PLC cycle after bOutput switches off.

tNextOn: Time until the next switch-on of the time switch program. Maximum value 10080 minutes (1 week).

tNextOff: Time until the next switch-off of the time switch program. Maximum forecast until midnight.

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACScheduler28TCHandling

Application

This function block can be used to select and modify an individual line from the data array of a weekly timer. In this way it is easily possible to edit the datasets with a visualisation that only offers a low graphic resolution, without having to show all the data of the array.
The dataset from arr7TimeChannel with index iCurrChannelNumber is copied to data structure stCurrChannel . Modifications of the data in structure stCurrChannel take effect immediately and are transferred to array arr28TimeChannel.

VAR_INPUT

      Name              : Type                      Range       Unit

bGoChannelUp       : BOOL;
bGoChannelDown  : BOOL;

bGoChannelUp: A positive edge shifts the focus to the next higher index in the data array arr28TimeChannel.

bGoChannelDown: A positive edge shifts the focus to the next lower index in the data array arr28TimeChannel.

VAR_IN_OUT

      Name                    : Type                    Range              Description

arr28TimeChannel           : ARRAY[1..28]OF ST_HVACTimeChannel;       (* 28 datasets of the timer switch channel *)
stCurrChannel           : ST_HVACTimeChannel;                       (* data of the dataset selected for the visualisation *)
iCurrChannelNumber      : INT;                                   (* selection index for arr28TimeChannel        *)
iNumOfChannelsToUse     : INT;                   1..7           (* limiter if not all datasets from arr28TimeChannel are to be used *)

arr28TimeChannel : Dataset array for timer switch FB_HVACScheduler28CH.

stCurrChannel: Includes the content of the dataset from array arr28TimeChannel, which is selected via the variable iCurrChannelNumber.

iCurrChannelNumber : Index for the array arr28TimeChannel .

iNumOfChannelsToUse : Maximum permitted index for iCurrChannelNumber


FB_HVACSchedulerSpecialPeriods

Application

This function block is a yearly timer switch planner in which, e.g., school holidays or factory shutdowns can be entered. The block is enabled by the input variable bEnable. The input dtSystemTime is linked to the current system time. The output bOutput is set if the time switch conditions are met. Besides the switching signal, the switch-on and switch-off edges plus the next switch-on or switch-off time as a countdown are available as outputs. The data of the timer switch channels is transferred as a reference. The block is therefore able to check the data for changes and to save it as persistent data. After booting, the data is at disposal of the building control system again. The switch-on and switch-off times on the respective day can be entered to the exact minute.

If the input variable bEnable is FALSE, then the output variable bOutput is FALSE. Futhermore the time switching channels arrPeriod are active.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
dtSystemTime             : DT;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 by the variable bEnable. If bEnable = FALSE there is no switching at the output bOutput.

dtSystemTime: The variable dtSystemTime transfers the computer system time to the time switch program.

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

VAR_IN_OUT

      Name                      : Type

arrPeriod                 : ARRAY[1..20] OF ST_HVACPeriod;

arrPeriod: The variable arrPeriod is an array with 20 declarations of the structure variable ST_HVACPeriod.

For each instance of the function block FB_HVACSchedulerSpecialPeriods it is necessary to create an array of type ST_HVACPeriod. The size of the array must be 20, since the function block processes a total of 20 time channels and expects these as a reference (VAR_IN_OUT).

      Name                      : Type         Persistent   Default         Range            Unit

TYPE ST_Period :
    STRUCT
        uiOn_hh          : UINT;            X           0            0 .. 23            h        (* Hour value of the switch-on time on the day *)
        uiOn_mm          : UINT;            X           0            0 .. 59            min      (* Minute value of the switch-on time on the day *)
        uiOn_Day         : UINT;            X           0            0 .. 29/30/31               (* Date: Daily value – range depends on the month *)
        uiOn_Month       : UINT;            X           0            0 .. 12                     (* Date : Monthly value *)
        uiOff_hh         : UINT;            X           0            0 .. 23            h        (* Hour value of the switch-off time on the day *)
        uiOff_mm         : UINT;            X           0            0 .. 59            min      (* Minute value of the switch-off time on the day *)
        uiOff_Day        : UINT;            X           0            0 .. 29/30/31               (* Date: Daily value – range depends on the month *)
        uiOff_Month      : UINT;            X           0            0 .. 12                     (* Date : Monthly value *)
        bEnable          : BOOL;            X         FALSE                                      (* Enables this time channel *)
        bResetAfterOn    : BOOL;            X         FALSE                                      (* Deletes the Enable after the switching cycle is complete *)
        bQ               : BOOL;                                                                 (* Result of the time channel *)
    END_STRUCT
END_TYPE

Special notes regarding time input

The following applies:

Switch-on time 00:00:00: switch-on begins at 0:00 on the selected day.

Switch-off time 00:00:00: switch-off takes place at 23:59:59 on the selected day.

Each time switch channel is enabled via the variable bEnable (On/Off). If bEnable = FALSE, then the time switch channel is deactivated and the times entered have no effect. For one-shot events, the variable bResetAfterOn (non-recurring) is activated. After the time set in this channel has elapsed, the entries created under uiOn_hh, uiOn_mm, uiOff_hh, uiOff_mm, uiOn_Day, uiOff_Day, uiOn_Month und uiOff_Month are retained. However, the variable bEnable (On/Off) is reset to FALSE. In this manner a one-shot event can be defined once and reactivated whenever it is required.

Example:

12/01 switched on from 12:20 until 14/01 at 12:00:00

23/06 switched on from 00:00 until 25/08 at 23:59:59

03/10 switched on from 12:00 until 03/10 at 18:00:00, one-shot!

1.1. until 1/1 Time switch channel not activated, always switched off!

Visualization template for the Target VISU with one time switch channel: P_SchedulerSpecialPeriods.zip

VAR_OUTPUT

      Name                    : Type          Range                              Description

bOutput                 : BOOL;
bEdgeOn                 : BOOL;
bEdgeOff                : BOOL;
tNextOn                 : TIME;      0 .. t#71582m47s295msmin    (* Next switch-on time, max. range = upper limit of Time, approx. 50 days *)
tNextOff                : TIME;      0 .. t#71582m47s295msmin    (* Next switch-off time, max.range = upper limit of Time, approx.50 days *)
bInvalidParameter       : BOOL;

bOutput: Is TRUE if one of the time switch channels has switched on.

bEdgeOn: Is TRUE for one PLC cycle after bOutput switches on.

bEdgeOff: Is TRUE for one PLC cycle after bOutput switches off.

tNextOn: Time until the next switch-on of the time switch program.

tNextOff: Time until the next switch-off of the time switch program.

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACSchedulerPublicHolidays

Application

This function block is a yearly time switch planner in which, e.g., school holidays or factory shutdowns can be entered. The block is enabled by the input variable bEnable. The input dtSystemTime is linked to the current system time. The output bOutput is set if the time switch conditions are met. Besides the switching signal, the switch-on and switch-off edges plus the next switch-on or switch-off time as a countdown are available as outputs. The data of the time switch channels is transferred as a reference. The block is therefore able to check the data for changes and to save it as persistent data. After booting, the data is at disposal of the building control system again. As opposed to the FB_HVACSchedulerSpecialPeriods, only daily switching is possible here.

If the input variable bEnable is FALSE, then the output variable bOutput is FALSE. Futhermore the time switching channels arrHoliday are active.

VAR_INPUT

      Name                     : Type

eDataSecurityType        : E_HVACDataSecurityType;
bSetDefault              : BOOL;
bEnable                  : BOOL;
dtSystemTime             : DT;
bReset                   : BOOL;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_Persistent , the persistent VAR_IN_OUT-Variables of the function block are written to the flash of the controller depending on a value change. Therefore it is mandatory to make one instance of the function block FB_HVACPersistentDataHandling in the main program which is called cyclic. Besides the instanced FB will not be enabled internally.

A value change can be triggered by a building management system, a local operator panel or by a write access out of TwinCAT. In case of a restart of the controller the saved data are read automatically from Flash into the RAM.

Application example: Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the variables which are declared persistent are not saved voltage fail-safe.

Attention A cyclic changing variable must not be connected to the IN_OUT-Variable of a function block if eDataSecurityType:= eHVACDataSecurityType_Persistent. This would lead to premature wear out 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 by the variable bEnable. If bEnable = FALSE there is no switching at the output bOutput.

dtSystemTime: The variable dtSystemTime transfers the computer system time to the time switch program.

bReset: Acknowledge input in the event of an error. Resets the flag bInvalidParameter.

VAR_IN_OUT

      Name                      : Type                              Description

arrHoliday                : ARRAY[1..20] OF ST_HVACHoliday;   (* 20 timer switch channels *)

arrHoliday: The variable arrHoliday is an array with 20 declarations of the structure variable ST_HVACHoliday.

For each instance of the function block FB_HVACSchedulerPublicHolidays it is necessary to create an array of type ST_HVACHoliday. The size of the array must be 20, since the function block processes a total of 20 time channels and expects these as a reference (VAR_IN_OUT).

      Name                     : Type     Persistent     Default       Range                Description

TYPE ST_Holiday:
    STRUCT
        uiOn_Day         : UINT;        X             0        0 .. 29/30/31    (* Date: Daily value – range depends on the month *)
        uiOn_Month       : UINT;        X             0        0 .. 12          (* Date : Monthly value *)
        uiOff_Day        : UINT;        X             0        0 .. 29/30/31    (* Date: Daily value – range depends on the month *)
        uiOff_Month      : UINT;        X             0        0 .. 12          (* Date : Monthly value *)
        bEnable          : BOOL;        X           FALSE                       (* Enables this time channel *)
        bResetAfterOn    : BOOL;        X           FALSE                       (* Deletes the Enable after the switching cycle is complete *)
        bQ               : BOOL;                                                (* Result of the time channel *)
    END_STRUCT
END_TYPE

Each time switch channel is enabled via the variable bEnable (On/Off). If bEnable = FALSE, then the time switch channel is deactivated and the times entered have no effect. For one-shot events, the variable bResetAfterOn (non-recurring) is activated. After the time set in this channel has elapsed, the entries created under uiOn_Day, uiOff_Day, uiOn_Month and uiOff_Month are retained. However, the variable bEnable (On/Off) is reset to FALSE. In this manner a one-shot event can be defined once and reactivated whenever it is required.

Example

24/12 switched on from 00:00 until 26/12 at 23:59:59

03/10 switched on from 00:00 until 03/10 at 23:59:59

18/07 switched on from 00:00 until 19/07 at 23:59:59

1.1. until 1/1 Time switch channel not activated, always switched off!

Visualization template for the Target VISU with one time switch channel: P_SchedulerPublicHolidays.zip

VAR_OUTPUT

      Name                   : Type            Range                                     Description

bOutput                : BOOL;
bEdgeOn                : BOOL;
bEdgeOff               : BOOL;
tNextOn                : TIME;          0 .. t#71582m47s295msmin          (* Next switch-on time, max. range = upper limit of Time, approx. 50 days *)
tNextOff               : TIME;          0 .. t#71582m47s295msmin          (* Next switch-off time, max.range = upper limit of Time, approx.50 days *)
bInvalidParameter      : BOOL;

bOutput: Is TRUE if one of the time switch channels has switched on.

bEdgeOn: Is TRUE for one PLC cycle after bOutput switches on.

bEdgeOff: Is TRUE for one PLC cycle after bOutput switches off.

tNextOn: Time until the next switch-on of the time switch program.

tNextOff: Time until the next switch-off of the time switch program.

bInvalidParameter: An error occurred during the plausibility check. It is deleted again by bReset.


FB_HVACGetSystemTime

Application

With this function block an internal clock (Real Time Clock RTC) can be implemented in the TwinCAT PLC. When the function block is enabled via bEnable, the RTC clock is initialized with the current NT system time. One system cycle of the CPU is used to calculate the current RTC time. The function block must be called once per PLC cycle in order for the current time to be calculated. Internally an instance of the function blocks NT_GetTime and RTC_EX2 is called in the function block from the Utilities library.

Note Due to system characteristics the RTC time deviates from a reference time. The difference depends on the PLC's cycle time, the value of the basic system ticks, and on the hardware being used. The RTC is therefore synchronized internally in the function block with the NT system time depending on the input variables sNETID and tGetSystemTime. The local NT system time can, in turn, be synchronized with a reference time with the aid of the SNTP protocol. Further Information can be found in the Beckhoff Information System on Beckhoff Information System > Embedded PC > Operatingsystem > CE > SNTP: Simple Network Time Protocol

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                    : Type

bEnable                 : BOOL;
sNETID                  : T_AmsNetId;
tGetSystemTime          : TIME;
bGetSystemTime          : BOOL;

bEnable: Enables the function block. If bEnable = TRUE, then the RTC clock is initialized with the NT system time.

sNETID: It is possible here to provide the AmsNetId of the TwinCAT computer whose NT system time is to be found. If it is to be run on the local computer, an empty string can be entered.

tGetSystemTime: Time specification with which the RTC clock is regularly synchronized with the NT system time. This time specification must be greater than or equal to 5 seconds, otherwise the RTC clock will not be synchronized. Parallel to the time specification tGetSystemTime, the RTC clock can be synchronized via the input variable bGetSystemTime.

bGetSystemTime: The RTC clock is synchronized with the NT system time with a rising edge at this input. This takes place in parallel with the time specification tGetSystemTime.

VAR_OUTPUT

      Name                     : Type

bReadyGetSystemTime      : BOOL;
bReadyRTC                : BOOL;
stSystemTime             : TIMESTRUCT;
dtSystemTime             : DT;
uiYear                   : UINT;
uiMonth                  : UINT;
uiDay                    : UINT;
uiDayOfWeek              : UINT;
uiHour                   : UINT;
uiMinute                 : UINT;
uiSecond                 : UINT;
uiMilliseconds           : UINT;
bErrorGetSystemTime      : BOOL;
udiErrorIdGetSystemTime  : UDINT;

bReadyGetSystemTime: The function block was successfully initialized or synchronized with the NT system time.

bReadyRTC: This output is set if the function block has been initialized at least once. If this output is set, then the values for date, time and milliseconds at the outputs are valid.

stSystemTime: Structure with the current RTC time.

dtSystemTime: Date and time of day of the RTC time.

uiYear: The year: 1970 ~ 2106;

uiMonth: The month: 1 ~ 12 (January = 1, February = 2 etc.);

uiDay: The day of the month: 1 ~ 31;

uiDayOfWeek: The day of the week: 0 ~ 6 (Sunday = 0, Monday = 1 etc.);

uiHour: Hour: 0 ~ 23;

uiMinute: Minute: 0 ~ 59;

uiSecond: Second: 0 ~ 59;

uiMilliseconds: Millisecond: 0 ~ 999;

bErrorGetSystemTime: This output is set in the event that an ADS error occurs when transmitting the command. The output indicates with a TRUE that an error has occurred during initialization or snychronisation with the NT system time. The function block continues to attempt to initialize or synchronize the RTC clock until the error has been rectified. The RTC clock starts with an incorrect date and time specification and must therefore be synchronized with the NT system time.

udiErrorIdGetSystemTime: Supplies the ADS error number when the bErrorGetSystemTime output is set.


FB_HVACNOVRAMDataHandling

Application

Located PLC variables are written voltage failure safe to NOVRAM with this function block. Following a power cut or a restart of the controller, the NOVRAM will be read out completely.

Note In the case of ARM-based runtime systems, please note that located PLC variables must be divisible by 4!

Comments

The globally-declared variables g_dwHVACVarConfigStart and g_dwHVACVarConfigEnd are located with the start address and the end address of the memory area. The user must take care to ensure that there are no memory overlaps. The block size is then determined internally from the two addresses. The entire located flag area will be written automatically to NOVRAM in the event of changes to the located flag variables.

see also application example: Example_NOVRAM.zip

VAR_INPUT

      Name                      : Type

sNETID                    : T_AmsNetId;
TMOUT                     : TIME;
udiDevID                  : UDINT;
usiBlockSize              : USINT;

sNETID : AmsNetId of the TwinCAT computer on which the function should be executed. If it is to be run on the local computer, an empty string can be entered.

TMOUT : States the length of the timeout that may not be exceeded by execution of the ADS command.

udiDevID : The Device ID specifies the NOVRAM of the CX90xx or CX10xx to be accessed with the function block for reading or writing. The device IDs are specified by the TwinCAT System Manager during hardware configuration.

usiBlockSize : The block size to be accessed per read/write cycle is given in percent; e.g. 20, i.e 5 read/write cycles will be required in order to access the entire located flag area.

VAR_OUTPUT

      Name                      : Type

udiStatus                 : UDINT;
iNovramReadCount          : INT;
iNovramWriteCount         : INT;
bDone                     : BOOL;
bBusy                     : BOOL;
bError                    : BOOL;
udiErrorID                : UDINT;

udiStatus : = 0 , no status

= 1 , valid data at last reading of NOVRAM

= 2 , invalid data at last reading of NOVRAM. Data were discarded.

iNovramReadCount : Counter that is incremented by 1 when NOVRAM is read from.

iNovramWriteCount: Counter that is incremented by 1 when NOVRAM is written to.

bDone: Will be set to TRUE if the function block is executed.

bBusy: When the block is activated the output is set, and it remains active until execution of the command has been completed.

bError: This output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in udiErrorID.

udiErrorID: Contains the command-specific error code. Please see ADS Return Codes.

Example of handling inside TwinCAT PLC

1st step
  • Start new project
  • Insertion of TcHVAC.lib; this takes place via the registry card Resources in Object Organizer

2nd step
  • Translate project; two warnings are received, since two incompletely defined addresses exist in TcHVAC.lib. The user must define the start and end addresses of the memory range via these two addresses.

3rd step
  • The menu command All Instance Paths in the Insert menu can be used via the tab Resources in Object Organizer under Variables_Configuration. The user can define the start and end addresses after performing this step.

4th step
  • Define the addresses in Variables_Configuration under the Global Variables.
Note On ARM-based platforms (e.g. CX90xx) care must be taken that the addresses of the located variables are divisible by 4.

5th step
  • In this example 0 was defined as the start address and 56 as the end address.

6th step
  • The project must be translated again after performing steps 1 to 5.

Note
  1. For reasons of performance it is useful to address the located variables (VAR_CONFIG Object) without gaps.
  2. If the variable configuration (VAR_CONFIG) is subsequently changed, it is compulsory to load the changes to the target system via an « Online Change » and not via « Load All ». Only an « Online Change » ensures that the NOVRAM data is retained correctly. The NOVRAM data would be recognized as invalid in the case of « Load All ».

Example of the declarations of located variables:

HeatingCurve.fbRealMinTemp_NOVRAM.rVar_N                AT %MB12 : REAL;
HeatingCurve.fbRealMaxTemp_NOVRAM.rVar_N                AT %MB16 : REAL;
HeatingCurve.fbRealNightSetback_NOVRAM.rVar_N           AT %MB20 : REAL;
HeatingCurve.fbRealSetpoint_Y1_NOVRAM.rVar_N            AT %MB24 : REAL;
HeatingCurve.fbRealSetpoint_Y2_NOVRAM.rVar_N            AT %MB28 : REAL;
HeatingCurve.fbRealSetpoint_Y3_NOVRAM.rVar_N            AT %MB32 : REAL;
HeatingCurve.fbRealSetpoint_Y4_NOVRAM.rVar_N            AT %MB36 : REAL;
HeatingCurve.fbRealOutsideTemp_X1_NOVRAM.rVar_N         AT %MB40 : REAL;
HeatingCurve.fbRealOutsideTemp_X2_NOVRAM.rVar_N         AT %MB44 : REAL;
HeatingCurve.fbRealOutsideTemp_X3_NOVRAM.rVar_N         AT %MB48 : REAL;
HeatingCurve.fbRealOutsideTemp_X4_NOVRAM.rVar_N         AT %MB52 : REAL;

.g_dwHVACVarConfigStart                              AT %MB0  : DWORD;
.g_dwHVACVarConfigEnd                                AT %MB56 : DWORD;


FB_HVACPersistentDataHandling

Application

With this function block, all PLC variables that are declared as persistent (VAR PERSISTENT) are written voltage failure safe to a file. The persistent PLC variables are written to this file in the event of changes. This file is saved under ..\TwinCAT\Boot Directory and is named as follows: TCPLC_T_x.wbp (x = number of the runtime system). So that the new status is not saved immediately after a change of the persistent variables, a timeframe of 5 sec is built into the standard setting. This timeframe can be changed by the user. He must assign the new time to the globally-declared constant variable g_tHVACWriteBackupDataTime : TIME := t#5s.

The new status is only saved after the timeframe has elapsed. In the worst case this can mean that changes made within the last timeframe are not saved if a power failure occurs during that time.

Each time the controller is restarted, the status of the persistent data is read from the file. The output variable udiStatus indicates whether or not the data is valid.

In order to secure the persistent variables inside the function block voltage failure safe, it is necessary to start an instance of the FB_HVACPersistentDataHandling block in the MAIN program. The handling of this function is described in more detail on the basis of the following application example.

see also application example: Example_PERSISTENT.zip

Note:

The following setting must be made in the TwinCAT System Manager:

Under PLC Configuration in the PLC Settings (Target System) tab

the option Delete invalid persistent data must be deactivated!!

VAR_INPUT

      Name                      : Type

sNETID                    : T_AmsNetId;
TMOUT                     : TIME;
ePersistentMode           : E_PersistentMode;

sNETID : AmsNetId of the TwinCAT computer on which the function should be executed. If it is to be run on the local computer, an empty string can be entered.

TMOUT : States the length of the timeout that may not be exceeded by execution of the ADS command.

ePersistentMode: Mode in which the persistent data should be written. See also E_PersistentMode.

VAR_OUTPUT

Name                     : Type
udiStatus                : UDINT;
iPersistCount            : INT;
bDone                    : BOOL;
bBusy                    : BOOL;
bError                   : BOOL;
udiErrorID               : UDINT;

udiStatus :    0 = No status
1 = Persistent data read successfully
2 = Backup from persistent data read
3 = Neither persistent nor backup data
read

iPersistCount:Counter that is incremented by 1 after successful writing.

bDone: Will be set to TRUE if the function block is executed.

bBusy: When the block is activated the output is set, and it remains active until execution of the command has been completed.

bError: This output is se to TRUE if an error occurs during the execution of a command.

udiErrorID: Contains the command-specific error code. Please see ADS Return Codes.


FB_HVACPersistentDataFileCopy

Application

This block can be used, for instance, to copy binary data on the local TwinCAT PC or from a remote TwinCAT PC to the local TwinCAT PC. The function block cannot be used to access network drives. The following steps are executed upon a rising edge at bExecute:

a) Open the source and destination files;

b) Read the source file into a buffer;

c) Write the bytes that have been read from the buffer into the destination file;

d) Check whether the end of the source file has been reached. If not, then repeat b) and c). If yes, then jump to e);

e) Close the source and destination files;

The file is copied one segment at a time. In this function block, the size of the buffer has been specified as 100 bytes, but this can be modified.

Application example

Download | Required library
 | TcHVAC.lib

VAR_INPUT

      Name                     : Type

srcNETID                 : T_AmsNetId;
srcFileName              : T_MaxString;
destNETID                : T_AmsNetId;
destFileName             : T_MaxString;
bExecute                 : BOOL;
tAdsTimeOut              : TIME;

srcNETID : AmsNetId of the TwinCAT computer on which the function should be executed. If it is to be run on the local computer, an empty string can be entered.

srcFileName: Contains the path and file name for the file to be opened. Note: The path can only point to the local computer’s file system! This means that network paths can not be used here!

destNETID : AmsNetId of the TwinCAT computer on which the file should be copied.

destFileName : Contains the path and the file name of the destination file. Note: The path can only point to the local computer’s file system! This means that network paths can not be used here!

bExecute : The steps listed above are executed upon a rising edge at bExecute.

tAdsTimeOut : States the length of the timeout that may not be exceeded by execution of the ADS command.

VAR_OUTPUT

      Name                     : Type

bDone                    : BOOL;
bBusy                    : BOOL;
bError                   : BOOL;
udiErrorID               : UDINT;

bDone: Will be switched to TRUE if the function block is executed.

bBusy: When the block is activated the output is set, and it remains active until execution of the command has been completed.

bError: This output is switched to TRUE if an error occurs during the execution of a command.

udiErrorID: Contains the command-specific error code. Please see ADS Return Codes.


FB_HVACSetLocalTime

Application

The function block FB_HVACSetLocalTime sets the local NT-system time and the date of a TwinCAT system (the local NT-system time is displayed in the task bar). The system time can be forced either over the variables uiYear, uiMonth, uiDay, uiHour, uiMinute and uiSecond or over the structure stSystemTime. This can be chosen with bEnableStruct.

Note It is possible to synchronize the local system time to a reference time with the help of the SNTP protocol. Further Information can be found in the Beckhoff Information System on Beckhoff Information System > Embedded PC > Operatingsystem > CE > SNTP: Simple Network Time Protocol

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib

VAR_INPUT

      Name                    : Type              RANGE:

sNetId                  : T_AmsNetId;
bSetLocalTime           : BOOL;
uiYear                  : UINT;             1970 - 2106
uiMonth                 : UINT;             1 - 12
uiDay                   : UINT;             1 - 31
uiHour                  : UINT;             0 - 23
uiMinute                : UINT;             0 - 59
uiSecond                : UINT;             0 - 59
bEnableStruct           : BOOL;
stSystemtime            : TIMESTRUCT;
tTimeout                : TIME;

sNetId: It is possible here to provide the AmsNetId of the TwinCAT computer whose NT system time is to be found. If it is to be run on the local computer, an empty string can be entered.

bSetLocalTime: Activation of the function block with a positive flag. Acknowledge input in the event of an error

uiYear: Year 1970-2106. The variable is active if bEnableStruct= FALSE. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

uiMonth: Month 1 - 12 (January =1, February=2, etc. ). The variable is active if bEnableStruct= FALSE. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

uiDay: Day of the month 1 - 31. The variable is active if bEnableStruct= FALSE. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

uiHour: Hour 0 - 23. The variable is active if bEnableStruct= FALSE. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

uiMinute: Minute 0 - 59. The variable is active if bEnableStruct= FALSE. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

uiSecond: Second 0 - 59. The variable is active if bEnableStruct= FALSE. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

bEnableStruct: If bEnableStruct= TRUE, the new local NT-system time will be set over the Input structure stSystemtime. By bEnableStruct= FALSE the new local NT-system will be set over the Input variable uiYear, uiMonth, uiDay, uiHour, uiMinute und uiSecond.

stSystemTime: Input structure with the new local system time. By using a wrong variable bInvalidParameter=TRUE. The new time will not be set.

tTimeout: Time out.

VAR_OUTPUT

      Name                     : Type

bBusy                   : BOOL;
bError                  : BOOL;
udiErrorId              : UDINT;
bInvalidParameter       : BOOL;

bBusy: When the block is activated the output is set, and it remains active until execution has been completed.

bError: This output is switched to TRUE if an error occurs during the execution. The command-specific error code is contained in udiErrorId. bError is acknowledge by the input variable bSetLocalTime.

udiErrorId: Contains the command-specific error code. See ADS error number.

bInvalidParameter: An error occurred during the plausibility check. bInvalidParameter is acknowledge by the input variable bSetlocalTime.


FB_HVACSystemTaskInfo

The function block determines system variables of the task with a resolution of 1 ms, in which it is currently called. If the current cycle time is less than 1 ms, the set task cycle time tTaskCycleTime is output at the output variable tCycleTime.

Attention The tTaskCycleTime of the PLC program must not be longer than 100 ms, as otherwise the digital outputs will be deactivated. The reason for this is that the internal K-Bus of the bus terminals runs synchronously to the PLC program, the bus will no longer be triggered early enough and the bus terminal watchdog is activated.

VAR_OUTPUT

      Name                    : Type

bReady                     : BOOL;
tTaskCycleTime          : TIME;
tCycleTime              : TIME;
usiSystemTask           : USINT;

bReady: The variable is TRUE if the system information has been read out.

tTaskCycleTime: Set task cycle time.

tCycleTime: Cycle time required for the last cycle.

usiSystemTask: Task index of the task.


BackupVar NOVRAM

The user can use standard data types (see table) and integrate them in his application in order to save defined PLC variables voltage failure safe.

Data type | BackupVar NOVRAM block
BOOL | FB_HVACNOVRAM_Bool
BYTE | FB_HVACNOVRAM_Byte
DINT | FB_HVACNOVRAM_Dint
DWORD | FB_HVACNOVRAM_Dword
INT | FB_HVACNOVRAM_Int
LREAL | FB_HVACNOVRAM_Lreal
REAL | FB_HVACNOVRAM_Real
TIME | FB_HVACNOVRAM_Time
SINT | FB_HVACNOVRAM_Sint
UDINT | FB_HVACNOVRAM_Udint
UINT | FB_HVACNOVRAM_Uint
USINT | FB_HVACNOVRAM_Usint
WORD | FB_HVACNOVRAM_Word


FB_HVACNOVRAM_Bool

VAR_INPUT

      Name                   : Type

bSetDefault            : BOOL;
bVar_Default           : BOOL;

bSetDefault: If the variable is TRUE, the value of the input variable bVar_Default is adopted.

bVar_Default: Default value defined by the user. The variable is of the data type BOOL.

VAR_IN_OUT

      Name                   : Type

bVar                   : BOOL;

bVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Byte

VAR_INPUT

      Name                   : Type

bSetDefault            : BOOL;
byVar_Default          : BYTE;

bSetDefault: If the variable is TRUE, the value of the input variable byVar_Default is adopted.

byVar_Default: Default value defined by the user. The variable is of the data type BYTE.

VAR_IN_OUT

      Name                   : Type

byVar                  : BYTE;

byVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Dint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
diVar_Default            : DINT;

bSetDefault: If the variable is TRUE, the value of the input variable diVar_Default is adopted.

diVar_Default: Default value defined by the user. The variable is of the data type DINT.

VAR_IN_OUT

      Name                     : Type

diVar                    : DINT;

diVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Dword

VAR_INPUT

      Name                      : Type

bSetDefault               : BOOL;
dwVar_Default             : DWORD;

bSetDefault: If the variable is TRUE, the value of the input variable dwVar_Default is adopted.

dwVar_Default: Default value defined by the user. The variable is of the data type DWORD.

VAR_IN_OUT

      Name                      : Type

dwVar                     : DWORD;

dwVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Int

VAR_INPUT

      Name                      : Type

bSetDefault               : BOOL;
iVar_Default              : INT;

bSetDefault: If the variable is TRUE, the value of the input variable iVar_Default is adopted.

iVar_Default: Default value defined by the user. The variable is of the data type INT.

VAR_IN_OUT

      Name                      : Type

iVar                      : INT;

iVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Lreal

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
lrVar_Default            : LREAL;

bSetDefault: If the variable is TRUE, the value of the input variable lrVar_Default is adopted.

lrVar_Default: Default value defined by the user. The variable is of the data type LREAL.

VAR_IN_OUT

      Name                     : Type

lrVar                    : LREAL;

lrVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Real

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
rVar_Default             : REAL;

bSetDefault: If the variable is TRUE, the value of the input variable rVar_Default is adopted.

rVar_Default: Default value defined by the user. The variable is of the data type REAL.

VAR_IN_OUT

      Name                     : Type

rVar                     : REAL;

rVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Sint

VAR_INPUT

      Name                      : Type

bSetDefault               : BOOL;
siVar_Default             : SINT;

bSetDefault: If the variable is TRUE, the value of the input variable siVar_Default is adopted.

siVar_Default: Default value defined by the user. The variable is of the data type SINT.

VAR_IN_OUT

      Name                      : Type

siVar                     : SINT;

siVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Time

VAR_INPUT

      Name                    : Type

bSetDefault                : BOOL;
tVar_Default            : TIME;

bSetDefault: If the variable is TRUE, the value of the input variable tVar_Default is adopted.

tVar_Default: Default value defined by the user. The variable is of the data type TIME.

VAR_IN_OUT

      Name                    : Type

tVar                       : TIME;

tVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Udint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
udiVar_Default           : UDINT;

bSetDefault: If the variable is TRUE, the value of the input variable udiVar_Default is adopted.

udiVar_Default: Default value defined by the user. The variable is of the data type UDINT.

VAR_IN_OUT

      Name                     : Type

udiVar                   : UDINT;

udiVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Uint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
uiVar_Default            : UINT;

bSetDefault: If the variable is TRUE, the value of the input variable uiVar_Default is adopted.

uiVar_Default: Default value defined by the user. The variable is of the data type UINT.

VAR_IN_OUT

      Name                      : Type

uiVar                     : UINT;

uiVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Usint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
usiVar_Default           : USINT;

bSetDefault: If the variable is TRUE, the value of the input variable usiVar_Default is adopted.

usiVar_Default: Default value defined by the user. The variable is of the data type USINT.

VAR_IN_OUT

      Name                     : Type

usiVar                   : USINT;

usiVar: Variable that is programmed non-volatilely by the user.


FB_HVACNOVRAM_Word

VAR_INPUT

      Name                  : Type

bSetDefault           : BOOL;
wVar_Default          : WORD;

bSetDefault: If the variable is TRUE, the value of the input variable wVar_Default is adopted.

wVar_Default: Default value defined by the user. The variable is of the data type WORD.

VAR_IN_OUT

      Name                  : Type

wVar                  : WORD;

wVar: Variable that is programmed non-volatilely by the user.


BackupVar Persistent

The user can use standard data types (see table) and integrate them in his application in order to save defined PLC variables voltage failure safe.

Data type | BackupVar Persistent block
BOOL | FB_HVACPersistent_Bool
BYTE | FB_HVACPersistent_Byte
DINT | FB_HVACPersistent_Dint
DWORD | FB_HVACPersistent_Dword
INT | FB_HVACPersistent_Int
LREAL | FB_HVACPersistent_Lreal
REAL | FB_HVACPersistent_Real
STRING | FB_HVACPersistent_String
STRUCT | FB_HVACPersistent_Struct
TIME | FB_HVACPersistent_Time
SINT | FB_HVACPersistent_Sint
UDINT | FB_HVACPersistent_Udint
UINT | FB_HVACPersistent_Uint
USINT | FB_HVACPersistent_Usint
WORD | FB_HVACPersistent_Word


FB_HVACPersistent_Bool

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
bVar_Default             : BOOL;

bSetDefault: If the variable is TRUE, the value of the input variable bVar_Default is adopted.

bVar_Default: Default value defined by the user. The variable is of the data type BOOL.

VAR_IN_OUT

      Name                     : Type

bVar                     : BOOL;

bVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Byte

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
byVar_Default            : BYTE;

bSetDefault: If the variable is TRUE, the value of the input variable byVar_Default is adopted.

byVar_Default: Default value defined by the user. The variable is of the data type BYTE.

VAR_IN_OUT

      Name                    : Type

byVar                   : BYTE;

byVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Dint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
diVar_Default            : DINT;

bSetDefault: If the variable is TRUE, the value of the input variable diVar_Default is adopted.

diVar_Default: Default value defined by the user. The variable is of the data type DINT.

VAR_IN_OUT

      Name                     : Type

diVar                    : DINT;

diVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Dword

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
dwVar_Default            : DWORD;

bSetDefault: If the variable is TRUE, the value of the input variable dwVar_Default is adopted.

dwVar_Default: Default value defined by the user. The variable is of the data type DWORD.

VAR_IN_OUT

      Name                     : Type

dwVar                    : DWORD;

dwVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Int

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
iVar_Default             : INT;

bSetDefault: If the variable is TRUE, the value of the input variable iVar_Default is adopted.

iVar_Default: Default value defined by the user. The variable is of the data type INT.

VAR_IN_OUT

      Name                     : Type

iVar                     : INT;

iVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Lreal

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
lrVar_Default            : LREAL;

bSetDefault: If the variable is TRUE, the value of the input variable lrVar_Default is adopted.

lrVar_Default: Default value defined by the user. The variable is of the data type LREAL.

VAR_IN_OUT

      Name                     : Type

lrVar                    : LREAL;

lrVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Real

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
rVar_Default             : REAL;

bSetDefault: If the variable is TRUE, the value of the input variable rVar_Default is adopted.

rVar_Default: Default value defined by the user. The variable is of the data type REAL.

VAR_IN_OUT

      Name                     : Type

rVar                     : REAL;

rVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Sint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
siVar_Default            : SINT;

bSetDefault: If the variable is TRUE, the value of the input variable siVar_Default is adopted.

siVar_Default: Default value defined by the user. The variable is of the data type SINT.

VAR_IN_OUT

      Name                     : Type

siVar                    : SINT;

siVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_String

VAR_INPUT

      Name                            : Type

bSetDefault                : BOOL;
dwAdrString             : DWORD;
udiSizeOfString                 : UDINT;
dwAdrString_Default     : DWORD;

bSetDefault: When this variable is set to TRUE, the value of variable located at dwAdrString_Default is used and hence copied to the address dwAdrString.

dwAdrString: Address of the String variable to be written as persistent.

udiSizeOfString: size of the String variable to be written as persistent.

dwAdrString_Default: Address of the default value of String variable.

VAR_OUTPUT

      Name                      : Type

bInvalidParameter         : BOOL;

bInvalidParameter: TRUE, if udiSizeOfString > g_udiMaxSizeOfString OR dwAdrString = 0 OR dwAdrString_Default = 0

VAR_GLOBAL CONSTANT

      Name                            : Type

g_udiMaxSizeOfString       : UDINT := 255; (* size in number of characters *)

g_udiMaxSizeOfString: Permissible size of String variable allowed to be written as persistent is defined under GLOBAL CONSTANT and can hence be overwritten according to need.

Example:

VAR
    fbBackupString         : FB_HVACPersistent_STRING;
    bSetDefault            : BOOL;                                              (* default flag *)
    sVar                   : STRING(55);                                        (* normal value *)
    sVar_Default           : STRING(55) := 'Store the default String Value';    (* default value *)
    bInvalidParameter      : BOOL:
END_VAR


FB_HVACPersistent_Struct

VAR_INPUT

      Name                            : Type

bSetDefault                : BOOL;
dwAdrStruct             : DWORD;
udiSizeOfStruct                 : UDINT;
dwAdrStruct_Default     : DWORD;

bSetDefault: When this variable is set to TRUE, the value of variables located at dwAdrStruct_Default are used and hence copied to the address dwAdrStruct.

dwAdrStruct: Address of the Structure (structure instance) to be written as persistent.

udiSizeOfStruct: Size of the Structure to be written as persistent.

dwAdrStruct_Default: Address of the instance where default values of Structure elements are located.

VAR_OUTPUT

      Name                      : Type

bInvalidParameter         : BOOL;

bInvalidParameter: TRUE, if udiSizeOfStruct > g_udiMaxNoOfBytesInStruct OR dwAdrStruct = 0 OR dwAdrStruct_Default = 0

VAR_GLOBAL CONSTANT

      Name                            : Type

g_udiMaxNoOfBytesInStruct  : UDINT := 16;  (* size in number of bytes *)

g_udiMaxNoOfBytesInStruct: Permissible size of Structure in bytes allowed to be written as persistent is defined under GLOBAL CONSTANT and can hence be overwritten according to need.

Example:

VAR
    fbBackupStruct         : FB_HVACPersistent_STRUCT;
    bSetDefault            : BOOL;              (* default flag *)
    stTemp                 : ST_Temp;   (* structure values *)
    stTemp_Default         : ST_Temp;   (* default Values *)
    bInvalidParameter      : BOOL;
END_VAR

ST_Temp:

TYPE ST_Temp :
STRUCT
        (* total of 8 bytes *)
        byVar1  : BYTE;
        byVar2  : BYTE;
        byVar3  : BYTE;
        byVar4  : BYTE;
        iVar1   : INT;
        iVar2   : INT;
END_STRUCT
END_TYPE

stTemp_Default.byVar1 := 11;    (* one byte *)
stTemp_Default.byVar2 := 22;    (* one byte *)
stTemp_Default.byVar3 := 33;    (* one byte *)
stTemp_Default.byVar4 := 44;    (* one byte *)
stTemp_Default.iVar1 := 55;             (* two bytes *)
stTemp_Default.iVar2 := 66;             (* two bytes *)


FB_HVACPersistent_Time

VAR_INPUT

      Name                      : Type

bSetDefault               : BOOL;
tVar_Default              : TIME;

bSetDefault: If the variable is TRUE, the value of the input variable tVar_Default is adopted.

tVar_Default: Default value defined by the user. The variable is of the data type TIME.

VAR_IN_OUT

      Name                      : Type

tVar                      : TIME;

tVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Udint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
udiVar_Default           : UDINT;

bSetDefault: If the variable is TRUE, the value of the input variable udiVar_Default is adopted.

udiVar_Default: Default value defined by the user. The variable is of the data type UDINT.

VAR_IN_OUT

      Name                     : Type

udiVar                   : UDINT;

udiVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Uint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
uiVar_Default            : UINT;

bSetDefault: If the variable is TRUE, the value of the input variable uiVar_Default is adopted.

uiVar_Default: Default value defined by the user. The variable is of the data type UINT.

VAR_IN_OUT

      Name                    : Type

uiVar                   : UINT;

uiVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Usint

VAR_INPUT

      Name                     : Type

bSetDefault              : BOOL;
usiVar_Default           : USINT;

bSetDefault: If the variable is TRUE, the value of the input variable usiVar_Default is adopted.

usiVar_Default: Default value defined by the user. The variable is of the data type USINT.

VAR_IN_OUT

      Name                     : Type

usiVar                   : USINT;

usiVar: Variable that is programmed non-volatilely by the user.


FB_HVACPersistent_Word

VAR_INPUT

      Name                      : Type

bSetDefault               : BOOL;
wVar_Default              : WORD;

bSetDefault: If the variable is TRUE, the value of the input variable wVar_Default is adopted.

wVar_Default: Default value defined by the user. The variable is of the data type WORD.

VAR_IN_OUT

      Name                      : Type

wVar                      : WORD;

wVar: Variable that is programmed non-volatilely by the user.


F_RoundLREAL

Application

The function F_RoundLREAL rounds the input variable IrIN of data type LREAL to 1 decimal place. This function can also be used for REAL data types.

VAR_INPUT

lrIN                       : LREAL;


F_RoundLREAL_EX

Application

The function F_RoundLREAL_EX rounds the input variable lrIN of the data type LREAL to the number of decimal places specified by iPrecision. This function can also be used for REAL data types. An instance of the function LTRUNC from the library TcMath.lib is used internally in the function.

VAR_INPUT

      Name                       : Type          Range

lrIN                       : LREAL;
iPrecision                 : INT;          0..5

lrIN: Floating point number that is to be formatted.

Due to the exponential representation in TwinCAT, the following is intercepted internally in the function:
- If lrIN > -0.1 AND lrIN <= -0.05, then the return value of the function is -0.1
- If lrIN < 0.0 AND lrIN > -0.05, then the return value of the function is 0.0
- If lrIN > 0.0 AND lrIN < 0.05, then the return value of the function is 0.0
- If lrIN < 0.1 AND lrIN >= 0.05, then the return value of the function is 0.1

iPrecision: Precision. The value determines the number of digits after the decimal point. The range of decimal places begins with 0 and ends with 5.

Application example

Download | Required library
TcHVAC.pro | TcHVAC.lib


E_HVAC2PointActuatorMode

TYPE E_HVAC2PointActuatorMode:
(
    eHVAC2PointActuatorMode_Auto_BMS        := 0,
    eHVAC2PointActuatorMode_Open_BMS        := 1,
    eHVAC2PointActuatorMode_Close_BMS       := 2,
    eHVAC2PointActuatorMode_Auto_OP         := 3,
    eHVAC2PointActuatorMode_Open_OP         := 4,
    eHVAC2PointActuatorMode_Close_OP        := 5
);
END_TYPE

.._BMS: Building Management System; remote control of the actuator from an BMS.

..OP: Operator Panel; local operation of the actuator from an OP.


E_HVAC2PointCtrlMode

TYPE E_HVAC2PointCtrlMode:
(
     eHVAC2PointCtrlMode_Auto_BMS   := 0,
     eHVAC2PointCtrlMode_On_BMS     := 1,
     eHVAC2PointCtrlMode_Off_BMS    := 2,
     eHVAC2PointCtrlMode_Auto_OP    := 3,
     eHVAC2PointCtrlMode_On_OP      := 4,
     eHVAC2PointCtrlMode_Off_OP     := 5
);
END_TYPE

.._BMS: Building Management System; remote control of the actuator from an BMS.

..OP: Operator Panel; local operation of the actuator from an OP.


E_HVAC3PointActuatorMode

TYPE E_HVAC3PointActuatorMode:
(
    eHVAC3PointActuatorMode_Auto_BMS       := 0,
    eHVAC3PointActuatorMode_Open_BMS       := 1,
    eHVAC3PointActuatorMode_Close_BMS      := 2,
    eHVAC3PointActuatorMode_Stop_BMS       := 3,
    eHVAC3PointActuatorMode_Auto_OP        := 4,
    eHVAC3PointActuatorMode_Open_OP        := 5,
    eHVAC3PointActuatorMode_Close_OP       := 6,
    eHVAC3PointActuatorMode_Stop_OP        := 7
);
END_TYPE

.._BMS: Building Management System; remote control of the actuator from an BMS.

..OP: Operator Panel; local operation of the actuator from an OP.


E_HVACActuatorMode

TYPE E_HVACActuatorMode :
(
  eHVACActuatorMode_Auto_BMS       := 0,
  eHVACActuatorMode_Off_BMS        := 1,
  eHVACActuatorMode_Speed1_BMS     := 2,
  eHVACActuatorMode_Speed2_BMS     := 3,
  eHVACActuatorMode_Speed3_BMS     := 4,
  eHVACActuatorMode_Speed4_BMS     := 5,
  eHVACActuatorMode_Auto_OP        := 6,
  eHVACActuatorMode_Off_OP         := 7,
  eHVACActuatorMode_Speed1_OP      := 8,
  eHVACActuatorMode_Speed2_OP      := 9,
  eHVACActuatorMode_Speed3_OP      := 10,
  eHVACActuatorMode_Speed4_OP      := 11
);
END_TYPE

.._BMS: Building Management System; remote control of the actuator from an BMS.

..OP: Operator Panel; local operation of the actuator from an OP.


E_HVACAirConditioning2SpeedMode

TYPE E_HVACAirConditioning2SpeedMode:
(
    eHVACAirConditioning2SpeedMode_Off                    := 0,
    eHVACAirConditioning2SpeedMode_Heating                := 1,
    eHVACAirConditioning2SpeedMode_Cooling                := 2,
    eHVACAirConditioning2SpeedMode_HeatingAndCooling      := 3
);
END_TYPE


E_HVACAnalogOutputMode

TYPE E_HVACAnalogOutputMode :
(
  eHVACAnalogOutputMode_Auto_BMS    := 0,
  eHVACAnalogOutputMode_Manual_BMS  := 1,
  eHVACAnalogOutputMode_Auto_OP     := 2,
  eHVACAnalogOutputMode_Manual_OP   := 3
);
END_TYPE

.._BMS: Building Management System; remote control of the actuator from an BMS.

..OP: Operator Panel; local operation of the actuator from an OP.


E_HVACAntiBlockingMode

TYPE E_HVACAntiBlockingMode:
(
    eHVACAntiBlockingMode_Off       := 0,
    eHVACAntiBlockingMode_Downtime  := 1,
    eHVACAntiBlockingMode_Weekly    := 2
);
END_TYPE


E_HVACBusTerminal_KL32xx

TYPE E_HVACBusTerminal_KL32xx :
(
        eHVACBusTerminal_None := 0,
(*================================================================================*)
        eHVACBusTerminal_KL3201_0000 := 1,(*Standard PT100*)
        eHVACBusTerminal_KL3201_0010 := 2,(*PT200*)
        eHVACBusTerminal_KL3201_0011 := 3,(*not supported, PT200 Siemens format*)
        eHVACBusTerminal_KL3201_0012 := 4,(*PT500*)
        eHVACBusTerminal_KL3201_0013 := 5,(*not supported, PT500 Siemens format*)
        eHVACBusTerminal_KL3201_0014 := 6,(*PT1000*)
        eHVACBusTerminal_KL3201_0015 := 7,(*not supported, PT1000 Siemens format*)
        eHVACBusTerminal_KL3201_0016 := 8,(*Ni100*)
        eHVACBusTerminal_KL3201_0017 := 9,(*not supported, Ni100 Siemens format*)
        eHVACBusTerminal_KL3201_0018 := 10,(*not supported*)
        eHVACBusTerminal_KL3201_0020 := 11,(*Ohm10_1200*)
        eHVACBusTerminal_KL3201_0021 := 12,(*not supported, PT100 Siemens format*)
        eHVACBusTerminal_KL3201_0023 := 13,(*Ni120*)
        eHVACBusTerminal_KL3201_0024 := 14,(*not supported, Ni120 Siemens format*)
        eHVACBusTerminal_KL3201_0025 := 15,(*Ni1000*)
        eHVACBusTerminal_KL3201_0026 := 16,(*not supported, Ni1000 Siemens format*)
        eHVACBusTerminal_KL3201_0027 := 17,(*not supported, Ohm10_10000*)
        eHVACBusTerminal_KL3201_0028 := 18,(*not supported, high resolution 0,01°C*)
        eHVACBusTerminal_KL3201_0029 := 19,(*Ni1000_LS, Landis&Stefa, TK5000*)
        eHVACBusTerminal_KL3201_0030 := 20,(*not supported*)
        eHVACBusTerminal_KL3201_0031 := 21,(*PT1000,2 wire connection*)
(*================================================================================*)
        eHVACBusTerminal_KL3202_0000 := 22,(*Standard PT100*)
        eHVACBusTerminal_KL3202_0010 := 23,(*PT200*)
        eHVACBusTerminal_KL3202_0011 := 24,(*not supported, PT200 Siemens format*)
        eHVACBusTerminal_KL3202_0012 := 25,(*PT500*)
        eHVACBusTerminal_KL3202_0013 := 26,(*not supported, PT500 Siemens format*)
        eHVACBusTerminal_KL3202_0014 := 27,(*PT1000*)
        eHVACBusTerminal_KL3202_0015 := 28,(*not supported, PT1000 Siemens format*)
        eHVACBusTerminal_KL3202_0016 := 29,(*Ni100*)
        eHVACBusTerminal_KL3202_0017 := 30,(*not supported, Ni100 Siemens format*)
        eHVACBusTerminal_KL3202_0018 := 31,(*not supported*)
        eHVACBusTerminal_KL3202_0020 := 32,(*Ohm10_1200*)
        eHVACBusTerminal_KL3202_0021 := 33,(*not supported, PT100 Siemens format*)
        eHVACBusTerminal_KL3202_0023 := 34,(*Ni120*)
        eHVACBusTerminal_KL3202_0024 := 35,(*not supported, Ni120 Siemens format*)
        eHVACBusTerminal_KL3202_0025 := 36,(*Ni1000*)
        eHVACBusTerminal_KL3202_0026 := 37,(*not supported, Ni1000 Siemens format*)
        eHVACBusTerminal_KL3202_0027 := 38,(*not supported, Ohm10_10000*)
        eHVACBusTerminal_KL3202_0028 := 39,(*not supported, high resolution 0,01°C*)
        eHVACBusTerminal_KL3202_0029 := 40,(*Ni1000_LS, Landis&Stefa, TK5000*)
        eHVACBusTerminal_KL3202_0030 := 41,(*not supported*)
        eHVACBusTerminal_KL3202_0031 := 42,(*PT1000,2 wire connection*)
(*================================================================================*)
        eHVACBusTerminal_KL3204_0000 := 43,(*Standard PT100*)
        eHVACBusTerminal_KL3204_0010 := 44,(*PT200*)
        eHVACBusTerminal_KL3204_0011 := 45,(*not supported, PT200 Siemens format*)
        eHVACBusTerminal_KL3204_0012 := 46,(*PT500*)
        eHVACBusTerminal_KL3204_0013 := 47,(*not supported, PT500 Siemens format*)
        eHVACBusTerminal_KL3204_0014 := 48,(*PT1000*)
        eHVACBusTerminal_KL3204_0015 := 49,(*not supported, PT1000 Siemens format*)
        eHVACBusTerminal_KL3204_0016 := 50,(*Ni100*)
        eHVACBusTerminal_KL3204_0017 := 51,(*not supported, Ni100 Siemens format*)
        eHVACBusTerminal_KL3204_0018 := 52,(*not supported*)
        eHVACBusTerminal_KL3204_0020 := 53,(*Ohm10_1200*)
        eHVACBusTerminal_KL3204_0021 := 54,(*not supported, PT100 Siemens format*)
        eHVACBusTerminal_KL3204_0023 := 55,(*Ni120*)
        eHVACBusTerminal_KL3204_0024 := 56,(*not supported, Ni120 Siemens format*)
        eHVACBusTerminal_KL3204_0025 := 57,(*Ni1000*)
        eHVACBusTerminal_KL3204_0026 := 58,(*not supported, Ni1000 Siemens format*)
        eHVACBusTerminal_KL3204_0027 := 59,(*not supported, Ohm10_10000*)
        eHVACBusTerminal_KL3204_0028 := 60,(*not supported, high resolution 0,01°C*)
        eHVACBusTerminal_KL3204_0029 := 61,(*Ni1000_LS, Landis&Stefa, TK5000*)
        eHVACBusTerminal_KL3204_0030 := 62,(*not supported*)
(*================================================================================*)
        eHVACBusTerminal_KL3228_0000 := 63,(*Standard PT1000*)
(*================================================================================*)
        eHVACBusTerminal_NotSupported        := 64,(*error, bus terminal not supported*)
        eHVACBusTerminal_KL3201_NotSupported := 65,(*error, bus terminal not supported*)
        eHVACBusTerminal_KL3202_NotSupported := 66,(*error, bus terminal not supported*)
        eHVACBusTerminal_KL3204_NotSupported := 67,(*error, bus terminal not supported*)
        eHVACBusTerminal_KL3228_NotSupported := 68 (*error, bus terminal not supported*)
(*================================================================================*)
        eHVACBusTerminal_KL3208_0010         := 69,(*Standard PT1000*)
        eHVACBusTerminal_KL3208_NotSupported := 70(*error, bus terminal not supported*)
);
END_TYPE


E_HVACCtrlMode

TYPE E_HVACCtrlMode :
(
    eHVACCtrlMode_Auto     := 0,
    eHVACCtrlMode_Manual   := 1
);
END_TYPE


E_HVACConvectionMode

TYPE E_HVACConvectionMode :
(
    eHVACConvectionMode_WithFan       := 0,
    eHVACConvectionMode_WithoutFan    := 1
);
END_TYPE


E_HVACDataSecurityType

TYPE E_HVACDataSecurityType:
(
    eHVACDataSecurityType_Persistent     := 0,
    eHVACDataSecurityType_Idle           := 1
);
END_TYPE


E_HVACErrorCodes

TYPE E_HVACErrorCodes :
(
eHVACErrorCodes_NoError                             := 0,
eHVACErrorCodes_Error_tTaskCycleTime                := 1,
eHVACErrorCodes_Error_tCtrlCycleTime                := 2,
eHVACErrorCodes_InvalidParam_rDeadRange             := 3,
eHVACErrorCodes_InvalidParam_rDeadBand              := 4,
eHVACErrorCodes_InvalidParam_rKpIsLessThanZero      := 5,
eHVACErrorCodes_InvalidParam_tTi                    := 6,
eHVACErrorCodes_InvalidParam_tTv                    := 7,
eHVACErrorCodes_InvalidParam_tTd                    := 8,
eHVACErrorCodes_InvalidParam_fBaseTime              := 9,
eHVACErrorCodes_InvalidParam_rYMaxIsLessThanrYMin   := 10,
eHVACErrorCodes_Error_MEMCPY                        := 11,
eHVACErrorCodes_Error_ModeNotSupported              := 12,
eHVACErrorCodes_Error_rErrHighLimitOverrun          := 13,
eHVACErrorCodes_Error_rErrLowLimitUnderrun          := 14,
eHVACErrorCodes_Error_NoFeedbackActuator1           := 15,
eHVACErrorCodes_Error_NoFeedbackActuator2           := 16,
eHVACErrorCodes_Error_NoFeedbackActuator3           := 17,
eHVACErrorCodes_Error_NoFeedbackActuator4           := 18,
eHVACErrorCodes_Error_NoFeedbackActuator5           := 19,
eHVACErrorCodes_Error_NoFeedbackActuator6           := 20,
eHVACErrorCodes_Error_NoFeedbackActuator7           := 21,
eHVACErrorCodes_Error_NoFeedbackActuator8           := 22,
eHVACErrorCodes_InvalidParam_tOverlap1Actuator      := 23,
eHVACErrorCodes_InvalidParam_iCountCtrl             := 24,
eHVACErrorCodes_iMaxOnLevel                         := 25,
eHVACErrorCodes_tNoFeedbActuator                    := 26,
eHVACErrorCodes_Error_iNumberOfSequences            := 27,
eHVACErrorCodes_Error_iMyNumberOfSequences          := 28,
eHVACErrorCodes_Error_iCurrentSequences             := 29,
eHVACErrorCodes_Error_MEMSET                        := 30
);
END_TYPE


E_HVACExternalMode

TYPE E_HVACExternalMode :
(
    eHVACExternalMode_Off                := 0,
    eHVACExternalMode_On                 := 1,
    eHVACExternalMode_ShiftAbsolute      := 2
);
END_TYPE


E_HVACExternalRequestMode

TYPE E_HVACExternalRequestMode:
(
    eHVACExternalRequestMode_ButtonOn_Off              := 0,
    eHVACExternalRequestMode_ButtonOffDelay            := 1,
    eHVACExternalRequestMode_SwitchOn_Off              := 2
);
END_TYPE


E_HVACPlantMode

TYPE E_HVACPlantMode:
(
    eHVACPlantMode_TimeSchedulingOnly                         := 0,
    eHVACPlantMode_ExternalRequestOnly                        := 1,
    eHVACPlantMode_TimeScheduling_And_ExternalRequest         := 2,
    eHVACPlantMode_TimeScheduling_Or_ExternalRequest          := 3
);
END_TYPE


E_HVACPowerMeasurementMode

TYPE E_HVACPowerMeasurementMode:
(
    eHVACPowerMeasurementMode_AutoAllValues         := 0,
    eHVACPowerMeasurementMode_Current               := 1,
    eHVACPowerMeasurementMode_Voltage               := 2,
    eHVACPowerMeasurementMode_EffectivePower        := 3,
    eHVACPowerMeasurementMode_EnergyConsumption     := 4,
    eHVACPowerMeasurementMode_PeakCurrentValue      := 5,
    eHVACPowerMeasurementMode_PeakVoltageValue      := 6,
    eHVACPowerMeasurementMode_PeakPowerValue        := 7
);
END_TYPE


E_HVACReferencingMode

TYPE E_HVACReferencingMode :
(
    eHVACReferencingMode_Emulation          := 0,
    eHVACReferencingMode_AnalogFeedback     := 1
);
END_TYPE


E_HVACRegOutsideTemp

TYPE E_HVACRegOutsideTemp:
(
    eHVACReqOutsideTemp_NoRequest          := 0,
    eHVACReqOutsideTemp_OTLowerLimit       := 1,
    eHVACReqOutsideTemp_OTHigherLimit      := 2
);
END_TYPE


E_HVACReqPump

TYPE E_HVACReqPump:
(
    eHVACReqPump_No             := 0,
    eHVACReqPump_OT_LL          := 1,
    eHVACReqPump_OT_HL          := 2,
    eHVACReqPump_VP             := 3,
    eHVACReqPump_OT_LL_OR_VP    := 4,
    eHVACReqPump_OT_HL_OR_VP    := 5,
    eHVACReqPump_OT_LL_AND_VP   := 6,
    eHVACReqPump_OT_HL_AND_VP   := 7
END_TYPE

eHVACReqPump_No: There is no request on the part of the Enum to control the pump

eHVACReqPump_OT_LL: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit)

eHVACReqPump_OT_HL: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit)

eHVACReqPump_VP: The valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_LL_OR_VP: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit) OR the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_HL_OR_VP: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit) OR the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_LL_AND_VP: The outside temperature (OT = rOutsideTemp) must be smaller than rOutsideTempLowLimit (LL = Lower Limit) AND the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn

eHVACReqPump_OT_HL_AND_VP: The outside temperature (OT = rOutsideTemp) must be larger than rOutsideTempHighLimit (HL = Higher Limit) AND the valve position (VP = rValvePosition) must be larger than rValvePositionLimitOn


E_HVACRegValve

TYPE E_HVACRegValve:
(
    eHVACReqValve_NoRequest                := 0,
    eHVACReqValve_OrValvePosHigherLimit    := 1,
    eHVACReqValve_AndValvePosHigherLimit   := 2
);
END_TYPE


E_HVACSensorType

TYPE E_HVACSensorType :
(
    eHVACSensorType_None           := 0,
    eHVACSensorType_PT100          := 1,
    eHVACSensorType_PT200          := 2,
    eHVACSensorType_PT500          := 3,
    eHVACSensorType_PT1000         := 4,
    eHVACSensorType_NI100          := 5,
    eHVACSensorType_NI120          := 6,
    eHVACSensorType_NI1000         := 7,(*Ni1000,DIN*)
    eHVACSensorType_NI1000_LS      := 8,(*Ni1000_LS, Landis&Staefa, TK5000*)
    eHVACSensorType_Ohm10_1200     := 9,
    eHVACSensorType_Ohm10_5000     := 10,
    eHVACSensorType_Ohm10_10000    := 11,
    eHVACSensorType_NotSupported   := 12
);
END_TYPE


E_HVACSequenceCtrlMode

The controller is enabled and controlled within the sequence via this ENUM, depending on the system operating modes.

TYPE E_HVACSequenceCtrlMode :
(
    eHVACSequenceCtrlMode_Stop                                       := 0,
    eHVACSequenceCtrlMode_On                                         := 1,
    eHVACSequenceCtrlMode_NightCooling                               := 2,
    eHVACSequenceCtrlMode_FreezeProtection                           := 3,
    eHVACSequenceCtrlMode_OverheatingProtection                      := 4,
    eHVACSequenceCtrlMode_NightCoolingAndOverheatingProtection       := 5
);
END_TYPE


E_HVACSetpointHeatingMode

TYPE E_HVACSetpointHeatingMode :
(
    eHVACSetpointHeatingMode_Off                    := 0,
    eHVACSetpointHeatingMode_OnOutsideTemp          := 1,
    eHVACSetpointHeatingMode_OnDate                 := 2,
    eHVACSetpointHeatingMode_OnPermanent            := 3,
    eHVACSetpointHeatingMode_OnFreezeProtec         := 4,
    eHVACSetpointHeatingMode_OnNight                := 5,
    eHVACSetpointHeatingMode_OnDay                  := 6
);
END_TYPE

eHVACSetpointHeatingMode_Off: The heating circuit is completely switched off.

Warning The frost protection function is also deactivated in this operating mode!

eHVACSetpointHeatingMode_OnOutsideTemp: Heating period according to outside temperature. The heating circuit is switched on if the average outside
temperature rOutsideTempDamped is smaller than the value of rHeatingLimit. The feed temperature set
value calculated by the heating characteristic curve or the room set value module is routed through to the
output iSetpoint. The output bHeating goes to TRUE and, hence, the heating circuit pump is switched on.
Switching on or off following the heating limits being undershot or exceeded can be delayed by the
parameters tDelayHeatingOn and tDelayHeatingOff.

eHVACSetpointHeatingMode_OnDate: Heating period according to date. The heating circuit is enabled from the date iOn_Day / iOn_Month until
iOff_Day / iOff_Month. The switching on or off of the heating circuit pump after the switch-on or switch-off limits
are reached can be delayed.

eHVACSetpointHeatingMode_OnPermanent: The heating circuit is permanently switched on.

eHVACSetpointHeatingMode_OnFreezeProtec: The heating circuit is in frost protection mode.

eHVACSetpointHeatingMode_OnNight: The heating circuit is in night operating mode.

eHVACSetpointHeatingMode_OnDay: The heating circuit is in day operating mode.


E_HVACSetpointMode

TYPE E_HVACSetpointMode :
(
    eHVACSetpointMode_DIN                 := 0,
    eHVACSetpointMode_DINLimited          := 1,
    eHVACSetpointMode_ConstantValueBase   := 2
);
END_TYPE


E_HVACState

TYPE E_HVACState :
(
  eHVACState_Idle        := 0,
  eHVACState_Active      := 1,
  eHVACState_Error       := 2
);
END_TYPE

This output indicates the current internal state of the block.

eHVACState_Idle: The block has successfully been reset, and is now waiting for selection of the operating mode.
eHVACState_Active: The block is in the active state, which is the normal operating state.
eHVACState_Error: An error has occurred; the block is not executed when in this state.


E_HVACTemperatureCurve

TYPE E_HVACTemperatureCurve :
(
    eHVACTemperatureCurve_None             := 0,
    eHVACTemperatureCurve_NTC1k8           := 1,(*NTC 1.8k, negative, Thermokon*)
    eHVACTemperatureCurve_Ni1000Tk5000     := 2,(*Ni1000 Tk5000, positive, Thermokon*)
    eHVACTemperatureCurve_NTC1k_3_A1       := 3,(*NTC1k, 1K3 A1, negative, S+S*)
    eHVACTemperatureCurve_NTC1k8_3_A1      := 4,(*NTC1.8k, 1.8K3 A1, negative, S+S*)
    eHVACTemperatureCurve_NTC2k2_3_A1      := 5,(*NTC2.2k, 2.2K3 A1, negative, S+S*)
    eHVACTemperatureCurve_NTC3k3_3_A1      := 6,(*NTC3.3k, 3.3K3 A1, negative, S+S*)
    eHVACTemperatureCurve_Ni1000Tk5000_TCR := 7,(*Ni1000 Tk5000 TCR, positive, S+S*)
    eHVACTemperatureCurve_Ni1000_DIN       := 8,(*Ni1000 DIN, positive, S+S*)
    eHVACTemperatureCurve_Pt1000_DIN       := 9 (*Ni1000 DIN, positive, S+S*)
);
END_TYPE


E_HVACTemperatureSensorMode

TYPE E_HVACTemperatureSensorMode :
(
  eHVACTemperatureSensorMode_ReplacementValue                := 0,
  eHVACTemperatureSensorMode_LastValue                       := 1,
  eHVACTemperatureSensorMode_AutoResetReplacementValue       := 2,
  eHVACTemperatureSensorMode_AutoResetLastValue              := 3
);
END_TYPE


ST_HVAC2PointCtrlSequence

TYPE ST_HVAC2PointCtrlSequence :
STRUCT
     tRemainingTimeIncreaseSequence    : TIME;
     tRemainingTimeDecreaseSequence    : TIME;
     rX                                : REAL;
     rW_Max                            : REAL;
     rW_Min                            : REAL;
     rE                                : REAL;
     rCtrl_I_HighLimit                 : REAL;
     rCtrl_I_LowLimit                  : REAL;
     rCtrl_I_Out                       : REAL;
     e2PointCtrlState                  : E_HVAC2PointCtrlMode;
     iNumberOfSequences                : INT;
     iMyNumberInSequence               : INT;
     iCurrentSequence                  : INT;
     bEnable                           : BOOL;
     bError                            : BOOL;
     bOut                              : BOOL;
     bActiveCtrl                       : BOOL;
     b_rW_Max                          : BOOL;
     b_rW_Min                          : BOOL;
END_STRUCT
END_TYPE


ST_HVACAggregate

TYPE ST_HVACAggregate :
STRUCT
    rY_Max             : REAL;
    rY_Min             : REAL;
    iAggregateStep     : INT;
    bBlock             : BOOL;
END_STRUCT
END_TYPE

rY_Max: Parameter specification for constant units.

rY_Min: Parameter specification for constant units.

iAggregateStep: Parameter that specifies the step in which the addressed unit should be fixed or should regulate; see bBlock.

bBlock: If bBlock = FALSE, then the addressed unit is fixed in the specified step via iAggregateStep. If bBlock = TRUE, then the control of the addressed unit is released from the off step (0) to the specified step via iAggregateStep.


ST_HVACCmdCtrl_8Param

TYPE ST_HVACCmdCtrl_8Param :
STRUCT
     udiSecDelayOn                     : UDINT;
     udiSecDelayOff                    : UDINT;
     udiSecMinOn                       : UDINT;
     udiSecMinOff                      : UDINT;
END_STRUCT
END_TYPE

udiSecDelayOn: switch-on delay in seconds

udiSecDelayOff: switch-off delay in seconds

udiSecMinOn: minimum switch-on time in seconds

udiSecMinOff: minimum switch-off time in seconds


ST_HVACCmdCtrl_8State

TYPE ST_HVACCmdCtrl_8State :
STRUCT
     udiSecRT_DelayOn                  : UDINT;
     udiSecRT_DelayOff                 : UDINT;
     udiStep                           : UDINT;
     udiSecRT_MinOn                    : ARRAY[0..g_iNumOfCmdCtrl_8] OF UDINT;
     udiSecRT_MinOff                   : ARRAY[0..g_iNumOfCmdCtrl_8] OF UDINT;
END_STRUCT
END_TYPE

udiSecRT_DelayOn: The remaining time of the switch-on delay of the current step udiStep is indicated.

udiSecRT_DelayOff: The remaining time of the switch-off delay of the current step udiStep is indicated.

udiStep: Status indicating which step the function block is in.

udiSecRT_MinOn[0..g_iNumOfCmdCtrl_8]: The remaining time of the minimum switch-on duration of the outputs is indicated in the one-dimensional field (Table) udiSecRT_MinOn[0..g_iNumOfCmdCtrl_8] .

udiSecRT_MinOff[0..g_iNumOfCmdCtrl_8]: The remaining time of the minimum switch-off duration of the outputs is indicated in the one-dimensional field (Table) udiSecRT_MinOff[0..g_iNumOfCmdCtrl_8] .


ST_HVACHoliday

TYPE ST_HVACHoliday :
STRUCT
  uiOn_Day        : UINT;
  uiOn_Month      : UINT;
  uiOff_Day       : UINT;
  uiOff_Month     : UINT;
  bEnable         : BOOL;
  bResetAfterOn           : BOOL;
  bQ              : BOOL;
END_STRUCT
END_TYPE


ST_HVACI_Ctrl

TYPE ST_HVACI_Ctrl :
STRUCT
    rIntegralHigh        : REAL;
    rIntegralLow         : REAL;
    udiSecDelayHigh      : UDINT;
    udiSecDelayLow       : UDINT;
END_STRUCT
END_TYPE

rIntegralHigh: Positive value for the upper limit at which the integration of the I-transfer element is stopped

rIntegralLow: Positive value for the lower limit at which the integration of the I-transfer element is stopped.

udiSecDelayHigh: Delay time after whose expiry the I-transfer elelment is activated.

udiSecDelayLow: Delay time after whose expiry the I-transfer elelment is activated.


ST_HVACPeriod

TYPE ST_HVACPeriod :
STRUCT
  uiOn_hh          : UINT;
  uiOn_mm          : UINT;
  uiOn_Day         : UINT;
  uiOn_Month       : UINT;
  uiOff_hh         : UINT;
  uiOff_mm         : UINT;
  uiOff_Day        : UINT;
  uiOff_Month      : UINT;
  bEnable          : BOOL;
  bResetAfterOn    : BOOL;
  bQ               : BOOL;
END_STRUCT
END_TYPE


ST_HVACParameterScale_nPoint

TYPE ST_HVACParameterScale_nPoint :
STRUCT
    rX               : ARRAY [1..g_iMaxNoOfScale_nPoint] OF REAL;
    rY               : ARRAY [1..g_iMaxNoOfScale_nPoint] OF REAL;
    iNumberOfPoint   : INT;
END_STRUCT
END_TYPE

rX[1..g_iMaxNoOfScale_nPoint]: Array that includes the values of the single points of the X-axis. The number of points depends on iNumberOfPoint.

Please note: The value rX[1] must be higher then rX[2], rX[2] must be higher then rX[n] OR rX[1] must be lesser then rX[2], rX[2] must be lesser then rX[n].

rY[1..g_iMaxNoOfScale_nPoint]: Array that includes the values of the single points of the Y-axis. The number of points depends on iNumberOfPoint.

iNumberOfPoint: Number of the single values of the X-Y-coordinates.

Please note: iNumberOfPoint must not be lesser then 2 or bigger then g_iMaxNoOfScale_nPoint(60).


ST_HVACPowerMeasurement

TYPE ST_HVACPowerMeasurement :
STRUCT
  diIL1, diIL2, diIL3                      : DINT;
  diUL1, diUL2, diUL3                      : DINT;
  diPL1, diPL2, diPL3                      : DINT;
  diPg                                     : DINT;
  diCosPhiL1, diCosPhiL2, diCosPhiL3       : DINT;
  diCosPhi                                 : DINT;
  diWL1, diWL2, diWL3                      : DINT;
  diWg                                     : DINT;
  diImaxL1, diImaxL2, diImaxL3             : DINT;
  diUmaxL1, diUmaxL2, diUmaxL3             : DINT;
  diPmaxL1, diPmaxL2, diPmaxL3             : DINT;
  diSg                                     : DINT;
  diQg                                     : DINT;
  dummy                                    : DINT;
END_STRUCT
END_TYPE


ST_HVACPowerMeasurementEx

TYPE ST_HVACPowerMeasurementEx :
STRUCT
  fIL1, fIL2, fIL3                      : LREAL;
  fIg                                   : LREAL;
  fUL1, fUL2, fUL3                              : LREAL;
  fPL1, fPL2, fPL3                              : LREAL;
  fPg                                           : LREAL;
  fCosPhiL1, fCosPhiL2, fCosPhiL3               : LREAL;
  fCosPhi                                       : LREAL;
  fWL1, fWL2, fWL3                              : LREAL;
  fWg                                           : LREAL;
  fImaxL1, fImaxL2, fImaxL3                     : LREAL;
  fUmaxL1, fUmaxL2, fUmaxL3                     : LREAL;
  fPmaxL1, fPmaxL2, fPmaxL3                     : LREAL;
  fSg                                           : LREAL;
  fQg                                           : LREAL;
  fFrequencyL1, fFrequencyL2, fFrequencyL3      : LREAL;
END_STRUCT
END_TYPE


ST_HVACPowerRangeTable

TYPE ST_HVACPowerRangeTable :
STRUCT
iAggregate            : INT;
iAggregateStep        : INT;
rY_Max                : REAL;
rY_Min                : REAL;
rIntegralHigh         : REAL;
rIntegralLow          : REAL;
udiSecDelayHigh       : UDINT;
udiSecDelayLow        : UDINT;
bBlock                : BOOL;
END_STRUCT
END_TYPE

iAggregate: Parameter that specifies to which output structure stAggregate1-6 of the function block FB_HVACPowerRangeTable the variables rY_Min, rY_Max, iAggregateStep and bBlock are written.

iAggregateStep: Parameter that specifies the step in which the addressed unit should be fixed or should regulate, depending on bBlock. This variable is output via the structure stAggregateX.

rY_Max: Parameter specification for constant units. The variable value must not be smaller than g_rY_Min and must not exceed g_rY_Max and rY_Max must not be smaller than rY_Min. Otherwise an error is indicated by bError = TRUE and the execution of the function block FB_HVACPowerRangeTable is stopped. This variable is output via the structure stAggregateX.

rY_Min: Parameter specification for constant units. The variable value must not be smaller than g_rY_Min and must not exceed g_rY_Max and rY_Max must not be smaller than rY_Min. Otherwise an error is indicated by bError = TRUE and the execution of the function block FB_HVACPowerRangeTable is stopped. This variable is output via the structure stAggregateX.

rIntegralHigh: Positive value for the upper limit at which the integration of the I-transfer element is stopped; see the VAR_IN_OUT-Variable rIntegralHigh in the FB_HVACI_CtrlStep. This variable is output via the structure stI_Ctrl.

rIntegralLow: Positive value for the lower limit at which the integration of the I-transfer element is stopped; see the VAR_IN_OUT-Variable rIntegralHigh in the FB_HVACI_CtrlStep. This variable is output via the structure stI_Ctrl.

udiSecDelayHigh: Delay time after whose expiry the I-transfer element is activated; see the VAR_IN_OUT-Variable udiSecDelayHigh in the FB_HVACI_CtrlStep. This variable is output via the structure stI_Ctrl.

udiSecDelayLow: Delay time after whose expiry the I-transfer element is activated; see the VAR_IN_OUT-Variable udiSecDelayHigh in the FB_HVACI_CtrlStep. This variable is output via the structure stI_Ctrl.

bBlock: If bBlock = FALSE, then the addressed unit is fixed in the specified step via iAggregateStep. If bBlock = TRUE, then the control of the addressed unit is released from the off step (0) to the specified step via iAggregateStep. This variable is output via the structure stAggregateX.


ST_HVACTimeChannel

TYPE ST_HVACTimeChannel :
STRUCT
  uiOn_hh          : UINT;
  uiOn_mm          : UINT;
  uiOn_ss          : UINT;
  uiOff_hh         : UINT;
  uiOff_mm         : UINT;
  uiOff_ss         : UINT;
  bEnable          : BOOL;
  bAllDays         : BOOL;
  bMonday          : BOOL;
  bTuesday         : BOOL;
  bWednesday       : BOOL;
  bThursday        : BOOL;
  bFriday          : BOOL;
  bSaturday        : BOOL;
  bSunday          : BOOL;
  bResetAfterOn    : BOOL;
  bQ               : BOOL;
END_STRUCT
END_TYPE


ST_HVACTempChangeFunction

Stucture of the node points for the temperature change function in the modules FB_HVACOptimizedOn and FB_HVACOptimizedOff.

TYPE ST_HVACPrestartFunction :
STRUCT
   rOutsideTemp    : ARRAY[1..10] OF REAL; (*[degC]*)
   rRoomTempChange : ARRAY[1..10] OF REAL; (*[degK/min]*)
END_STRUCT
END_TYPE

rOutsideTemp / rRoomTempChange : The 10 node points (outdoor temperature in degree Celsius to room temperature change in degree Kelvin / minute), which are passed.


Calculation of switching time when changing sequence

Example of the determination of the switching time from one sequence to the next.


ExampleProject

TS8000 | TwinCAT PLC Lib: HVAC

Example project

Download | Required library
 | TcHVAC.lib


VAR_GLOBAL CONSTANT

VAR_GLOBAL CONSTANT
    g_tHVACWriteBackupDataTime        : TIME := T#5s;
    g_udiMaxNoOfBytesInStruct         : UDINT := 16;         (* Size in number of bytes *)
    g_udiMaxSizeOfString              : UDINT := 256;        (* Size in number of characters(as in string declaration) + 1 byte for termination*)
    g_iMaxNoOfScale_nPoint            : INT := 60;           (* FB_HVACScale_nPoint*)
    g_iMaxNumberOfSteps               : INT := 32;           (*FB_HVACI_CtrlStep/FB_HVACPowerRangeTable*)
    g_iMinNumberOfSteps               : INT := 0;            (*FB_HVACI_CtrlStep/FB_HVACPowerRangeTable*)
    g_iMaxNumberOfProfiles            : INT := 16;           (*FB_HVACPowerRangeTable*)
    g_iMinNumberOfProfiles            : INT := 1;            (*FB_HVACPowerRangeTable*)
    g_iMaxNumberOfAggregates          : INT := 6;            (*FB_HVACPowerRangeTable*)
    g_iMinNumberOfAggregates          : INT := 1;            (*FB_HVACPowerRangeTable*)
    g_rYMin                           : REAL := -1000;       (*FB_HVACPowerRangeTable*)
    g_rYMax                           : REAL := 1000;        (*FB_HVACPowerRangeTable*)
    g_iAggregateMinNumberOfSteps      : INT := 0;            (*FB_HVACPowerRangeTable*)
    g_iAggregateMaxNumberOfSteps      : INT := 6;            (*FB_HVACPowerRangeTable*)
    g_udiMaxSec                       : UDINT := 4294967;    (*FB_HVACI_CtrlStep / FB_HVACPowerRangeTable*)
    g_iMinNumberOfSequences           : INT := 1;            (*FB_HVAC2PointCtrlSequence*)
    g_iMaxNumberOfSequences           : INT := 16;           (*FB_HVAC2PointCtrlSequence*)
    g_iNumOfCmdCtrl_8                 : INT := 8;            (*FB_HVACCmdCtrl_8*)
END_VAR


Table of sequence controller operating modes

Operating modes

A further special feature of the sequence controller is its control by the Enum E_HVACSequenceCtrlMode
 Not only is the controller enabled by the Enum E_HVACSequenceCtrlMode, it also transmits the operating mode of the air conditioning system to the controller blocks in the sequence. Depending on the operating modes, each sequence controller hence reacts specially to the Enum E_HVACSequenceCtrlMode as illustrated in the table.

Value of: E_HVACSequenceCtrlMode | 0 (Stop) | 1 (On) | 2 (night cooling) | 3 (support operation) | 4 (overheating protection) | 5 (night cooling and overheating protection)
FB_HVACMasterSequenceCtrl Master controller | disabled 0 % | Enable | disabled 0 % | Enable rY=ZuluftMax.Temp | Enable rY=ZuluftMin.Temp | Enable rY=ZuluftMin.Temp
FB_HVACPIDPreHeating Pre-heater | disabled 0 % | Enable | disabled 0 % | Enable 0 % - 100 % | disabled 0 % | disabled 0 %
FB_HVACPIDReHeating Re-heater | disabled 0 % | Enable | disabled 0 % | disabled 0 % | disabled 0 % | disabled 0 %
FB_HVACPIDCooling Cooler | disabled 0 % | Enable | disabled 0 % | disabled 0 % | Enable 0 % - 100 % | Enable 0 % - 100 %
FB_HVACPIDEnergyRecovery Heat recovery | disabled 0 % | Enable | disabled 0 % | disabled 0 % | disabled 0 % | disabled 0 %
FB_HVACPIDMixedAir Mixed air flaps | disabled 0 % | Enable | max. outside air rate 100 % | 0 % air circulation only | 0 % air circulation only | max. outside air rate 100 %


Safety Instructions

Safety Rules

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

State at Delivery

All the components are supplied in particular hardware and software configurations appropriate for the application. Modifications to hardware or software configurations other than those described in the documentation are not permitted, and nullify the liability of Beckhoff Automation GmbH.

Personnel Qualification

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.

Description of safety symbols

The following safety symbols are used in this operating manual. They are intended to alert the reader to the associated safety instructions.

Danger This symbol is intended to highlight risks for the life or health of personnel.

Warning This symbol is intended to highlight risks for equipment, materials or the environment.

Note This symbol indicates information that contributes to better understanding.


E_HVACBackupDataSecurityType

TYPE E_HVACBackupDataSecurityType:
(
    eHVACBackupDataSecurityType_Persistent   := 0,
    eHVACBackupDataSecurityType_Idle         := 1,
    eHVACBackupDataSecurityType_NovRAM       := 2
);
END_TYPE


Functional diagram - PID controller

TwinCAT PLC Library: Building Automation HVAC

PID controller

Standard Proportional-Integral-Differential controller (PID controller) in additive (parallel) form.

Transmission function

Functional diagram


FB_BARSunblindActuatorEx

This function block serves to position a blind via two outputs: drive up and drive down. The blind can be driven to any desired (height) position and louvre angle via the positioning telegram stSunblind. On top of that, the positioning telegram stSunblind also contains manual commands with which the blind can be moved individually to certain positions. These manual commands are controlled by the function block FB_BARSunblindSwitch.

This function-block has to be used, if driving-times longer than 65s are given. The variable format for those times is UDINT (udiTotalTimeUp/udiTotalTimeDown) compared to FB_BARSunblindActuator, where they are to be entered in UINT-format.

Structure of the blind positioning telegram stSunblind.
TYPE ST_BARSunblind:
STRUCT
     uiPosition      : UINT;
     iAngle          : INT;
     bManUp          : BOOL;
     bManDown        : BOOL;
     bManualMode     : BOOL;
     bActive         : BOOL;
END_STRUCT
END_TYPE

The current height position and the louvre angle are not read in by an additional encoder, but determined internally by the travel time of the blind. The calculation is based on the following drive profile (regarded from the highest and lowest position of the blind):

Downward drive profile:

More detailed explanations of the terms "backlash" and "turning" are given here in the downward movement:

The blind normally describes its downward movement with the louvre low point directed outwards, as in fig. 3.
If the blind is in an initial position with the low point directed inwards (i.e. after the conclusion of an upward movement), then a certain time elapses after a new downward movement begins before the louvres start to turn from the "inward low point" to the "outward low point". During this time the louvre angle does not change; the blind only drives downward (fig.1 and fig. 2). This time is an important parameter for the movement calculation and is entered in the function block in ms under uiBacklashTimeDown. Since it is not known at an arbitrary point after a blind movement of an arbitrary length whether part of the backlash has already been travelled, the most secure way to measure the backlash of the downward movement or its travel time is when the blind has initially been driven fully upward. A further important parameter is the time interval of the subsequent turning of the louvres from the "Inward low point" to the "Outward low point". This time is to be entered as uiTurningTimeDown in ms in the function block.

Upward travel profile:

More detailed explanations of the terms "backlash" and "turning" are given here in the upward movement:

The circumstances are similar to the downward movement described above: The blind normally describes its upward movement with the louvre low point directed inwards, as in fig. 3.
If the blind is in an initial position with the low point directed outwards (i.e. after the conclusion of a downward movement), then a certain time elapses after a new upward movement begins before the louvres start to turn from the "Outward low point" to the "Inward low point". During this time the louvre angle does not change; the blind only drives upward (fig. 1 and fig. 2). This time is also an important parameter for the movement calculation and is entered in the function block in ms under uiBacklashTimeUp. Since it is not known at an arbitrary point after a blind movement of an arbitrary length whether part of the backlash has already been travelled, the most secure way to measure the backlash of the upward movement or its travel time is when the blind has initially been driven fully downward. A further important parameter is the time interval of the subsequent turning of the louvres from the "Outward low point" to the "Inward low point". This time is to be entered as uiTurningTimeUp in ms in the function block.

Parameterisation

For the calculation of the (height) position and the louvre angle, the following times now have to be determined for both the upward and downward movement:

  • the travel time of the backlash (uiBacklashTimeUp / uiBacklashTimeDown in ms)
  • the turning duration (uiTurningTimeUp / uiTurningTimeDown in ms)
  • the total travel time (udiTotalTimeUp / udiTotalTimeDown in ms)

Furthermore the following are required for the calculation:

  • the total extended blind height (uiBlindHeight in mm)
  • the highest louvre angle after turning upwards (iAngleLimitUp in degrees)
  • the lowest louvre angle after turning downwards (iAngleLimitDown in degrees)

The louvre angle λ is defined by a notional straight line through the end points of the louvre to the horizontal.

Functioning

The function block fundamentally controls the blind via the information from the positioning telegram stSunblind. If automatic mode is active (bManualMode=FALSE), then the current position and louvre angle are always driven to, wherein changes are immediately accounted for. The height positioning takes priority: First the entered height and afterwards the louvre angle are driven to. For reasons of the simplicity the position error due to the angle movement is disregarded. In manual mode (bManualMode=TRUE) the commands bManUp and bManDown control the blind.

Referencing

Secure referencing is ensured if the blind is driven upward for longer than its complete drive-up time. The position is then in any case "0" and the louvre angle is at its maximum. Since blind positioning without an encoder is naturally always susceptible to error, it is important to automatically reference as often as possible: each time the "0" position is to be driven to (the angle is unimportant), the blind initially drives upward quite normally with continuous position calculation. Once the calculated position value of 0% has been reached, the output bBlindUp is kept active until another complete drive-up time + 5 s has elapsed.
For reasons of flexibility there are now two possibilities to interrupt the referencing procedure: Until the calculated 0% position has been reached, a change of position is still accepted and executed; after reaching this 0% position, the manual command "down" can still move the blind differently. These two sensible limitations make it necessary for the user to ensure that the blind is securely referenced as often as possible.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bEnable            : BOOL;
stSunblind         : ST_BARSunblind;

eDataSecurityType:if eDataSecurityType:= eDataSecurityType_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 internally released.

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:= eDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

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

bEnable: enable input for the function block. As long as this input is TRUE, the actuator function block accepts and executes commands as described above. A FALSE signal on this input resets the control outputs bBlindUp and bBlindDown and the function block remains in a state of rest.

stSunblind: positioning telegram, see ST_BARSunblind.

VAR_OUTPUT

bBlindUp       : BOOL;
bBlindDown     : BOOL;
uiActPosition  : UINT;
uiActAngle     : UINT;
bReferencing   : BOOL;
bBusy          : BOOL;
bError         : BOOL;
udiErrorId     : UDINT;

bBlindUp: control output for blind up.

bBlindDown: control output for blind down.

uiActPosition: current position in percent.

uiActAngle: current louvre angle in degrees.

bReferencing: the blind is in the reference-process, which means, that the output bBlindUp will be set for the complete drive-up time + 5 s. Only the manual command "down" can move the blind in the opposite direction an terminate the reference-mode.

bBusy: a positioning or a referencing procedure is in progress.

bError: this output is switched to TRUE if the parameters entered are erroneous.

udiErrorId: contains the error code if the values entered should be erroneous. See Error codes.

VAR_IN_OUT

In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only to be defined as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip

uiBacklashTimeUp   : UINT;
uiBacklashTimeDown : UINT;
uiTurningTimeUp    : UINT;
uiTurningTimeDown  : UINT;
udiTotalTimeUp      : UINT;
udiTotalTimeDown    : UINT;
uiBlindHeight      : UINT;
iAngleLimitUp      : INT;
iAngleLimitDown    : INT;

uiBacklashTimeUp: time to traverse the backlash in the upward direction in ms.

uiBacklashTimeDown: time to traverse the backlash in the downward direction in ms.

uiTurningTimeUp: time for turning the louvres in the upward direction in ms.

uiTurningTimeDown: time for turning the louvres in the downward direction in ms.

udiTotalTimeUp: complete time for driving up in ms.

udiTotalTimeDown: complete time for driving down in ms.

uiBlindHeight: blind height in mm.

iAngleLimitUp: highest position of the louvres in degrees.

This position is reached, when the blind is completely driven up.

The lamella-angle λ, as described above, is typically greater than 0.

iAngleLimitDown: lowest position of the louvres in degrees.

This position is reached, when the blind is completely driven down.

The lamella-angle λ, as described above, is typically lower than 0.


HVAC LIB Intro

TwinCAT PLC Library: Building Automation HVAC