FB_BA_LightGroupSwitch
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) which is only operated via switches.
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.
Switched by manual commands (not presence), the light function block FB_BA_LightCtrl normally works in such a way that it is always active and indicates this at the output bManualMode. This is due to the fact that the user may want to switch off the light in a targeted manner and this must not lead to a situation where the function block becomes inactive and a lower priority light telegram switches the actuators.
Normally, a falling edge at presence input bPrc deactivates the function. As this is not possible without presence detection, the light function is preceded by a logic that sends a trigger pulse to the reset input bRst when 0% is reached at the light output and thus deactivates the light control input anyway. Alternatively, deactivation can also be carried out via the template input bResetRoomFunction.
If the light is switched on, the function block LightEvent is activated by bManualMode = TRUE and a light telegram with the set light value is output.
In addition to the internal telegram from LightEvent, the input-side telegrams stAreaLighting and stScene are also routed to a 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:
- fSetLightValueMan_In: Light value to be set via the HMI.
- bSetLightValueMan_In: Command from the HMI that the above light value is to be set.
- bLightOn_Out: Output information "Light On" to the HMI.
- fLightValue_Out: Output information light value to the HMI.
- bErr_Out: Output information "Reference actuator faulty" to the HMI.
- eActualPrio_Out: Currently controlling telegram priority to the HMI.
The initialization of the template takes place within the method FB_Init. |
Block diagram
Syntax
FUNCTION_BLOCK FB_BA_LightGroupSwitch EXTENDS FB_BA_Ext_LightCtrl
VAR_INPUT
bManualSwitch : BOOL;
bOn : BOOL;
bOff : BOOL;
bResetRoomFunction : 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
LightEvent : FB_BA_LightingEvt :=( ePrio:= E_BA_LightingPrio.eSimple);
END_VAR
VAR
LightSwitch : FB_BA_LightCtrl;
PrioSwi : FB_BA_LightingTgmSel4;
rtZero : R_TRIG;
bRst : BOOL;
END_VAR
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. |
stAreaLighting | Resulting telegram from the higher levels (area, floor and building), which is formed in the function block FB_BA_AreaLighting. | |
stScene | Reserved telegram input for scene control. | |
stReferenceFeedback | Feedback input of the controlled light actuator or the guide light of the controlled group. |
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 | Selection of the automatic lighting function:
| |
fLgtT | REAL | Light temperature: Pre-set to 3000 K in FB_Init. |
Inputs CONSTANT
Name | Type | Description |
---|---|---|
LightEvent | Telegram generator for the light values. The priority is pre-set to eManualActuator. |
VAR
Name | Type | Description |
---|---|---|
LightSwitch | Light control block. | |
PrioSwi | Telegram selection. | |
rtZero | R_TRIG | Trigger that is activated by the light output value "0". |
bRst | BOOL | Internal variable for deactivating the overall function. A valid light control telegram stLighting is no longer output. |
Requirements
Development environment | Necessary function |
---|---|
TwinCAT from v3.1.4024.56 | TF8040 | TwinCAT Building Automation from V5.8.0.0 |