法兰克经典宏程序.
发那科b类宏程序(Fanuc B macro program)

发那科b类宏程序(Fanuc B macro program)Topic four: class B macro programmingClass B macro programIn the old model FANUC0MD system panel without "+", "one", "X" and "/" and "=", "[]" symbol, it is impossible to compare these symbol input, also cannot use these symbols are assigned and mathematical operations. So, in this system, you can only program by class a macro program. In the FANUC0i and its later (such as FANUC18i, etc.) system, you can input these symbols, and use these symbols for assignment and mathematical operation, that is, according to the B class macro program programming1, variablesThe variables of class B macro program are basically similar to the variables of class a macro program, and the main differences are as follows.(1) variables of the class that represents the B macro program except that the method can be used a macro program variables, also can be represented by the expression, but the expression must write all square brackets "[]" in parentheses in the program "()" only for comments.Example #[#l+#2+lO]When #1=lO, #2=100, this variable represents #120.(2) references to variables can also be expressed by variables.Example G01X[#l00-30.0]Y-#101F[#101+#103];When #100=100.O, #101=50.O, #103=80.O, the above statement is represented as G01X70.OY-50.OF130.2. Assignment of variables(1) the direct assignment variables can be assigned directly to the operating panel in MDI or in the program, but not to the left of the equals sign.Example #100=100.0;#100=30.O+20.O:(2) assign macro program in subroutine arguments, the variable assignment in the macro program is invoked.Example G65P1000x100.0Y30.OZ20.0F100.0;The X, Y, Z does not represent the coordinates of F words, nor feed words, but corresponding to the macro variables in the program, the specific numerical variables is determined by numerical argument after. Variable mapping argument macro program in two, the two methods can be mixed, including G, L, N, O, P is not an argument instead of variable assignment.1 cases of variable argument assignment method IG65P0030A50.0I40.0J100.0K0I20.0J10.0K40.0;After assignment, #l=50.0, #4=40.0, #5=100.0, #6=0, #7=20.0, #8=10.0, #9=40.0.Table 3-4 variable argument assignment method 1Table 3-5 variable argument assignment method II2 cases of variable argument assignment method IIG65P0020A50.0X40.0F100.0;After assignment, #1=50.0, #24=40.0, #9=100.0.3 cases of variable argument assignment method I and mixed useG65P0030A50.0D40.0I100.0K0I20.0;After assignment, I20.0 and D40.0 are assigned to variable #7 at the same time, then the latter #7 is valid, so the variable is #7=20.0, and the rest is the same as above.After an instance is assigned by variables, a class a finishing macro program of figure 3-4 can be changed into the following form:O0503; main program......C65P0504A12.5B25.0CO.0D126.86F100.0; after assignment, X tohalf axis length #l=12.5, Z to half axis length #2=25.0, angle starting angle #3=0.0, angle termination angle #7=126.86, feed speed #9=100.0.......O504; finish machining macro programN1000#4=#l x SIN[#3];#5=#2 x COS[#3];#6=#4 x 2;#8=#5-#2;G01X#6Z#8F#9;#3=#3+0.0l:IF[#3LE#7]GOTO1000;M99;3. Operation instructionThe operation instruction of class B macro program is very different from the operation instruction of class a macro program. Its operation is similar to the mathematical operation, and it is still expressed by various mathematical symbols. Use operation instruction to see table:Table 3-6B various operations of class macro program variables(1) the angle units of function SIN, COS and so on are 0, and the sum of them should be converted to 0. If 90030 'should be expressed as' 90.5030018', it should be expressed as 30.30.(2) the order of mathematical calculation of macro program is function calculation (SIN, COS, ATAN, etc.), multiplication and division operations (x, /, AND, etc.), addition and subtraction operations (+, -, OR, XOR, etc.).Case #l=#2+#3 x SIN[#4];The order of operation is: function SIN[#4], multiplication and division, #3 * SIN[#4] + add and subtract operations #2+#3 * SIN[#4].(3) parentheses in a function. Parentheses are used to change the order of operations. Parentheses in a function are allowed to be nested, but at most 5 nested layers are allowed.Case #1=SIN[[[#2+#3] x 4+#5] / #6];(4) in macro program and rounding operation. CNC numerical calculation, if the operation is greater than the original integer number is rounded, whereas under rounding.Let's set #1=1.2, #2=-1.2When #3=FUP[#1] is executed, 2 is assigned to #3;When #3=FIX[#l] is executed, 1.O is assigned to #3;When #3=FUP[#2] is executed, -2.O is assigned to #3;When #3=FIX[#2] is executed, -1.0 is assigned to #3;4 control instructions: control instructions play a role in controlling the flow of programs.(1) branch statementsFormat one GOTOn;Example GOTO1000The case is unconditional transfer. When the program segment is executed, it is unconditionally transferred to the N1000 program segment.Format two IF[conditional expression]GOTOn;Example IF[#1GT#100]GOTO1000This is a conditional transfer statement. If the condition is set, then it is transferred to the N1000 program segment; if the condition is not valid, the next program segment is executed: the type of the conditional expression is shown in table 3-7.Table 3-7B kinds of conditional expressions for class macro programsAttention: the representation of condition in conditional judgment(2) the cyclic instruction instruction format is:WHlLE[conditional expressions]DOm (m=l, 2, 3)... )......ENDm:When the condition is satisfied, the program segment m between WHlLE and END is executed again; when the condition is not satisfied, the next program segment of ENDm is executed.5, B class macro programming examplesExample: use B class macro program to write the program of toy horn punch curve as shown in figure 3-5.Example of class macro program programming of graph 3-5BCase analysis: this case is processed by B macro program, with Z value as independent variable, each change 0.1mm, X value as the corresponding variable, and the corresponding X value is calculated by variable operation. Programming uses the following variables to perform operations:Note: macro programming, first of all, to find the corresponding relationship between each point X coordinatesand Z coordinates.#101 is the Z coordinate in the equation (starting point Z=72);#102 is the X coordinate in the equation (starting radiusX=3.5);#103 is the Z coordinate in the workpiece coordinate system, #103=#101-72.0;#104 is the X coordinate in the workpiece coordinate system, #104=R2 * 2;Finishing procedures are as follows:0420......G00X9.0Z2.0; macro program starting point#101=72.0:#102=3.5:N100#103=#10l-72.O; jump target program segment#104=#102 x 2;C01X#104Z#103;#101=#101-0.1; Z coordinates each increment -0.1mm#102=36/#101+3; the variable calculates the X coordinateIF[#101GE2.0]GOTO100; conditional jumpG28U0W0;M30:Two, programming examplesExample: use B class macro program to write the NC lathe processing program of the curve outline of the winding cylinder shown in figure 3-6.Fig. 3-6 application of macro program of class BThis example of programming and processing ideas: the fine machining outline of this subject using B class macro programming. The compound fixed loops cannot be used in macro programming. Therefore, in the rough machining of this project, the coordinate translation instruction (G52) is used to compile the machining program which is similar to the compound cycle G73 instruction of the copying car. The processing procedures are shown in table 3-8.1, example analysisThe sine curve consists of two periods, with a total angle of 7200 (-6300 ~ 900). The curve is divided into 1000 segmentsalong the Z axis, and the distance between each line in the Z axis is 0.04mm, and the angle of the sine curve increases by 7200/1000. According to the formula, the X coordinate value of each line end point on the curve is calculated, X=34+6sin.In rough machining, local coordinates are used to program, and the following variables are used in programming:#100 is the X coordinate variable in the local coordinate system;#10l is sine curve angle variable;#102 is the X coordinate of each point of the sine curve;#103 is the Z coordinate of each point of the sine curve.2, reference procedures (see table 3-8)Table 3-8 NC lathe reference programTool No. 1 cutting tool: 350 carbide turning toolProgram FANUC0i system description of the proceduresO0400; main programN10 G98G40G21F100; the beginning of the programN20 T0101;N30 M03S800;N40 G0042.0Z-13.0; macro program starting pointN50 #100=10.0; local coordinate system X with initial valueN60 N200G52X#100Z0; local coordinate systemN70 M98P402; calling macro programN80 #100=#100-2.0; radial depth of Cut 2mmN90 IF[#100GE0]GOTO200; conditional judgmentN100 G00X100.0Z100.0; program endN110 M30;O0402 Curve Machining macro programN10 G01X40.0Z-15.0; machining the straight line connected with the curveN20 Z-20.0;N30 #101=90.0; sinusoidal angle with initial valueN40 #103=-20.0; curve Z coordinates initial valueN50 N300#102=34+6 x SIN[#101]; curvilinear X coordinateN60 G01X#102Z#102F100; straight line fitting curveN70 #101=#101-0.72; angle increment is -0.720N80 #103=#103-0.04; Z coordinate increment is -0.04mmN90 IF[#101GE-630.0]GOTO300; conditional judgmentN100 G01X40.0Z-67.0; machining the line segment connected with the curve and retracting the cutterN110 X42.0;N120 G00Z-13.0;N130 M99; returns the main program。
刻字宏程序 自动刻序列号 FANUC宏程序 加工中心刻字宏程序 流水号刻字宏程序 连号刻字宏程序

刻字宏程序自动刻序列号 FANUC宏程序加工中心刻字宏程序流水号刻字宏程序连号刻字宏程序刻字宏程序是一种用于在加工中心上自动刻写序列号、流水号或者连号的程序。
在FANUC宏程序中,我们可以使用一些特定的指令和函数来实现这个功能。
下面我将详细介绍如何编写一个FANUC宏程序来实现刻字功能。
首先,我们需要明确刻字的要求和规范。
例如,刻字的字体、大小、位置等。
这些要求将决定我们后续编写宏程序的具体步骤和指令选择。
在开始编写宏程序之前,我们需要了解一些基本的FANUC宏指令和函数。
FANUC宏指令是一种特定的指令集,用于编写FANUC机器人和加工中心的控制程序。
宏函数则是一些预定义的函数,用于实现一些常见的功能,如数学计算、逻辑判断等。
接下来,我们可以按照以下步骤编写刻字宏程序:1. 设置刻字参数:首先,我们需要定义一些刻字的参数,如字体、大小、位置等。
可以使用宏变量来存储这些参数,方便后续调用和修改。
2. 获取序列号:根据需求,我们可能需要自动生成序列号、流水号或者连号。
可以使用宏函数来实现这个功能。
例如,可以使用一个计数器来记录当前的序列号,并在每次刻字后自增。
3. 定位刻字位置:根据刻字要求,我们需要确定刻字的位置。
可以使用加工中心的坐标系来定位刻字位置。
可以通过挪移加工中心的工具或者工件来调整刻字位置。
4. 设置刻字工具:根据刻字要求,我们需要选择合适的刻字工具。
可以使用宏指令来选择刻字工具,并设置相应的刻字参数,如刀具半径、切削速度等。
5. 刻字操作:使用宏指令来实现刻字操作。
可以使用G代码来控制刻字工具的挪移和切削操作。
可以根据刻字要求,选择合适的切削方式,如直线切削、圆弧切削等。
6. 刻字结束:刻字完成后,我们可能需要进行一些收尾工作,如清理刻字工具、保存刻字结果等。
可以使用宏指令来实现这些操作。
以上就是一个简单的刻字宏程序的编写步骤。
固然,具体的编写过程还需要根据实际需求进行调整和修改。
FANUC宏程序详解

FANUC宏程序详解在FANUC系统中,宏程序是一种非常重要的功能,通过编写宏程序,我们可以让机器在无人值守的情况下完成一系列复杂的操作。
本文将对FANUC宏程序进行详细地介绍,包括宏程序的作用、编写方法、语法规则等方面。
1. 宏程序的作用宏程序是指一组可以重复使用的指令序列,通常用于执行一些常见的任务,例如生产线上的自动化操作、零件加工等。
通过编写宏程序,我们可以节省大量的时间和人力成本,提高整个生产线的效率和产能。
在FANUC系统中,宏程序主要有以下两个作用:1.1 缩短程序编写时间FANUC系统使用G代码编写程序,编写复杂的G代码序列会消耗大量的时间和精力。
而宏程序可以将常用的代码封装起来,减少了程序的编写时间。
例如,在加工中心上,我们可以编写一个宏程序来完成换刀操作,这样就可以省去手动编写换刀程序的时间。
1.2 提高工作精确度宏程序可以确保在每一次执行相同的任务时保持一致性,从而提高工作的精确度和可靠性。
例如,在装配生产线上,我们可以编写一个宏程序来完成紧固螺丝的操作,这样就可以确保每次紧固力度一致,避免螺丝过紧或过松的情况发生。
2. 编写宏程序在FANUC系统中,我们可以通过两种方式来编写宏程序:手动编写和自动生成。
手动编写是指通过手工输入代码来编写宏程序,而自动生成则是指通过FANUC系统自动生成宏程序。
2.1 手动编写手动编写是编写宏程序的最常见方式。
在手动编写宏程序时,我们需要按照FANUC系统的语法规则来编写G代码序列,并保存在一个文件中。
一般情况下,宏程序的文件扩展名为“.mac”。
以下是一个简单的宏程序:O1234G00 X10 Y10G01 Z-5 F500M30上述宏程序的功能是将机器头移动到坐标(10,10)点处,然后向下移动5个单位,同时切削速度为500,最后停止机床。
2.2 自动生成除了手工编写宏程序,我们还可以通过FANUC系统自动生成宏程序。
在FANUC系统中,系统提供了各种预制宏程序,我们可以在需要的时候直接调用这些宏程序。
fanu宏程序编写讲解

FANUC系统宏程序编程一变量普通加工程序直接用数值指定G代码和移动距离;例如,GO1和X100.0。
使用用户宏程序时,数值可以直接指定或用变量指定。
当用变量时,变量值可用程序或用MDI面板上的操作改变。
#1=#2+100G01 X#1 F300说明:变量的表示计算机允许使用变量名,用户宏程序不行。
变量用变量符号(#)和后面的变量号指定。
例如:#1表达式可以用于指定变量号。
此时,表达式必须封闭在括号中。
例如:#[#1+#2-12]变量的类型变量根据变量号可以分成四种类型变量号#0#1-#33#100-#199#500-#999#1000变量值的范围局部变量和公共变量可以有0值或下面范围中的值:-1047到-10-29或-10-2到-1047如果计算结果超出有效范围,则发出P/S报警NO.111.小数点的省略当在程序中定义变量值时,小数点可以省略。
例:当定义#1=123;变量#1的实际值是123.000。
变量的引用为在程序中使用变量值,指定后跟变量号的地址。
当用表达式指定变量时,要把表达式放在括号中。
例如:G01X[#1+#2]F#3;被引用变量的值根据地址的最小设定单位自动地舍入。
例如:当G00X#/;以1/1000mm的单位执行时,CNC把123456赋值给变量#1,实际指令值为G00X12346.改变引用变量的值的符号,要把负号(-)放在#的前面。
例如:G00X-#1当引用未定义的变量时,变量及地址都被忽略。
例如:当变量#1的值是0,并且变量#2的值是空时,G00X#1 Y#2的执行结果为G00X0。
双轨迹(双轨迹控制)的公共变量对双轨迹控制,系统为每一轨迹都提供了单独的宏变量,但是,根据参数N0.6036和6037的设定,某些公共变量可同时用于两个轨迹。
系统变量变量类型空变量局部变量公共变量功能该变量总是空,没有值能赋给该变量. 局部变量只能用在宏程序中存储数据,例如,运算结果.当断电时,局部变量被初始化为空.调用宏程序时,自变量对局部变量赋值, 公共变量在不同的宏程序中的意义相同.当断电时,变量#100-#199初始化为空.变量#500-#999的数据保存,即使断电也不丢失. 系统变量用于读和写CNC运行时各种数据的变化,例如,刀具的当前位置和补偿值.未定义的变量当变量值未定义时,这样的变量成为空变量。
FANUC用户宏程序编程操作说明

FANUC用户宏程序编程操作说明一、宏程序的概念和作用宏程序是一种FANUC机器人控制器中的编程语言,用于定义和执行一系列操作指令。
宏程序可以通过使用特定的编程语法,实现自动化的工作过程。
在机器人控制器上创建和调用宏程序可以有效提高生产效率,减少人力成本。
4.确认并保存宏程序。
确保没有语法错误,并将其保存在机器人控制器的内存中。
三、宏程序的调用和执行1.在主程序中调用宏程序。
可以使用特定的指令来调用已创建的宏程序,以便在工作流程中执行相关的任务。
2.配置宏程序的输入参数。
在调用宏程序之前,可以设置相关的输入参数,以便宏程序能够根据不同的情况执行不同的动作。
3.执行宏程序。
一旦宏程序被调用和配置完成,机器人控制器将根据宏程序中定义的指令序列依次执行相应的动作。
4.检查宏程序执行结果。
可以通过监视机器人、制作运动轨迹的视觉效果或通过输出信号检查机器人执行宏程序后的运动状态,确保宏程序的执行效果符合预期。
四、宏程序的调试和优化1.进行宏程序的语法和逻辑检查。
在调用和执行宏程序之前,可以使用FANUC机器人控制器提供的调试工具对宏程序进行语法和逻辑检查,以确保程序的正确性。
2.调整宏程序的时间和空间复杂度。
根据实际应用需求和机器人控制器的性能,可以对宏程序进行适当的优化,以减少程序执行时间和占用的内存空间。
3.进行宏程序的场景仿真。
在实际生产环境之前,可以使用机器人控制器提供的仿真工具对宏程序进行虚拟场景的测试,以确保宏程序的执行效果满足预期,同时减少实际生产中的错误和故障。
五、宏程序的应用示例1.示教和运动控制:通过将示教动作转化为相应的宏指令,可以实现机器人在特定位置和角度上的运动控制,以完成精确的操作。
2.任务自动化:将一系列任务步骤组织成宏程序,可以实现从物料处理到产品组装等一系列任务的自动化执行。
3.智能感应:通过编写合适的宏指令,可以实现机器人对环境的感知和判断,并根据实际情况自动调整动作和运动轨迹。
FANUC用户宏程序

二、宏程序的适用范围
✓ 形状类似但大小不同(圆、方及其它)
加工程序编程 ✓ 大小相同但位置不同(组孔、阵列等)
生产管理
✓ 特殊形状(椭圆、球等) ✓ 自动化功能(刀具长度测量) ✓换刀功能
PMC强电控制 ✓ 其它
4
BEIJING-FANUC
三、宏程序与子程序的比较
使用变量 调用方式 程序结束
嵌套
宏程序 可使用变量 G65 P_ L _<自变量赋值> ;
11
BEIJING-FANUC
二、变量的种类
变量号 #0、 #3100★
#1~#33
#100~#199 #500~#999
变量类型 空变量
局部变量
公共变量
用
途
总为空,不能写,只能读
只能用在当前用户宏程序中存储变量 断电/复位后数据初始化
在不同的程序中意义相同,各用户宏程 序公用. 断电后:#100~#199初始化为空, 500~#999数据保存
• 公共变量的写保护:参数6031~6032 ★对#500~#999进行保护,属性 为READ,以防止输入/全清的误操作.
• 系统变量:在系统中固定,属性有只读、只写、可读可写三种. • 系统常量:其值不变的常量,属性只读.
13
BEIJING-FANUC
变量的显示
四、变量的显示与设定
1).按下MDI面板上 的功能键 OFFSET
33
BEIJING-FANUC
...
34
BEIJING-FANUC
35
BEIJING-FANUC
36
BEIJING-FANUC
举例
37
BEIJING-FANUC
fanuc宏程序保护参数
fanuc宏程序保护参数Fanuc宏程序保护参数对于Fanuc数控系统的使用者来说是一个重要的概念。
在使用Fanuc数控系统进行切削加工时,我们需要使用Fanuc的宏程序进行加工,但是由于宏程序也是可以被修改的,为了保证加工质量,必须加以保护。
下面我们来分步骤阐述如何使用Fanuc宏程序保护参数。
首先,在进行Fanuc宏程序保护参数设置之前,需要进入Fanuc数控系统,从“system”菜单进入“para”选项,然后选择“parasave”选项。
在这个选项中,我们可以选中“Program protect”参数,这是保护宏程序的核心参数。
其次,在设置“Program protect”参数之后,需要设置一个密码来保护这个参数。
在Fanuc数控系统中,可以通过“Password setting”选项进行设置。
在这个选项中,我们可以设置两种密码:一个是程序口令密码(Program Password),另一个是参数口令密码(Parameter Password)。
我们要设置程序口令密码,以保护“Program protect”参数。
设置完成后,再通过“system”菜单进入“custom”选项,在这个选项中,我们可以选择“Memory protection”参数。
这个参数可以保护NC程序、宏程序等所需的内存区域,防止误操作后数据丢失。
最后,在进行Fanuc宏程序保护参数设置之后,我们需要把设置好的密码保存下来。
在Fanuc数控系统中保存密码的方法为:从“system”菜单进入“set”选项,然后选择“key”选项,按照提示进行设置,设置完成后把密码保存下来即可。
总的来说,使用Fanuc宏程序保护参数的方法十分简单。
需要注意的是,在设置完成后一定要把密码保存下来,以免出现数据丢失或忘记密码的情况。
如果需要修改或解除宏程序保护的参数,也需要进行相应的操作,代码为:1. 解除宏程序保护:O9001;#7=0;#6=32767;CALL PRGM_END;#7=1;M30;2. 取消宏程序保护:O9002;#7=0;#6=32767;CALL PRGM_END;#7=0;M30; 在使用Fanuc数控系统进行切削加工时,一定要注意这些细节,以保证加工质量和生产效率。
FANUC系统宏程序基础讲解
抛物线加工
G1 X 0 Z 0 F0.3; #1=0; #2=0; WHILE[#1 LE 12] DO1; G1X#1*2Z#2; #1=#1+0.5; #2=-#1*#1/12;
END1;
• 椭圆加工(参数编程)
• 程序:#1=0 (角度赋值) • WHILE[#1LE90] DO1;(循环) • #2=25*SIN[#1];(X坐标计算) • #3=25*COS[#1]-25.;(Z坐标计算,-25取Z轴的负方向) • G1 X#2 Z#3 F0.3;(直线拟合) • #1=#1+0.5;(角度计算) • END1;
G0 X 100.;
关于循环控制的注意事项
G65 宏程序非模态调用
格式:G65 P_ X_ Z_ A_ B_ C_ ; G65为自变量,直接对相对应的变量号赋 值,被调用的程序内无需再赋值, P表示被 调用的程序号。,X对应#24,Z对应#26, A对应#1,B对应#2,C对应#3。被调用 的程序最多可以4级嵌套,被调用的程序可 以再执行程序调用。被调用的程序结束符 为M99。
G66 宏程序模态调用
格式相同,但不同于G65的是G66为模态 调用,当执行完被调用的程序,返回到主 程序时,若主程序段出现轴移动,如G0或 G1,那么它执行完轴移动后再去调用宏程 序,直到主程序中出现G67,才能停止调用。
G67 取消宏程序模态调用
宏程序非模态调用:
G65 P9001 A100 B200 C300 ;
பைடு நூலகம்
WHILE[#2GT10] DO1; 当#2大于10的话,循环到 END1之间的程序,当条件不满足时,结束循环,程 序往下执行。循环最多可以3级嵌套。
举例:
#100=10;
FANUC数车宏程序
x向精加工余量 z向精加工余量 半精精加工控制 进刀,准备精加工 角度初值 曲线加工 X Z
FANUC Oi-T
抛物线加工
加工下图所示抛物线孔,方程为Z=X2/16,换算成直径编程形式 为Z=X2/64,则X=sqrt[Z]/8。采用端面切削方式,编程零点放在
工件右端面中心,工件预钻有Φ30底孔。
回刀
• #3=#3+2 进刀
• END1 粗加工结束
• G0Z100 退刀
• X100
• S1200M3
• T0202
• G0X30Z2
• G0X80
• G1Z1.4 精加工定位
• #1=80 X初始值
• WHILE[#1GE30]DO1 精加工条件控制
• #2=[#1*#1]/64
Z值
• #1=#1-0.2
• 变量的赋值
程序中的地址
A B C D E F H I J K M
在宏程序体中的 变量
#1 #2 #3 #7 #8 #9 #11 #4 #5 #6 #13
程序中的地址
Q R S T U V W X Y Z
在宏程序体中的 变量
#17 #18 #19 #20 #21 #22 #23 #24 #25 #26
可粗一些,易保ห้องสมุดไป่ตู้加工质量。
精加工:一般应采用仿形加工,即半精车、精车各一次
• 椭圆轮廓的加工
对椭圆轮廓,其方程有两种形式。对粗加工,采用G71/G72走刀方 式时,用直角坐标方程比较方便;而精加工(仿形加工)用极坐标 方程比较方便。
极坐标方程
直角坐标方程:
注意:方程式中的X、Z为数车坐标轴,通常a<b,且X为直径值。
• #1=#2+100
FANUC系统宏程式详解
宏程序的简单调用格式:格式:G65 P程序序号 L重复次数变量分配控制命令1.If [条件表达式] GOTO n2.While [条件表达式] DO mEnd m运算符号相等:EQ 不等于: NE 大于:GT 小于:LT 大于等于:GE 小于等于:LEFANUC系统宏程式FANUC系统宏程序编程一变量普通加工程序直接用数值指定G代码和移动距离;例如,GO1和X100.0。
使用用户宏程序时,数值可以直接指定或用变量指定。
当用变量时,变量值可用程序或用MDI面板上的操作改变。
#1=#2+100G01 X#1 F300说明:变量的表示计算机允许使用变量名,用户宏程序不行。
变量用变量符号(#)和后面的变量号指定。
例如:#1表达式可以用于指定变量号。
此时,表达式必须封闭在括号中。
例如:#[#1+#2-12]变量的类型变量根据变量号可以分成四种类型变量号变量类型功能#0 空变量该变量总是空,没有值能赋给该变量.#1-#33 局部变量局部变量只能用在宏程序中存储数据,例如,运算结果.当断电时,局部变量被初始化为空.调用宏程序时,自变量对局部变量赋值,#100-#199 #500-#999 公共变量公共变量在不同的宏程序中的意义相同.当断电时,变量#100-#199初始化为空.变量#500-#999的数据保存,即使断电也不丢失.#1000 系统变量系统变量用于读和写CNC运行时各种数据的变化,例如,刀具的当前位置和补偿值.变量值的范围局部变量和公共变量可以有0值或下面范围中的值:-1047到-10-29或-10-2到-1047如果计算结果超出有效范围,则发出P/S报警NO.111.小数点的省略当在程序中定义变量值时,小数点可以省略。
例:当定义#1=123;变量#1的实际值是123.000。
变量的引用为在程序中使用变量值,指定后跟变量号的地址。
当用表达式指定变量时,要把表达式放在括号中。
例如:G01X[#1+#2]F#3;被引用变量的值根据地址的最小设定单位自动地舍入。