Sample 3

This example corresponds to a small application. The application includes the recognition, reading and writing of a transponder in an automatic sequence.
The example was created with a Pepperl+Fuchs RFID reader. Both the 2-channel and the 4-channel model can be used.
In the example, the device is connected directly to the Com Port. If a Pepperl+Fuchs RFID reader is used that is connected to a serial Beckhoff terminal instead of to the Com port, the serial background communication in the PLC code must be changed and reconfigured in the TwinCAT System Manager. (See chapter RFID reader connection)

Sequence of the implemented application:

Sample 3 1:

Two read/write heads are connected to the RFID device. Both detect transponders arriving in the field fully automatically. After detection, a memory block is read out from the transponder's data memory. The 4-byte value in it is incremented by one by the first read head or decremented by one by the second read head. The new value is immediately written back to the transponder. This process of detection, reading and writing takes about half a second in total. There must be an interval of at least three seconds between two such processes on the same read head in order to avoid unwanted multiple execution. (This could also be solved by checking the tag serial number)

The program essentially contains a state machine with 6 states:
0: Initialization - execution of GetReaderVersion, GetConfig, etc.
1: Tag detection at read head 1- buffered GetInventory
2: Tag detection at read head 2- buffered GetInventory
3: Waiting for tag detection
4: Action at read head 1 - ReadBlock and WriteBlock
5: Action at read head 2 - ReadBlock and WriteBlock

Sample 3 2:

The data carrier type (iUSEDDCTYPE) should be adapted to the transponder types used.

The example project contains the call of the RFID function block with different commands. For further information on the RFID reader communication sequence, please refer to the chapter Handling the RFID function block.

Project Download: TcRFID_Sample03.zip

Sample 3 3:

The current version of the TwinCAT library must be used.