FB_BA_LightGroupConstant
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) with constant light regulation and manual override.
Function
If fully automatic is set via the parameter eLightActivationMode, the light function ConstLgtCtrl switches to control mode when presence is detected at the input bPresence. However, if semi-automatic is selected, the first press of a button on the template bManualSwitch will set the function block to control mode. Further button presses or a value specification via the HMI (fSetLightValueMan_In / SetLightValueMan_In) abort the control mode and the function block is in manual override.
In this mode, the light can be switched on and off alternately via the template input bManualSwitch or dimmed up and down with a long keystroke (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.
The light control block displays its current state "Control mode" or "Manual override" at the outputs bControlMode and bManualMode; both outputs are not set simultaneously. These outputs are used either to generate a light output telegram with the priority eAutomaticLight via the CnstLgtAuto function block 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, a HMI can be used to display a distinction between control mode and manual override.
On a falling edge at the template input bPresence or by setting bResetRoomFunction, the light control block is disabled, whereby, if selected, it still announces its shutdown via a switch-off ramp with a dwell time at a pre-switch-off value. Both function block outputs bControlMode and bManualMode are then deleted.
In addition to the internal telegrams from bControlMode and ManMode, the input-side stAreaLighting and stScene are also routed to the selector (PrioSwi).
Here, stArea represents the resulting telegram from the higher-level, higher-order 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).
The setpoint for constant light regulation is set using an analog object SpBrightness.
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_LightConstCtrl (internal function block). The use of the following variables is visible in this template:
- bSetLightValueMan_In: Command to switch to manual mode.
- fSetLightValueMan_In: Light value to be adopted.
- bSetCtrlMod_In: Command to switch to constant light control mode.
- eLightActivationMode_In: Activation mode of the light control function from the HMI (fully automatic or semi-automatic). The mode selected via the HMI is saved persistently.
- fLightValue_Out: Output of percentage light value to the HMI.
- bLightOn_Out: Output information "Light On" to the HMI.
- bErr_Out: Output information "Reference actuator faulty" to the HMI.
- eActualPrio_Out: Currently controlling telegram priority to the HMI.
- bCtrlMod_Out: Output information "Light function is in control mode" to the HMI.
The initialization of the template takes place within the method FB_Init. |
Block diagram
Syntax
FUNCTION_BLOCK FB_BA_LightGroupConstant EXTENDS FB_BA_Ext_LightConstCtrl
VAR_INPUT
bManualSwitch : BOOL;
bOn : BOOL;
bOff : BOOL;
bResetRoomFunction : BOOL;
bPresence : BOOL;
fBrightness : REAL;
stAreaLighting : ST_BA_Lighting;
stScene : ST_BA_Lighting;
stReferenceFeedback : ST_BA_LightActuatorFeedback;
END_VAR
VAR_OUTPUT
stLighting : ST_BA_Lighting;
bAdjusting : BOOL;
END_VAR
VAR_INPUT CONSTANT PERSISTENT
fHys : REAL;
nSwiOvrTi : UDINT;
nSwiTi : UDINT;
nDimTi : UDINT;
nRampTi : UDINT;
nPreOffRampTi : UDINT;
nBrtnsAdjTi : UDINT;
fOnValCtrl : REAL;
fOnValMan : REAL;
fPreOffVal : REAL;
nPreOffDly : UDINT;
fMinVal : REAL;
nMinOffDly : UDINT;
nMinOnDly : UDINT;
bMemoryMode : BOOL;
fLgtT : REAL;
END_VAR
VAR_INPUT CONSTANT
SpBrightness : FB_BA_AV_Op;
ManMode : FB_BA_LightingEvt := ( ePrio := E_BA_LightingPrio.eManual);
CnstLgtAuto : FB_BA_LightingEvt := ( ePrio := E_BA_LightingPrio.eAutomaticLight);
END_VAR
VAR
ConstLgtCtrl : FB_BA_LightCtrlConst;
PrioSwi : FB_BA_LightingTgmSel4;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
bManualSwitch | BOOL | If the constant light control function block is not yet active, a short button press first switches the control on, then further signals cause the function block to switch to the manual mode and the following applies: short button press: on / off, long button press: alternately dimming up or down. |
bOn | BOOL | If the constant light control function block is not yet active, a TRUE signal first switches on the control, then this input only refers to switching on in manual mode. |
bOff | BOOL | Switches the light off, the constant light control function block is still in manual mode. If the constant light control function block was previously in control mode, it is now in manual mode. |
bResetRoomFunction | BOOL | This input switches off the constant light control function block. 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 the constant light control block is configured in fully automatic mode, a rising edge can switch the function on and a falling edge can switch it off via this input. In semi-automatic mode, only a falling edge at this input switches off the constant light control block. |
fBrightness | REAL | Current brightness for constant light automatic: Range and unit depend on the light sensor. |
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. |
Outputs
Name | Type | Description |
---|---|---|
stLighting | Resulting output program. | |
bAdjusting | BOOL | The constant light control function block is in regulation mode. This signal can be used to query light sensors, which do not operate in analog mode but via communication, more frequently and thus achieve a more favorable control behavior. |
Inputs CONSTANT PERSISTENT
Name | Type | Description |
---|---|---|
fHys | REAL | Constant light automatic: Hysteresis band. The constant light regulation controls the output up or down until the measured brightness reaches or slightly exceeds or falls below the target value. The light is then considered as adjusted. Only when the measured brightness exceeds or falls below the setpoint by fHys/2, it is readjusted again. The range and unit depend on the used light sensor, see above: fBrtnsSP and fBrtnsSen. Pre-set to 50 in FB_Init. |
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. |
nRampTi | UDINT | Control ramp of the constant light automatic in seconds, related to a dimming from 0 to 100%. Pre-set to 60 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. |
nBrtnsAdjTi | UDINT | Waiting time in seconds after switching on the light for the light sensor to detect the correct value. |
fOnValCtrl | REAL | Switch-on value for control operation, this should be activated with the function previously switched off. Pre-set to 50% in FB_Init. |
fOnValMan | REAL | Switch-on value of the manual function, if "Memory mode" is not selected via the parameter eOperationalMode. 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. |
fMinVal | REAL | Constant light automatic: Minimum output value. If this value has fallen below internally (i.e. it is bright enough that no artificial light is needed), the constant light control switches the light off after nOffDly (in seconds) has elapsed. If the light is switched off and the control detects the need for light above the minimum value again, the control switches the light on again after nOnDly (in seconds) to initially fMinVal. Pre-set to 4% in FB_Init |
nMinOffDly | UDINT | Constant light automatic: Switch-off waiting time in seconds, see fMinVal. Pre-set to 300 s in FB_Init. |
nMinOnDly | UDINT | Constant light automatic: Switch-on waiting time in seconds, see fMinVal. Pre-set to 300 s in FB_Init. |
bMemoryMode | BOOL | Memory mode: 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. |
fLgtT | REAL | Light temperature: Pre-set to 3000 K in FB_Init. |
Inputs CONSTANT
Name | Type | Description |
---|---|---|
SpBrightness | Analog input object: Setpoint of the control [lx]. | |
ManMode | Telegram generator for the light values in manual mode (bManualMode = TRUE). The priority is pre-set to eManualActuator. | |
CnstLgtAuto | Telegram generator for the light values in control mode (bControlMode = TRUE). The priority is pre-set to eConstantLightControl. |
VAR
Name | Type | Description |
---|---|---|
ConstLgtCtrl | Constant light control block. | |
PrioSwi | Telegram selection. |
Requirements
Development environment | Necessary function |
---|---|
TwinCAT from v3.1.4024.56 | TF8040 | TwinCAT Building Automation from V5.8.0.0 |