FB_BARTwilightAutomatic

FB_BARTwilightAutomatic 1:

Automatic twilight function

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

Automatic mode

In automatic mode a positive edge on bSwitch activates the automatic twilight function, if it had been inactive beforehand. A further edge on bSwitch deactivates the automatic twilight function again. The automatic function is explicitly switched on and off with bCentralOn and bCentralOff, independent of the previous state of the automatic function. If the automatic twilight function is activated, then the function block switches the output lrDimValue to the switch-on value lrDimValueOn when the brightness falls below a switch-on threshold value uiSwitchOnValue for an entered delay time uiOnDelay. Conversely, if a switch-off threshold value uiSwitchOffValue is exceeded for an entered time delay uiOffDelay, then the output is switched to the value lrDimValueOff. In the inactive state the light output value lrDimValue is set to 0.0.

Manual operation

The inputs bSwitch, bCentralOn and bCentralOff have no function in the manual operation modes: if uiLightCtrlMode=1 the output value lrDimValue is set constantly to lrManualDimValue and if uiLightCtrlMode=2 it is set constantly to 0.0.

Switch-on and switch-off delay

The switch-on and switch-off delays, as described above (“automatic mode”), are always run through irrespective of the state of the automatic function (active or inactive) and the operation mode, i.e. the timers are not reset by these operating states.

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: Positive edges on this input switch the automatic twilight function 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 automatic twilight function on. This command input is active only in automatic mode (uiLightCtrlMode=0).

bCentralOff: A positive edge on this input switches the automatic twilight function 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;
uiRemainingOnDelay  : UINT;
uiRemainingOffDelay : UINT;
bControlActive      : BOOL;
bError              : BOOL;
udiErrorId          : UDINT;

lrDimValue: Light output value, 0..100%.

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.

bControlActive: This output is TRUE if the function block is in automatic mode and the automatic twilight function is activated. This is intended to serve as an additional feedback signal if switch-on has taken place but the controller outputs a light value of lrDimValue=0.0.

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.

FB_BARTwilightAutomatic 2:

If an error should occur, then this automatic function is deactivated and position and angle are set to 0. This means that if a priority controller is in use, another function with a lower priority (see Overview) automatically takes over control of the blind. In the case of a direct connection, conversely, the blind will drive to position/angle 0.

VAR_IN_OUT

uiSwitchOnValue  : UINT;
uiSwitchOffValue : UINT;
uiOnDelay        : UINT;
uiOffDelay       : UINT;
lrDimOnValue     : LREAL;
lrDimOffValue    : LREAL;
lrManualDimValue : LREAL;

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: Switch-on threshold value. This is compared with the brightness value at the input uiBrightness. This value must be greater than the output threshold value uiSwitchOffValue.

uiSwitchOffValue: Switch-off threshold value. This is compared with the brightness value at the input uiBrightness.

uiOnDelay: Switch-on delay in seconds.

uiOffDelay: Switch-off delay in seconds.

lrDimOnValue: Switch-on light value in %.

lrDimOffValue: Switch-off light value in %.

lrManualDimValue: Output dimming value in Manual On mode (uiLightCtrlMode=1).

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