FB_DALIV2Communication

FB_DALIV2Communication 1:

The blocks for the DALI commands do not access the process image of the KL6811 directly, but place the individual DALI commands in three different buffers. The FB_DALIV2Communication() block sequentially reads the DALI commands from these three buffers and passes the DALI commands to the KL6811. This prevents multiple blocks accessing the KL6811 process image at the same time. Each of these three buffers is processed with a different priority (high, medium or low). The user of the PLC library can use the eCommandPriority parameter (available in most blocks) to determine the priority which with the FB_DALIV2Communication() block processes the respective DALI command.

All buffers in which the DALI commands are stored are associated with a variable of type ST_DALIV2CommandBuffer. There is one instance of the FB_DALIV2Communication() block and a variable of type ST_DALIV2CommandBuffer for each KL6811. If possible, the FB_DALIV2Communication() block should be called in a separate, faster task.

The buffer utilisation can be determined via the block outputs based on three arrays in which each element (0, 1 or 2) represents one of the three buffers (high, medium or low). If you detect regular overflow for one of the three buffers, you should consider the following:

- How heavily are the individual PLC tasks utilized? The TwinCAT System Manager offers various analysis tools.

- Try reducing the cycle time of the task in which the FB_DALIV2Communication() block is called. The value should not exceed 6 ms. Ideally it should be 2 ms.

- Check the cycle time of the PLC task in which the blocks for the individual DALI commands are called. This value should be between 10 ms and 60 ms.

- If possible avoid polling (regular reading) of values. Only read values when they are actually required.

- Distribute the individual ballasts evenly over several DALI lines. Overall data throughput is increased by the fact that several DALI lines are processed simultaneously during each PLC cycle.

VAR_INPUT

bResetMaximumDemandCounter  : BOOL;
bResetOverflowCounter       : BOOL;

bResetMaximumDemandCounter: A rising edge at this input resets the value of the maximum command-buffer-load, arrBufferMaximumDemandMeter (0 - 100%, see VAR_OUTPUT).

bResetOverflowCounter: A rising edge at this input resets the value of the total buffer-overflow-counter, arrBufferOverflowCounter (see VAR_OUTPUT).

VAR_OUTPUT

arrBufferDemandMeter         : ARRAY [0..2] OF BYTE;
arrBufferMaximumDemandMeter  : ARRAY [0..2] OF BYTE;
arrBufferOverflowCounter     : ARRAY [0..2] OF UINT;
bLineIsBusy                  : BOOL;
bLineIsInitialized           : BOOL;

arrBufferDemandMeter: Buffer utilisation (0 – 100%).

arrBufferMaximumDemandMeter: Previous maximum utilisation of the respective buffer (0 – 100%).

arrBufferOverflowCounter: Previous number of buffer overflows.

bLineIsBusy: This output is set as long as the FB_DALIV2Communication() block is active.

bLineIsInitialized: If the block is being called for the first time (e.g. when the controller is starting up) an initialisation process is executed. No DALI commands can be processed during this time.

VAR_IN_OUT

stDALIInData          : ST_DALIV2InData;
stDALIOutData         : ST_DALIV2OutData;
stCommandBuffer       : ST_DALIV2CommandBuffer;

stDALIInData: Structure in the input process image of the KL6811. It is used for communication from the KL6811 to the PLC. If FB_KL6811Config() is used, this structure is linked to the stInData parameter of the function block.

stDALIOutData: Structure in the output process image of the KL6811. It is used for communication from the PLC to the KL6811. If FB_KL6811Config() is used, this structure is linked to the stOutData parameter of the function block.

stCommandBuffer: A reference to the internal structure for communication with the DALI function blocks.