FB_DALIV2LightControl

FB_DALIV2LightControl 1:

Daylight-Lamp-control.

This function-block is based upon a table of 30 nodes containing measured input- 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 actual control value will change (see diagram). The threshold-switch is followed by a ramp-function which ramps the control value to the new control value over the time tRampTime. With a rising-edge at bOn the light is switched immediately to the nearest control value and similarily a rising 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.

FB_DALIV2LightControl 2:

It is not required to use all 30 entries in the node table. The first element with a nSwitchRange of "0" will mark the beginning of the unused table-range.

Parameter nMasterDevAddr

The DALI system provides facilities not just for controlling lamps individually, but also for addressing them as groups or through common commands. Because the individual devices can be members of a variety of groups, it can happen that, prior to the issue of a group or common control command, the individual lamps have different brightness levels. So that it is nevertheless possible to be clear whether the lamps now are to be switched on or off, a master device is assigned to each group, whose state is followed by the other devices. It is not necessary to specify a master device if the function block is to be used to control a single lamp, eAddrType = eAddrTypeShort. In this case, the nMasterDevAddr parameter has no significance.

VAR_INPUT

bEnable                     : BOOL := TRUE;
bOn                         : BOOL;
bOff                        : BOOL;
nActualValue                : UINT;
tRampTime                   : TIME := t#30s;
arrControlTable             : ARRAY[1..30] OF ST_DALIV2ControlTable;
nOptions                    : DWORD := 0;
nAddr                       : BYTE := 0;
eAddrType                   : E_DALIV2AddrType := eDALIV2AddrTypeShort;
nMasterDevAddr              : BYTE := 0;
tCycleActualLevelMasterDev  : TIME := t#0s;

bEnable: A positive input enables the function block. A negative state deactivates the inputs and sets the function-block to the idle-mode, after the last necessary DALI-commands are sent. Except for the cyclic query of the light-level of the master-device, the function-block sends no further DALI-commands.

bOn: A rising edge sets the addressed lamps directly to the next control value.

bOff: A rising edge turns the addressed lamps immediately off.

nActualValue: measured light-value.

tRampTime: time to drive the lamp from the actual value to the new control value. (Preset value: 30s).

arrControlTable: Input-/control-value-table. arrControlTable[1] to arrControlTable[30] of ST_DALIV2ControlTable

nOptions: Reserved for future developments.

nAddr: The address of a participating device or of a group.

eAddrType: Short address, group address or broadcast.

nMasterDevAddr: The address of the master device for group and common switching operations.

tCycleActualLevelMasterDev: Cycle time required to read the current actual value (ACTUAL DIM LEVEL) in the background. In order not to disturb the dimming of the lamps, reading always has the lowest priority. If the value is set to 0, reading is deactivated.

VAR_OUTPUT

nActualLevelMasterDev  : BYTE;
bBusy                  : BOOL;
bControlActive         : BOOL;
bError                 : BOOL;
nErrorId               : UDINT;

nActualLevelMasterDev: The current control value of the master device (if eAddrType = eAddrTypeShort this is always the device being addressed at the time).

bBusy: When the block is activated the output is set, and it remains active until execution of the command has been completed.

bControlActive: This output is set once the control is activated.

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 of the most recently executed command. nErrorId is reset to 0 by the execution of an instruction at the inputs. See Error codes.

VAR_IN_OUT

stCommandBuffer           : ST_DALIV2CommandBuffer;

stCommandBuffer: A reference to the structure for communication with the FB_DALIV2Communication() (KL6811) or FB_KL6821Communication() (KL6821) block.