Be based on the communication means of the PLC of multi-line Cheng technology and PC

  • Time:
  • Click:155
  • source:SEENER CNC Machining
Introduction: In system of modern industry control, PLC relies on a gender with its Gao Ke, get used to the characteristic such as industrial procedure spot, powerful couplet net function, by wide application. Can realize sequence control, PID data of loop adjustment, high speed collects analysis, computer to go up a management, it is the important step that achieves Electromechanical unifinication and development direction. 0.

Foreword is in system of modern industry control, PLC relies on a gender with its Gao Ke, get used to the characteristic such as industrial procedure spot, powerful couplet net function, by wide application. Can realize sequence control, PID data of loop adjustment, high speed collects analysis, computer to go up a management, it is the important step that achieves Electromechanical unifinication and development direction. But PLC cannot make whole control system alone, cannot undertake complex operation is mixed show all sorts of real time control chart and curve, without good user interface, do not facilitate monitoring. the PC (PC) and PLC union rise use, can make both advantage complementary, make full use of the application software with powerful man-machine interface function, rich PC and cheap price advantage, form the control system that high-powered price compares. 1.

The system is formed in boosting a system, the PC chooses labour to control the computer. It is the core of whole control system, it is to go up a machine. Its basically use good graphical user interface, show the switch amount that receives from PLC and the niche that dominate handle, have a few more complex data operation, and issue control statement to PLC. PLC is this system leave an opportunity, data of responsible spot high speed is collected (the positional) that controls handle, realize the function such as logistic, time, computation, PID adjustment, to the PC through serial communication mouth status of deferent PLC job reachs concerned data, accept a statement from the PC at the same time, wait to the buzzer, indicator light, slippery oil pump, niche that dominates handle issue an order, achieve the PC administration to controlling a system, increased the control ability of PLC and control scope, make whole system makes system of distributing center control. 2.

The communication between communication agreement computer and PLC is to build in the asynchronous that is a foundation with RS232 standard on two-way communication, FX series PLC has its specific communication pattern, whole communication system is used go up the communication means with an active machine, PLC interior does not need to write special communication program, in wanting to deposit data in corresponding data register only can, every data register has corresponding physical communication address, the computer when communication undertakes operating to physical communication address directly. In communication process, transmission character and command word are with ASC Ⅱ code accurate, commonly used character and correspondence of code of its ASC Ⅱ concern. When the computer and PLC have news report, undertake for the unit with frame information is exchanged between the computer and PLC, control character ENQ, ACK, NAK among them, can form monomial accord with to frame is sent and be accepted, when the information frame of the others is sent and be being accepted, be by character STX, command ETX of word, data, character and with desired result 5 parts are comprised. What desired result and the rear in information frame use judgement to transmit is correct, the computational method that piles up with desired result is the ASC Ⅱ code that piles up the command all character between ETX (hexadecimal number) addition, take the minimum that earning mixes 2 digit, retrospective still can be mentioned inside communication programming. The method that undertakes accident examines is very much, have yard of odd even desired result commonly usedly, the level is perpendicular and redundant desired result LRC, what use extensively at present is code of CRC desired result, it can investigate 99% above 18 or chiefer outstanding error, and when bit righter stone's throw news report is being ordered with PLC in the computer, the odds that make mistake is lesser, use desired result and method consequently, can satisfy a requirement basically. 3.

Multi-line Cheng technology and in VC++ the implementation in program of the communication that string together a mouth is inside a process of Windows, include Cheng of one or more line, every line Cheng shares all process resource, label of the file that includes to open, signal and dynamic distributive memory are waited a moment. All line Cheng inside a process is used same a 32 addresses space, and the execution of these line Cheng is attempered by the system programme controll, attemper the program decides which line when to Cheng Ke is carried out and carry out line Cheng. Line Cheng has preferential level, the line Cheng with inferior lien must when after the line Cheng with higher priority executes the mission, carry out again. In multiprocessing implement on the machine, attemper the program can put many lines Cheng to different processor to move, can make the task of processor is balanced so, also improve moving efficiency of the system. Of Windows interior attemper first the program allots CPU time between line Cheng of the activity, windows is divisional the line Cheng of two kinds of different types, one kind is Cheng of user interface line (UserInterfaceThread) , it includes message loop or message pump, with the information that receives at processing; Another kind is working line Cheng (WorkThread) it circulates without the message, the line Cheng that is used at carrying out the tiring-room task, surveillant incident that string together a mouth is working line Cheng namely. This system uses method of MFC process designing, MFC is what string together a mouth to be handled as file equipment, it is opened with CreateFile() string together a mouth, obtain to string together a mouth sentence handle, undertake with SetCommState() port is configured, include buffer setting, overtime setting and data format. Call what function ReadFile() and WriteFile() have data to read next write, with incident of WaitForSingleObject() surveillant communication. Reading with ReadFile() and WriteFile() write when stringing together a mouth, use jackknife means commonly. Because synchronous I/O means is,carry out ending ability to return when the program, such meeting block are other line Cheng, reduce a program to carry out efficiency. And the function that jackknife means can make call is returned instantly, i/O operates backstage to undertake, such line Cheng can handle other work, also realized line Cheng to be in at the same time same string together a mouth sentence the implementation on the handle is read keep an operation. When means of use jackknife I/O, line Cheng should found OVERLAPPED structure to write function to use for reading, the member with this the most important structure is HEvent incident sentence handle. It uses the synchronous target that regards a line as Cheng, read the HEvent when writing function to finish to be in have signal state, express to be able to undertake reading writing operating; Read write when function is half-baked, HEvent is not to have signal by buy. Use the multi-line Cheng technology of Windows, in auxiliary line Cheng surveillance strings together a mouth, know exactly about sth occupies drive of incident of the support when arriving, read in data and report to masterstroke Cheng; And, support jackknife is read keep an operation, let string together a mouth to read write operation backstage to move. 4.

Go up the data of 2 byte that take PLC in order to read to output coil Y0 to head is a computer communication programming exemple, write program of a communication. Check PLC watch of soft component address is knowable, output an address of coil Y0 to be 00A0H, the data of 2 byte is Y0-Y7 and Y10-Y17 namely, according to returned data, can know PLC right now condition, in order to realize the monitoring to PLC. Before every time reads an operation, want to have handclasp contact first. Request question mark ENQ to PLC hair, the response that reads PLC next question mark. The response that if read,arrives question mark is ACK, express PLC already be all set, wait to receive communication data. BOOLCPlcComDlg: : ReadFromPLC(char*Read_char, char*Read_address, intRead_bytes){CSerialSerial; / / kind of If(Serial that is used at serial communication.

Open(1))// initialization is serial communication mouth COM1{Serial.

SendData(&ENQ_request, 1) ; / / send Sleep(20) of contact question mark; / / await 20ms second Serial.

ReadData(&read_BUFFER, 1) ; / / read take PLC to answer question mark If(read_BUFFER==ACK){... Serial.

SendData(&STX_start, 1) ; / / send to PLC " begin " mark code Serial.

SendData(&CMD0_read, 1) ; / / send " read " command code Datasum_check+=CMD0_read; For(i=0; I<4; I++){Serial.

SendData(&Read_address[i> , 1) ; / / the ASC Ⅱ code that delivers initiative component address... Serial.

SendData(&ETX_end, 1) ; / / send Change_to_asci(senddatasum_CHECK of end mark code, datasum_check) ; / / will " and " change into Sleep(40) of ASC Ⅱ code; / / the reaction that awaits PLC... Serial.

ReadData(&Read_char[i> , 1) ; / / read Read_bytes byte If(*readdatasum_CHECK==*Readdatasum_check)// " and " desired effect {AfxMessageBox(" data is read take a success! " ) ; ReturnTRUE; } Else{AfxMessageBox(" desired result mistake! " ) ; ReturnFALSE; } } } 5.

Article author innovation chooses the last word: The author offerred the news report of a kind of PC that is based on multi-line Cheng and PLC, this correspondence course uses VC to have better real time sex than using VB; Use method of MFC process designing to be read with jackknife structure write string together a mouth, make string together a mouth to read write backstage to undertake. This correspondence course is reliable, can transplant the gender is good. This correspondence course regards this as a of the system main component, classics spot debugs a proof, already simple practical, have very good economic value. In the meantime, this system has intuitionistic man-machine interface and convenient mode of operation, have wide applied perspective. Bibliographical reference: [1>MitsubishiElectricCorporation.

Can write brochure of Cheng controller communication [Z> .

1998.

[Copy of 2> Wang Ye can make up Cheng controller to use a technology [M> .

Beijing: Machinist trade publishing house, 2004.

[3>KRUGLINSKIProgrammingVisualC++6.

0 technologies inside [) of M>(revised edition.

Beijing: Hope electron press, 1999.

[4> Hu Yinbiao uses VC++6.

Message of small computer of curve of test-drive of engine of scale of 0 real time 2002 the 18th the 10th period 69-70 page.

CNC Milling CNC Machining