FB_BARAutomaticLight

FB_BARAutomaticLight 1:

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

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 holding 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:

The bSwitch input has no function in the manual modes: if uiLightCtrlMode=1 the output value lrDimValue is set constantly to lrManualDimValue and if uiLightCtrlMode=2 it is set constantly to 0.0.

FB_BARAutomaticLight 4:

Resetting the holding time

Changing to manual mode resets any holding time that had started up to that point.

VAR_INPUT

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

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:  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 holding 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 holding time (uiHoldTime), in order to illustrate the countdown of the holding 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 to be defined as input variables, they would not be able to write a reference variable.
Application example: example_persistent.zip.

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

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

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

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