FB_KL6811Communication

FB_KL6811Communication 1:

The function blocks for the DALI commands do not directly access the process image of the KL6811, but store the individual DALI commands in three different buffers. The function block FB_KL6811Communication sequentially reads the DALI commands from these three buffers and forwards the DALI commands to the KL6811. This prevents multiple function blocks accessing the KL6811 process image simultaneously. 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 influence 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 function block FB_KL6811Communication 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:

FB_KL6811Communication 2: Inputs

VAR_INPUT
  bResetMaximumDemandCounter : BOOL;
  bResetOverflowCounter      : BOOL;
END_VAR

Name

Type

Description

bResetMaximumDemandCounter

BOOL

A positive edge resets the stored value of the maximum command buffer utilization, arrBufferMaximumDemandMeter (0 - 100 %, see VAR_OUTPUT).

bResetOverflowCounter

BOOL

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

FB_KL6811Communication 3: Inputs/outputs

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

Name

Type

Description

stDALIInData

ST_KL6811InData

Structure in the input process image of the KL6811. It is used for communication from the KL6811 to the PLC.

stDALIOutData

ST_KL6811OutData

Structure in the output process image of the KL6811. It is used for communication from the PLC to the KL6811.

stCommandBuffer

ST_DALIV2CommandBuffer

Reference to the internal structure for communication with FB_KL6821Communication (KL6821).

FB_KL6811Communication 4: Outputs

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;
END_VAR

Name

Type

Description

bBusy

BOOL

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

bError

BOOL

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

UDINT

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

ARRAY

Demand of the respective buffer (0 - 100 %)

arrBufferMaximumDemandMeter

ARRAY

Previous maximum demand of the respective buffer (0 - 100 %)

arrBufferOverflowCounter

ARRAY

Number of buffer overflows so far

bLineIsBusy

BOOL

This output is set as long as the function block FB_KL6811Communication is active.

bLineIsInitialized

BOOL

If the function block is called up for the first time (e.g. when starting the controller), initialization is carried out. No DALI commands can be processed during this time.

Requirements

Development Environment

PLC library to include

TwinCAT from v3.1.4022.4

Tc2_DALI from v3.6.2.0