With the development of network technology, network control technology is attracting increasing attention. A network control system combines computer network technology and automation control technology to achieve network control. It integrates machine tool technology, control technology, communication technology, detection technology, image technology, computer software technology, and network technology, enabling remote monitoring of machine tools via the Internet/Intranet, thus giving machine tools greater flexibility and controllability. Many scholars both domestically and internationally have researched and developed network control systems, some based on Web communication platforms, others using Windows as the development platform with VC++ tools and Windows Sockets technology, and still others based on CORBA middleware technology, among others.
This article uses Java Sockets technology to implement real-time monitoring of machine tools over a network.
1. Introduction to Java
For general-purpose network programming languages, the three essential pillars are: portability, speed, and security. Figure 1 shows the results of a comparison between Java and other languages.
Figure 1 Comparison of JAVA with other languages
As shown in the diagram above, Java performs well across various aspects. Based on the comparison and analysis, it's clear that using Java is the right choice, both from a long-term development perspective and considering current needs. A network control system, as a program developed and used in a network environment, must possess good versatility, cross-platform compatibility, stability, and security. Using Java to implement network programming can meet these requirements in all aspects.
Java provides two powerful network support mechanisms: classes for accessing network resources via URLs and classes for communication using sockets, to meet different requirements. One is for applications that use URLs to access resources on the Internet; the other is for applications in a client/server model and applications that implement certain special protocols, whose communication process is based on the socket interface of the TCP/IP protocol transport layer.
1.1 TCP/IP Protocol
TCP/IP is an abbreviation for Internet Protocol (IP) and Transmission Control Protocol (TCP), two crucial communication protocols in the Internet, applicable to communication on any network. Building a TCP/IP network is relatively inexpensive and offers greater flexibility. The TCP/IP architecture is specifically designed to describe the TCP/IP protocol suite, dividing the network into four layers: application layer, transport layer, network layer, and data link layer.
1.2 Introduction to Java sockets
A socket is a general-purpose network programming interface. It's an abstraction of a communication endpoint, providing a mechanism for sending and receiving data. There are currently two types of sockets: Datagram sockets and Stream sockets. We will use stream sockets because they can send data to the destination in order without repetition, providing a reliable connection-oriented data transmission method.
1.2.1 How to use stream sockets
Stream sockets are used in a connection-based protocol. A connection must be established before data can be transmitted or received, and data can then be read from the stream. First, the server creates a listening socket, assigns an address to it, and calls the `listen()` function to put it in a listening state. The client, after creating its socket, assigns an address to it and calls the `connect()` function to request a connection to the server socket. Upon receiving the client's connection request, the server socket calls the `accept()` function, which creates a connection socket. Using this socket and the connection socket on the client, data can be transmitted between the server and client. After the transmission ends, both parties call the `closesocket()` function to close the socket. Its usage is shown in Figure 2.
Figure 2. Communication flowchart of Java Stream Sockets
2. Implementation of the network control system
2.1 Principles of Networked Control Systems
The network control system software runs on the client machine, which connects to the server via Intranet/Internet. The machine tool's CNC system runs on the server. First, the server's local CNC system is started and initialized. Then, it enters network control mode, opens the listening socket, and waits for connection requests from the client. Upon receiving a connection request, the server verifies the connection information. If the connection conditions are met, a connection is established, and both sides can send and receive information or commands. In network control mode, the server's CNC system can use a camera to capture real-time images and parameters of the machine tool's machining status. The images are saved in bitmap format and periodically sent to the client machine for display, and status parameters are sent to the client machine in real-time. The server and client can also communicate via voice chat or a network intercom. The client machine's remote control software can edit CNC machining code, which is then transmitted to the server and downloaded to the PMAC to await control commands. The client machine sends machining control commands to the server to control the machine tool's operation and simultaneously receives information from the server, dynamically monitoring the machine tool's machining status. Through the remote control program, the client machine can also modify machining parameters online and debug the machine tool.
2.2 Hardware Structure of Network Control System
This paper designs an open CNC system embedded in a PC. The system has 3 control axes and 2 linked axes. An industrial PC serves as the host, and the CNC core uses the PMAC-LITE programmable multi-axis motion controller from DELTATAU, USA. The CPU on the PC and the CPU on the PMAC card form a master-slave dual-microprocessor structure. Each CPU performs its corresponding function: the PMAC handles interpolation, position control, tool compensation, speed processing, and real-time control via PLC; the PC implements the basic functions of the CNC system by calling corresponding functions from the Pcomm32 library. To achieve the PMAC multi-axis motion control functionality, corresponding I/O boards, servo drive units, servo motors, encoders, etc., need to be added to the PMAC board, ultimately forming a complete control system. The network system adopts a "server + client" approach. The CNC system runs on the server, and the network control software runs on the client. The server and client are connected to the Intranet/Internet via network cards and communication cables. A CCD camera is installed on the CNC machine tool to monitor the machine's machining process, and the image acquisition card captures and saves the machine's operation in real time. Both the server and client PCs are equipped with voice functionality to facilitate better communication between them. The hardware structure of this system is shown in Figure 3.
Figure 3 Hardware structure diagram of the network control system
2.3 Software Design of Network Control System
A user-friendly human-machine interface is indispensable for any control system. This system's interface design employs split-view technology from Windows programming, dividing the CNC system's human-machine interface into two sub-windows. The left window is the image display window, enabling image monitoring of the machine tool's machining process; the right window is the network control window, enabling functions such as network connection and disconnection, machining code editing and sending, display of machine tool machining status parameters, and online network debugging of the machine tool.
The key to software design is data network transmission. To ensure timely data transmission, multi-threading technology is employed, with a dedicated thread for transmitting the acquired machine tool data over the network. The system flowchart is shown in Figure 4. After the CNC code is edited on the client machine, it can be transmitted to the server all at once. The server saves the CNC code in memory and then compiles and executes it. Control commands can be transmitted from the client machine to the server at any time, and the server executes the commands immediately upon receipt. The transmission of machine tool machining images and status parameters is more complex. On the server, the CNC system acquires machining images in real time via a CCD camera. A timer saves the images as bitmap files in each cycle, and then transmits these bitmap files to the client machine via the network. After receiving each bitmap file, the client machine refreshes the image display window using a timer in each cycle to maintain the continuity of the machining images. Simultaneously, the CNC system on the server acquires machine tool status parameters in real time, transmitting data in a specific format to the client machine in each cycle using a timer. The client machine receives and analyzes the data, and then updates the status parameters using a timer in a given cycle.
To avoid confusion between bitmap data and parameter data during transmission, an interruption method is used on the server side. The transmission of parameter data is interrupted during the transmission of image data, and resumed only after the image data transmission is complete. This effectively resolves the conflicting issue of channel occupancy during data transmission. During software operation, there will be a certain lag in image display and parameter updates, which is related to the network transmission speed and the size of the data.
3. Network security strategy
Remote control security is a critical and complex issue, primarily encompassing factors such as information integrity, confidentiality, and availability. Employing encrypted network security technologies can provide end-to-end security for network communications. Firewall technology can also enhance server-side security; furthermore, vulnerability scanning and intrusion detection technologies contribute to improved system security performance.
Figure 4. Software flowchart of the network control system
4. Summary
This paper introduces a network control system for CNC machine tools. Based on the TCP/IP communication protocol and utilizing Java Sockets, it establishes a server/client model, with the host computer containing the CNC system acting as the server and the network control terminal acting as the client. By controlling and debugging the CNC machine tool through the client, the machine tool gains greater flexibility and controllability. This system allows for remote, real-time operation of the machine tool, essentially achieving the goal of dynamic debugging and monitoring of its operation. It provides an efficient approach to machine tool control and debugging technology, demonstrating practicality and value.