FB_KL6831KL6841Config

The function block FB_KL6831KL6841Config 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 function block is called in the same task as the function block FB_KL6831KL6841Communication().

The function block FB_KL6831KL6841Config() is linked to the process image of the KL6831/KL6841. Once the configuration is complete, the function block FB_KL6831KL6841Communication() receives the process values of the KL6831/KL6841. No SMI commands can be sent while the configuration is in progress.
![]() | Sample |
Inputs
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;
END_VAR
Name | Type | Description |
---|---|---|
bConfigurate | BOOL | 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 | DWORD | Reserved for future extensions |
Inputs/outputs
VAR_IN_OUT
stInDataTerminal : ST_KL6831KL6841InData;
stOutDataTerminal : ST_KL6831KL6841OutData;
stInData : ST_KL6831KL6841InData;
stOutData : ST_KL6831KL6841OutData;
END_VAR
Name | Type | Description |
---|---|---|
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() |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
udiErrorId : UDINT;
wTerminalDescription : WORD;
wFirmwareVersion : WORD;
sDescription : STRING;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | This output is set as soon as the function block processes a command and remains active until the command has been processed. |
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 udiErrorId. The output is reset to FALSE by the reactivation of the function block via the input bStart. |
udiErrorId | UDINT | Contains the command-specific error code of the most recently executed command. It is reset to 0 by the reactivation of the function block via the input bStart (see error codes). |
wTerminalDescription | WORD | Contains the terminal name (e.g. 6831). Corresponds to register 8 of the bus terminal. |
wFirmwareVersion | 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 KL6831 / Firmware 1D') |
Requirements
Development Environment | PLC library to include |
---|---|
TwinCAT from v3.1.4020.32 | Tc2_SMI from 3.3.6.0 |