FB_KL6821Config

FB_KL6821Config 1:

This function block 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.

Unpacking the example files FB_KL6821Config 3:

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;

bConfigurate: Configuration of the Bus Terminal is started by a positive edge at this input.

eCommandKBusWatchdog: Defines the DALI command that is sent as soon as the Bus Terminal is no longer addressed via the K-bus.

eCommandDI1RisingEdge: Defines the DALI command that is sent as soon as a rising edge is detected at input 1 of the Bus Terminal.

eCommandDI1FallingEdge: Defines the DALI command that is sent as soon as a falling edge is detected at input 1 of the Bus Terminal.

eCommandDI2RisingEdge: Defines the DALI command that is sent as soon as a rising edge is detected at input 2 of the Bus Terminal.

eCommandDI2FallingEdge: Defines the DALI command that is sent as soon as a falling edge is detected at input 2 of the Bus Terminal.

ePowerSupplyMode: Defines the operation mode of the internal DALI power supply.

nOptions: reserved for future expansions.

VAR_OUTPUT

bBusy                 : BOOL;
bError                : BOOL;
nErrorId              : UDINT;
nTerminalDescription  : WORD;
nFirmwareVersion      : WORD;
sDescription          : STRING;

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. Reactivating the function block via the bConfigurate input sets the output to FALSE again.

nErrorId: Contains the command-specific error code of the most recently executed command. It is reset to 0 by activating the function block again via the input bConfigurate. See Error codes.

nTerminalDescription: Contains the terminal designation (e.g. 6821). Corresponds to register 8 of the Bus Terminal.

nFirmwareVersion: Contains the firmware version. Corresponds to register 9 of the Bus Terminal.

sDescription: Terminal designation and firmware version as string (e.g. 'Terminal KL6821 / Firmware 2H').

VAR_IN_OUT

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

stInDataTerminal: Reference to the structure for communication with the KL6821.

stOutDataTerminal: Reference to the structure for communication with the KL6821.

stInData: Reference to the internal structure for communication with the function block FB_KL6821Communication() (KL6821).

stOutData: Reference to the internal structure for communication with the function block FB_KL6821Communication() (KL6821).

Requirements

Development environment

Target system

Required libraries

TwinCAT 2.11 R3/x64 from build 2260

PC/CX, BX or BC

TcDALIV2 library from V2.12.0