FB_BARConstantLightControl

FB_BARConstantLightControl 1:

The constant light control function block controls the lighting when the room is occupied such that the lighting intensity does not fall below a preset minimum. This ensures adequate lighting whilst at the same time minimizing energy consumption.

The constant light control is enabled when the room is entered or by a rising edge on the input bPresence. Optionally the constant light control can also be operated by a pushbutton. A short pulse on the input bToggle enables the constant light control or switches it off, depending on the current state. If many constant light controllers are to be switched on by a central command, for example on an office floor, this can be realized with the input bCentralOn. A central command to switch off can be connected to the input bCentralOff.

Actuating the pushbutton on bToggle for a longer period manually changes the setpoint value for the room brightness. Upon a falling edge on bToggle the current room brightness value is stored as a setpoint value. The rate of change when manually increasing or decreasing the room brightness can be set by means of a parameter.

The manually set setpoint value for the constant light control is retained until the next time the lighting is switched off. On restarting the controller by a rising edge on bPresence, a rising edge on bCentralOn or a pulse on bToggle, the last manually selected setpoint value or the value of uiSetpointlValue is adopted, depending on the setting of the parameter bInitialMode.

In automatic mode the lighting is switched on only if the room brightness lies below an adjustable hysteresis value (uiTargetRange). As the external brightness increases, the constant light controller reduces the artificial light portion until a minimum load control value lrMinDimValue lies at the output of the controller lrDimValue. Subsequently, the controller switches the lighting off following a time delay with the timer uiOffDelay.
If the external brightness decreases and the light should be turned on again, it can be delayed by uiOnDelay [sec].

In order to avoid unpleasant visible changes in the brightness, the rate of change of the control signal is retarded with the parameter uiControlRampTime.

For maintenance and test purposes the automatic constant light control can be deactivated and the lighting can be switched on and off in manual mode. This deactivates the edge detection at the inputs bCentrolOn,bCentalOff and bToggle.

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

Automatic mode

In automatic mode the control can be activated or deactivated in three different ways:

  1. Via the input bSwitch: A short TRUE signal (shorter than uiSwitchOverTime in milliseconds) at bSwitch activates the constant light control if it had been inactive before. Another short signal at bSwitch deactivates the constant light control again. A long TRUE signal on bSwitch switches the function block to setpoint value adjustment mode; this is described below.
  2. Via the input bPresence: Switching on via this input must be explicitly enabled by a TRUE signal on bPresenceOnActive (VAR_IN_OUT). A rising edge then activates the control, while a falling edge always deactivates the control independent of the state of bPresenceOnActive.
  3. The control is explicitly switched on and off via TRUE edges on the inputs bCentralOn and bCentralOff, independent of the previous state of the control. These inputs do not have an override function: for example, if switching off has taken place via bCentralOff, bSwitch can be used to switch on again at any time.

The light output value lrDimValue is initially set in the active state to the starting value lrStartDimValue. After that an actual value/setpoint value comparison takes place continuously. If the actual room value uiBrightness [lux] thereby leaves the target range uiTargetRange [lux] around the setpoint value uiSetpointValue [lux], then this is counteracted by dimming the lighting up or down. The control always operates with a constant, parameterizable dimming ramp uiRamptime [s], which indicates the time of a complete dimming process from 0% to 100%. The control target values are likewise constant: 0% for dimming down and 100% for dimming up. In the inactive state the light output value lrDimValue is set to 0.0.

FB_BARConstantLightControl 2:

Switch-on and switch-off delay, minimum output value

If the external brightness increases, then less and less artificial light is necessary in order to obtain the desired total brightness. The lighting can be switched off completely if the external brightness is sufficient.
However, switch-on and switch-off processes can be perceived as distracting, as can very low output dimming values. Therefore a switch-on and switch-off delay uiOnDelay/uiOffDelay can be defined in the function block around a lower limit value lrMinDimValue. If the internally determined output value sinks below this minimum value, then the output remains at this minimum for the time uiOffDelay [s]. Only after that is 0.0 output at the output lrDimValue. If in the reverse case switching off to 0.0 has taken place, then if artificial light is required this is only switched on after the expiry of uiOnDelay [s] and then to the value lrMinDimValue. The following diagram is intended to clarify the behavior:

The yellow areas indicate the ranges where the external brightness permits the lighting to be dimmed down; in the blue areas, conversely, the external brightness alone is not sufficient to obtain the desired room brightness. In the white areas the output control value lrDimValue is appropriate for the lighting conditions.

FB_BARConstantLightControl 3:

Manual adjustment of the setpoint value

In order to be able to adapt the light control to personal brightness needs, there is an option to increase or decrease the setpoint value. A long TRUE signal on bSwitch (longer than uiSwitchOverTime in milliseconds) switches the function block to the dimming mode and the light is dimmed up if it had been dimmed down in the preceding dimming mode and vice versa. If bSwitch resets to FALSE, then the brightness value now measured on uiBrightness is adopted as the new setpoint value to which control is to take place.

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.

FB_BARConstantLightControl 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 is 0.0 and the controller must be restarted.

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
uiLightCtrlMode   : UINT;
bSwitch           : BOOL;
bPresence         : BOOL;
bCentralOn        : BOOL;
bCentralOff       : BOOL;
uiBrightness      : UINT;
uiSetpoint        : 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).

bPresence:  A continuous TRUE signal on this input activates the control if the presence function is activated by bPresenceOnActive=TRUE (VAR_IN_OUT). Conversely, a falling edge on this input always deactivates the control. 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].

uiSetpointValue: Light setpoint value [lux].

VAR_OUTPUT

lrDimValue              : LREAL;
bControlActive          : BOOL;
bAdjustedSetpointActive : BOOL;
uiAdjustedSetpoint      : UINT;
diActDeviation          : DINT;
bError                  : BOOL;
udiErrorId              : UDINT;

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

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

bAdjustedSetpointActive: If the control is active and the setpoint value has been manually adjusted (see above), then the state of this output changes to TRUE in order to indicate that the setpoint value on the input uiSetpointValue is no longer active.

uiAdjustedSetpoint: This output indicates the active setpoint value if this has been manually adjusted (bAdjustedSetpointActive = TRUE). This output is set to 0 if no manually adjusted setpoint value is active.

diActDeviation: Current control deviation in lux. This output indicates a valid value only if the function block is in automatic mode and activated. Otherwise 0.0 is output.

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;
uiAdjustRampTime  : UINT;
bPresenceOnActive : BOOL;
bInitialMode      : BOOL;
uiTargetRange     : UINT;
uiControlRampTime : UINT;
uiOnDelay         : UINT;
uiOffDelay        : UINT;
lrMinDimValue     : LREAL;
lrMaxDimValue     : LREAL;
lrStartDimValue   : 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 for the input bSwitch for the recognition of short and long signals. (short signal: switch-on/switch-off function; long signal: dimming function)

uiAdjustRampTime: Ramp time in seconds with which the setpoint value is changed during manual adjustment.

bPresenceOnActive: If this input is TRUE, then the control is activated by a positive edge on bPresence if the function block is in automatic mode (uiLightCtrlMode = 0).

bInitialMode: A TRUE signal on this input makes the function block begin with the setpoint value on uiSetpoint each time it is activated. If on the other hand this input is FALSE, then the setpoint value that was last active – i.e. including manually adjusted setpoint values – is adopted on activation of the function block.

uiTargetRange: Target range around the setpoint value in which no further control is to take place.

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

uiOnDelay: Switch-on delay in seconds around the minimum value lrMinDimValue.

uiOffDelay: Switch-off delay in seconds around the minimum value lrMinDimValue.

lrMinDimValue: Lower limit value for dimming, see introduction.

lrMaxDimValue: Upper limit to which the output lrDimValue can be controlled.

lrStartDimValue: Value to which the light should jump on activating the control.

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