A real-time acquisition method of siemens numerical control system based on s7 protocol extension
Patent Information
- Application Number
- CN202310383816.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-12
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2043-04-12
AI Technical Summary
[0005]本发明旨在解决现有技术中的数控系统采集速度较慢,无法满足今后智能自动监控需求的问题,提出了基于S7协议拓展的西门子数控系统数据实时采集方法,使用该方法可实现对数控系统进行全要素采集,采集速度最高可达500HZ
本发明方法设计的采集程序可直接安装在机床数控系统内部,随机床一同运行,无需占用机床的网络端口,以最小的资源占用、最高的采集频率进行西门子数控系统的数据采集,可突破传统采集器采集速度慢的技术瓶颈,采集频率最高可达500HZ。
Smart Images

Figure CN116400643B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of CNC machining, and more specifically to a method for real-time data acquisition of Siemens CNC systems based on the S7 protocol extension. Background Technology
[0002] With the continuous development of industrial production, the increasing integration of automation systems, the growing number of devices in industrial systems, and the rising demands for on-site information exchange and sharing capabilities, traditional communication methods for information sharing between intelligent devices and between intelligent devices and control systems can no longer meet the development needs of industrial control systems. Most high-end CNC machine tools in my country use Siemens CNC systems. Although these machines are equipped with world-leading CNC systems, there is a lack of effective information management methods for managing these machines and improving their utilization rate. Obtaining real-time machine tool operating conditions, evaluating machine tool performance, tracking part processing, and optimizing part processing programs all rely heavily on high-frequency data acquisition from the CNC system.
[0003] Currently, commonly used data acquisition methods for Siemens CNC systems include DDE acquisition, OPC / OPC UA acquisition, and Siemens third-party plug-in acquisition, etc. However, these acquisition methods are limited by the Siemens CNC system, and the highest acquisition frequency is difficult to exceed 10Hz.
[0004] To address this technical bottleneck, this invention researches and develops a high-frequency data acquisition method suitable for Siemens systems based on the S7 protocol PLC internal communication component. Summary of the Invention
[0005] This invention aims to solve the problem that the acquisition speed of existing CNC systems is too slow and cannot meet the needs of future intelligent automatic monitoring. It proposes a real-time data acquisition method for Siemens CNC systems based on the S7 protocol extension. Using this method, full-element acquisition of CNC systems can be achieved, with an acquisition speed of up to 500Hz.
[0006] To achieve the above-mentioned objectives, the technical solution of the present invention is as follows: A real-time data acquisition method for Siemens CNC systems based on the S7 protocol extension is characterized by the following steps: First, different models of CNC systems are connected and configured based on the PLC's internal communication components, so that they can correctly obtain the MLFB codes of the programmable logic controller (PLC) and digital controller (NC). Secondly, obtain all the machine tool's element variables through the machine tool's configuration file and convert them into a readable array format; Then, we used a self-developed service to perform single and loop reads of variables and tested the data reading speed. Finally, the read data is published to the server in real time for processing and storage.
[0007] Furthermore, for the Siemens CNC system 840D SL, the connection and configuration method based on the PLC's internal communication components is as follows: Connect a network cable from a switch to the PC via the MMC port of the machine tool. Configure the PC's IP address to be on the same network segment as the machine tool's HMI interface. Then, use the Configuration tool of the PLC's internal communication component to configure the connection. Locate the rack and slot numbers of the programmable logic controller (PLC) and the digital control core (NCK) in the machine tool. Configure device0, select the S7-TCP / IP connection method, and input the IP, rack number, slot number, and PLC type parameters of the PLC and NC. Save the settings. Next, perform a communication test on the configured connection. If there are no connection errors and the MLFB numbers of the programmable logic controller (PLC) and digital controller (NC) can be obtained normally and are consistent with the MLFB parameters corresponding to the machine tool, then the PLC and NC have been successfully connected. At this time, the XML configuration file is automatically generated by the Configuration tool of the PLC's internal communication component.
[0008] Furthermore, for the Siemens CNC system 840D PL, the connection and configuration method based on the PLC's internal communication components is as follows: Use an ACCON-NetLink-PRO adapter to convert the MPI port to a network port for connection on the CNC system; Connect the ACCON-NetLink-PRO adapter to the machine tool, and then connect it to the PC via a network cable. Configure the machine on the computer as follows: Configure the IP address and Station number of the PROFIBUS interface using the Set PG / PC Interface command. After setting up, configure the connection, test it, and read the MLFB number.
[0009] Furthermore, the process of obtaining all machine tool element variables through the machine tool's configuration file and converting them into a readable array format specifically includes: Locate the *.nsk variable address configuration file in the CNC system and export it to the computer. Then, develop an application for reading nsk files based on the PLC internal communication component to convert the nsk variable address configuration file into a data format that the PLC internal communication component can recognize, namely the NckDataRW[] array. The machine tool storage location of the corresponding variable is obtained by reading the nsk file.
[0010] Furthermore, for single-time variable reading, a request-response communication mechanism is adopted for reading one-time variables. When a data request is received from the outside world at a certain communication port, the single-time reading function is executed, and the result is returned upon successful reading.
[0011] Furthermore, for variable loop reading, a separate thread is started to continuously read all the defined variables in a loop. After each successful read, the result is published through a new port, and other clients or services can obtain the data by subscribing to this port.
[0012] Furthermore, when reading variables in a loop using a self-developed service, for the 840D CNC system, the AGL4.NCK_ReadMixEx(ConnNr, ref Realvars, timeout) single-read function is used to automatically read variables in a loop without delay within the thread.
[0013] Furthermore, an NckDataRW[] array is used to define all the variables to be collected. Data is read using the NCK_ReadMixEx function. The reading is successful when the function returns a value that is not less than zero. The reading result can be obtained in the BUFF field of the NckDataRW[] array variable. In summary, the present invention has the following advantages: The acquisition program designed by the method of this invention can be directly installed inside the CNC system of a machine tool and run together with the machine tool. It does not need to occupy the network port of the machine tool. It can acquire data from the Siemens CNC system with minimal resource consumption and the highest acquisition frequency. It can overcome the technical bottleneck of slow acquisition speed of traditional acquisition devices, and the acquisition frequency can reach up to 500HZ. Attached Figure Description
[0014] Figure 1 This is a diagram showing the PLC connection and configuration method for the 840DSL CNC system; Figure 2 This is a test diagram of the equipment connectivity of the 840DSL CNC system; Figure 3 This is the NetLink-PRO adapter configuration diagram for the 840D PL CNC system; Figure 4 This is a schematic diagram of an NSK file reading application developed based on a communication component. Detailed Implementation
[0015] To more clearly illustrate the present invention, the following description, in conjunction with preferred embodiments and accompanying drawings, further clarifies the invention. Those skilled in the art should understand that the specific descriptions below are illustrative rather than restrictive and should not be construed as limiting the scope of protection of the present invention. The terms "first," "second," etc., used in the specification, claims, and accompanying drawings are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, or apparatuses.
[0016] Example 1 This embodiment provides a real-time data acquisition method for Siemens CNC systems based on the S7 protocol. Through PLC internal communication technology based on the S7 protocol, a high-frequency data acquisition program suitable for the Siemens 840DPL / SL CNC system was researched and developed. This program overcomes the technical bottleneck of slow acquisition speed in traditional acquisition devices, achieving an acquisition frequency of up to 500Hz. This acquisition program can be directly installed inside the machine tool's CNC system and runs alongside the machine tool without occupying its network port, enabling data acquisition from the Siemens CNC system with minimal resource consumption and the highest acquisition frequency.
[0017] The specific implementation steps of this method are as follows: Step 1: Connect and configure different CNC systems based on the PLC internal communication component to ensure they can correctly acquire the MLFB codes from the PLC (Programmable Logic Controller) and NC (Digital Controller). The PLC internal communication component is an application developed by Deltalogic GmbH, Germany, based on the PLC S7 protocol, specifically for CNC system connection configuration. Alternatively, this application can use commercially available PLC connection configuration tools to convert the connection configuration parameters into XML files for subsequent acquisition program development.
[0018] Step 2: Next, obtain all the machine tool's variable elements through the machine tool's configuration file and convert them into a readable array format (i.e., the NckDataRW[] array).
[0019] Step 3: Then, use a self-developed service to perform single and loop readings of variables, and test the data reading speed.
[0020] Step 4: Finally, the read data is published to the server in real time for processing and storage.
[0021] Based on the above steps, a high-frequency data acquisition program for the 840D CNC system can be developed using the PLC internal communication component. This program can be packaged as a Windows service and installed on the machine tool's MMC. Running this service will enable high-frequency acquisition of internal data from the CNC system during machine tool processing.
[0022] Install the developed Windows service program on the machine tool's MMC, configure the machine tool's IP address and data port, and then run the service. Run the test data reception program on a PC connected to this machine tool. After the test is successful, install the official data relay service on the PC and configure the IP address and data port of the connected machine tool. The data collected by the machine tool can then be successfully received and stored on the upper-level server.
[0023] After repeated testing, this data acquisition device can operate stably, with a maximum acquisition frequency of 500Hz, and can be successfully applied to data acquisition of Siemens CNC systems in production sites.
[0024] Specifically, the connection and configuration of the PLC internal communication components in step one vary greatly depending on the Siemens CNC system model. The following describes the connection and configuration methods for the Siemens CNC system models 840D PL and SL respectively.
[0025] The following describes the Siemens CNC system models 840D SL and PL respectively.
[0026] ①For the 840D SL system First, connect a network cable from a switch to the PC via the machine tool's MMC network port. Configure the computer's IP address to be on the same network segment as the machine tool's HMI. Use the component's Configuration tool to configure the connection. Locate the rack and slot numbers of the PLC and NCK (Numerical Control Kernel) in the machine tool, and then press... Figure 1 Configure device0 as shown, that is: Select the S7-TCP / IP connection method, input the PLC and NC IP, RackNo, SlotNo and PLC type parameters, and save.
[0027] Secondly, such as Figure 2 As shown, a communication test is performed on the configured connection. If there are no connection errors and the MLFB numbers of the PLC and NC can be obtained normally, and they match the corresponding MLFB parameters of the machine tool, then the PLC and NC have been successfully connected. At this point, the configuration tool of this component automatically generates an XML configuration file, which is required during the development of the high-frequency data acquisition unit.
[0028] ②For the 840D PL system Since the MMC of the 840D PL system lacks a network port, an ACCON-NetLink-PRO adapter is needed on the CNC system to convert the MPI port to a network port for connection. Therefore, the adapter needs to be configured, such as... Figure 3 As shown, the specific operation is as follows: Connect the adapter to the machine tool, connect it to the PC via a network cable, and then configure it on the computer. The method is as follows: Set the IP address and Station number of the PROFIBUS interface through "SetPG / PC Interface". After setting, use the same method as the SL system to connect, configure, test and read the MLFB number.
[0029] Example 2 This embodiment is based on the data acquisition method described in Embodiment 1. Further, the specific implementation steps of step two are as follows: Locate the *.nsk variable address configuration file in the CNC machine tool system and import it onto the computer. Develop an application for reading nsk files based on the PLC's internal communication component. This application will convert the nsk variable file into a data format recognizable by the component (i.e., an NckDataRW[] array). Figure 4 As shown.
[0030] By reading the nsk file, the machine tool storage location of the variable can be obtained. variable is the variable address, area is the area where the variable is located, block is the block where the variable is located, bufflen is the number of bytes occupied by the variable storage, unit is the variable unit number, column is the variable column, and row is the variable row.
[0031] For example, by looking up the DDE variable address corresponding to the tool radius in the variable manual: / channel / state / actToolRadius, and finding the corresponding area in the variable list as eNCK_AreaChannel, the block as eNCK_BlockS, the data buffer length as 8, the data column position as 27, the row position as 1, the cell position as 1, and the DDE variable type as eNCK_LE_Float64, etc., these parameters can be combined into the following data types: rwfield[0] = new AGL4.NckDataRW(); rwfield[0].Area= AGL4.NCK_Area.eNCK_AreaChannel; rwfield[0].Block = AGL4.NCK_Block.eNCK_BlockS; rwfield[0].Column = 27; rwfield[0].Row = 1; rwfield[0].RowCount = 1; rwfield[0].Unit = 1; rwfield[0].DDEVarType= AGL4.NCK_DDEVarFormat.eNCK_LE_Float64; rwfield[0].BuffLen = 8; rwfield[0].Buff = new Byte[rwfield[0].BuffLen]; rwfield[0].Result = 0.
[0032] Example 3 This embodiment is based on the data acquisition method described in Embodiment 1 or 2. Further, in step three, the PLC internal communication component can provide various PLC variable reading methods, including single variable reading and variable loop reading. However, the minimum loop time for loop variable reading is 100ms. To improve the data acquisition frequency, for the 840D CNC system, we use the AGL4.NCK_ReadMixEx(ConnNr, ref Realvars, timeout) single read function for automatic loop variable reading within a thread with no delay.
[0033] The specific development steps are as follows: First, configure the CNC system PLC connection in the program, activating different communication component versions. Import the path from the successfully connected XML configuration file, set the device number, PLC number, slot number, and rack number in the program, and then attempt to connect to the component. After successful connection, obtain the MLFB number and compare it with the machine tool system to see if they match.
[0034] Secondly, variable reading in the data collector is divided into two types: one-time variable reading and loop reading, each employing a different communication method: For reading one-time variables, a request-response communication mechanism is adopted. When a data request is received from the outside world at a certain communication port, a one-time read function is executed, and the result is returned if the read is successful. Another approach is to read variables in a loop. A separate thread is started to continuously read all the defined variables. After each successful read, the result is published through a new port. Other clients or services can obtain the data by subscribing to this port.
[0035] The program uses the NckDataRW[] array to define all the variables to be collected, and reads the data through the NCK_ReadMixEx function. When the function returns a value that is not less than zero, the reading is successful. The reading result can be obtained in the BUFF field of the NckDataRW[] array variable.
[0036] Although specific embodiments of the present invention have been described in detail with reference to the accompanying drawings, this should not be construed as limiting the scope of protection of this patent. Various modifications and variations that can be made by those skilled in the art without inventive effort within the scope described in the claims still fall within the scope of protection of this patent.
[0037] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications or equivalent changes made to the above embodiments based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A real-time data acquisition method for Siemens CNC systems based on the S7 protocol, comprising the following steps: First, based on the PLC's internal communication components, different models of Siemens CNC systems are connected and configured to correctly obtain the MLFB codes of the programmable logic controller (PLC) and the digital controller (NC); among which: For the Siemens CNC system 840D SL, connect a network cable from a switch to the PC via the machine tool's MMC network port. Configure the PC's IP address to be on the same network segment as the machine tool's HMI interface. Then, use the Configuration tool of the PLC's internal communication component to configure the connection. Locate the rack and slot numbers of the programmable logic controller (PLC) and the digital control core (NC) in the machine tool. Configure device0, select the S7-TCP / IP connection method, and input the IP, rack number, slot number, and PLC type parameters of the PLC and NC, and save. For the Siemens CNC system 840D PL, the MPI port is converted to a network port using an ACCON-NetLink-PRO adapter; and the IP address and Station number of the PROFIBUS interface are set via Set PG / PC Interface to complete the configuration. Secondly, the machine tool's full-element variables are obtained through the machine tool's *.nsk variable address configuration file, and an nsk file reading application is developed based on the PLC's internal communication component to convert the *.nsk variable address configuration file into an NckDataRW[] array format that the component can recognize; Then, we used a self-developed service to perform single and loop readings of variables and tested the data reading speed. Specifically, for the 840D CNC system, we used the AGL4.NCK_ReadMixEx(ConnNr, ref Realvars, timeout) single read function to perform automatic loop reading of variables within the thread without delay. Finally, the read data is published to the server in real time for processing and storage.
2. The method for collecting data of a Siemens numerical control system based on S7 protocol extension in real time according to claim 1, characterized in that, After connecting and configuring the Siemens CNC system 840D SL, a communication test is performed on the configured connection. If there are no connection errors and the MLFB numbers of the programmable logic controller (PLC) and digital controller (NC) can be obtained normally, and they are consistent with the MLFB parameters corresponding to the machine tool, then the PLC and NC have been successfully connected. At this time, the XML configuration file is automatically generated by the Configuration tool of the PLC's internal communication component. 3.The method of claim 1, wherein, After configuring the Siemens CNC system 840D PL, the same method as for the 840D SL system is used for connection configuration, testing, and reading of the MLFB number.
4. The method of claim 1, wherein the method is characterized by, The machine tool storage location of the corresponding variable is obtained by reading the nsk file, specifically including obtaining the variable, area, block, bufflen, unit, column, and row parameters.
5. The real-time data acquisition method for Siemens CNC systems based on S7 protocol extension according to claim 1, characterized in that, For single-time variable reading, a request-response communication mechanism is adopted. When a data request is received from the outside world at a certain communication port, the single-time reading function is executed, and the result is returned upon successful reading.
6. The real-time data acquisition method for Siemens CNC systems based on S7 protocol extension according to claim 1, characterized in that, For looping variable reading, a separate thread is started to continuously read all the defined variables. After each successful read, the result is published through a new port, and other clients or services can obtain the data by subscribing to this port.
7. The real-time data acquisition method for Siemens CNC systems based on S7 protocol extension according to claim 1, characterized in that, The NckDataRW[] array is used to define all the variables to be collected. The NCK_ReadMixEx function is used to read the data. When the function returns a value that is not less than zero, the reading is successful. The reading result is obtained in the BUFF field of the NckDataRW[] array variable.
Citation Information
Patent Citations
Method for collecting, transmitting and processing high-frequency mass data of fan in real time
CN113944601A