Serial connection
In this example the RFID reader is connected via an EL 6001 serial EtherCAT Terminal.
- 1. Create a send buffer and a receive buffer (gEL6ComTxBuffer, gEL6ComRxBuffer) of type "ComBuffer". In addition, you should create two data structures as they are used for serial communication in the TwinCAT System Manager.
gEL6ComRxBuffer :ComBuffer;
gEL6ComTxBuffer :ComBuffer;
EL6ComInData AT %I* : EL6ComInData;
EL6ComOutData AT %Q* : EL6ComOutData;
- 2. Link the structures in the TwinCAT System Manager to the channels of the serial port.
- 3. For serial communication, create an instance of the SerialLineControl. Call this cyclically in a fast task. (Mode: Enter the EtherCAT Terminal with 22 bytes of user data as handle.)
LineControl(
Mode := SERIALLINEMODE_EL6_22B,
pComIn := ADR(EL6ComInData),
pComOut := ADR(EL6ComOutData),
SizeComIn := SIZEOF(EL6ComInData),
TxBuffer := gEL6ComTxBuffer,
RxBuffer := gEL6ComRxBuffer
);