Fanuc macro b programming manual

47 1.7K 0
Fanuc macro b programming manual

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Local & Common Variables > Introduction Although subprograms are useful for repeating the same operation, the custom macro function also allows use of variables, arithmetic and logic operations, and conditional branches for easy development of general programs such as pocketing and user–defined canned cycles A machining program can call a custom macro with a simple command, just like a subprogram, the only difference being; we can pass information into the sub program and manipulate it as we want Main Program Sub Program O0001; ; ; G65 P9010 A1 B26 F500 ; ; M30; O9010; G91; N100 #101=#2/2 G#1 G42 X#101 Y#1 F#9 IF[#5021LT100]GOTO100; M99; www.cncdata.co.uk Local & Common Variables > Local & Common Variable In the world of Macro B, everything revolves around variables, that is because 90% of the information visible on a Fanuc control, has its own variable address, these are called System Variables Fanuc has also given the end user its own set of variables, two types, local and common, located: [OFFSET] – {MACRO} (see page 5) Here are some of the System variables available: • • • • • • • • Tool Offsets Work Offsets Axis Positions Modal Information PMC Signals Alarms Automatic Operation Control Timers and Counters Plus many more An ordinary machining program specifies a G code and the travel distance directly with a numeric value; examples are G01 X100.0 With a custom macro, numeric values can be specified directly or using a variable number When a variable number is used, the variable value can be changed by a program or using operations on the MDI panel #2=0 #1=#2+100; G01 X#1 F200; When specifying a variable, specify a number sign (#) followed by a variable number General–purpose programming languages allow a name to be assigned to a variable, but this capability is only available for custom macros on a 30xi Series Example: #1 An expression can be used to specify a variable number In such a case, the expression must be enclosed in brackets Example: #[#1+#2–12] www.cncdata.co.uk Local & Common Variables > Local & Common Variables Variables are classified into four into four different types Variable number Type of variable Function #0 Always null This variable is always null No value can be assigned to this variable It is not a value, it is nothing/empty/null #1 – #33 Local variables Local variables can only be used within a macro to hold data such as the results of operations When the power is turned off, local variables are initialized to null When a macro is called, arguments are assigned to local variables These should only be used to pass values, not for calculations #100 – #149 (#199) Common Variables Common variables can be shared among #500 - #531 (#999) different macro programs When the power is turned off, variables #100 to #149 are initialized to null Variables #500 to #531 hold data even when the power is turned off As an option, common variables #150 to #199 and #532 to #999 are also available #1000 + System variables System variables are used to read and write a variety of NC data items such as the current position and tool compensation values Note Common variables #150 - #199 and #532 - #999 are a purchasable option from Fanuc GE (J887) Range of Variables: Local and common variables can have value or a value in the following ranges: –1047 to –10–29 10–29 to 1047 If the result of calculation turns out to be invalid, a P/S alarm No 111 is issued No decimal point is required with variables Example When #1=123; is defined, the actual value of variable #1 is 123.000 www.cncdata.co.uk Local & Common Variables > Examples of Variables When the value of a variable is not defined, such a variable is referred to as a “null” variable Variable #0 is always a null variable It cannot be written to, but it can be read If you look at variables #100 - #149 they are empty, this is written as #0 When an undefined variable is quoted, the address itself is also ignored When #1 = < vacant > When #1 = G01 X100 Y #1 G01 X100 Y #1 G01 X100 G01 X100 Y0 When < vacant > is the same as except when replaced by < vacant> When #1 = < vacant > When #1 = #2 = #1  #2 = < vacant > #2 = #1  #2 = #2 = #1*5  #2 = #2 = #1*5  #2 = #2 = #1+#1  #2 = #2 = #1 + #1  #2 = www.cncdata.co.uk Local & Common Variables > Examples of Variables < vacant > differs from only for EQ and NE When #1 = < vacant > When #1 = #1 EQ #0 #1 EQ #0   Established Not established #1 NE #1 NE   Established Not established #1 GE #0 #1 GE #0   Established Established Conditions Expressions EQ NE LT LE GT GE EQUAL NOT EQUAL TOO LESS THAN LESS THAN OR EQUAL TOO GREATER THAN GREATER THAN OR EQUAL TOO To display the macro variables press [OFFSET] – {MACRO} If ******** is displayed then an overflow has occurred An overflow means the variable is either greater than 99999999 or less than 0.00000001 www.cncdata.co.uk System Variables > PMC Variables System variables can be used to read and write internal NC data such as tool compensation values and current position data Note, however, that some system variables can only be read System variables are essential for automation and general–purpose program development Interface signals can be exchanged between the programmable machine controller (PMC) and custom macros In order to use these variables the PMC must be programmed to this PMC’s should only be written or modified by MTB’s Do not alter your PMC Variable number #1000–#1015 #1032 #1100–#1115 #1132 #1133 Function A 16–bit signal can be sent from the PMC to a custom macro Variables #1000 to #1015 are used to read a signal bit by bit Variable #1032 is used to read all 16 bits of a signal at one time A 16–bit signal can be sent from a custom macro to the PMC Variables #1100 to #1115 are used to write a signal bit by bit Variable #1132 is used to write all 16 bits of a signal at one time Variable #1133 is used to write all 32 bits of a signal at one time from a custom macro to the PMC For detailed information, refer to the connection manual (B–63523EN–1) www.cncdata.co.uk System Variables > Tooling Variables Tool compensation values can be read and written using system variables Usable variable numbers depend on the number of compensation pairs, whether a distinction is made between geometric compensation and wear compensation, and whether a distinction is made between tool length compensation and cutter compensation When the number of compensation pairs is not greater than 200, variables #2001 to #2400 can also be used System Variables for Tool Compensation Memory A Compensation Number System Variable : 200 : 999 #10001(#2001) : #10200(#2200) : #10999 System Variables for Tool Compensation Memory B Compensation Number Geometry Compensation Wear Compensation : 200 : 999 #11001(#2201) : #11200(#2400) : #11999 #10001(#2001) : #10200(#2200) : #10999 System Variables for Tool Compensation Memory C Tool Length Compensation (H) Compensation Number : 200 : 999 Geometric Compensation Wear Compensation #11001(#2201) #10001(#2001) : : #11200(#2400) #10200(#2200) : : #11999 #10999 Cutter Compensation (D) Geometric Compensation Wear Compensation #13001 : #13200 : #13999 #12001 : #12200 : #12999 www.cncdata.co.uk System Variables > Tooling Variables If the control being used has memory C (below) and we want to read the length of Tool into common variable 100, we need: #100=#11001 #100=#11001 The value of specified in the offset table for the length of tool is now input into variable 100 www.cncdata.co.uk System Variables > Alarms Using system variables we can make the machine stop instantly and display a custom message When a value from to 200 is assigned to variable #3000, the CNC stops with an alarm After an expression, an alarm message not longer than 26 characters can be described The CRT screen displays alarm numbers by adding 3000 to the value in variable #3000 along with an alarm message Example: #3000=1(TOOL LIFE EXPIRED) If you program #3000=23 (TOOL LIFE EXPIRED) then “3023 TOOL LIFE EXPIRED” is dispalyed www.cncdata.co.uk Macro Call > Rules and Limitations Calls can be nested to a depth of four levels including simple calls (G65) and modal calls (G66) This does not include subprogram calls (M98) • • • • Main Program Level Macro Level Macro Level Macro Level Macro Level O0001; : #1=1; G65 P2 A2; : : M30; O0002; : (#1=2); G65 P3 A3; : : M99; O0003; : (#1=3); G65 P4 A4; : : M99; O0004; : (#1=4); G65 P5 A5; : : M99; O0005; : (#1=5); : : : M99; Local variables from level to are provided for nesting The level of the main program is Each time a macro is called (with G65 or G66), the local variable level is incremented by one The values of the local variables at the previous level are saved in the CNC When M99 is executed in a macro program, control returns to the calling program At that time, the local variable level is decremented by one; the values of the local variables saved when the macro was called are restored www.cncdata.co.uk 32 Macro Call > Modal Call Modal Call (G66) Once G66 is issued to specify a modal call a macro is called after a block specifying movement along axes is executed This continues until G67 is issued to cancel a modal call G66 Pp Ln P: Number of the program to call L: Repetition count O0001; : G66 P9010 L2 A1 B2; G00 X100.; Y300 M30; • • • • • O9010; G00 Z-#1 G01 Z-#2 M99; After G66, specify at address P a program number subject to a modal call When a number of repetitions is required, a number from to 9999 can be specified at address L As with a simple call (G65), data passed to a macro program is specified in arguments When a G67 code is specified, modal macro calls are no longer performed in subsequent blocks Calls can be nested to a depth of four levels including simple calls (G65) and modal calls (G66) This does not include subprogram calls (M98) Modal calls can be nested by specifying another G66 code during a modal call www.cncdata.co.uk 33 Macro Call > G Code Macro Call Using G Code By setting a G code number used to call a macro program in a parameter, the macro program can be called in the same way as for a simple call (G65) By setting parameter 6050 to 100, G65 Pn is now replaced by G100 G65 Pp = G100 O0001; : G100 L2 A1 B2; : M30; O9010; #3=#1+#2; IF[#3GT360]GOTO99; G0 G54 X10; M99; By setting a G code number from to 9999 used to call a custom macro program (O9010 to O9019) in the corresponding parameter (N0.6050 to No.6059), the macro program can be called in the same way as with G65 For example, when a parameter is set so that macro program O9010 can be called with G81, a user–specific cycle created using a custom macro can be called without modifying the machining program The following table shows the correspondence between program number and parameter If for example your macro program is O9010, enter the value of the G code you want in parameter 6050 I.E if you want G125 to open O9010 then 6050 must be 125 Program Number Parameter Number O9010 6050 O9011 6051 O9012 6052 O9013 6053 O9014 6054 O9015 6055 O9016 6056 O9017 6057 O9018 6058 O9019 6059 www.cncdata.co.uk 34 Macro Call > M Code Macro Call Using M Code By setting an M code number used to call a macro program in a parameter, the macro program can be called in the same way as for a simple call (G65) By setting parameter 6080 to 100, G65 Pn is now replaced by M100 G65 Pp = M100 O0001; : M100 L2 A1 B2; : M30; O9020; #3=#1+#2; IF[#3GT360]GOTO99; G0 G54 X10; M99; By setting an M code number from to 99999999 used to call a custom macro program (9020 to 9029) in the corresponding parameter (No.6080 to No.6089), the macro program can be called in the same way as with G65 Program Number Parameter Number O9020 6080 O9021 6081 O9022 6082 O9023 6083 O9024 6084 O9025 6085 O9026 6086 O9027 6087 O9028 6088 O9029 6089 www.cncdata.co.uk 35 Macro Call > Sub Call Subprogram Call Using M Code By setting an M code number used to call a subprogram (macro program) in a parameter, the macro program can be called in the same way as with a subprogram call (M98) By setting parameter 6071 to 100, M98 Pn is now replaced by M100 M98 Pp = M100 O0001; : M100; : M30; O9001; M99; By setting an M code number from to 99999999 used to call a subprogram in a parameter (No.6071 to No 6079), the corresponding custom macro program (O9001 to O9009) can be called in the same way as with M98 Program Number Parameter Number O9001 6071 O9002 6072 O9003 6073 O9004 6074 O9005 6075 O9006 6076 O9007 6077 O9008 6078 O9009 6079 www.cncdata.co.uk 36 Exercises > Joint Joint Exercise Scenario You have a customer that wants you to machine circular holes into a square billet Problem is there are over 50 variations of this job All different hole sizes, depths and centre points Process Move the tool to centre point Move the tool down into the job Interpolate out several times until diameter is met Return tool to the centre point Repeat steps and until depth and diameter is met Now we have to think about every possibilty and options available to us, to come up with the best method Here are a few things to think about: • Where is the datum point going to be? • Absolute or Incremental? • Climb milling/direction? • What letters to use on the Macro call? • What information shall we require? • Cutter compensation, yes/no? • What error checks can we make? • What G code to create? • What material is the component? • What variables shall we use, #100-#149 or #500-#531? It’ always a good idea to have a pen and paper to hand to make notes on all of the above when you’re writing Macro B programs www.cncdata.co.uk 37 Exercises > Exercise Using the joint the joint exercise just completed, we need to make the macro machine to the correct sizes specified Ensuring the macro doesn’t cut oversize, radially or in depth We also need to put in place measures to prevent the macro running without all the necessary information For example if the user forgets to input the diameter of te circle, then the macro cannot run This macro should run with G100 www.cncdata.co.uk 38 Exercises > Exercise Scenario You have a customer that wants you to create a G-Code to enable him to drill various PCD’s These comes with various depths, diameters and the amount of holes vary Process Move the tool to the centre point Using Trigonometry calculate hole position Drill the hole Using a WHILE statement repeat steps & until all holes are drilled www.cncdata.co.uk 39 Exercises > Exercise Scenario We have just received an order for several thousand components Each component has a raised square face on it There are ten different types of component, where features such as the height or square size of the component differ Rather than write ten different NC programs, we can write one Macro program instead X X Xsq X www.cncdata.co.uk 40 Exercises > Exercise Scenario You have just written several macro programs on a cylindrical grinder All of these programs use the offsets of Tool 1, as there is only one wheel and the datum’s positions on G54 If the operator sets any other offsets then your macro has a problem The control has 300 tool offsets and work piece offsets Again if the operator sets any offset other than G54, your macro has a problem So we have to create a check program to make sure no unnecessary information is set, for tool length, tool radius and work pieces Also if the external offset is, display a message so the operator is aware the EXT offset is active www.cncdata.co.uk 41 Exercises > Exercise Scenario Thread milling at your place of work is a common operation Currently for every cycle a new helical interpolation program is written, consuming a lot of time Your task is to create a cycle for thread milling, using G184 to call up the macro; the G180 line should look similar to a G84 line Once the tool enters the component, it must not be stopped, Be sure to rad on and rad off www.cncdata.co.uk 42 Exercises > Exercise Scenario You have a customer that wants you to machine elliptical bosses into a square billet Problem is there are over 20 variations of this job All different major and minor diameters and some are not complete ellipses, i.e start at 90 degrees and finish at 180 degrees Process Move the tool to centre point Move the tool down into the job Interpolate (varying radiuses throughout) out several times until diameter is met Return tool to the centre point Repeat steps and until depth and diameter is met www.cncdata.co.uk 43 Variable List > Variable List Variable #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 #15 #16 #17 #18 #19 #20 #21 #22 #23 #24 #25 #26 #100 #101 #102 #103 #104 #105 #106 #107 #108 #109 #110 #111 #112 #113 #114 #115 #116 #117 #118 Description A B C I J K D E F H M Q R S T U V W X Y Z Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Variable #119 #120 #121 #122 #123 #124 #125 #126 #127 #128 #129 #130 #131 #132 #133 #134 #135 #136 #137 #138 #139 #140 #141 #142 #143 #144 #145 #146 #147 #148 #149 Description Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable All of these are variables are cleared either on reset, at the end of the program or at power off www.cncdata.co.uk 44 Variable List > Variable List Variable #500 #501 #502 #503 #504 #505 #506 #507 #508 #509 #510 #511 #512 #513 #514 #515 #516 #517 #518 #519 #520 #521 #522 #523 #524 #525 #526 #527 #528 #529 #530 #531 #1000 #1001 #1002 #1003 #1004 #1005 #1006 #1007 #1008 #1009 #1010 #1011 #1012 Description Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Common Variable Variable #1013 #1014 #1015 #1032 #1100 #1101 #1102 #1103 #1104 #1105 #1106 #1107 #1108 #1109 #1110 #1111 #1112 #1113 #1114 #1115 #1132 #1133 Description PMC Bit Read PMC Bit Read PMC Bit Read PMC Word Read PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Bit Write PMC Word Write PMC Double Word Write PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read PMC Bit Read www.cncdata.co.uk 45 Variable List > Variable List Variable #3000 #3001 #3002 #3003 #3004 #3005 #3006 #3007 #3008 #3009 #3010 #3011 #3012 Description Alarm & Stop Timer (m/s) Timer (hourly) Single Block Feed control #3901 #3902 Machine Parts Required Parts #4001 #4002 #4003 #4004 #4005 #4006 #4007 #4008 #4009 #4010 #4011 #4012 #4013 #4014 #4015 #4016 #4017 #4018 #4019 #4020 #4021 #4022 #4102 #4107 #4109 #4111 #4113 #4114 #4115 Modal Group Modal Group Modal Group Modal Group Modal Group Modal Group Modal Group Modal Group Modal Group Modal Group 10 Modal Group 11 Modal Group 12 Modal Group 13 Modal Group 14 Modal Group 15 Modal Group 16 Modal Group 17 Modal Group 18 Modal Group 19 Modal Group 20 Modal Group 21 Modal Group 22 Modal B Code Modal D Code Modal F Code Modal H Code Modal M Code Modal Sequence No Modal Program No Operator Message Date Time Variable #4119 #4120 #4130 Description Modal S Code Modal T Code Modal P Code #5001 : #5008 #5021 : #5028 #5041 : #5048 #5061 : #5068 Workpiece Position 1st Axis (B) : Workpiece Position 8th Axis (B) Machine Position 1st Axis : Machine Position 8th Axis Workpiece Position 1st Axis (C) : Workpiece Position 8th Axis (C) Skip Signal Position 1st Axis : Skip Signal Position 8th Axis #5201 : #5208 #5221 : #5228 #5241 : #5248 #5261 : #5268 #5281 : #5288 #5301 : #5308 #5321 : #5328 1st Axis EXT Zero Offset : 8th Axis EXT Zero Offset 1st Axis G54 Zero Offset : 8th Axis G54 Zero Offset 1st Axis G55 Zero Offset : 8th Axis G55 Zero Offset 1st Axis G56 Zero Offset : 8th Axis G56 Zero Offset 1st Axis G57 Zero Offset : 8th Axis G57 Zero Offset 1st Axis G58 Zero Offset : 8th Axis G58 Zero Offset 1st Axis G59 Zero Offset : 8th Axis G59 Zero Offset www.cncdata.co.uk 46

Ngày đăng: 13/10/2016, 22:25

Từ khóa liên quan

Mục lục

  • Macro B FP

  • Macro B[no fp]

    • Note

    • When an undefined variable is quoted, the address itself is also ignored

    • When < vacant > is the same as 0 except when replaced by < vacant>

    • System Variables for Tool Compensation Memory A

    • System Variables for Tool Compensation Memory B

    • System Variables for Tool Compensation Memory C

    • Round Function - #i=ROUND[#j];

    • Differences from NC Statements

    • NC statements that have the same property as macro statements

    • Macro Call

    • /

    • Scenario

    • Scenario

    • Process

Tài liệu cùng người dùng

Tài liệu liên quan