FB_KL6831KL6841Config

FB_KL6831KL6841Config 1:

This block is used to configure the KL6831/KL6841. 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 KL6831/KL6841 in a fail-safe manner. In addition, some general information, such as the firmware version, is read from the KL6831/KL6841.

Example

The block is called in the same task as the block FB_KL6831KL6841Communication().

FB_KL6831KL6841Config 2:

The block FB_KL6831KL6841Config() is linked to the process image of the KL6831/KL6841. After the configuration, the block FB_KL6831KL6841Communication() is assigned the process values of the KL6831/KL6841. During the configuration, it is not possible to send SMI commands.

Unpacking the example files FB_KL6831KL6841Config 3:

VAR_INPUT

bConfigurate            : BOOL := FALSE;
eCommandKBusWatchdog    : E_SMIConfigurationCommands := eSMICommandDoNothing;
eCommandDI1RisingEdge   : E_SMIConfigurationCommands := eSMICommandUp;
eCommandDI1FallingEdge  : E_SMIConfigurationCommands := eSMICommandStop;
eCommandDI2RisingEdge   : E_SMIConfigurationCommands := eSMICommandDown;
eCommandDI2FallingEdge  : E_SMIConfigurationCommands := eSMICommandStop;
dwOptions               : DWORD := 0;

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

eCommandKBusWatchdog: Defines the SMI command that is sent as soon as the Bus Terminal is no longer addressed via the K-bus. Corresponds to register 33 to 35 of the Bus Terminal.

eCommandDI1RisingEdge: Defines the SMI command that is sent as soon as a rising edge is detected at input 1 of the Bus Terminal. Corresponds to register 36 to 38 of the Bus Terminal.

eCommandDI1FallingEdge: Defines the SMI command that is sent as soon as a falling edge is detected at input 1 of the Bus Terminal. Corresponds to register 39 to 41 of the Bus Terminal.

eCommandDI2RisingEdge: Defines the SMI command that is sent as soon as a rising edge is detected at input 2 of the Bus Terminal. Corresponds to register 42 to 44 of the Bus Terminal.

eCommandDI2FallingEdge: Defines the SMI command that is sent as soon as a falling edge is detected at input 2 of the Bus Terminal. Corresponds to register 45 to 47 of the Bus Terminal.

dwOptions: Reserved for future expansions.

VAR_OUTPUT

bBusy                 : BOOL;
bError                : BOOL;
udiErrorId            : UDINT;
wTerminalDescription  : WORD;
wFirmwareVersion      : WORD;
sDescription          : STRING;

bBusy: When the 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 udiErrorId. The output is again set to FALSE by the reactivation of the function block via the bConfigurate input.

udiErrorId: Contains the command-specific error code of the most recently executed command. It is set back to 0 by the reactivation of the function block via the bConfigurate input. See Error codes.

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

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

sDescription: Terminal designation and firmware version as string (e.g. 'Terminal KL6831 / Firmware 1D').

VAR_IN_OUT

stInDataTerminal          : ST_KL6831KL6841InData;
stOutDataTerminal         : ST_KL6831KL6841OutData;
stInData                  : ST_KL6831KL6841InData;
stOutData                 : ST_KL6831KL6841OutData;

stInDataTerminal: Reference to the structure for communication with the KL6831/KL6841.

stOutDataTerminal: Reference to the structure for communication with the KL6831/KL6841.

stInData: Reference to the structure for communication with the function block FB_KL6831KL6841Communication().

stOutData: Reference to the structure for communication with the function block FB_KL6831KL6841Communication().

Requirements

Development environment

Target system

Required libraries

TwinCAT 2.11 R3/x64 from build 2253

PC/CX, BX or BC

TcSMI library from V1.1.0