FB_KL3228Config

FB_KL3228Config 1:

Function block for parameterization of a KL3228: 8-channel input terminal for resistance sensors.

FB_KL3228Config 2:

The function block only parameterizes one terminal channel. For parameterizing all channels, the corresponding number of function blocks has to be instantiated. A mixed configuration (e.g. different sensor types) is possible.

VAR_INPUT

bConfigurate   : BOOL;
bReadConfig    : BOOL;
iSetSensorType : INT;
tTimeout       : TIME;

bConfigurate: A rising edge at this input starts a configuration-sequence. At first the common terminal data like "terminal type", "special type" and "firmware version" will be read. Afterwards the internal registers will be set according to the configurations at the inputs of this function-block. To make sure, the configuration has been successful, the registers will be read and the information will be shown at the outputs of the FB, together with the common terminal-data. As long as this sequence is running, the output bBusy is set to TRUE and no other command, like bReadConfig, will be executed.

bReadConfig: A rising edge at this input starts the reading-sequence only. The common terminal data like "terminal type", "special type" and "firmware version" will be read together with the internal configuration-parameters. The read information will be shown at the FB-outputs afterwards. If this sequence is running, the output bBusy is set to TRUE and no other command, like bConfigurate, will be executed.

iSetSensorType: At this input, the sensor type is to be set according to the table below.

tTimeout: The commands bConfigurate and bReadConfig must be successfully executed within this time.

iSetSensorType

Element

0

PT1000

1

NI1000

2

RSNI1000 (NI1000 with Landis&Staefa characteristic: 1000 Ω at 0 °C and 1500 Ω at 100 °C)

VAR_OUTPUT

bBusy            : BOOL;
bError           : BOOL;
iErrorId         : UDINT;
iState           : USINT;
iDataIn          : INT;
iTerminalType    : WORD;
iSpecialType     : WORD;
iFirmwareVersion : WORD;
sDescription     : STRING;
sSensorType      : STRING;

bBusy: If a reading- or configuration-sequence is being processed, this output will be set to TRUE.

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.

iErrorId: 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 or the bReadConfig input. See Error codes.

iState: This value corresponds to the state-variable of the process-data stInData.iState, see VAR_IN_OUT. During command-execution (bBusy = TRUE) this output is set to 0 and remains unchanged. It is thus suitable to evaluate the state of the terminal under normal conditions: disturbing values during configuration and reading due to register-communication will not be shown.

iDataIn: This value corresponds to the process data stInData.iDataIn, see VAR_IN_OUT. During command-execution (bBusy = TRUE) this output is set to the value previous to the execution and remains unchanged. It is thus suitable for direct process control: disturbing values during configuration and reading due to register-communication will not be shown.

iTerminalType: Contents of register 8. If the right terminal is selected, this value should be 0x0C88 (3228dec).

iSpecialType: Contents of register 29: special-type.

iFirmwareVersion: Contents of register 9: firmware-version.

sDescription: Terminal-type, special-version and firmware-version put together to a readable string (e.g. 'Terminal KL3228-0000 / Firmware 1C').

sSensorType: Entered sensor type as readable text.

VAR_IN_OUT

stInData   : ST_KL3228InData;
stOutData  : ST_KL3228OutData;

stInData: Reference to the structure containing the input process image.

stOutData: Reference to the structure containing the output process image.

Background information

On ARM systems, the structure as a whole cannot be linked to the image of the terminal - the structure variables must be linked individually.
In addition, a new DWORD key must be created in the Windows registry of the development computer, otherwise memory image shifts will occur.
Under "HKEY_CURRENT_USER\Software\Beckhoff\TwinCAT System Manager\On Startup" the key "SubVarOffsByOffs" with the value "1" is inserted.
Afterwards restart the development computer once.

FB_KL3228Config 3:

Requirements

Development Environment

Target System

IO Hardware

PLC Libraries to include

TwinCAT v2.11 R3/x64 from Build 2254

PC/CX

KL3228

TcIoFunctions.Lib

( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )

TwinCAT v2.11 R3/x64 from Build 2256

BC

KL3228

TcIoFunctions.lb6 ( Standard.lb6 will be included automatically )

TwinCAT v2.11 R3/x64 from Build 2256

BX

KL3228

TcIoFunctions.lbx ( Standard.lbx will be included automatically )