FB_KL6811Communication

FB_KL6811Communication 1:

The function 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 function block FB_KL6821Communication() sequentially reads the DALI commands from these three buffers and passes the DALI commands to the KL6821. This prevents multiple function 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 parameter eCommandPriority, which is available for most function blocks, can be used to specify the priority with which the respective DALI command is processed by the function block FB_KL6811Communication().

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

The extent to which the buffers are utilized can be determined from the outputs of the function block. Three arrays are output for this in which each element (0, 1 or 2) represents one of the three buffers (high, middle 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 appropriate utilities for the analysis.
  • Try to reduce the cycle time of the task in which the function block FB_KL6811Communication() 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 function 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 control gears 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 positive edge resets the stored value of the maximum command buffer utilization, arrBufferMaximumDemandMeter (0 - 100%, see VAR_OUTPUT).

bResetOverflowCounter: a positive edge resets the stored value of the number of command buffer overflows, arrBufferOverflowCounter (see VAR_OUTPUT).

VAR_OUTPUT

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

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

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 command-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)

arrBufferDemandMeter: Occupancy of the respective buffer (0 - 100%).

arrBufferMaximumDemandMeter: previous maximum occupancy of the respective buffer (0 - 100%).

arrBufferOverflowCounter: Number of buffer overflows to date.

bLineIsBusy: The output is set as long as the function block FB_KL6811Communication() is active.

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

VAR_IN_OUT

stDALIInData    : ST_KL6811InData;
stDALIOutData   : ST_KL6811OutData;
stCommandBuffer : ST_DALIV2CommandBuffer;

stDALIInData: Structure in the input process image of the KL6811. It is used for communication from the KL6811 to the PLC (see ST_KL6811InData).

stDALIOutData: Structure in the output process image of the KL6811. It is used for communication from the PLC to the KL6811 (see ST_KL6811OutData).

stCommandBuffer: A reference to the structure for communication (buffer) with the FB_EL6811Communication() function block.

Requirements

Development environment

required PLC library

TwinCAT from v3.1.4022.4

Tc2_DALI from v3.6.2.0