Home » Equipment News » Design and Realization of Numerical Control Software Based on Windows

Design and Realization of Numerical Control Software Based on Windows

Posted by: Yoyokuo 2021-07-29 Comments Off on Design and Realization of Numerical Control Software Based on Windows

The PC machine entered the field of numerical control, which greatly enriched the hardware and software resources of the numerical control system, which is conducive to the realization of a bus-based, modular, and open numerical control system, so that it has a high performance-price ratio. With the development and popularization of Windows system, the development of CNC system under WindowB CE) has become the consensus of the majority of CNC counterparts. In recent years, many domestic manufacturers have developed several Windows-based control systems. Domestic control systems have their own advantages, but judging from the development trend of numerical control systems, there are still many areas that need to be improved.

and other new operating systems. Software development ideas and technologies are backward, and are always at or even lower than the level of structured programming. Insufficient use of new object-oriented theories and new technologies.

Secondly, there are design irregularities in the software design of the numerical control system, and the reliability and maintainability are poor. An open and modular software design method is not adopted.

The system software introduced in this article uses the multithreading mechanism and interrupt mechanism of Windows to solve the real-time multitasking of CNC software; uses new object-oriented theories and new technologies, and adopts an open and modular software design method to make the software have Openness. This system software can make interpolation, servo control, and NC programming at the same time, can better meet the requirements of the CNC system, and has formed a product with good application effects.

2 The overall design of the CNC software In order to make the CNC software have obvious open CNC features and make the CNC software easy to assemble, expand and maintain, we adopted an engineering design method and developed a set of Windows 32-bit CNC software based on object-oriented technology. The software design follows the principle of modularization, hierarchization, and dynamic configuration.

The open control system shall adopt a layered architecture. Layering enables isolation of each layer, and communication between layers through standard interfaces, to achieve portability and third-party software available, and only need to replace the corresponding layer. The vertical ** level of the system is the interface layer, which completes the monitoring and management of the system: input, I/O processing, display, diagnosis and monitoring. This interface layer is composed of interfaces and various callback functions. The function of the callback function is to complete the event-driven operation of the controls on the interface. The call operation of the callback function is managed by the operating system.

The second vertical level of the system is the functional unit level, including decoding, tool compensation, interpolation dynamic link library, and motion controller. The decoding layer interprets the numerical control instructions into the internal data format of the numerical control system. Tool compensation layer performs tool compensation. The interpolation dynamic link library completes data interpolation, generates processing data, speed processing, and auxiliary function equipment control. D motion controller completes position servo control. D decoding and tool compensation are composed of multiple software chips. The calling operation of this functional unit layer is placed in the callback function.

The third level of the vertical system is the support layer, including motion controller cards, device drivers for motion controllers, I/O cards, operating systems, and PCs. The motion controller card mainly completes the task of position servo. The device driver of the motion controller completes the direct operation of the motion control card and the I/O card. The architecture of this system is as shown.

In the software of the numerical control system, a front-back and back-end structure is adopted. The foreground program is the real-time interrupt program, which completes all the real-time functions (interpolation dynamic link library, motion controller class, device driver), mainly the interpolation function. The main function of the background program is the pre-interpolation preparation function and scheduling management (including interface, I user sub-entry I decoding type, tool compensation type). Specifically, it is the scheduling management function between CNC program input, decoding, tool compensation, display and the above tasks. The background program structure is a multi-threaded structure to complete multi-task processing. In the process of running, the foreground program (interrupt service program) is continuously inserted to complete the part processing task together. The task of position servo is mainly completed by the motion controller. After the processing program is decoded, tool compensation, and speed processed by the computer, the interpolation command data of the tool center is obtained. The computer stores these interpolation instruction data and other instruction data in a buffer in a fixed format. Each time an interrupt occurs, the computer performs corresponding processing according to these instruction data. If there is an interpolation instruction, the interpolation data is calculated in real time and sent to the buffer, and the motion controller controls the motor action of the corresponding axis according to these data. When a frame of instruction data in the computer is read, the new interpolation instruction data is automatically calculated in the interpolation gap, and the buffer is filled.

File editing, hard work, stone surface cutter/alcohol set, 1 side, system setting surface, manual push work, ipi pry work, automatic operation, sub-pages, knives, and basic movements, I/O card support layer, color compensation plug, M CNC software architecture 3 Realization method 3.1 Multi-task real-time control strategy of software system CNC system is a dedicated multi-task computer system.

In its control software, it integrates many advanced technologies in software technology. Among them, the most prominent is that the multi-task parallel processing and real-time processing CNC device is usually used as an independent process control unit in the industrial automation production process. The software must complete the two functions of management and control. The management part of the system includes input, I/O processing, display, and diagnosis. The control part of the system includes decoding, tool compensation, speed processing, interpolation, and position control. In the actual operation of the CNC device, several tasks among the multiple tasks must be performed at the same time.

In the actual application process of industrial automation, CNC software must be real-time in order to meet the requirements of production.

In order to enable our CNC software to have parallel processing and real-time processing capabilities, we adopt the multi-threaded model of Windows 95 and the control strategy of the interrupt mechanism.

In order to enable CNC system software to process multiple tasks in parallel in the Windows environment, multi-threading is used to achieve multi-task control. Thread is the main feature of 32-bit operating system. It supports preemptive multitasking mechanism and is the basic scheduling unit of operating system. We can put each management and control module in an independent thread, so as to realize the parallel processing operation of the numerical control software system. In our CNC software, the main control thread (monitoring and interface thread), display/panel operation thread and automatic processing thread are established. The preset time slice of the display/panel operation thread is 50ms. The automatic processing thread is started and eliminated by the main thread. By establishing these three threads, the coordinated operation of the entire system can be realized.

The main control thread mainly completes monitoring and interface management, function control, system management, etc., and is responsible for real-time startup and elimination of automatic processing threads. When the system exits, the display/panel operation thread will be eliminated. The main control thread is through the Windows message queue to realize its operation flow.

User input (program start p: NC initialization-system main menu interface and event cycle 3 without thread stop) file editing method to achieve real-time tasks. Since interrupts can occur at any time, and are not limited to the running period of the application program using the device, the interrupt service routine must be in a fixed code segment. In the large-frame EMS memory configuration, only one type of code can be used to ensure that this type of interrupt service can be used at any time. This type of code is the code in the fixed code segment of the dynamic link library (DLL). Therefore, a DLL must be used to implement interrupts. In our system, the hardware interrupt is realized by DLL, and the operation is reliable.

In our software, in the automatic processing thread, the interrupt mechanism is used for real-time control. The automatic processing thread mainly completes opening the NC file, syntax checking, decoding, tool compensation, interpolation, and generating processing data. In these functions, interpolation must be completed in real time, so interrupt service routines are used to achieve. The opening of the automatic processing thread is completed in the callback function. See the control flow of the automatic processing thread, and the control flow of the interrupt service program, see the automatic processing thread. Since the dynamic link library can be flexibly loaded and unloaded by the application as needed, the system resources occupied will be reduced accordingly, so the interpolation interrupt service program is compiled Use in the form of linking into a dynamic link library.

Because object-oriented software development technology integrates functional abstraction and data abstraction, it better realizes the scalability and polymorphism of the software, and makes the software easy to modify. We use the object-oriented method to model the CNC software, and describe and implement it in three levels: system, control unit and basic class, so that the CNC software can be assembled and easily extended.

The basic category is the result of the fine-grained decomposition of CNC system functions, and is the smallest unit that constitutes an open system. The basic classes constitute the class system of object-oriented numerical control software. The basic class with standardized interfaces is called software chip.

A control unit is a software entity that is composed of a series of basic functions related to a certain function. Control units can be nested.

system is a certain type of numerical control system software composed of a series of control units.

In the category of our CNC software development, there are motion controller category, decoding category, tool compensation category. They are all used as functional units to complete the position servo function, decoding function, and tool compensation function respectively. The decoding class and the tool compensation class are more complicated and consist of multiple software chips inherited.

3.3 Multi-buffer technology Motion controller, decoding, tool compensation, and dynamic link library are all relatively independent functional units. They have a large amount of data exchange with each other, so multiple buffers are used to realize data exchange.

In order to coordinate the operation of each thread and each task, and make each module relatively independent, multiple data buffers are established in the software. The specific implementation method is: allocate memory for multiple buffers, and establish read and write points to the current buffer Pointer, constitute a ring multi-buffer; set a flag bit for each block of memory, as the basis for judging the operation of each buffer; each time a buffer is read, the buffer is set with a read flag, and the current read pointer moves forward A buffer; each time a buffer is written, the written flag is set for the buffer, and the current write pointer moves forward by one buffer; for the buffer that is not currently operated, the operating flag is set, and other operations are prohibited.

Using this method, the calculations that must be completed in a single interpolation cycle in the system are “equalized” to be completed in multiple interpolation cycles, which effectively utilizes the calculation time of the CPU and improves the work efficiency of the system.

3.4 Interface Implementation Technology The interface of measurement and control software not only has Windows-like control functions, but also must have controls that simulate some real objects, such as: 7TC, knobs, etc. on the electricity meter. Therefore, the LabWindows/CVI tool is used to design the system interface. It is very convenient to design the interface in a C language when using LabWindows/CVI. The interface designed by this tool includes header files (.h) and interface files (.uir). In, provide the callback function of the interface control. The application can implement the required functions in the callback function. In this system, the display/panel operation thread serves as the callback function of the timer control of the interface. Windows regularly calls the callback function of the timer control according to the time set by the timer.

4 Conclusion The control strategy and hierarchical architecture that combine the multithreading model and the interrupt mechanism, use object-oriented technology, multi-buffer technology, and interface implementation technology to successfully realize the real-time multi-task control requirements of the CNC system under the Windows environment. Better realize the scalability, polymorphism, and reconfiguration of the software, and make the software easy to modify. This design method has been applied to the CNC software developed by us and has achieved good results.

Please keep the source and address of this article for reprinting:Design and Realization of Numerical Control Software Based on Windows

Reprint Statement: If there are no special instructions, all articles on this site are original. Please indicate the source for reprinting.:Cnc Machine Wiki,Thanks!^^