FB_BARAutomaticLight

Function block for an automatic light circuit as used in corridors or sanitary facilities.

FB_BARAutomaticLight 1:
FB_BARAutomaticLight

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

The automatic light circuit is active in automatic mode (uiLightCtrlMode=0). A positive edge on bSwitch sets the output lrDimValue to the value entered under lrManualDimValue. A negative edge starts the holding time generator. If the hold time uiHoldTime [s] has expired, the output lrDimValue is reset to 0.0.

FB_BARAutomaticLight 2:

The sequence can be restarted at any time:

FB_BARAutomaticLight 3:

In the manual operation modes the input bSwitch has no function: with uiLightCtrlMode=1 the output value lrDimValue is constantly set to lrManualDimValue and with uiLightCtrlMode=2 constantly set to 0.0.
Changing to manual mode resets any hold time that had started up to that point.

VAR_INPUT

eDataSecurityType: E_HVACDataSecurityType;
uiLightCtrlMode  : UINT;
bSwitch          : BOOL;

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_BARAutomaticLight 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: a rising edge switches the light on in automatic mode (uiLightCtrlMode=0), a falling edge starts the holding time generator. This input has no function in manual operation mode (uiLightCtrlMode=1 or 2).

VAR_OUTPUT

lrDimValue         : LREAL;
uiRemainingHoldTime: UINT;
bError             : BOOL;
udiErrorId         : UDINT;

lrDimValue : output dimming value for the lighting in percent.

uiRemainingTimeHold : remaining hold time in seconds. If the light is off or if manual operation mode is active, then this output is "0". With a rising edge on bSwitch in automatic mode, this output initially indicates the complete number of seconds of the hold time (uiHoldTime), in order to illustrate the countdown of the hold time, starting with a falling edge on bSwitch. This output is 0 as long as no countdown of the time is taking place.

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_BARAutomaticLight 5:Example_PERSISTENT.zip.

uiHoldTime       : UINT;
lrOnDimValue     : LREAL;
lrManualDimValue : LREAL;

uiHoldTime : hold time [s] of the automatic light controller after a falling edge on bSwitch.

lrOnDimValue : on dimming value in automatic mode (uiLightCtrlMode=0).

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