FB_KL6821Config

FB_KL6821Config 1:

The function block FB_KL6821Config is used to configure the KL6821. The configuration is executed when the PLC program starts, or it can be triggered by a positive edge at the input bConfigurate. The parameters are stored in the respective registers of the KL6821 in a fail-safe manner. In addition, some general information, such as the firmware version, is read from the KL6821.

Example

The function block is called in the same task as the function block FB_KL6821Communication.

FB_KL6821Config 2:

The function block FB_KL6821Config is linked to the process image of the KL6821. Once the configuration is complete, the function block FB_KL6821Communication receives the process values of the KL6821. DALI commands cannot be sent during configuration.

Sample: DALI_Sample_KL6821Config.zip

FB_KL6821Config 3: Inputs

VAR_INPUT
  bConfigurate           : BOOL := FALSE;
  eCommandKBusWatchdog   : E_DALIV2ConfigurationCommands := eDALIV2CommandDoNothing;
  eCommandDI1RisingEdge  : E_DALIV2ConfigurationCommands := eDALIV2CommandOff;
  eCommandDI1FallingEdge : E_DALIV2ConfigurationCommands := eDALIV2CommandDoNothing;
  eCommandDI2RisingEdge  : E_DALIV2ConfigurationCommands := eDALIV2CommandRecallMaxLevel;
  eCommandDI2FallingEdge : E_DALIV2ConfigurationCommands := eDALIV2CommandDoNothing;
  ePowerSupplyMode       : E_DALIV2PowerSupplyMode := eDALIV2PowerSupplyModeOn;
  nOptions               : DWORD := 0;
END_VAR

Name

Type

Description

bConfigurate

BOOL

Configuration of the bus terminal is started by a positive edge at this input.

eCommandKBusWatchdog

E_DALIV2ConfigurationCommands

Defines the DALI command that is sent as soon as the bus terminal is no longer addressed via the K-bus.

eCommandDI1RisingEdge

E_DALIV2ConfigurationCommands

Defines the DALI command that is sent as soon as a rising edge is detected at input 1 of the bus terminal.

eCommandDI1FallingEdge

E_DALIV2ConfigurationCommands

Defines the DALI command that is sent as soon as a falling edge is detected at input 1 of the bus terminal.

eCommandDI2RisingEdge

E_DALIV2ConfigurationCommands

Defines the DALI command that is sent as soon as a rising edge is detected at input 2 of the bus terminal.

eCommandDI2FallingEdge

E_DALIV2ConfigurationCommands

Defines the DALI command that is sent as soon as a falling edge is detected at input 2 of the bus terminal.

ePowerSupplyMode

E_DALIV2PowerSupplyMode

Defines the operation mode of the internal DALI power supply.

nOptions

DWORD

Reserved for future developments.

FB_KL6821Config 4: Inputs/outputs

VAR_IN_OUT
  stInDataTerminal         : ST_KL6821InData;
  stOutDataTerminal        : ST_KL6821OutData;
  stInData                 : ST_KL6821InData;
  stOutData                : ST_KL6821OutData;
END_VAR

Name

Type

Description

stInDataTerminal

ST_KL6821InData

Reference to the structure for communication with the KL6821

stOutDataTerminal

ST_KL6821InData

Reference to the structure for communication with the KL6821

stInData

ST_KL6821InData

Reference to the internal structure for communication with the function block FB_KL6821Communication

stOutData

ST_KL6821InData

Reference to the internal structure for communication with the function block FB_KL6821Communication

FB_KL6821Config 5: Outputs

VAR_OUTPUT
  bBusy                      : BOOL;
  bError                     : BOOL;
  nErrorId                   : UDINT;
  nTerminalDescription       : WORD;
  nFirmwareVersion           : WORD;
  sDescription               : STRING;
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).

nTerminalDescription

WORD

Contains the terminal name (e.g. 6821). Corresponds to register 8 of the bus terminal.

nFirmwareVersion

WORD

Contains the firmware version. Corresponds to register 9 of the bus terminal.

sDescription

STRING

Terminal name and firmware version as string (e.g. "Terminal KL6821 / Firmware 2H").

Requirements

Development Environment

PLC library to include

TwinCAT from v3.1.4022.4

Tc2_DALI from v3.6.2.0