本文是计算机专业的留学生作业代写范例，题目是“Graphical User Interface For The 3 Axis Cnc Milling Machine Computer Science Essay（图形用户界面的三轴数控铣床计算机科学论文）”，本文详细介绍了三轴数控铣床图形用户界面的设计和开发，该图形用户界面是由南太平洋大学为测试和研究目的而自行设计的。三轴数控铣床采用COM端口终端软件TeraTerm，通过RS232链路与电子硬件进行通信。该GUI是使用Microsoft®Visual Basic 2008集成开发环境开发的。
This paper details the design and development of a Graphical User Interface for the 3-Axis CNC Milling Machine, which was designed in-house for testing and research purposes at the University of the South Pacific. The 3-axis CNC Milling Machine used COM Port terminal software, TeraTerm to communicate with the electronics hardware via RS232 link. The GUI was developed using Microsoft® Visual Basic 2008 Integrated Development Environment.
The end result is an interface that is user friendly and is capable of controlling various tasks of the Milling Machine. This paper aims to explain how simple components of Microsoft® Visual Basic 2008 has been used to design a Windows® based user interface which is capable of complete control of CNC milling machine.
最终的结果是一个用户友好的界面，并能够控制铣床的各种任务。本文旨在说明如何使用Microsoft®Visual Basic 2008的简单组件来设计一个基于Windows®的用户界面，能够完全控制数控铣床。
Over the years a number of methods have been developed to control machine tools. The most widespread used throughout the industry is the G Code language for NC machine tools programming. It is based on the data model stipulated by ISO6983, and has been used for over 50 years . G codes, however, limits the usage of today’s fast evolving high-performance hardware .
The latest development in NC machine tools programming is ISO 14649 or STEP NC. It is a new standard for data transferring between CAD/CAM systems and CNC machines. It remedies the shortcomings of ISO 6983 by specifying the machining processes rather than machine toolmotion by means of ”Workingstep”, as the basic entity .
Whichever method of programming NC machine tools is used, it is always important to verify the program before doing actual testing. Verification of NC part programs using a PC is inexpensive compared to testing on model parts. Cutting simulation as a means of testing and verifying NC cutting paths has become an important part of modern machining . With the latest advancements in PC technology and 3D graphics it is much easier to simulate NC cutting paths.
A common CNC executes G-code programs, which are generated as a result of planning and scheduling in CAM tools . However an interface is required to send or execute NC part program to the CNC. The user interface is the communication Tool between the operator and the PC-based CNC drilling machine, via the computer screen . The recent advancement in software development technology using Object Oriented Programming (OOP) has made it possible to create simple user interface with a sound communication link to control NC machines. In 2002 , a GUI was developed at the University of the South Pacific for a PC-Based computer numeric control drilling machine. The platform for the graphical user interface (GUI) was written in Borland’s new rapid application product, C++ Builder®.
Gordon and Hillery  developed a Windows® based graphical user interface for their CNC cutting machine. The user interface communicated with the machine via RS232 serial link. The programming environment used was Borland C++ Builder 3, which allowed the visual development of the program interface. The user interface developed also had features for homing the three axes, editing of NC part program (G Codes) and also previewing the two dimensional cutter motion.
This paper mainly focuses on the design of the Graphical User Interface (GUI) for the 3-Axis CNC milling machine. The user interface has been designed in Microsoft® Visual Basic 2008 Integrated Development Environment (IDE). The features of the GUI are explained in detail.
2.OVERVIEW OF CNC MILLING 数控铣削概述
The CNC Milling Machine was designed in-house at the School of Engineering and Physics (SEP) at the University of the South Pacific (USP), for testing and research purposes. It uses an absolute three dimensional coordinate system to create its tool path. It sequentially passes instructions which are in the form of three dimensional coordinates to the Milling Machine for controlling the tool, similar to how G Codes are used.
The operational framework of the CNC milling machine is shown in Figure 2.1. It consists of a dedicated PC running Graphical User Interface Software which is used to upload a text file containing X, Y and Z coordinates. It also has features to control the milling operations and to get a two dimensional cutter path preview. The software is linked to the electronics hardware via RS232 serial link.
The current CNC Milling machine is only capable of linear interpolation (G01), in terms of G Codes, or moving linearly from one point in the three dimensional space to the next point. To mill different geometries other than straight lines the milling machine has to be given a number of coordinate points which can be used to approximate that particular geometry. For instance to mill a curve the milling machine needs to be given a set of points which lie on the curve. Similar method was used by Min-Yang Yang and Won-Pyo Hong  in their three dimensional linear interpolation algorithm.
The CNC Milling Machine uses an absolute three dimensional coordinate system (X, Y, and Z) for its tool path generation. The three dimensional coordinates are defined in a text file. Each of the three coordinates has three characters in the text file for instance the X coordinate ‘0’ is defined as ‘000’ in the text file. The Basic Length Unit (BLU) is in millimeters.
The electronics architecture of the CNC milling machine consisted of five PIC microcontrollers (PIC16F877) in a distributed architecture, with one master controller and several slave controllers. The master controller of the CNC Milling Machine consists of a PIC16F877 microcontroller which is responsible for coordinating and controlling the overall operations of the Machine. It is the central intelligence system of the CNC Milling Machine. It receives its commands from the user through a user interface and commands other co PIC16F877 Microcontrollers in a distributed architecture to carry out their respective tasks.
The mechanical hardware consists of three stepper motors which drive the three axis of the CNC Milling Machine. It also has a 24V DC Motor which is the spindle motor. The worktable consists of clamps to clamp the workpiece firmly on the worktable. For feedback, the machine constitutes of limit switches which control the limit of the worktable.
3.USER INTERFACE 用户界面
Until recently, the CNC machine was using COM port terminal software, TeraTerm, to communicate with Master Controller via RS232 link. The GUI was designed to provide a user friendly interface instead of typing coordinates in TeraTerm. The GUI was designed using Microsoft® Visual Basic 2008 and coded in BASIC (Beginners All purpose Symbolic Instruction Code).
直到最近，数控机床使用COM端口终端软件TeraTerm，通过RS232链路与主控制器通信。GUI被设计为提供一个用户友好的界面，而不是在TeraTerm中输入坐标。该图形用户界面使用Microsoft®Visual Basic 2008设计，用Basic(初学者通用符号指令代码)编写。
It was decided to incorporate the following features in the GUI.
Opening of text file which contains the coordinates.
Previewing of coordinate file (or tool path) in two dimensional X and Y axis.
Communication with the CNC Machine via RS232 link.
Milling control features such as homing, manual jog etc.
Displaying coordinate file.
4.File Input 文件输入
The GUI contains a MenuStrip at the top of the main form on which there are three menus, File, Setup and Help.The software utilizes an OpenFileDialog control of Visual basic 2008 to prompt the user for the files path. It allowed the user to choose which text file to open in the program. The OpenFileDialog control contains the Filter property which was used to control the type of file to be opened in the program. The only extension allowed was the *.txt. The ShowDialog() method was used to display the Open Coordinate File dialog box on the screen. The FileName property was used to get the path specified by the user.
这个GUI包含一个菜单带在主窗体的顶部，上面有三个菜单，文件，设置和帮助。该软件利用Visual basic 2008的OpenFileDialog控件提示用户输入文件路径。它允许用户选择在程序中打开哪个文本文件。OpenFileDialog控件包含Filter属性，该属性用于控制要在程序中打开的文件类型。唯一允许的扩展名是*.txt。ShowDialog()方法用于在屏幕上显示打开坐标文件对话框。FileName属性用于获取用户指定的路径。
After getting the path from the user, the program used a FileOpen() function to open the file specified by the user. The end of file function, EOF() was used to iterate through the file until the no more coordinates are left. The LineInput() function was used get a line of coordinates into a string variable. This string variable was then extracted to get the X, Y and Z coordinates in a separate array. The array containing the X, Y and Z coordinate was then used later to generate two dimensional previews and to send to the CNC milling machine. Finally the FileClose() function closes the text file.
5.Tool Path Preview 刀位轨迹预览
The graphical user interface that is designed also contains a two dimensional preview feature which can be used to preview the path taken by the milling tool on the workpiece. The GUI uses the system.drawing.graphics namespace to create tool path. The preview panel, as shown in figure 3.2.1, gives a two dimensional (X, Y) preview of the tool path which will be followed by the cutting tool. It is also to check and verify that the input text file does not contain errors.
A Preview command button is used to generate preview. This is activated only when a valid coordinate file is loaded. The GUI utilizes system.drawing namespace which includes system.drawing.graphics class to draw the preview. The DrawLines() method was used to draw a series of lines according to the X and Y coordinates in the coordinate file.
The use of three-dimensional absolute coordinate system has made the previewing algorithm much easier since the preview is two dimensional (X, Y), the program utilizes these X and the Y coordinates to draw a preview of the shape in the preview panel.
Once the Preview command button is clicked, the btnPreview_Click event procedure gets the array containing the X and Y coordinates which was previously read from the text file. The procedure then used these coordinates as points to draw a series of lines using the DrawLines() method. Since absolute coordinates are used, the lines connect from the end point of the first X, Y coordinate to the start point of the next X, Y coordinate. In this way the path taken by the cutter is drawn by connecting the series of points.
6.Milling Controls 铣削控制
The GUI on the main form contained a group box with a number of command buttons for commanding the milling machine. The Home command button was used to command the milling machine to rapidly move to its home position.
The advantage of using a software interface to control the CNC Milling Machine is that it acts like a control panel of the CNC which resides on the PC. Several command buttons have been used on the main form to command the CNC Milling Machine to carry out various tasks. The Home command button is used to command the CNC Milling Machine to move to its home position. The milling control also contains a command button Start to run or to send the coordinates to the milling machine to start milling.
Another improvement that can be implemented on the GUI is using an abort button to cancel or abort the operations of the CNC Milling Machine. This is a standard safety feature which exists on most industrial machines including CNC machines.