FB_BA_RoomSample1

This template represents a simple room with a heating/cooling controller, a sun protection zone function with two blinds and a sun protection zone function with two DALI lights.
The room is also controlled and monitored by a DALI occupancy sensor, which also provides the room brightness.
DALI control
As this room template is an example with DALI components, it requires a fast task with a DALI communication block.
The data exchange with the DALI devices then takes place via an interface and is predefined in FB_Init, here using the example of the brightness and occupancy sensor:
BrtnsPrcSns.iParent := THIS^;
BrtnsPrcSns.iLabel := LblCtl_BrightnessPresenceSensor;
BrtnsPrcSns.eDPADMode := E_BA_DPADMode.eInclude;
BrtnsPrcSns.nAdr := 11;
BrtnsPrcSns.nInstancePresence := 1;
BrtnsPrcSns.nInstanceBrightness := 0;
BrtnsPrcSns.nResBrtns := 10;
BrtnsPrcSns.ipDALICommunication := DALICommunication.fbKL6821Communication;
In the last line, the DALI communication block is assigned to the communication interface pointer of the brightness and occupancy sensor.
This sample implements the function block fbKL6821Communication in the program DALICommunication:

The program DALICommunication must be called in a fast task - instructions can be found in the chapter: Fast task for serial communication.
Brightness and occupancy sensors
The function block FB_BA_BrightnessPresenceDALI represents DALI devices that can read both brightness and presence. The function block instructions describe that the presence is output event-driven, but the brightness is read in intervals of the adjustable duration nPrdQueryBrtns [s].
In this sample, a short duration nPollingIntervalFast and a long duration nPollingIntervalNormal are specified: the short duration is intended for the brightness adaptation of a constant light regulation if it receives a readjustment order (LightZoneConstant.bAdjusting), the long duration is then used in normal operation to avoid further loading of the DALI bus.
Heating and cooling controller
The core of the heating and cooling function is the function block FB_BA_HeatCool_PID.
The global variable list Site informs the function block whether heating or cooling mode is active (eHeatCoolMedium), which temperatures apply for which energy level (stBuildingSpRmT) and which energy level is currently valid building-wide (eBuildingEnergyLevel).
In general, the full heating and cooling output in the Comfort energy level should only be available when people are present. This is reported to the function block via the room's occupancy sensor at the bPrc input.
Two window contacts WdwCon1 and WdwCon2 monitor the heating/cooling. These contacts are designed to supply a TRUE signal when the window is closed. If one of the windows is opened, the function block FB_BA_HeatCool_PID receives a TRUE signal at the bWdwCon input and switches internally to the Protection energy level so as not to control unnecessarily against the outside temperature.
Like the window contacts, the DewPointSensor is designed according to the quiescent current principle. In the critical case, it will output a FALSE signal, which is negated and sent as TRUE to the bDewPnt input of the FB_BA_HeatCool_PID. This immediately ends and locks the cooling mode.
An analog sensor RmTSen provides the room temperature to the control system; the room temperature setpoint can be changed within small limits via a setpoint generator RmTAdj. The pre-set values for fRmTAdjMin and fRmTAdjMax in FB_Init are -5K and 5K.
![]() | The room temperature adjustment is only effective if the Comfort or Precomfort energy level is present, see FB_BA_RmTAdj. |
Blind control
In this sample, a zone function block FB_BA_SunblindZone is predefined for the blind controller, which controls 2 blind actuator function blocks FB_BA_SunBld in parallel.
The zone function block bundles the entire generation of automatic commands, manual control and the link to a visualization (HMI).
The blind actuator function blocks only contain the travel profiles and the link to the hardware. Each blind or blind group that is to be controlled individually therefore requires a zone function block.
The zone function block receives data such as storm protection and anti-icing or sun protection and thermal automatic via the stFacade input. It is thus assigned to a specific facade. If it were a corner room with blinds of different orientations, a further zone function block would have to be added.
Via the occupancy sensor input bPrcDetc, to which the brightness and occupancy sensor is linked, the function block decides whether the sun protection can be active (occupancy) or whether the thermal automatic can be active (non-occupancy).
The thermal automatic also needs to know the room temperature and the building's current setpoint in order to use the sun's radiant heat or protect against it with the help of the blinds. Sun protection and thermal automatic can also generally be deselected within the FB_BA_SunblindZone.
The inputs bSunbldSwiUp and bSunbldSwiDwn are declared here as simple variables and it is up to the user to link them to his application.
To assess the status of the blind group and to display it in a visualization, a blind actuator must be selected as a reference. Its output stFeedback must be connected to the input stReferenceFeedback of the zone function block. In the case of a single blind, the blind itself is the reference actuator.
Light control
Similar to the blinds, the core of the lighting system is a zone function block that combines the generation of higher-level commands (building, floor, area) with local manual operation and the control and display of a possible visualization. The actuator function blocks merely represent the control of the lamps, which can be directly via a bus terminal or via a protocol (DALI).
Here, too, each actuator to be controlled individually requires a zone function block. A reference actuator whose output stFeedback must be linked to the input stReferenceFeedback of the zone function block must also be selected to assess the status of a group. In the case of a single lamp, this itself is the reference actuator.
In this sample, the light zone is a constant light regulation FB_BA_LightGroupConstant.
If fully automatic is selected, the FB_BA_BrightnessPresenceDALI brightness and presence function block can activate constant light regulation via the bPrcDetc input. If presence is no longer detected, the lighting controllers are reset via the bResetRoomFunction input. The automatic function, or its local manual override, is then no longer active and light telegrams of lower priority from the building, floor or area arriving at the stAreaLighting input, can take over the lighting controllers.
The fBrightness input receives the measured luminous intensity of the brightness sensor for light control. The bLightSwi input is declared here as a simple variable and it is up to the user to link it to his application.
![]() | The initialization of the template takes place within the method FB_Init. |
Syntax
FUNCTION_BLOCK FB_BA_RoomSample1 EXTENDS FB_BA_View
VAR_INPUT
stFacade : ST_BA_Facade;
stAreaLighting : ST_BA_Lighting;
END_VAR
VAR_INPUT CONSTANT PERSISTENT
fRmTAdjMin : REAL;
fRmTAdjMax : REAL;
fLgtT : REAL;
nPollingIntervalFast : UDINT;
nPollingIntervalNormal : UDINT;
END_VAR
VAR_INPUT CONSTANT
BrtnsPrcSns : FB_BA_BrightnessPresenceDALI;
Ctrl : FB_BA_HeatCool_PID;
VlvHtg : FB_BA_ActuatorAnalog;
VlvCol : FB_BA_ActuatorAnalog;
WdwCon1 : FB_BA_SensorBinary;
WdwCon2 : FB_BA_SensorBinary;
DewPointSensor : FB_BA_SensorBinary;
RmTSen : FB_BA_SensorAnalog;
RmTAdj : FB_BA_SensorAnalog;
SunBldZone : FB_BA_SunblindZone;
SunBld1 : FB_BA_SunBld;
SunBld2 : FB_BA_SunBld;
LightZoneConstant : FB_BA_LightGroupConstant;
Light1 : FB_BA_LightDALI_TC;
Light2 : FB_BA_LightDALI_TC;
END_VAR
VAR
bSunbldSwiUp : BOOL;
bSunbldSwiDwn : BOOL;
bLightSwi : BOOL;
RmTAvg : FB_BA_EnAvrg02;
bInitializeSensor : BOOL;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
stFacade | Facade-specific blind data and telegrams. | |
stAreaLighting | Resulting light telegram from the building, the floor and finally the area (prioritization). |
Inputs CONSTANT PERSISTENT
Name | Type | Description |
---|---|---|
fRmTAdjMin | REAL | Minimum value of the temperature setpoint shift, predefined to -5K. |
fRmTAdjMax | REAL | Minimum value of the temperature setpoint shift, predefined to 5K. |
fLgtT | REAL | Fixed light temperature of the constant light regulation, predefined at 3000K. |
nPollingIntervalFast | UDINT | Fast polling interval of the brightness sensor, predefined to 1 s. |
nPollingIntervalNormal | UDINT | Slow polling interval of the brightness sensor, predefined to 15 s. |
Inputs CONSTANT
Name | Type | Description |
---|---|---|
BrtnsPrcSns | Reading and evaluation function block for a DALI brightness and occupancy sensor. | |
Ctrl | Heating-cooling control block. | |
VlvHtg | Analog output object heating valve. | |
VlvCol | Analog output object cooling valve. | |
WdwCon1 | Binary input object window contact. | |
WdwCon2 | Binary input object window contact. | |
DewPointSensor | Binary input object dew point sensor. | |
RmTSen | Analog input object room temperature sensor. | |
RmTAdj | Analog input object setpoint adjustment. | |
SunBldZone | Function block blind-specific zone functions. | |
SunBld1 | Actuator function block for a blind. | |
SunBld2 | Actuator function block for a blind. | |
LightZoneConstant | Light zone function block of a constant light regulation. | |
Light1 | Actuator function block for a DALI light. | |
Light2 | Actuator function block for a DALI light. |
VAR
Name | Type | Description |
---|---|---|
bSunbldSwiUp | BOOL | Variable for the "Blinds manually open" button assignment. |
bSunbldSwiDwn | BOOL | Variable for the "Blinds manually down" button assignment. |
bLightSwi | BOOL | Variable for "Switch light manually" button assignment. |
bInitializeSensor | BOOL | Variable for reinitializing the DALI brightness and occupancy sensor. |
Prerequisites
Development environment | Necessary function |
---|---|
TwinCAT from v3.1.4024.64 | TF8040 | TwinCAT Building Automation from V5.10.1.0 |