Design of Virtual Simulation System for CNC Milling Machine

The goal of this system is to create a true NC machining environment. In this environment, machine model and process model need to be established. The machine tool model is the physical environment of the entire machining process. The real machine tool appears in the form of a 3D image on the computer. The machining process model is an animation process that simulates the movement of a real machine tool, tool, cutting, and other machining processes.

The system should meet the requirements:

1) has a realistic processing environment;
2) It is able to detect the NC code, that is, it has the NC program compiling function of the machine tool, can find the error of the NC program, and generate the target file;
3) Ability to display tool path and cutting process;
4) It can adjust and modify the machine state parameters to monitor the machine's movement status in real time;
5) There is a friendly man-machine interface that can be easily operated by the user.

It has the following features:

1) The environment is real, the environment of the system and the real machine environment are as same as possible;
2) The function is the same, the function of the system must be the same as the function of the machine tool;
3) strong ability to correct errors, can find a variety of errors while giving alarm information;
4) Quickly complete the simulation process. The time required for the simulation process cannot be the same as the real process time, otherwise it is unbearable. The time of the process can be adjusted according to the user's requirements.

1 The overall architecture of the system
The simulation process is: edit the NC program or transfer to the NC program on the control panel, then check the prepared machining program, trace the simulation, confirm the error, and prepare for processing. The necessary settings for the entire system, tool parameter settings, workpiece coordinate system settings, etc. before machining. During machining, the animation of the machine tool and the animation of the workpiece cutting are displayed. The status of the machine tool is monitored and the monitored information is displayed. If there is any information such as illegal operation or overreach, a corresponding alarm is issued.

The system is divided into five modules: human-machine interface, geometry module, motion module, compilation module and monitoring feedback module. The module division of the entire system is shown in Figure 1.

The man-machine interface is used to realize the human-computer interaction, that is, the control panel of the machine tool; the geometry module is used to implement the system's physical environment, tool path and workpiece model and other geometric objects; the NC module main functions are numerical control program editing, tool compensation, interpolation, and compilation Generate virtual machine tool driver files, etc.; motion modules are used to implement virtual machine tool movements, tool movements, and cutting motions; machine parameter settings, machine state information feedback, and monitoring functions are implemented using monitoring feedback modules. The relationship between the various modules of the entire system is shown in Figure 2.

2 Design of each module
2.1 Man-machine interface (control panel) design
This module has two aspects: The first is to design the various interface elements of the panel, and one is to control the various virtual objects such as the machine tool. There are many components on the operation panel, but most of them have similarities. Therefore, components with the same function can be designed as ActiveX controls. The use of ActiveX controls encapsulation and dynamic connectivity to achieve the same function on the virtual operation panel Components. Interface Elements Build Three Classes CRob, CMyButton, CMyEdilo CRob is a rotary switch implemented in meters. CMyEdit is used to implement the display. CMyBunon comes to realize a square button. Almost all the operations used and controls are on the control panel. Then all the modules are assembled here, which can be pointers and entities, used to control the entire machine tool and the machining process. Design a NcPanel class that provides various control variables for NC file inspection, machine parameter settings, machine motion control, and more.

2.2 Design of geometry module
2.2.1 Complex geometric model of machine body model, tool model, cutting fluid nozzle, etc.
This model of peaks is more complex and it is difficult to directly implement such a complicated graph by using the drawing programming method. Even if it is realized, it takes a great deal of time and effort, and the effect of drawing is difficult to achieve the desired effect. This article uses some mature drawing application software such as 3dsMax, UG, Pro/E to achieve these geometric models. The system can not directly call these software-generated geometric models, only descriptive documents of these geometric models can be obtained. The documents had to be studied to find the necessary geometric information and then converted into the geometric entities that could be used in the program. There is a standard file format - the 3DS file format. Almost all 3D drawing software supports this file format and can be converted into this file format. Therefore, the job of this module is to write a file interface that reads the 3DS binary files into 0penGL geometry entities. The constructed classes are as follows:

Class C3dsReader;//3DS files read human class8 CTriList;//generate data link list (small triangles//sets used to approximate 3DS graphics)

The geometric model of each part of the machine tool is made up of a machine class class Machine. This class includes the various components of the machine tool, such as the bed and the main shaft.

2.2.2 Tool Trajectory and Part Geometric Model
This module is used for tool path simulation, to verify that the NC program is correct and to display the tool path geometry after machining. It can be divided into two layers:

The first layer: the basic geometric element layer.
Points, lines, arcs, planes, ruled surfaces and other geometric elements of the drawing, points, vectors, various operations of the matrix. In the 0penGL environment, a device environment class can be similarly constructed to allow it to draw out some basic geometric elements: straight lines, arcs, and so on.
The second layer: model building layer.

The tool path formed by the entire NC file is composed of various geometric elements. Modeling is to compose various geometric elements into a complete figure. If you process a word, the font consists of multiple lines. From this we can construct classes for each geometric model such as CLine, CAre, CCircIe, and CLin_Are. Each of the blanks calls the member functions of the upper layer of the glCDC class. If self-drawn on the line can be written as:

pDC->Line(start,end);
pDC is a pointer to an instance of glCDC.

2.2.3 Artifact Model
The workpiece model is used for workpiece cutting motion. The space model is used to model the workpiece model. This article only divides the workpiece on the X and Y planes. The Z direction is represented by the top value. The model constructed is as follows:

Class PexSeL//Discrete small cube solid model
The entire workpiece can be expressed as: PexSel Box[x][y];//x,y is the workpiece resolution
2.3 The design of the motion module
The movement model includes machine body movement, tool movement, machining cutting movement, and belongs to the animation production process. Animation can make a picture-related picture switch at a faster speed, and it can get continuous motion effect. Similarly, drawing N related pictures in a certain time can get computer animation effects. First set a system time, let it constantly refresh the picture, the next work is to draw these related pictures.

The drawing of a graphic is encapsulated in a parametric form. As long as its parameters are modified, animation control can be achieved.

For example, a cube drawing can be written as:

Translated(m_x,m_y,m_z);//
DrawBox(length,width,high);

Then control the three variables m_x, m_y, and m_z, and then let the drawing module continuously draw the parameters to achieve the cube movement animation. The next job is to control the position variables by time to achieve the required movement. Design some position controllers, such as straight line, arc position controllers, etc.
cIass MoveCircle//Circular Motion Calculator class Movenne //Realize Linear Motion Calculator...

2.4 The design of the compilation module
The compilation module is mainly divided into four parts: lexical analysis, syntax analysis, object code generation, and error handling. The compilation process is to enter the NC machining program and output the target code or error message. The system adopts a progressive scan method, with lexical analysis program and syntax analysis program as the core, error processing as an independent process, and the generation of object code is generated under the condition that the error is zero.

Design a compile class Compile.
Input: CString m_Nccode;//an NC code function function:
Wo-check() // Syntax Check SyntaxCheck() // Syntax check Output: CString errInfo// Error information Operation data object ProgramNode NcSegementStruct// Intermediate file generated after compilation.
CTypedPtrList *m_curvelist;//Generated tool track linked list
2.5 Design of monitoring feedback module
The machine parameter system did not count:

1) Design a back-end database CDaoDatabase m_db, back-end database using Microsoft's ACCESS production;
2) All variables design a MachineState class for centralized management.
3) Condition monitoring, design a class RunErrCheck, to achieve functions including illegal alarms, workpiece and tool interference, illegal operations and overreach.

3 Summary
The NC machining process itself is a very complicated process. It is an inspection of many parts such as parts design and process planning. The system established in this article already has the basic functions of a virtual machine tool, and there are still several areas for improvement:

1) The workpiece model can be further studied to find a model with better structure and faster display speed, which makes the cutting process more realistic and faster;
2) The motion model needs further study to construct more powerful motion controllers, such as advanced curve motion control and advanced surface motion control, to meet the position control requirements of more advanced CNC systems;
3) The system only studied the pure geometric simulation, and did not consider some mechanical factors in the machining. In the future, the mechanical physics simulation model of the machining process can be used to simulate the cutting performance and cutting effect of the machining process.

Electric Motorcycle

weihaimaideqi , https://www.weihaimaideqi.com