FB_KL6821Communication

FB_KL6821Communication 1:

The function blocks for the DALI commands do not directly access the process image of the DALI Bus Terminal, but store the individual DALI commands in three different buffers. The function block FB_KL6821Communication sequentially reads the DALI commands from these three buffers and forwards the DALI commands to the KL6821. This prevents several function block accessing the process image of the bus terminal 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 by the PLC library user to influence the priority with which the respective DALI command is processed by the function block FB_KL6821Communication.

All buffers in which the DALI commands are stored are associated with a variable of type ST_DALIV2CommandBuffer. For each KL6821 there is one instance of the function block FB_KL6821Communication and one variable of type ST_DALIV2CommandBuffer. If possible, the function block FB_KL6821Communication 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 find that one of the three buffers overflows on a regular basis, you should consider the following measures:

How heavily are the individual PLC tasks utilized? The TwinCAT System Manager offers various appropriate utilities for the analysis.

FB_KL6821Communication 2: Inputs

VAR_INPUT
  bResetMaximumDemandCounter   : BOOL;
  bResetOverflowCounter        : BOOL;
  bResetInactiveProcessImage   : BOOL;
  nOptions                     : DWORD := 0;
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).

bResetInactiveProcessImage

BOOL

A positive edge cancels the blocking of the process image of the terminal. The outputs bProcessImageInactive, bDigitalInput1Active and bDigitalInput2Active are again set to FALSE. The lock is activated when one of the two digital inputs on the terminal is activated.

nOptions

DWORD

Reserved for future developments.

FB_KL6821Communication 3: Inputs/outputs

VAR_IN_OUT
  stInData                     : ST_KL6821InData;
  stOutData                    : ST_KL6821OutData;
  stCommandBuffer              : ST_DALIV2CommandBuffer;
END_VAR

Name

Type

Description

stInData

ST_KL6821InData

Structure in the input process image of the KL6821. It is used for communication from the KL6821 to the PLC. When using FB_KL6821Config, this structure is linked to the parameter stInData.

stOutData

ST_KL6821OutData

Structure in the output process image of the KL6821. It is used for communication from the PLC to the KL6821. When using FB_KL6821Config, this structure is linked to the parameter stOutData.

stCommandBuffer

ST_DALIV2CommandBuffer

Reference to the internal structure for communication with the DALI function blocks.

FB_KL6821Communication 4: Outputs

VAR_OUTPUT
  bBusy                        : BOOL;
  bError                       : BOOL;
  nErrorId                     : UDINT;
  arrBufferDemandMeter         : ARRAY [0..2] OF BYTE;
  arrBufferMaximumDemandMeter  : ARRAY [0..2] OF BYTE;
  arrBufferOverflowCounter     : ARRAY [0..2] OF UINT;
  bLineIsBusy                  : BOOL;
  bLineIsInitialized           : BOOL;
  bDigitalInput1Active         : BOOL;
  bDigitalInput2Active         : BOOL;
  bProcessImageInactive        : BOOL;
  bCollisionError              : BOOL;
  bPowerSupplyError            : BOOL;
  bShortCircuit                : 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 OF BYTE

Demand of the respective buffer (0 - 100 %)

arrBufferMaximumDemandMeter

ARRAY OF BYTE

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

arrBufferOverflowCounter

ARRAY OF BYTE

Number of buffer overflows so far

bLineIsBusy

BOOL

The output is set as long as the function block FB_KL6821Communication is active.

bLineIsInitialized

BOOL

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

bDigitalInput1Active

BOOL

The digital input 1 on the terminal was or is actuated (see also terminal documentation). The output bProcessImageInactive is set and no further DALI commands can be processed by the controller.

bDigitalInput2Active

BOOL

The digital input 2 on the terminal was or is actuated (see also terminal documentation). The output bProcessImageInactive is set and no further DALI commands can be processed by the controller.

bProcessImageInactive

BOOL

One of the two digital inputs was actuated at the terminal. No further DALI commands can be processed by the controller. The blockage must be released again via the input bResetInactiveProcessImage.

bCollisionError

BOOL

A data collision on the DALI bus was detected while a command was sent.

bPowerSupplyError

BOOL

The KL6821 has detected an error in the internal DALI power supply.

bShortCircuit

BOOL

Short circuit on the DALI bus

Requirements

Development Environment

PLC library to include

TwinCAT from v3.1.4022.4

Tc2_DALI from v3.6.2.0