Share this

Development of PC-based DNC transmission software

2026-04-06 04:47:51 · · #1
1. Introduction With the rapid development of China's manufacturing industry, CNC machine tools have been widely used in the machining industry. To achieve automatic control of the entire machining process by CNC machine tools, it is necessary to write CNC machining programs that the machine tool's CNC system can recognize. These programs can be written manually or automatically generated by Computer-Aided Manufacturing (CAM) software. In recent years, CAM software has developed rapidly, such as Pro/E, UG, and MasterCAM abroad, and CAXA domestically. Their functions are becoming increasingly intelligent, enabling rapid programming of parts with complex curved surfaces, bringing great convenience to product manufacturing. However, with the increasing complexity of part structures, the capacity of machining code generated by CAM software will be very large. If it exceeds the program storage space of the machine tool's CNC system, it cannot be stored in the CNC system all at once. Although more advanced CNC systems are equipped with Ethernet or USB communication interfaces, considering that early CNC systems were only equipped with RS232C serial communication interfaces, and this still accounts for a significant proportion in many enterprises... To address the issue of handling large-capacity programs in this type of CNC system, the CNC machine tool must be in DNC machining mode. This involves transmitting a portion of the program to the CNC system via a serial communication interface, where the system processes and controls the part machining process. After this portion of the program is executed, it is deleted, and the remaining program is read again via the serial communication interface. This cycle continues until the entire program is executed, at which point the process ends. This paper discusses the hardware connection requirements, CNC system parameter settings, and VB program design methods for implementing DNC machining on a CNC machine tool. 2 Hardware Connection Requirements The machine tool used in this study is a V600 CNC milling machine manufactured by Nantong Machine Tool Factory, equipped with a FANUC 0iMATE-MC CNC system. This CNC system provides a 25-pin RS232C serial communication interface. The CNC machining program is sent by the PC through a serial communication interface. Since most PCs on the market currently only provide a 9-pin RS232C serial communication interface, a serial communication cable with 9 pins (DB9) on one end and 25 pins (DB25) on the other end is required when connecting the microcomputer to the CNC machine tool. The electrical signals and connection precautions for this cable are explained below. 2.1 Electrical Signals The serial communication cable can be provided by the machine tool manufacturer or purchased from the electronics market. The various pins of the RS232C have different functions. To achieve serial communication between the microcomputer and the CNC machine tool system, generally only three pins are needed: receive data, transmit data, and signal ground. Their pin connections are shown in Table 1. Table 1 shows the common pin connections for DB9 and DB25. During serial communication, the CNC system's receive and transmit data pins must be connected to the microcomputer's transmit and receive data pins respectively to achieve data "reception" and "transmission". Therefore, serial communication cables purchased from the electronics market must be jumpered; this is done by swapping the receive and transmit data pins at one end of the cable. If the serial communication cable is provided by the machine tool manufacturer, jumpering is not required as the manufacturer has already done so. Data flow control must also be considered during communication to prevent "overflow" of the serial port receive buffer between the CNC system and the microcomputer. This flow control is achieved through handshake signals. Handshakes can be hardware or software. Hardware handshakes are implemented using dedicated handshake signal pins in the serial port, while software handshakes control the pause and resumption of data transmission by sending the 19th and 17th characters of ASCII code from the CNC system and microcomputer's serial port transmit data pins. If the transmitted data contains the 19th or 17th character of ASCII code, the software handshake method cannot be used; otherwise, an "incorrect handshake" will occur. Since the CNC machining program does not contain machining instructions corresponding to the 19th and 17th characters of the ASCII code, "incorrect handshakes" will not occur. Furthermore, the FANUC Oi-MATE-MC CNC system supports software handshakes. If software handshakes are used for serial communication, only three pins are needed to complete the task, making the hardware connection simple and easy. 2.2 Connection Precautions: When either the CNC system or the microcomputer is powered on first, the potential of their serial port circuits may differ. If a cable is directly used to connect the serial ports of the CNC system and the microcomputer at this time, discharge may occur due to the potential difference, potentially burning out the serial port circuit. Therefore, it is recommended to use opto-isolators installed at both ends of the cable to protect the CNC system and the microcomputer separately. Using opto-isolators ensures the safety of the equipment but increases hardware investment costs. If the CNC machine tool and the microcomputer are connected with a serial communication cable before being powered on, the potential of their serial port circuits will be the same. Then, powering on the CNC machine tool and the microcomputer separately will prevent damage to the serial port circuit. In actual production use, since the serial communication cable is rarely unplugged, it is safe to connect the CNC system and the microcomputer's serial port using the above method when not using an opto-isolator. This also reduces hardware costs. 3. Machine Tool CNC System Parameter Settings During serial communication, both communicating parties must adhere to the same communication protocol to achieve correct data transmission. The CNC system sets the serial communication parameters in the form of system parameters. For the FANUC 0i-MATE-MC CNC system used in this study, the required serial communication parameters are shown in Table 2. Correct settings for data bits and parity are also necessary during serial communication. The FANUC 0i-MATE-MC CNC system has fixed values ​​for these two parameters and does not require setting. However, when programming with VB software, it is essential to know the data bit and parity settings in the CNC system; otherwise, correct communication will not be possible. By consulting the instruction manual of this CNC system, we know that its data bits are 7 bits, which can represent characters with ASCII codes 0-127. Since the instructions of the CNC machining program are all characters with ASCII codes 0-127, 7 bits of data should also be used to transmit each character in the VB software. At the same time, this model of CNC system does not perform parity checking, so the VB software should also be set to no parity checking. Table 2 Serial Communication Parameter Settings and Meanings of Machine Tool CNC System 4 VB Program Design Method Figure 1 CNC DNC Software Running Interface The programming software used in this study is Visual BASIC 6.0. Considering that the DNC software should be simple and easy to use, a single programming interface (SD1) was used, and all operation options are categorized. The main controls used in programming are RichTextBox, ProgressBar, ComboBox, CommonDialog, and MSComm. The RichTextBox control displays the loaded CNC machining program text; the ProgressBar control displays the progress of sending the program; the ComboBox control provides selection options for various communication parameters; the CommonDialog control generates dialog boxes for opening and saving files; and the MSComm control enables data transmission and reception via the PC's serial communication interface. This DNC software provides two main functions: first, the microcomputer sends the CNC machining program to the machine tool for DNC machining; second, the microcomputer reads the CNC machining program sent by the machine tool, backing up the machine tool's program storage area. The main workflow and key design methods for each function of the software are described below, and its interface is shown in Figure 1. 4.1 Main Workflow of the Software When sending a file, an open file dialog box should be generated using the CommonDialog control and related code, and the selected file content should be loaded into the text display area of ​​the RichTextBox control. Finally, the CNC machining program is sent to the CNC system by pressing the send file button. When receiving a file, pressing the "Receive File" button will generate a dialog box for saving the file using the CommonDialog control and related code. The save path will be selected, and the system will enter a waiting state. Once data arrives, reception will begin, and the file will be automatically saved to the corresponding path after reception is complete. Figure 2 shows the design flowchart for the sending and receiving process. Figure 2: Design Flowchart of Sending and Receiving Process 4.2 Key Design Methods for Each Function 4.2.1 Splitting the File and Sending it to the CNC System The CNC machining program may be quite large. Considering that the size of the MSComm control's sending buffer cannot be set too large (the default 512 bytes is used here), the CNC machining program must be split and sent in multiple parts. A FOR loop structure can be used to achieve multiple sending operations. The number of loop iterations is determined by the total file size and the size of each data transmission. Considering the relatively small receiving buffer of the CNC system's serial port, if the data transmitted at one time is too large, it will cause the buffer to overflow and generate an alarm. Therefore, the size of each data transmission can be set to 200 bytes. 4.2.2 Implementation of Software Handshake During DNC machining, flow control is necessary to prevent the CNC system from overshooting due to excessive PC serial port transmission. Software handshake is used here to control the flow. The design method involves adding a DoLoop loop structure to the transmission loop. This loop continuously reads the input buffer and checks for a pause (13H) or resume (11H) signal from the CNC system to determine whether to continue sending data. The code for this loop structure is as follows: Do bufwait: Comml. Input 'Read the input buffer If InStr(bufwait, Chr$(&H13))>0 Then wait=True End If 'Check if to pause transmission If InStr(bufwait, Chr$(&H11))>0 Then wait=False End If 'Check if to resume transmission DoEvents 'First, hand over control to Windows Loop While wait=True' In the above code, bufwait must be defined as a string variable and wait as a boolean variable beforehand. 4.2.3 Checking the Output Buffer Before sending a program segment via the serial port, it is necessary to check whether there are any unsent bytes in the output buffer. Otherwise, new data may accumulate in the output buffer, leading to overflow. The design method to achieve this function is to add a DoLoop loop structure after the software handshake function. It continuously checks whether the OutBufferCount property in the MSComm control is 0 to determine whether to continue sending data. The program code for this loop structure is as follows: Do outcount = Comml.OutBufferCount 'Number of bytes to read from the output buffer If outcount = 0 Then sendempty = False Else sendempty = True End If 'Check if zero bytes are read from the output buffer DoEvents 'First hand over control to the Windows Loop While sendempty = True In the above program code, outcount must be defined as an integer variable and sendempty as a boolean variable beforehand. 4.2.4 Checking if File Sending or Receiving is Complete During file sending, to determine if the sending is complete, one can check if the current iteration of the FOR loop is the total iteration count. However, during file receiving, since the size of the program sent by the CNC system is unknown beforehand, other methods must be used to address this issue. The FANUC CNC system specifies the following communication protocol for program transmission: the beginning and end of the program must use "%" to indicate the start and end of program transmission. Therefore, to determine whether the program has finished sending or receiving data, you can look for the "%" character in the program. The program code that implements this function in the file sending loop is as follows: j = InStr(buf, "%") 'Returns the address of the "%" character in the sent data If j > 0 Then counter = counter + 1 'Counts the "%" character If times = 1 Then j = j + 1 If InStr(j, buf, "%") > 0 Then counter = counter + 1 End If End If 'Checks the "%" character twice for the case where the total number of sends is 1 End If 'Checks whether the file sending is finished If counter = 2 Then msgvalue = MsgBox("Transmission complete", vbOKOnly + vbInformation, "Message") If msgvalue = vbOK Then Frame3.Enabled = True Comm1.PortOpen = False 'Closes the serial port and ends the sending process ProgressBar1.Visible = False Label1.Visible = False Command1.Enabled = True Command3.Enabled = True Command4.Enabled = True End If Exit Sub End If In the above code, `buf` must be defined as a string variable beforehand, and `j`, `counter`, `times`, and `msgvalue` must be integer variables. The design also considers that if the sent program is too short (total number of sends, `times` variable is 1), there might be two "%" characters in the sent string variable `buf`. Therefore, in this case, after finding the first "%", the remaining string must be searched again to determine if there is a second "%" character. If two "%" characters are found (counter variable is 2), the user is prompted that the program transmission is complete. The code for checking whether the received file has ended is similar to the code for checking whether the sent file has ended, and will not be repeated here. 4.2.5 Automation of File Reception When the receiving program is in a waiting state, the file receiving process of the software automatically starts after the operator presses the send program button on the CNC system. To automate the file receiving process, the OnComm procedure of the MSComm control should be used to handle data reception. In the initialization of communication parameters, the RThreshold property of the MSComm control should be set to 1 to ensure that the OnComm process is triggered as soon as a character is received by the serial port to receive and process the received data. To facilitate future data processing, a byte array should be used in the OnComm process to receive and temporarily store data in binary mode. The following is a partial code snippet to implement this function: `Select Case Comm1.CommEvent Case comEvReceive 'Determine if the serial port has received data slen=Comm1.InBufferCount 'Read the number of bytes received from the input buffer Comm1.InputLen=slen 'Set the length of bytes to be read to the number of bytes received ReDimbytlnput(slen) 'Redefine the length of the byte array tmp=Comm1.Input bytInput=tmp 'Read the data from the input buffer into the byte array processdata 'Call the data processing function` In the above code, slen must be defined as an integer variable, tmp as a variant variable, and bytInput() as a byte array. `processdata` is the data processing function, which filters out unwanted characters and displays the data in the text box of the RichTextBox control. 5. Conclusion This paper, based on the hardware connection requirements and communication parameter setting methods for serial communication between a PC and a CNC system, describes how VB6.0 software was used to implement program sending and receiving backup functions in DNC machining mode. The software was tested on a FANUC 0iMATE-MC CNC machine and ran normally. Furthermore, the software provides a rich set of communication parameter options, thus it can run normally on other FANUC CNC systems or CNC systems from other manufacturers using the same communication protocol, greatly improving its versatility.
Read next

CATDOLL 138CM Airi(TPE Body with Hard Silicone Head)

Height: 138cm Weight: 26kg Shoulder Width: 30cm Bust/Waist/Hip: 65/61/76cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22