• PLC and PC and the RFID recognition reader-writer serial communication realizes - en.51rd.net

    The RFID full title is Radio Frequency Identification, namely the radio frequency recognition, it uses the radio radio frequency to realize the programmable controller (PLC) or the microcomputer (PC) with the marking data transmission, thus realizes the non-contact type target identification and the track.

      A typical RFID radio frequency recognition system including four parts: Marking, the antenna, the controller and the main engine (PLC or PC), the system structure drawing see Figure 1.

      

      Figure 1 RFID radio frequency recognition system structure drawing

      Marking fixes generally on the track recognition object, like the tray, the shelf, the car, the container, may save certain byte in marking the data, uses in recording the recognition object the important information. When marks along with the recognition object migration, marking becomes a motion the data carrier. By RFID, in the computing group installs wiring on application is an example, in marking may record engine case’s type (vertical horizontal type), to need the working procedure which the fitting and the model (motherboard, hard disk, CD-ROM and so on), need to complete and so on. Also like in mail carrier’s bag’s automatic sort and the track application, may save information and so on mail carrier’s bag’s initial sending, destination, route in marking.

      Antenna’s function is reads the data through the wireless electromagnetic wave from marking or writes the data to marking. The antenna shape size varies, big may make the goods warehouse export the gate or the channel, small may slightly to 1mm.

      The controller uses in the control antenna and PLC or the PC data communication, some controllers also have the digital quantity input output, may use in controlling directly. The controller and the antenna gather call the reader-writer.

      PLC or PC in the marking data which catches according to the reader-writer complete the corresponding process control, or carries on the data analysis, the demonstration and the memory.

      This article namely take has representative American EMS (Escort Memory Systems) company’s 13.56MHz passive RFID radio frequency recognition reader-writer LRP830 as an example, introduced PLC and PC and the RFID reader-writer carries on the serial communication, thus the gain marking data, uses in controlling or the data processing realizes the method specifically.

      2 RFID radio frequencies distinguish reader-writer’s order collection and the serial communication protocol

      Take the LRP830 reader-writer as the example, LRP830 is EMS in the 13.56MHz passive series radio frequency reader-writer’s one kind, its marking and the antenna may in submarine or the hot corrosion environment the normal work, may a read-write 99 marking, the biggest read-write be away from 63.5cm. It has two serial ports, a DeviceNet connection, 4 DI isolation input, 4 DI isolation output, protects the rank IP66, NEMA4 seal, in applies very suitably in the industrial automation.

      On the LRP830 reader-writer’s serial port is gathers in the same place, may divide through the special cable leads COM1 and the COM2 two serial ports, two serial port functions are different, COM1 serves as the communication mouth, orders and returns to the response data from PLC or the PC receive, may dispose is RS232, RS422 or the DeviceNet connection. COM2 uses in disposing the system parameters (for example read-write pattern, baudrate and so on) or the downloading system upgrade procedure.

      LRP830 may with all EMS FastTrackTM series passive marking union use, in each marking be possible to save 48 bytes the data, in addition before has 8 bytes to use in saving the read-only series number (leaving the plant, by factory hypothesis).

      LRP830 provided the list marking read-write order collection (to see Table 1), marked the read-write order and this similar.  

      Table 1 list marking order collection

      Each kind of order may have three kind of communication protocols: ABxS, ABxF, ABx ASCII. Table 2 are the ABxS communication protocol continues to read the list marking order an example, other orders and this similar.

      Table 2 ABxS agreements continue to read the list marking order example

      3 RFID reader-writers and PLC serial communication

      Take EMS RFID reader-writer LRP830 and the GE Fanuc VersaMax PLC serial communication as an example. The VersaMax PLC RS232 serial port and the LRP830 COM1 wiring corresponding relationships see Table 3.

      Table 3 VersaMax and LRP830 reader-writer’s serial port wiring corresponding relationships

      Controls the RFID reader-writer read-write marking data through PLC to realize flow as shown in Figure 2.

      Figure 2 PLC read-write RFID marking data program structure diagram

      The technical detail which the following is realizes specifically when must pay attention:

      when 1) LRP830 and the VersaMax PLC serial port is connected, the holding wire wants the wrong line, namely VersaMax RS232 mouth TXD/RXD must meet LRP830 COM1 RXD/TXD, LRP830 and when the PC connection goes nonstop.

      2) PLC uses the serial I/O communication protocol and the RFID reader-writer communication. The serial port initialization, the establishment buffer, the elimination buffer, write the serial port, to read operations and so on serial port condition are first through group of BLKMOV the WORD instruction for the COMMREQ block data evaluation, then carries out COMMREQ order complete. For example, the following sentence (see Figure 3) to write 10 FF through the RFID reader-writer (46H) to marking, writes from the first byte.

      

      Figure 3 PLC and RFID reader-writer serial communication routine

      3) must pay attention to PLC to write the marking data only to need to carry out writes the serial port order to be possible, but PLC read the marking data the process to contain two steps: First, the PLC execution writes the serial port order, namely writes reads marking to order the RFID reader-writer; Second, the PLC execution reads the serial port order, catches data which the RFID reader-writer returns. This is because RFID reader-writer after receiving reads the marking order, will return reads the order the response message to the serial port buffer, has contained the marking data which reads.

      when 4) uses the ABxS agreement, must the attention to orders command character MSB and the LSB smooth question. When RFID reader-writer and PLC communication, must inverts reader-writer instruction MSB and LSB, namely LSB before, MSB after. For example in Figure 3, second BLKMOV WORD instruction’s third inputs IN3 to be 16#4AA, but non-16#AA04.

      5) is auxiliary the PLC program debugging using the reader-writer indicating lamp’s change. On the LRP830 reader-writer’s kneading board has two row of LED indicating lamps, when “ANT” is bright, indicates the antenna in the execution read-write operation; When “COM1″ is bright, indicated that the serial port 1 carried out has written the order, when “RF” was bright, indicated that had marking by the read-write, and still in read-write scope.

      4 RFID reader-writers and PC serial communication

      Still take EMS RFID reader-writer LRP830 as the example. Is connected when with PC machine, LRP830 COM1/COM2 and the PC machine 9 needle serial port COM1/COM2 connection corresponding relationships see Table 4.

      Table 4 LRP830 serial ports and PC serial port connection corresponding relationships

      

      Develops the serial port communication procedure on PC machine, may use the existing communication to control (for example VB Mscomm), may also use the high-level programming language to unify Windows API to realize. This article with Delphi 6 in the Windows2000 environment, the application multithreading technology has realized PC and serial communication between the RFID reader-writer’s. Uses Delphi the merit is, Delphi function has made the seal to many Windows the first floor API, simplified the procedure code. The use multithreading’s merit is, the programming is quite flexible, moreover the serial port monitor thread does not affect main thread other duties the execution. The program structure diagram see Figure 4.

      

      RFID

      When realizes the above mentality specifically, must pay attention to the following technical detail:

      1) acts according to the RFID reader-writer communication protocol the characteristic, the reader-writer carries out the instruction which every time a main engine sends, regardless of being reads marking or writes marking, can return to certain byte the response data, with confirmed that the order has carried out the data which or in returns marking saves. Therefore, after the main engine reads or writes the marking data needs to write (serial port order) first, reads (returns serial port data).

      2) to cause the procedure to manifest modular the design concept, easy to debug and the maintenance, may store in advance each kind of RFID order in the order array, but catches the main engine to the RFID serial port’s order the RFID reader-writer command response to establish the independent subroutine, before transferring it, transfers the order character evaluation subroutine first.

      3) to main thread explanation: Establishes the serial port event in the main thread with the CreateFile function, the establishment buffer and the correspondence parameter, the foundation serial port monitor thread. Writes the serial port function with WriteFile to complete through the RFID reader-writer writes the data to marking. The subprograms are as follows:

      ……

      hcom: = CreateFile (pchar (Whichcom), GENERIC_WRITE or GENERIC_READ,

      0th, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); // has the serial port event

      setupcomm (hcom, TOTALBYTES, TOTALBYTES); // establishment buffer

      getcommstate (hcom, lpdcb);

      lpdcb.BaudRate:=BAUDRATE; // baudrate

      lpdcb.StopBits: = STOPBIT; // stop position

      lpdcb.ByteSize: = BYTESIZE; // each byte has several

      lpdcb. Parity: =PARITY; // parity check

      setcommstate (hcom, lpdcb); // establishment serial port

      Mycomm: = Tcomm2.Create (False); // foundation serial port monitor thread

      WriteFile (hcom, WriteBuffer, sizeof (WriteBuffer), lpBytesSent, 0); // writes the marking order

      ……

      4) to serial port monitor thread explanation:

      In the procedure uses the method mainly has Synchronize and Terminate. Synchronize is one safe transfer thread method which Delphi provides, it has given the thread transfer power the main thread, thus has avoided the thread conflict, this is one kind of simple the thread the synchronized method, may omit with other language programming when needs to transfer many Windows API function, for example createEvent (foundation synchronization event), Waitforsingleobject (waiting synchronization event setting), resetevent (synchronized event replacement), PostMessage (to main thread sending a message) and so on. Compiles the multi-thread communication procedure with Delphi the merit is obvious. For example the following sentence then realizes the serial port monitor thread:

      ……

      While (not Terminated) do //, if terminates the attribute not for really

      Begin

      dwEvtM

    ask:=0;

      Wait: = WaitCommEvent (hcom, dwevtmask, lpol); // waiting serial port event

      if Wait Then

      begin

      Synchronize (DataProcessing); // synchronization serial port event

      end;

      end;

      Once the above procedure examines the serial port event, transfers the DataProcessing method to read the serial port data, and reads in the array, transfers for procedure other parts, in addition when can examine withdraws from the thread, the procedure is as follows:

      procedure Tmainform.DataProcessing

      begin

      clear: = CLEARCOMMERROR (hcom, lperrors,@comms); // elimination serial port is wrong

      if Clear Then

      The Begin // processes the receive data

      ReadFile (hcom, ReadBuffer, Comms.cbInQue, LPReadNumber,0);

      ReceBytes[I ArrayOffset]: = ReadBuffer[I];

      // reads the serial port buffer data and reads in the array

      gameover: = (ReceBytes[I ArrayOffset-1]=Byte ($FF))

      and (ReceBytes[I ArrayOffset]=Byte ($FF)); // terminal condition

      if gameover then terminate; // withdrawal thread

      ……

      End;

      End;

      And, Terminate the thread Terminated attribute establishment is True. Once the thread examines the Terminated attribute is True, will finish the thread, carried out the Onterminate event, to the RFID marking data which gathered carries on processing in the Onterminate event. Because RFID reader-writer’s ABxS agreement’s command response’s final two bytes are FF, therefore may receive continual two FF to take one of termination thread conditions.

      Procedure using example:

      Take continues to read in marking all 48 byte data order as the example, guarantees the debit and credit order in the procedure with the WriteBuffer array, is as follows to the WriteBuffer array’s each element evaluation:

      WriteBuffer[0]: = Byte ($AA); WriteBuffer[1]: = Byte ($0D); // reads the marking order prefix continuously

      WriteBuffer[2]: = Byte ($00); WriteBuffer[3]: = Byte ($00); // starts from the first byte to read

      WriteBuffer[4]: = Byte ($00); WriteBuffer[5]: = Byte ($30); // reads 48 byte data

      WriteBuffer[6]: = Byte ($00); WriteBuffer[7]: = Byte ($02); // time delay 2 seconds

      WriteBuffer[8]: = Byte ($ff); WriteBuffer[9]: = Byte ($ff); // reads the marking order character continuously

      After the execution continues reads the marking order, the procedure by the WriteBuffer array writes the serial port, the RFID reader-writer carries out this order, and returns to the response data (to see Figure 5).

      

      Figure 5 continues to read the marking order to carry out the result

      From Figure 5 in the window may see that first 4 byte AA OD FF FF is the LRP830 reader-writer to continues to read the order the confirmation information, before is in data message AA OD and marking 48 byte data (each byte data, adds 00), finally is data message tail FF FF.

      5 concluding remark

      This article introduced the programmable controller and the microcomputer and the RFID radio frequency recognition reader-writer carries on the serial communication, thus in the gain marking data realizes the method specifically: PLC realizes the serial communication through the serial I/O communication protocol and the RFID reader-writer, PC realizes the serial communication through the Windows multithreading technology and the RFID reader-writer. This article states the method to have the versatility, also has certain reference value regarding other factory’s PLC and the RFID system. The RFID radio frequency recognition technology in domain and so on our country industrial automation applications only then just started, the prospect is broad. This article regarding promotes this technical promoted application to have certain positive sense.

    Share/Save/Bookmark

    Wednesday, December 10th, 2008 at 14:22
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

TOP
Copyright © 51 Research and Design, Electronic Engineers website - Embedded Systems, MCU, DSP, EDA, Test and Measurement, Components, Communications, Power, Microelectronics, Semiconductors
Powered by WordPress | Theme by mg12 | Valid XHTML 1.1 and CSS 3