FB_LightControl

FB_LightControl 1:

Function block for daylight-dependent lighting control with up to 30 interpolation points.

At the core of this function block is an input/control value table consisting of 30 elements with threshold switching. If the input value reaches the range of an interpolation point (arrControlTable[n].nActualValue-arrControlTable[n].nSwitchRange/2 ... arrControlTable[n].nActualValue+arrControlTable[n].nSwitchRange/2), the control value jumps to the corresponding function value arrControlTable[n].nSetpoint (see diagram). Coupled to this is a ramp block that runs up the control value over the time tRampTime.
When switching on with a positive edge at bOn, however, the light is initially switched directly to the nearest control value. Only then is the controller activated. While the control is active, "post-starting" can take place at any time with a positive edge at bOn, thus directly controlling the light to the nearest control value. A positive edge at bOff switches the light off directly.

FB_LightControl 2:

The whole range of the table does not have to be used. The first table element (arrControlTable, see below) for which the parameter nSwitchrange is 0 is considered the start of the unused area.

VAR_INPUT

bEnable           : BOOL;
bOn               : BOOL;
bOff              : BOOL;
nActualValue      : UINT;
tRampTime         : TIME := t#30s;
arrControlTable   : ARRAY[1..30] OF ST_ControlTable;
nOptions          : DWORD;

bEnable: The bOn and bOff inputs are active as long as this input is TRUE. A negative state deactivates the inputs.

bOn: A rising edge directly switches nLightLevel to the nearest control value.

bOff: A rising edge directly switches nLightLevel to "0".

nActualValue: Current brightness.

tRampTime: Time period during which the brightness value is controlled to the next control value. (Preset value: 30 s).

arrControlTable: Input value/control value table. arrControlTable[1] to arrControlTable[30] of type ST_ControlTable.

nOptions: Reserved for future developments.

VAR_OUTPUT

bLight            : BOOL;
bBusy             : BOOL;
bControlActive    : BOOL;
bError            : BOOL;
nErrorId          : UDINT;

bLight: This output is set as long as nLightLevel is greater than "0".

bBusy: This output is always active as long as the processing of a command (bOn, bOff, bToggle or ramp) is active.

bControlActive: This output is active as long as the control is active.

bError: This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in nErrorId. Is reset to FALSE by the execution of a command at the inputs.

nErrorId: Contains the specific error code of the most recently executed command. Is reset to "0" by the execution of a command at the inputs. See Error codes.

VAR_IN_OUT

nLightLevel           : UINT;

nLightLevel: Output control value of the function block and reference to the light output value.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4020.32

Tc2_BABasic from v3.1.0.0