Wednesday, December 15, 2010

PLC and PC and RFID identification reader implementation of serial communication (1)

RFID is the full name of the Radio Frequency Identification, or RFID, it utilizes a wireless RF programmable controller (PLC) or computer (PC) and identifies the data transfer between, thus achieving a contactless identification and tracking.

A typical RFID radio frequency identification system consists of four parts: identity, antenna, controllers and host (PLC or PC), the system structure is shown in Figure 1.

  

Figure 1 RFID radio frequency identification system chart

Identify general fixed in tracking to identify the object, such as trays and racks, carts, container, can be stored in the identity necessarily bytes of data that is used to record important information to identify the object.

When you identify with the recognition of object moves, the identity becomes a mobile data carriers. RFID in computer assembly line of the application, for example, identity can record the chassis type (vertical or horizontal), the necessary accessories and models (motherboard, hard disk, CD-ROM, etc.), you need to complete the process. And if the parcel of automatic sorting and tracking application, you can identify the origin in the storage bag, destination, route, and other information.

The role of the antenna is through wireless electromagnetic wave data from identity reading or writing data to identify.

Antenna shape size, and large exports can be made to the warehouse door or channel, little can be as small as 1mm.

Controller used to control the antenna and PLC or data communication among PC, some controllers with digital input output can be directly used for the control.

Controller and collectively reader antenna.

PLC and PC based reader to capture the identity of the data, and complete the process control, or for data analysis, display and storage.

This article is to be representative of the United States EMS (Escort Memory Systems) the company's RFID 13.56MHz passive RFID reader LRP830, for example, introduced the PLC and PC and RFID reader for serial communication, which gets the identity data that is used to control or data processing of specific implementation.

2 RFID RFID reader command sets and serial communication protocols

For example, LRP830 reader is EMS 13.56MHz passive LRP830 series RF reader, its identity and an antenna can be under water or high temperature corrosion environment working, can one read-write 99 identification, maximum reading distance 63.5cm.

It comes with two serial ports, a DeviceNet interface, 4 DI isolation input, 4 DI isolation output, the protection IP66, NEMA4 package, and is ideally suited for applications in industrial automation.

LRP830 reader on the serial port is combined by a dedicated cable can tap out the COM1 and COM2 two serial ports, two serial ports COM1 as role, communication port, from the PLC or PC receiving commands and returns the response data that can be configured as RS232, RS422 or DeviceNet interface.

COM2 is used to configure the system parameters (such as read-write mode, baud rate, etc.) or download system upgrades.

LRP830 can and all EMS of FastTrackTM series passive identifies, for each identity you can store 48 bytes of data, there are 8 bytes to store the read-only a unique serial number (factory set by the manufacturer).

LRP830 provides single-label read/write command set (see table 1), the number identifies the read and write commands and the like.

Table 1 single identity command set

Each order can have three types of communication protocols: ABxS, ABxF, ABx ASCII.

Table 2 is a communication protocol continued reading ABxS single identity command example, similar to other commands.

Table 2 ABxS agreement continued reading single identity command examples

3 RFID reader serial communication with the PLC

To EMS RFID reader LRP830 and GE Fanuc VersaMax PLC's serial communications, for example.

VersaMax PLC RS232 serial port COM1 with LRP830 of correspondence between the wiring as shown in table 3.

Table 3 VersaMax and serial wiring LRP830 reader correspondence between the

Through the PLC control read and write RFID reader identification data of the implementation process, as shown in Figure 2.

Figure 2 PLC to read and write RFID identification data of the program structure diagrams

The following are the specific implementation of the technical details to note:

1) VersaMax PLC LRP830 and serial port signal lines are connected to the wrong line, that is, the VersaMax RS232 RXD TXD/to add the COM1 LRP830 RXD/TXD, LRP830 and PC connection when you are through.

2) PLC use serial I/O communication protocol and RFID reader traffic.

Serial port initialization, set buffer, clear the buffer, write the serial port, serial port status, and so reading is first through a set of instructions to COMMREQ BLKMOV WORD block assignment, and then follow the instructions to complete the. COMMREQ For example, the following statement (see Figure 3) through RFID readers write 10 FF (46H) to identify, from the firstBytes to write.

  

Figure 3 PLC and RFID reader serial communication routines

3) attention should be paid to identifying data PLC write only need to perform the write serial commands on the can, and PLC, reading, identification data contains two step process: first, do write serial command PLC, which identifies the command to read and write RFID reader; the second is read serial command PLC, capture the data returned by the RFID reader.

This is because RFID reader in order to read identity, will return a read command response to the serial port buffer, which contains the identification data to read.

4) when using ABxS Protocol, it is necessary to pay attention to the command Word MSB and LSB of order issue.

RFID reader communicates with the PLC, to reader instructions MSB and LSB reverse, that is, LSB, MSB. For example, Figure 3, the second WORD directive BLKMOV third input IN3 should be 16 # 4AA, rather than 16 # AA04.

5) use of the reader LEDs change secondary PLC program debugging.

LRP830 Reader Panel has two rows of LED lights, which, when the "ANT" lit, it indicates that the antenna in the implementation of the read and write operations; " COM1 "lit, it indicates that the serial port 1 to perform the write command," RF "lit, it indicates that there is identity is read/write and is still read and write.

4 RFID reader and PC serial communications

Still to EMS RFID reader LRP830, for example.

And PC are connected to the COM1/COM2 LRP830 and PC 9 pin serial port COM1/COM2 connection corresponding relationships, see table 4.

Table 4 LRP830 PC serial and UART correspondence

  

On PC serial communication program development, you can use the existing communications control (such as VB Mscomm), you can also use advanced programming language combined with Windows API implementation.

This article with Delphi 6 in Windows2000 environment, application of multithreading technology enables PC and RFID reader for serial communication. The advantage of using Delphi, Delphi for many Windows API functions for the base package, simplifies the program code. The advantages of using multiple threads, the program is to prepare a more flexible, and serial port listening thread does not affect the main thread of execution of other tasks. Program structure diagrams shown in Figure 4.

  

RFID

In the implementation of these ideas, it is necessary to pay attention to the following technical details:

1) based on RFID reader communication protocol features, read the execution of each host to the directive, whether read or write identity, the identity will return a byte of the response data to confirm that the command has been executed or returns the ID of the data in storage.

Therefore, host read or write to identify the data you need to write (serial command) after reading (return of serial data).

2) in order to make the program reflects the modular design for easy debugging and maintenance, you can take a variety of RFID command prior to command an array, and the host command to the RFID serial and capture RFID reader command response developed into separate subroutines, call it before calling the command Word assignment subroutine.

3) description of the primary thread: in the main thread using the CreateFile function to establish a serial event, set the buffer and communication parameters, create serial listening thread.

Use the WriteFile function to write serial port complete RFID reader writes data to identify. Part of the program are as follows:

……

hcom := CreateFile(pchar(Whichcom), GENERIC_WRITEorGENERIC_READ,

0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); //Generate the serial event

setupcomm(hcom,TOTALBYTES,TOTALBYTES); //Set the buffer

getcommstate(hcom,lpdcb);

lpdcb.BaudRate:=BAUDRATE; //Baud rate

lpdcb.StopBits := STOPBIT; //Stop bits

lpdcb.ByteSize := BYTESIZE; //Several per bytes

lpdcb.Parity :=PARITY; //Parity

setcommstate(hcom,lpdcb); //Set the serial port

Mycomm := Tcomm2.Create(False); //Create a serial listening thread

WriteFile (hcom, WriteBuffer, sizeof (WriteBuffer), lpBytesSent, 0);//write the ID command

……

4) description of the serial port listening thread:

程序中用到� [1] [2

]

No comments:

Post a Comment