摘要:针对实际的训练和学习,在VB 6上设计了数控车床仿真系统。 0。该系统模拟了N091数控车床配备的Fanuc-0i Mate TB NC操作系统,实现了编写NC代码,检查代码错误,不正确过程属性警告,PC仿真处理和操作培训等功能。通过这种数控仿真系统,培训师可以轻松掌握操作N091数控车床的技能,该系统有机地将学与教结合在一起。本文介绍了设计,一些关键技术及其程序代码。关键词:N091数控车床; VB 6。 0软件;数控仿真0 PrefaceCNC机床作为现代制造业的基础设备,随着科学技术的进步,已成为机械制造自动化,灵活性和一体化。转型的重要基础和核心内容。近年来,国内高校建立了工程训练中心,在数控机床的基础上进行工程训练,培养学生的工程实践和工程意识。目前,除了对相应的数控培训进行必要的理论解释外。机床,大部分工作必须在具有相应功能的实际系统(实际数控机床或培训系统)上完成。数控产品价格昂贵,工厂的数控机床比较重。处理任务,然后考虑到教练的误用,也可能危及机床设备甚至操作者自己的人身安全。因此,大型数控培训不适合学生在实际机床上使用数控机床工程培训。虚拟设备作为教学载体,进行数控机床的功能和状态仿真。学生可以使用台式机或笔记本电脑熟悉数控机床的编程和手动操作方法。通过在软件中集成交互式教学功能模块,也可以解决数控设备更新缓慢的问题。具体实施过程不受设备,场地和时间的限制,既经济又安全,可以及时获取更新的教学资源。无忧无虑,是一种经济技术可行,教学效果明显的解决方案。目前,在中国数控培训领域,优秀的仿真软件主要包括三个软件:南京思沃,上海玉龙和北京飞科。虽然这三种类型的软件在模拟数控系统中具有不同的长度和类型,但机床的数量及其功能,其模拟目标大致相同。它们是在功能和原型机方面追求虚拟设备的一致性,即追求数据处理。仿真对象的一致性主要与仿真原型数控系统的解码和插补过程一致。正是由于与原型设备在功能原理方面的追求相似,上述软件无法识别原型设备可能无法正确处理的编程错误,尽管它们符合语法规则,但可能导致严重设备故障。由于现有仿真软件的重点是机床主体是否能够根据数据信息正确移动,因此操作员可能导致操作事故的操作细节和操作习惯只有一些问题。这是造成设备故障的主要原因。本项目以N091数控车床为原型对象,利用VB 6.0语言强大的界面设计功能,开发出一种模拟数控车床运行方式和工作过程的方法。测试CNC车床零件加工程序的正确性,并实时显示动画。仿真软件。除了模拟设备的功能外,该软件还重点关注学生在数控车床工程培训安全性方面更容易做出的四种错误。为了有效地指导学生培养良好的编程风格和操作习惯,该软件旨在正确设计NC程序处理过程。报告中的详细信息可以及时报告导致安全事故的各种非语法错误,并自动调整切削参数等过程数据.1系统总体设计本系统采用配备N091数控车床的Fanuc-0i Mate TB数控系统作为主要的模拟对象。它可以完整,清晰地显示零件坯料和加工工具,并详细模拟数控加工工艺,操作方法简单。受过培训的学生可以使用该软件在没有数控机床的情况下练习数控机床操作方法,调试由通用基本指令组成的数控零件加工程序,显示动态零件实时加工过程,观察和分析加工结果,及时发现零件加工程序。错误和可能的干扰。系统模块按照高内聚和低耦合原理设计.2系统关键技术实现在虚拟数控加工过程中,虚拟机床不能直接执行NC代码。因此,翻译模块需要首先将NC代码转换为虚拟机可识别和执行的代码。该模拟数控系统的开发难度在于数控代码的读取,解码,错误报告和自动调整方面。除了机器功能的实际仿真外,仿真数控系统的开发重点是如何促使学生掌握机器操作方法,养成良好的操作习惯。 1 NC代码的预处理NC代码的预处理包括从源存储器地址读取程序文件,删除NC代码中不需要的符号,例如注释语句,空语句和空行,以及将小写字母转换为大写字母和在每个字母前添加空格。使读取的NC代码易于阅读。安装该系统时,会提醒用户在创建TXT格式的NC代码文件时,需要将其保存在计算机的指定文件夹中。这样,当操作员单击操作面板的PROG按钮时,VB程序中名为File1的FileListBox控件的Path属性直接将存储在该文件夹中的所有NC程序文件名提取到机床显示面板中。指定文件夹。在RichTextBox3中,操作员可以根据机器显示面板的程序选择窗口中的文件名选择NC程序。从外部文件顺序读取语句的Line Input语句集成在VB中,读取的内容分配给字符串。在N091数控车床上的FANUC-0i MATE TB系统中,NC程序用分号终止当前的代码输入行,光标向下移动以开始下一行代码输入。 VB使用vbCrLf或Chr(13)&Chr(10)作为换行标志,因此可以使用换行符作为换行符将外部读取文件读入系统,并且显示面板中的行以“分号+换行符”分隔(RichText-Box1)。相关代码如下:TextLine = Split(RichTextBox1。Text,vbCrLf)'按行拆分RichTextBox1。 Text =“”For row = 0 To UBound(TextLine)RichTextBox1。 SelColor = vbYellowRichTextBox1。 SelText = RichTextBox1。 SelText&TextLine(row)&Chr(13)&Chr(10)RichTextBox1。 SelColor = vbYellowNext rowSemicolon TextLine在内部,VB集成了Replace函数和Trim函数。可以通过ASC代码转换替换功能,以使NC代码从小写字母更改为大写字母。 Trim函数可以删除一行代码开头和结尾的空格。要删除空行,只需使用Len函数确定它是0,如果值为0,则表示空行,然后它将存储NC代码Textline()的字符串。通过行号变量MoveRow,下一行是Textline(MoveRow + 1)到Textline(MoveRow),这是空白行。 ;如果有多个空行,可以通过循环代码删除它。这里没有描述代码实现。 2 NC代码检查,过程数据错误功能对于NC代码检查,除了NC代码语法规则之外,更重要的是要考虑处理时间表是否合理。本文使用以下三个示例来分析解决方案并演示相关代码。 2. 1 G00指令禁止切削工件对于CNC车削操作,G00是快速定位指令。在此命令下,刀具根据CNC系统中的预设机床参数值沿坐标轴快速移动。在实际加工中,如果操作员由于粗心或不清楚而在切削过程中使用G00指令,则机床不会报告错误,而是直接执行该指令。这将不可避免地导致碰撞事故并破坏工件和工具。仿真系统将该问题归结为NC程序中缺乏语义分析。在模拟加工过程中,如果刀具在G00指令下移动到工件圆周面,系统将给出报警信息。界面如图1所示。图1报警信息界面该信息提示程序员在程序中错误地应用了切割指令。在实际加工中,将发生刀具与工件之间的碰撞。通过在仿真系统中添加该功能,可以显着提升初学者的良好编程习惯,从而在实际编程中可以习惯性地避免错误。为了实现此功能,系统定义NowData()双精度组以存储当前工具位置的坐标。其中,NowData(1)存储当前车刀z的坐标值,NowData(2)存储当前车刀的坐标值x。由于系统设计为考虑是否可以在有限的显示界面中显示空白的长度,因此在此处将空白尺寸参数设置为bl。此时,NowData()中的坐标值乘以模拟界面中的参数bl。这里,工件坐标系的原点设置在工件右端面与轴的交点处,然后确定程序的原点。因此,要判断当前刀具是否在G00指令下具有切削运动,您只需确定两个条件:1)刀具坐标z是否为负。 2)刀具的坐标值x是否小于工件毛坯的半径,即确定NowData(1)是否小于0,以及NowData(2)是否小于工件半径。由于NowData(2)的值x是实际值乘以bl,因此输入空白直径的值乘以不等式符号右侧的bl,以便不等式确定有效,表示为数学表达式即z <0和x <workpiece. Blank diameter × bl /2. If the system determines that a collision occurs during operation, an alarm will be given and the program will be reprogrammed. The following is the code to implement this feature:If g00 = True ThenIf NowData( 1) < 0 And NowData( 2) < Form2. Text1. Text*bl / 2 Thenmianban. RichTextBox2. SelColor = vbRedmianban. RichTextBox2. SelText = mianban. RichTextBox2.SelText &” ‘G00’命令下禁止切削工件,请重新编写程序,再次运行! “PlaySound ” warn. wav”mianban. temg. Text = ” - - ALM - - ” : mianban. temg.Visible = TrueTimer5. Enabled = TrueTimer16. Enabled = FalseAlm( 116) = True2. 2. 2 cutting parameter out of range alarmThe reasonable setting of cutting parameters directly affects the machining quality of parts. In actual production and processing, due to carelessness or unfamiliarity with the cutting parameters, the setting of the feed amount per revolution of the turning tool may cause problems. The amount of tool feed depends on the surface roughness and the cutting force. When rough-cutting, the surface roughness is not high, and the feed is mainly caused by the knife.The precision and strength of rods, blades, workpieces and machine tools are determined by the cutting forces. When semi-finishing and fine-cutting, the economics of cutting are mainly considered. That is to say, the cutting load cannot exceed the power of the machine tool while ensuring the economic life of the tool. Therefore, the tool feed amount cannot be too large or too small. If an oversight or error occurs during programming, an error will be indicated in the code detection of the simulation system. The simulation system provides that the spindle feedrate of one revolution must not be less than 0. 05mm or greater than 0. 5mm (The amount of cutting is closely related to the workpiece material and the tool type and material. The value range of this feed amount is in most cases. For other individual cases, it can be determined by referring to the manual or cutting test).A line of NC code is read in the FileDebugger of the system code. If the feed “F” is found from this line of code by the Mid function, then the custom GetNumber function is used to convert the number immediately followed by F to a single-precision floating-point number. 0. 05 and 0. 5 if less than 0. 05mm or greater than 0. 5mm, then the alarm prompts, its interface is shown in Figure 2.Fig. 2 Feed range out of range alarm prompt interface2. 2. 3 tool instruction alarm errorIn CNC turning, the tool command T is used to select the tool and its corresponding tool compensation. Example: T0202 represents the No. 2 knife and the No. 2 knife make-up. Therefore, it is agreed in this paper that the tool number and its tool complement number are the same value, which is not easy to confuse. If the tool number and the tool compensation number do not match in the NC program or one of them is default, the coordinate system will be disordered and the machining code will not be executed correctly. The system stores 3 commonly used tools: T0101 for 93° roughing tool; T0202 for cutting tool; T0303 for fine turning tool. If “T” appears in a row and the following number is not the above number, the system will indicate which row of tool number T is illegal. code show as below:If TExist = True Then Call ErrCase( 3,FileRow,CaseType)TExist = TrueNumberString = GetNumber ( Right ( TextLine,Len ( TextLine ) -NumberStart) )If NumberString = ” ” ThenCall ErrCase( 1,FileRow,CaseType)ElseNumberStart = NumberStart + Len( NumberString)CaseNumber = CDbl( NumberString)If CaseNumber = 101 Or CaseNumber = 202 Or CaseNumber = 303Or CaseNumber = 404 Then ‘刀具编号ElseCall ErrCase( 9,FileRow,CaseType) ‘ 此处调用 ErrCase 函数显示错误信息End IfEnd If3 system learning functionThis simulation system is used as a teaching aid for engineering training. Students can use this software to conduct self-study, develop good programming styles and operating habits as starting points, and conduct detailed studies on module settings, selection of interaction methods, and logic arrangement of actions.3. 1 Simulation System InterfaceIn order to enable the trainees to quickly get acquainted with the actual machine tool, the software simulates the real machine tool as much as possible in the interface design. The simulation system interface is shown in Figure3.3. 2 Operation Panel Button Function TipsFor trainees who have not touched the N091 CNC lathe or the software, there are dozens of knobs and buttons on the control panel. The system uses the ToolTipText property in the Command control that comes with the VB platform, and the corresponding knob or The name of the button is filled in the operation panel. When the mouse is moved to the corresponding position, the system will give a text prompt. The interactive function is good, which is very helpful for students self-study. The function prompt interface of the machine tool operation panel is shown in Figure 4.Figure 3 Simulation System InterfaceFig. 4 Tool operation panel button function prompt interface3. 3 lathe operation sequence trainingAfter investigating the commercialized CNC simulation software on the market, the author found that most of the software does not strictly regulate the operation sequence of the machine tool. If the trainee has not touched the CNC lathe, the complex operation interface will be at a loss and I do not know where to go. If you start, you will soon lose interest in learning. In view of this, the simulation system uses VB to solve the above problem with the visible property of the Command control, and the order is limited by the selection of the property false/true visible to this control in the Command_Click( ) function. If the operation sequence is wrong, it triggers. MsgBox, prompt error information, operation sequence warning interface as shown in Figure 5.Figure 5 Operation Sequence Warning InterfaceFigure 6 Interpolation Principle Learning Module Interface3. 4 interpolation principle learning moduleLinear interpolation and arc interpolation are the most basic tool path generation methods for CNC lathes. The above two types of interpolation in the N091 CNC lathe are implemented using a point-by-point comparison method. The simulation system embeds an interpolation learning module, and students can select the circumcircle, inverse circle, and linear interpolation in the interpolation learning window, and give the starting and ending coordinates accordingly to generate a circle or a straight line. Realize the consolidation of classroom knowledge teaching. The interpolation principle learning module interface is shown in Figure 6.4 ConclusionThis software is aimed at the training and teaching of CNC lathe engineering. It aims at cultivating engineering practices and focuses on the development of self-learning functions. Students participating in the CNC lathe engineering training can use the computer at any time to carry out simulations of CNC lathe machining procedures, lathe operation methods, and learning of related CNC knowledge. While significantly improving the training effect, it effectively ensures the safety of equipment and trainees. It actually solves the problem of excessive man-machine ratio caused by a large number of students and limited training equipment in the school’s CNC lathe engineering training, and improves the operation practice. The efficiency reaches the goal of the students to better learn the CNC machining process.
资料来源:Meeyou Carbide

添加评论

zh_CN简体中文