FB_BARDaylightControl

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

FB_BARDaylightControl 1:
FB_BARDaylightControl

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

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

FB_BARDaylightControl 2:

FB_BARDaylightControl 3:

Manual mode

In the manual operation modes, the bSwitch, bCentralOn and bCentralOff inputs have no function: with uiLightCtrlMode=1, the output value bOn is set to TRUE and with uiLightCtrlMode=2 to FALSE.
A change to manual mode resets a previously started control. On re-entering automatic mode the output value bOn is FALSE and the control must be restarted.

VAR_INPUT

eDataSecurityTyp: 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: FB_BARDaylightControl 4:Example_PERSISTENT.zip

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

Notice

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.

uiLightCtrlMode : operation mode.

bSwitch : positive 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 positive edge on this input switches the control on. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOff : a positive 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 : actual light value [lux].

VAR_OUTPUT

lrDimValue        : LREAL;
bOn               : BOOL;
uiRemainingOnDelay: UINT;
uiRemainingOffDel : 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 : switching 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 time 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 declared as input variables, they would not be able to write a reference variable.
Application example: FB_BARDaylightControl 5: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 outdoor 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 luminous 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 outdoor brightness sinks in such a manner that the constant light regulation 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 outdoor brightness increases in such a manner that the constant light regulation needs to be switched off, then this should take place only after this time delay in order to mask out short-term fluctuations.