FB_LightControl
Daylight-Lamp-control.
This function-block is based upon a table of 30 nodes containing actual- and control-values for threshold-switching. If the actual value comes within the range of a new node (arrControlTable[n].nActualValue - arrControlTable[n].nSwitchRange/2 ... arrControlTable[n].Input + arrControlTable[n].nSwitchRange/2), the control-value will change (see diagram). The threshold-switch is followed by a ramp-function which ramps the light-level to the new control-value over the time tRampTime.With a rising-edge at bOn the light is switched immediatelyto the nearest control-value and similarily arising edge at bOff switches the light off,without the delay of a ramp. It is possible to trigger a positive edge on bOn or bOff at anytime.

It is not required to use all 30 entries in the node table. The first element with a switch-range of "0" will mark the beginning of the unused table-range.
VAR_INPUT
bEnable : BOOL;
bOn : BOOL;
bOff : BOOL;
nActualValue : UINT;
tRampTime : TIME := t#30s;
arrControlTable : ARRAY[1..30] OF ST_ControlTable;
nOptions : DWORD;
bEnable: A positive input enables the function block. A negative state deactivates the inputs and sets the function-block to the idle-mode.
bOn: A rising edge sets the output nLightLevel directly to the next control-value.
bOff: A rising edge sets the output nLightLevel immediately to "0".
nActualValue: measured light-value.
tRampTime: time to drive the lamp from the actual light-level to the new control-value. (Preset value: 30s).
arrControlTable: Actual-/control-value-table. arrControlTable[1] to arrControlTable[30] of ST_ControlTable
TYPE ST_ControlTable : STRUCT nActualValue : UINT; nControlValue : UINT; nSwitchRange : UINT; END_STRUCT END_TYPE nActualValue: Measured light value. nControlValue: Control value of a node. nSwitchRange:Switching range around the node. nSwitchRange can only be "0" for the first node of the unused table-range. |
nOptions: Reserved for future developments.
VAR_OUTPUT
bLight : BOOL;
bBusy : BOOL;
bControlActiv : BOOL;
bError : BOOL;
nErrorId : UDINT;
bLight: If nLightLevel is greater than 0, this output is set to TRUE.
bBusy: When the block is activated the output is set, and it remains active until execution of the command has been completed.
bControlActive: If the control loop is active, this output is set to TRUE.
bError: This output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in nErrorId. bError is reset to FALSE by the execution of an instruction at the inputs.
nErrorId: Contains the command-specific error code. nErrorId is reset to 0 by the execution of an instruction at the inputs. See Error codes.
VAR_IN_OUT
nLightLevel : UINT;
nLightLevel: Reference to the actual light-level-output.