Serial connection

In this example the RFID reader is connected via an EL 6001 serial EtherCAT terminal.

Variables:

Create a send buffer and a receive buffer (gEL6ComTxBuffer, gEL6ComRxBuffer) of type ComBuffer.

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

gEL6ComRxBuffer       :ComBuffer;
gEL6ComTxBuffer       :ComBuffer;
EL6ComInData AT %I*   :EL6ComInData;
EL6ComOutData AT %Q*  :EL6ComOutData;

Link these structures with the channels of the serial port in the system manager.

For serial communication, create an instance of the 'SerialLineControl'. Call this cyclically in a fast task.

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

Mode: As a handle, specify the serial EtherCAT terminal with 22 bytes of user data in our example.

Further instructions can be found in the chapter Serial RFID reader connection.

nächste Tutorial-Seite