发那科b类宏程序(Fanuc B macro program)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

发那科b类宏程序(Fanuc B macro program)
Topic four: class B macro programming
Class B macro program
In 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 programming
1, variables
The 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 I
G65P0030A50.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 1
Table 3-5 variable argument assignment method II
2 cases of variable argument assignment method II
G65P0020A50.0X40.0F100.0;
After assignment, #1=50.0, #24=40.0, #9=100.0.
3 cases of variable argument assignment method I and mixed use
G65P0030A50.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 to
half 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 program
N1000#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 instruction
The 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.2
When #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 statements
Format one GOTOn;
Example GOTO1000
The 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]GOTO1000
This 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 programs
Attention: 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 examples
Example: 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-5B
Case 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 coordinates
and Z coordinates.
#101 is the Z coordinate in the equation (starting point Z=72);
#102 is the X coordinate in the equation (starting radius
X=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 coordinate
IF[#101GE2.0]GOTO100; conditional jump
G28U0W0;
M30:
Two, programming examples
Example: 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 B
This 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 analysis
The sine curve consists of two periods, with a total angle of 7200 (-6300 ~ 900). The curve is divided into 1000 segments
along 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 program
Tool No. 1 cutting tool: 350 carbide turning tool
Program FANUC0i system description of the procedures
O0400; main program
N10 G98G40G21F100; the beginning of the program
N20 T0101;
N30 M03S800;
N40 G0042.0Z-13.0; macro program starting point
N50 #100=10.0; local coordinate system X with initial value
N60 N200G52X#100Z0; local coordinate system
N70 M98P402; calling macro program
N80 #100=#100-2.0; radial depth of Cut 2mm
N90 IF[#100GE0]GOTO200; conditional judgment
N100 G00X100.0Z100.0; program end
N110 M30;
O0402 Curve Machining macro program
N10 G01X40.0Z-15.0; machining the straight line connected with the curve
N20 Z-20.0;
N30 #101=90.0; sinusoidal angle with initial value
N40 #103=-20.0; curve Z coordinates initial value
N50 N300#102=34+6 x SIN[#101]; curvilinear X coordinate
N60 G01X#102Z#102F100; straight line fitting curve
N70 #101=#101-0.72; angle increment is -0.720
N80 #103=#103-0.04; Z coordinate increment is -0.04mm
N90 IF[#101GE-630.0]GOTO300; conditional judgment
N100 G01X40.0Z-67.0; machining the line segment connected with the curve and retracting the cutter
N110 X42.0;
N120 G00Z-13.0;
N130 M99; returns the main program。

相关文档
最新文档