Abstract Abstract: This paper cutting machine Metallographic Sample PC-PLC control system for the application background, the PC and the PLC serial communication protocol based on a specific interpretation of the OMRON CPM2AH series communication between PLC and Computer the command frame and response frame format, using VB6.0 MSComm control achieved in the PC and the PLC serial communication, and the corresponding data communication program.
Keywords: PC-PLC; control system; serial communication; MSComm control
Abstract: This paper regards PC-PLC control system of the large metallographic specimen cutter as the background . Ccubqnbsp; On the basis of PC and PLC serial communication protocol, it explains the order frame and the response frame of communication between PLC and computer specifically. Making use of VB MSComm control, it realizes the serial communication of PC and PLC. In the end, the data communication procedure is provided.
Key words: PC-PLC; control system; serial communication; MSComm control
0 Introduction
Programmable Logic Controller (PLC) with easy to use, high reliability, strong anti-interference, etc, so in the field of industrial control has been widely used. But most small and medium display PLC s poor human-computer interaction to maneuver. In the actual control system, usually with a personal computer PLC (PC) combined PLC and PC to complement each other greatly improved cost control system. PC-PLC control system to achieve the key is to achieve reliable data communication between the two.
In this paper, discussion group development and design of PC-PLC-based large-scale metallurgical sample cutting machine control system for the background, in the windows environment, use Visual Basic 6.0 MSComm control design in the computer and OMRON CPM2AH string type PLC line communication program, a PC and the PLC in order to achieve reliable communication, capable of large-scale metallurgical sample cutting machine in real time basedPreparation of monitoring and information management.
1 large metallurgical sample cutting machine control
Cutting equipment for cutting domestic range of Metallographic small (cutting diameter ????è 100mm), and the low degree of automation, can not be directly part of the large sample size and other shortcomings, the research group designed the PC-PLC-based large-scale metallurgical test kind of cutting machine control system.
The system of the three-phase induction motor variable frequency speed control, so that the speed of cutting pieces from the 0 ~ 3400r/min infinitely adjustable, can cut pieces of sample material to set the speed. Stepper motor through a worm drive to arm swing in order to achieve Z-cut pieces of feed (ie, vertical feed). The other two are stepper motor driven by screw and nut pairs can be X to the table (ie the left and right), Y to (the front direction) movement. System with constant speed cutting, cutting into a three-back, layer by layer cutting and continuous cutting of four cutting mode.
In this system, PLC as the next bit machine, use of sensor acquisition control motor, inverter and other relevant object information, after processing the input information, integrated information obtained by the collector, feedback control monitoring object, the information is sent to host PC machine; the other hand, PLC received the control instruction PC, through the analysis of input and operating instructions to determine, for an integrated approach, the output control signal, to achieve the control of the cutting machine. UpperMachine on the PLC to monitor, send control information, while the computer is also able to accept the PLC collected information on the monitoring object and the parameters of the fault alarm display. The system has the cutting mode selection control system, start, stop, pause control, cutting the state s display, the display of cutting speed, accident alarm display functions .
2 PC-PLC hardware configuration of serial communication
PC and PLC communications using RS-232C asynchronous serial interface mode. CPM2AH and PC-connection, first through CPM2AH external port adapter with RS-232C connection, use the RS-232C adapter model CPM1-CIF01, the mode setting switch is set to "OFF". Then, by XW2Z-500S cable to connect the computer s serial port. Cable wiring shown in Figure 1 .
Figure 1 RS-232C cable wiring diagram
3 VB in MSComm communication control Comprehensive comparison of various visual programming language, the will is easy to learn and efficient VB6.0 as a PC programming language that provides a dedicated serial communication MSComm control. The control has a very good serial data transmit and receive functions, just to set and monitor MSComm control properties and events, you can easily realize the asynchronous serial communication. It attributes many of them used a few key attributes as follows:
CommPort: communication port settings and return code;
Settings: Set initialization parameters to set or return a string in the form of the baud rate, parity, data bits, stop bits and other four parameters;
PortOpen: communication port settings and return to the state, also can open and close the port;
InputMode: Input attribute set and return to retrieve the data type, that is OK to receive data in binary mode or in text mode to receive data;
CommEvent: communication error or the time of the incident will have OnComm event, CommEvent property there is the value of the error or event code .
MSComm control provides two way communication treatment: one is event-driven, it is dealing with a serial port interactionVery effective method; the other way is to check, in the process of each key function, you can by reading the value of the property inquiries CommEvent communication events and errors, and handle accordingly.
4 Serial Communication Protocol
PLC data memory DM by Area with the unit setting the initialization of serial communication interface, select the host computer link communication. Select communication protocol: 9600 baud, 7 data bits, 2 stop bits, even parity. Select PC s serial port COM2 as the communications port with the PLC.
Communication between PC and PLC by way of the Lord from the response, PC has a transmission priority to the PLC to issue needed to read and write commands; PLC in a passive state to respond to host PC, the command. PC and PLC first initialization, set the communication format (include baud rate, parity, data bits, stop bits), communications format must be consistent .
Send commands from the host computer, the program in the preparation of the format of the command data shown in Figure 2.
Figure 2 Command frame format
Where: @ the frame start identifier; IP2, IP1 node identification code for the PLC, the two decimal numbers, used to specify and PC communications PLC, the corresponding host computer, PLC can be set in the DM own communication node code; ID2, ID1 is two byte command code; CT for the text content to set a specific command parameters; F2, F1 frame for the two-byte checksum FCS, it is the start symbol "@" to the end of all text ASCII character code bitwise XOR of the results; "*" and "/" two characters that command the end.
After the success of the command frame transmission, PLC to the PC immediately sends a response frame format shown in Figure 3.
Figure 3 Response frame format
Where: @ the frame start identifier; TP2, TP1 for the host to communicate with the PLC node identification code; ID2, ID1 is two byte command code; E2, E1 end for the command status code that the normal end of the 00, 01, said RUN mode state are unable to complete; CT for the body of the content, only the receipt of orders generated when reading data; P2, P1Frame for the two-byte checksum FCS, it is the start symbol "@" to the body of the end of the ASCII code for all the characters bitwise XOR of the results; "*" and "/" two characters that command the end of .
5 PC-PLC Serial Communication
In the PC and the PLC communication process, the use of PC priority, send the command to start the Communications PLC, PLC automatically returns the response of the communication. Read data, PC through the serial port data to the PLC to issue read commands, PLC is ready to respond to the data, then PC serial port can be read again, read the data needed. Write data, PC through the serial port to the PLC to issue write commands and data, PLC to receive. Data transfer process shown in Figure 4.
Figure 4 data communication flow chart
The following shows part of the communication process :
(1) serial port initialization
Private Sub Form_load () </ P>
MSComm1.CommPort = 2 select COM2 port communication
MSComm1.Settings = "9600, E, 7,2" set the communication format, 9600 baud, even parity, 7 data, 2 stop bits
MSComm1.InputLen = 0 read all the data in the cache
MSComm1.InputMode = ComInputModeBinaiy set the communication format is a binary
MSComm1.PortOpen = True open ports
End Sub
(2) to send data procedure
Private Sub Send_Click ()
Dim outarr As Byte
MSComm1.Output = Outarr to send data
End Sub
(3) to receive the number ofAccording to program
Private Sub MSComm1_OnComm ()
Dim buffer As Variant to read the data from the buffer using Variant variables received
Dim inarr As Byte
Select Case MSComm1. CommEvent event triggered by the ComEvReceive after the data into the corresponding array, and work status display subroutine call
Case ComEvReceive
inarr = MSComm1.Input
End Select
End Sub
6 Conclusion
Using VB6.0 s MSComm PC and PLC control designed for serial communication, in order to achieve a large-scale metallurgical sample cutting machine real-time remote monitoring and data management. RealInternational run that cut the PC-PLC controlled machine system is reliable, simple manipulation, and has a flexible and real time, high cost performance advantages, not only cutting the workpiece diameter 150mm, but also improves the efficiency of sample preparation, have broad application prospects.
Innovation of this article:
The PC-PLC serial communication technology for large-scale metallurgical sample cutting machine, to make a powerful PLC and PC control and efficient information management capabilities combine to achieve a cutting machine real-time monitoring and remote data management. The use of high-level programming language Visual VB6.0 in MSComm control, serial communication program was designed, the program simple and powerful. Experiments show that the system can a large part of the 150mm diameter direct sampling, in the same industry occupies a leading position.
References:
[1] Li Jie. Based on PLC control of a large metallurgical sample cutting machine of [D]. Baoding: Hebei Agricultural University, 2004,6
[2] Yang Yonggang, Yang Jidong. PLC and host computer serial communication design and research [J]. Machinery and Electronic ,2004,8:68-70
[3] Xiao Ying Wang, Bao-Guo Xu. PLC and PC serial communication programImplementation [J]. Instrumentation Analysis Monitoring ,2003,4:8-10
[4] OMRON-CPM2AH Series Programming Manual [Z]. Shanghai Omron Automation System has eyes Corporation .1999
[5] Li Yan, Guo Zongren, Wangzhi Kai, Li. PLC and the serial communication between computer and program design [J]. Control Engineering, 2002,9 (3) :84-86
[6] Tian Hongfang, Li Yinghong. PLC and host computer serial communication [J]. Micro Computer, 2001,17 (3) :36-37
-->