FB_BA_LightGroupSwitchPresence

FB_BA_LightGroupSwitchPresence 1:

One or more light actuators are combined in a light zone for simultaneous control, depending on local conditions.

This template represents a light zone (room) that is operated both via switches and occupancy sensors.

Function

The light can be switched on and off alternately via the template input bManualSwitch using the control block LightSwitch or dimmed up and down with a long button press (t > SwiOvrTi).

The inputs bOn and bOff allow the light to be switched on and off selectively, while the light value fSetLightValueMan_In is set directly via a HMI using the bSetLightValueMan_In command.

If fully automatic mode is set via the parameter eLightActivationMode, the light switches on automatically when presence is detected at the input bPresence and switches off automatically on a falling edge. However, if semi-automatic mode is selected, the presence input is only used to switch off.

The light control block distinguishes whether it has been activated or overridden manually or by presence. In the first case, the output bAutomaticMode is set, in the second case bManualMode; both outputs are not set at the same time. These outputs are used either to generate a light output telegram with the priority eAutomaticLight via the function block AutoMode or a telegram with the priority eManual via ManMode. The different telegram priority is assigned to the internal HMI variable eActualPrio_Out on the PrioSwi function block. For example, an HMI can be used to display a distinction between automatic or manual/manual override.

On a falling edge at the template input bPresence or by setting bResetRoomFunction, the light control block is deactivated, whereby, if selected, it still announces its switch-off via a switch-off ramp with a dwell time at a pre-switch-off value. Both function block outputs bAutomaticMode and bManualMode are then deleted.

In addition to the internal telegrams from AutoMode and ManMode, the input-side stAreaLighting and stScene are also routed to the selector (PrioSwi).

Here, stArea represents the resulting telegram from the higher levels (area, floor and building), while stScene is reserved for any lighting scene to override the constant light regulation.

The telegram selector (PrioSwi) forwards the telegram with the highest priority - with the same priority, the last telegram sent (last writer wins).

Input stReferenceFeedback

Information about the controlled light actuator or the reference actuator of a group is fed back into the light control function via this input.

The light value of the reference actuator is of particular importance here: If the light actuator is already controlled by another function of the same or lower priority and the template described here now "takes over" control, it must control the actuator based on its existing light value.

In addition, current values and states are transmitted and can be displayed via the HMI.

Data exchange HMI

The data exchange with the HMI is realized here in the base class FB_BA_Ext_LightCtrl (internal function block). The use of the following variables is visible in this template:

FB_BA_LightGroupSwitchPresence 2:

The initialization of the template takes place within the method FB_Init.

Block diagram

FB_BA_LightGroupSwitchPresence 3:

Syntax

FUNCTION_BLOCK FB_BA_LightGroupSwitch EXTENDS FB_BA_Ext_LightCtrl
VAR_INPUT
  bManualSwitch           : BOOL;
  bOn                     : BOOL;
  bOff                    : BOOL;
  bResetRoomFunction      : BOOL;
  bPresence               : BOOL;
  stAreaLighting          : ST_BA_Lighting;
  stScene                 : ST_BA_Lighting;
  stReferenceFeedback     : ST_BA_LightActuatorFeedback;
END_VAR
VAR_OUTPUT
  stLighting              : ST_BA_Lighting;
END_VAR
VAR_INPUT CONSTANT PERSISTENT
  nSwiOvrTi               : UDINT;
  nSwiTi                  : UDINT;
  nDimTi                  : UDINT;
  nPreOffRampTi           : UDINT;
  fOnVal                  : REAL;
  fPreOffVal              : REAL;
  nPreOffDly              : UDINT;
  bMemoryMode             : BOOL;
  eLightActivationMode    : E_BA_LightActivationMode;
  fLgtT                   : REAL;
END_VAR
VAR_INPUT CONSTANT 
  ManMode                 : FB_BA_LightingEvt :=( ePrio:= E_BA_LightingPrio.eManual);  
  AutoMode                : FB_BA_LightingEvt :=( ePrio:= E_BA_LightingPrio.eAutomaticLight);
END_VAR
VAR
  LightSwitch             : FB_BA_LightCtrl;
  PrioSwi                 : FB_BA_LightingTgmSel4;
END_VAR

FB_BA_LightGroupSwitchPresence 4: Inputs

Name

Type

Description

bManualSwitch

BOOL

Short button presses at this input switch the light on and off. Long button presses (t > SwiOvrTi) cause the light to dim up and down.

bOn

BOOL

Switches the light on and activates the light control block.

bOff

BOOL

Switches the light off. Due to an additional circuit that sends a trigger pulse to the bRst input when 0% is reached on the light control block, the block is also deactivated at the same time.

bResetRoomFunction

BOOL

This input switches off the light function block LightSwitch - it is then no longer active (output bAutmaticMode/bManualMode = FALSE). Switch-off takes place via a ramp and dwell time on a basic light value, see parameters: fPreOffVal, nPreOffDly and nPreOffRampT.

bPresence

BOOL

Presence signal input. If fully automatic is selected via the parameter eLightActivationMode, the light function block is activated as "automatic" with a rising edge (output bAutomaticMode = TRUE), provided it was not previously set to manual/manual override (output bManualMode = TRUE).

A falling edge deactivates the light control block (output bAutomaticMode=FALSE, bMaualMode=FALSE).

stAreaLighting

ST_BA_Lighting

Resulting telegram from the higher levels (area, floor and building), which is formed in the function block FB_BA_AreaLighting.

stScene

ST_BA_Lighting

Reserved telegram input for scene control.

stReferenceFeedback

ST_BA_LightActuatorFeedback

Feedback input of the controlled light actuator or the guide light of the controlled group.

FB_BA_LightGroupSwitchPresence 5: Outputs

Name

Type

Description

stLighting

ST_BA_Lighting

Resulting output program.

FB_BA_LightGroupSwitchPresence 6: Inputs CONSTANT PERSISTENT

Name

Type

Description

nSwiOvrTi

UDINT

Distinction time [ms] between short and long button press. Pre-set to 250 ms in FB_Init.

nSwiTi

UDINT

Ramp for the switching functions in seconds, related to a dimming from 0 to 100%. Pre-set to 2 s in FB_Init.

nDimTi

UDINT

Ramp for the dimming functions in seconds, related to a dimming from 0 to 100%. Pre-set to 10 s in FB_Init.

nPreOffRampTi

UDINT

Ramp used to drive to a base value fPreOffVal before switching off. Pre-set to 2 s in FB_Init.

fOnVal

REAL

Switch-on value. Pre-set to 100% in FB_Init.

fPreOffVal / nPreOffDly

REAL / UDINT

Base value and hold time at this value before switching off the overall function. If the current light value already falls below the base value, this function is not active and it is switched off immediately. Pre-set to 4% and 10 s in FB_Init.

bMemoryMode

BOOL

When the light is switched on in manual mode, the light assumes the value that the function had before it was last switched off. If the "Memory-Mode" is not active, the switch-on value is defined via fOnValMan. Pre-set to FALSE in FB_Init.

eLightActivationMode

E_BA_LightActivationMode

Selection of the automatic lighting function:

  • Semi-automatic: Activation of the light control function only by pressing a button; it is automatically deactivated when not occupied.
  • Fully automatic: The light function can be activated either by presence detection or by pressing a button; it is automatically deactivated if there is no presence.

fLgtT

REAL

Light temperature: Pre-set to 3000 K in FB_Init.

FB_BA_LightGroupSwitchPresence 7: Inputs CONSTANT

Name

Type

Description

ManMode

FB_BA_LightingEvt

Telegram generator for the light values. The priority is pre-set to eManualActuator.

AutoMode

FB_BA_LightingEvt

Telegram generator for the light values if the function block has been activated via the occupancy sensor and is not (yet) manually overridden.

The priority is pre-set to eAutomaticLight.

VAR

Name

Type

Description

LightSwitch

FB_BA_LightCtrl

Light control block.

PrioSwi

FB_BA_LightingTgmSel4

Telegram selection.

Requirements

Development environment

Necessary function

TwinCAT from v3.1.4024.56

TF8040 | TwinCAT Building Automation from V5.8.0.0