KL6Configuration

KL6Configuration 1:

The function block KL6Configuration initializes and configures a serial Bus Terminal KL6xxx.

The function block uses the standard register communication for KL Terminals for the configuration. For EtherCAT Terminals EL this register communication is not available. EL Terminals can be configured with function blocks from the EtherCAT library (FB_EcCoeSdoWrite).

KL6Configuration 2: Inputs

VAR_INPUT
  Execute         : BOOL;
  Mode            : ComSerialLineMode_t;
  Baudrate        : UDINT;
  NoDatabits      : BYTE;
  Parity          : ComParity_t;
  Stopbits        : BYTE;
  Handshake       : ComHandshake_t;
  ContinousMode   : BOOL;
  pComIn          : POINTER TO BYTE;
  pComOut         : POINTER TO BYTE;
  SizeComIn       : UINT
END_VAR

Name

Type

Description

Execute

BOOL

A rising edge at the Execute input resets the connected serial hardware.

Mode

ComSerialLineMode_t

The Mode input specifies unambiguously which serial hardware is being used.

Baud rate

UDINT

The baud rate, provided it is supported by the serial hardware.
115200, 57600, 38400, 19200, 9600, 4800, 2400, 1200

NoDatabits

BYTE

The number of user data bits in one data byte.
7 or 8

Parity

ComParity_t

The type of the parity bit in a data byte.
PARITY_NONE=0, PARITY_EVEN=1, PARITY_ODD=2

Stop bits

BYTE

The number of stop bits per data byte.
1 or 2

Handshake

ComHandshake_t

The type of handshake used, provided it is supported by the serial hardware.
HANDSHAKE_NONE=0, HANDSHAKE_RTSCTS=1, HANDSHAKE_XONXOFF=2

ContinousMode

BOOL

Switches on continuous transmission, provided this is supported by the serial hardware.

If ContinousMode is TRUE, transmitted data is not sent out by the serial hardware until the hardware transmit buffer is full. This means that there are no time gaps in the transmission, provided the quantity of data is similar in size to the hardware transmit buffer. Continuous mode is only necessary in special cases in which the end device reacts to time gaps with a time-out.

pComIn

POINTER TO BYTE

Universal pointer to the input variable of the process data for the serial hardware (data types: KL6inData, KL6inData5b, KL6inData22b, PcComInData). The pointer is assigned with the ADR() function.

pComOut

POINTER TO BYTE

Universal pointer to the output variable of the process data for the serial hardware (data types: KL6outData, KL6outData5b, KL6outData22b, PcComOutData). The pointer is assigned with the ADR() function.

SizeComIn

UINT

Size of the input process image of the serial hardware being used. The size is determined and assigned with the SIZEOF() function.

KL6Configuration 3: Outputs

VAR_OUTPUT
  Done       : BOOL;
  Busy       : BOOL;
  Error      : BOOL;
  ErrorID    : ComError_t;
END_VAR

Name

Type

Description

Done

BOOL

The Done output becomes TRUE when the function has been carried out without error.

Busy

BOOL

The Busy output becomes TRUE in response to rising edge at Execute, and remains TRUE for as long as the function block is performing its function.

Error

BOOL

This output Error goes TRUE as soon as an error occurs.

ErrorID

ComError_t

The ErrorID output provides an error code when an error occurs.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4012

PC or CX (ARM, x86, x64)

Tc2_SerialCom