RFID reader connection

All RFID readers supported by this PLC library are connected to the controller via serial communication interfaces (RS 232, RS 422, RS 485 and virtual serial COM ports).

The following Beckhoff products can be used for this:

RFID reader connection 1:
RFID reader connection 2:

Using multiple RFID readers

A separate connection must be made to a separate terminal for each RFID reader. The PLC RFID library does not support more than one RFID reader on one RS485 network for the time being.

Setting up serial communication under TwinCAT PLC Control

The serial data exchange is established with the blocks of the TwinCAT PLC library COMlibV2.

Create a send buffer and a receive buffer of type ComBuffer. This can take place globally but does not have to.

Additionally create two data structures, as used for serial communication in the TwinCAT system manager:

If the COM port is used, this looks as follows:

gPcComRxBuffer      :ComBuffer;
gPcComTxBuffer      :ComBuffer;
PcComInData AT %I*  :PcComInData;
PcComOutData AT %Q* :PcComOutData;

When using a serial terminal, EL6inData22B/EL6outData22B as well as KL6inData5B/KL6outData5B and other data types are possible in addition to PcComInData/PcComOutData. These structures are linked in the system manager with the channels of the serial interface.

RFID reader connection 3:

In case of using the ComPort the SyncMode in the TcSystemManager must be activated.

RFID reader connection 4:

In the TcSystemManager the Plc variables must be related to the right (fast) task and must be mapped. If several tasks are used and the PLC variables are in the wrong task, they can be moved to the right task by Drag & Drop.

For serial communication, an instance of the 'SerialLineControl' must be created. This is called cyclically in a fast task (<= 1 ms). The required task cycle time depends on the application, the data amount, the baud rate, and the interface.

Depending on the application and the interface it is often recommended to process this in an additional task, which is faster than the task of the application.
Example 1: For communication with a COM port at a baud are of 115200 baud, a cycle time of 1 ms is required.

Example 2: For communication with a serial EL6001 terminal at a baud rate of 9600 baud, a cycle time of 6 ms is required.

Further information as well as explanation of virtual serial COM port usage are to be found in the Documentation for the PLC library serial communication.

The COM Port properties in the TwinCAT System Manager are represented by way of example below:

RFID reader connection 5:

The call of the SerialLineControl is represented by way of example below.

Call as StructuredText in the case of use of the COM port:

LineControl(
    Mode        := SERIALLINEMODE_PC_COM_PORT,
    pComIn      := ADR(PcComInData),
    pComOut     := ADR(PcComOutData),
    SizeComIn   := SIZEOF(PcComInData),
    TxBuffer    := gPcComTxBuffer,
    RxBuffer    := gPcComRxBuffer
);

Call as StructuredText in the case of use of an EtherCAT terminal:

LineControl(
    Mode        := SERIALLINEMODE_EL6_22B,
    pComIn      := ADR(EL6ComInData),
    pComOut     := ADR(EL6ComOutData),
    SizeComIn   := SIZEOF(EL6ComInData),
    TxBuffer    := gEL6ComTxBuffer,
    RxBuffer    := gEL6ComRxBuffer
);

Call as StructuredText in the case of use of a K-bus terminal:

KL6Config3(
    Execute         := bConfig3,
    Mode            := SERIALLINEMODE_KL6_5B_STANDARD,
    Baudrate        := 9600,
    NoDatabits      := 8,
    Parity          := 0,
    Stopbits        := 1,
    Handshake       := RS485_FULLDUPLEX,
    ContinousMode   := FALSE,
    pComIn          := ADR(KlComInData3),
    pComOut         := ADR(KlComOutData3),
    SizeComIn       := SIZEOF(KlComInData3),
    Busy        => bConfig3Act,
    Done        => bConfig3Done,
    Error       => bConfig3Error
);
IF NOT KL6Config3.Busy THEN
    bConfig3 := FALSE;

    LineControl3(
        Mode        := SERIALLINEMODE_KL6_5B_STANDARD,
        pComIn      := ADR(KlComInData3),
        pComOut     := ADR(KlComOutData3),
        SizeComIn   := SIZEOF(KlComInData3),
        TxBuffer    := gKlComTxBuffer3,
        RxBuffer    := gKlComRxBuffer3
    );
END_IF