FB_BARDaylightControl

FB_BARDaylightControl 1:

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

The function block knows three 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 external 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 external 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 external 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 operation

The inputs bSwitch, bCentralOn and bCentralOff have no function in the manual operation modes: the output value bOn is set to TRUE if uiLightCtrlMode=1 and to FALSE if uiLightCtrlMode=2.

FB_BARDaylightControl 4:

Manual mode / automatic mode

Changing to manual mode resets any control process that had previously started. On re-entering automatic mode the output value bOn is FALSE and the controller must be restarted.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;
uiBrightness      : UINT;

eDataSecurityType: If eDataSecurityType:= eHVACDataSecurityType_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 released internally.

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: example_persistent.zip

If eDataSecurityType:= eHVACDataSecurityType_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: Rising 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: Light actual value [lux].

VAR_OUTPUT

lrDimValue          : LREAL;
bOn                 : BOOL;
uiRemainingOnDelay  : UINT;
uiRemainingOffDelay : 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: Switch 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 expiry of an additional waiting time of 1s. 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

uiSwitchOnValue   : UINT;
uiSwitchOffOffset : UINT;
uiLightOnTime     : UINT;
uiOnDelay         : UINT;
uiOffDelay        : UINT;

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 to be defined as input variables, they would not be able to write a reference variable.
Application example: example_persistent.zip.

uiSwitchOnValue: Light switch-on value. The lighting is switched on after the expiry of the switch-on delay if the external 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 light 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 external brightness sinks in such a manner that the constant light control 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 external brightness increases in such a manner that the constant light control needs to be switched off, then this should take place only after this time delay in order to mask out short-term fluctuations.

Requirements

Development environment

required library

required function

TwinCAT 3.1 build 4022.16 or higher

Tc2_HVAC V3.3.1.0

TF8000 | TC3 HVAC V1.0.0.0