FB_BARLightCircuitDim

FB_BARLightCircuitDim 1:

This function block represents a light switching circuit with a dimming function.

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

In automatic mode (uiLightCtrlMode=0) the function block can be controlled via the inputs bSwitch, bCentralOff and bCentralOn. Whereas the output lrDimValue is set to 0.0 or to the value reached before the last switch-off by rising edges on bCentralOff and bCentralOn, the behavior of the input bSwitch depends on the duration of the signal. A short TRUE signal that is shorter than uiSwitchOverTime in milliseconds switches the output lrDimValue. If the output lrDimValue is initially larger than 0.0, then it is switched to 0 and the previous value is saved. If on the other hand it is 0.0, then the output is set to the previously internally saved value. This saved value is set to the maximum value in the switch-on state of the program, see below. Unlike in the case of the inputs bCentralOff and bCentralOn, the falling edge triggers the switching event here. A long TRUE signal on bSwitch starts the dimming process. In principle dimming takes place only between the set minimum and maximum values (lrMinDimValue and lrMaxDimValue). The dimming ramp is defined in seconds by uiRampTime. This dimming time refers to the dimming range from 0 to 100 percent, even if the limits lrMinDimValue and lrMaxDimValue are set differently. If the output value lrDimmValue reaches one of the limits without bSwitch resetting to FALSE, then it remains there for the time uiCycleDelay in milliseconds, before dimming takes place again to the other limit value.

Exception: A uiCycleDelay value of 0 is not interpreted as an immediate dimming direction reversal, but instead deactivates this. Only another long TRUE signal on bSwitch starts the dimming in the opposite direction.

FB_BARLightCircuitDim 2:

In the manual operation modes the output value lrDimValueOut is set constantly to the value lrManualDimValue if uiLightCtrlMode=1 and constantly to the value 0.0 if uiLightCtrlMode=2.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bCentralOn        : BOOL;
bCentralOff       : 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 short TRUE signal that is shorter than uiSwitchOverTime in milliseconds switches the output lrDimValue. If the output lrDimValue is initially larger than 0.0, then it is switched to 0 and the previous value is saved. If on the other hand it is 0.0, then the output is set to the previously internally saved value. This saved value is set to the maximum value in the switch-on state of the program, see below.
A long TRUE signal that is longer than uiSwitchOverTime in milliseconds starts the dimming process, wherein the dimming direction changes if two long signals follow one another on the input bSwitch.

bCentralOn: Switches the output lrDimValueOut to the previously saved (at the last switch-off) dimming value, see bSwitch.

bCentralOff: Switches the output lrDimValueOut to 0.0.

Note: All switching commands, bSwitch, bCentralOn and bCentralOff are effective only in automatic mode.

VAR_OUTPUT

lrDimValue  : LREAL;
bLight      : BOOL;
bError      : BOOL;
udiErrorId  : UDINT;

lrDimValue: Light output value; can adopt values between lrMinDimValue and lrMaxDimValue, see VAR_IN_OUT, but maximally 0..100%.

bLight: FALSE if lrDimmValue = 0.0, otherwise TRUE.

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

uiSwitchOverTime : UINT;
uiDimRampTime    : UINT;
uiCycleDelay     : UINT;
lrMinDimValue    : LREAL;
lrMaxDimValue    : 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.

uiSwitchOverTime: Switching time in milliseconds from button to dimming mode.

uiDimRampTime: Ramp time in seconds (time required to dim from 0% to 100%).

uiCycleDelay: Switching time in milliseconds of the automatic change between dimming up and dimming down. The automatic change is inactive if this value is zero.

lrDimMinValue: Minimum light value in % that can be reached by dimming.

lrDimMaxValue: Maximum 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