Custom Macro Programming - PMPA

Transcription

Custom Macro ProgrammingParametric ProgrammingPMPA NTC 2013Presented by Ron Gainer & Dan MurphyTsugami/Rem Sales

Safety Every effort has been made to verify theinformation presented here is correct,however you should assume it is not andexercise caution when putting any of theexamples presented here to use.

Safety Macro programs can affect the motions of themachine tool. They can also be used tochange coordinate data and parametersettings. Any of these changes can causeunexpected motion, crashes, and othermachine malfunctions. Always exercisecaution and follow safe procedures forproving out new programs or edits to existingprograms.

Back Up Your Data Since Macro programming can be used tochange parameters, offsets, and workcoordinate data, make sure you have recentlybacked up your parameters, settings, workshifts, and offsets.

Introduction This Seminar is meant to be an introductionto Custom Macro Programming. There is noway to cover all the material you should beaware of in such a short time period.Be sure to read the Custom Macro section ofthe manual for your particular control

Don’t Be These Guys

Introduction This program concerns the application and use of“Custom Macro “B” on Fanuc controls. Particularlythe Fanuc Oi The general concepts apply to almost any CNCcontrol that has parametric programmingcapabilities.

For Further Learning

For Further Learning Fanuc USA offers a course called“Programming Level II” that cover Macro B Call - 888-FANUC-US (888-326-8287)

Introduction Applications for Custom Macro Programming Family of parts programmingCustom cycles Program complex motions Canned or multiple repetitionParabolas, ellipses, etcUse variables to adjust dimensions that offsets alone can’tchange“Smart” programs Macro programs can make decisions by using conditionalstatements IF THEN, AND, OR, XOR, IF GOTO, GOTO, WHILE DO, ENDCustom alarms and error traps

Introduction Applications for Custom Macro Programming Probing and in process gaugingCommunication with external devices AutomationPrintersMetrology devicesMachine status Check if machine is in proper position “Safe Start” macroCheck that offset data and work shifts are within rangeCheck other conditions Cut off tool breakage on Swiss

Uses for Macro Programming Repetitive operations Similar to using a sub program, but a macro will allow you tochange conditions without having to edit multiple lines of code.Example: Milling a pocket taking a number of passes. Usingvariables will allow you to change the DOC and number ofpasses without having to rewrite the sub routine.

Uses for Macro Programming Family of parts programming One program can run all variations of a part on atabled drawing.Variables are used in place of coordinatenumbers in the program.Conventional programG01 Z0.5 F0.003Macro programG01 Z#501 F0.003

Variables Variables are expressed in the program by anumerical value preceded by the pound sign #100, #500The numerical value corresponds to aregister on the macro page of the CNCdisplay

Navigating to the Macro Variable Register 1st Press the Offset Key on Main Panel2nd Press the right softkey that has the symbol.

Navigating to the Macro Variable Register 3rd Press the Macro Softkey.

Navigating to the Macro Variable Register Macro Register Screen

Assigning a Value to a variable Values can be input manually into a variable registerValues can also be assigned via the NC program Range is eight digits maximum #510 1.5#100 #100 1#510 12345678#510 1234.5678#510 12345.6789 will generate “TOO MANY DIGITS”alarmDecimal points are not considered digits howeverleading zeros are #510 1234.5678 is ok#510 0.12345678 is too many digits

Variables Variables Can Only be Mathematical Quantities(numbers) Can not have values of “Yes” or “No” Can’t be “True” or “False” Can’t be letters

A Variable Can Be Made ConditionalO1234;#10 60;#20 30;IF [#10 GT #20] THEN #1 #10 - #20;M#1;(Variable 10 is assigned a value of 60)(Variable 20 is assigned a value of 30)(If the value of variable 10 is greaterthan variable 20 “True” conditionSo the value of variable 1 30)

Expressions An expression is either a mathematicalstatement or a conditional statement.Conditional Statement – IF [#103 EQ 0] GOTO5If variable number 103 is equal to zero go to line N5Mathematical Statement - #107 #106 - #105Subtract variable number 105 from variable number 106and place the result in variable number 107

Expressions Enclosing a value within brackets [ ] isconsidered a macro expression G00 X[.5]G01 X[.5-.2]Brackets also denote the hierarchy ofoperationsIF [#1 LT #2] GOTO 99(Compare #1 to #2, then if true go to line N99)#100 #20 – [#10 * 2](Multiply #10 by 2, then subtract the result from #20)

Expressions A macro variable can also be represented asan expression #[#100]#[#1001-1]#[#6/2]

Substituting Variable Values in Program All NC “words” can have a variable as theirvalue, except “O” (program number) and “N”(sequence number)Coordinate word examples:#100 1.2;G00 X#100; (same as G00 X1.2)G-codes#10 00G#10 X1.2 (same as G00)S-codes#100 2500;G97 M03 S#100; (same as M03 S2500)O#100 (Illegal)F-codes#100 .003;G99 G01 X.5 F#100; (same as F0.003)N#100 (Illegal)

Substituting Variable Values in Program Caution Must Be Exercised Using variables with G-codes is not good practiceWhenever variables are used in place ofcoordinate values and/or NC words, unexpectedmachine movement can result

Substituting Variable Values in Program Understand how real numbers and integers aretreated by the CNC control Real numbers are any number rational or irrational Integers are whole numbers Real numbers include integers1.25, -.3765, 5, -10 are all real numbers2500, 3, 20Numbers with decimals are not integers i.e. 1.25Some NC words only allow integers S-commands: M03 S2000 is ok, M03 S2000.5 is not

Substituting Variable Values in Program Understand how real numbers and integers are treated by the CNC controlSome NC words only allow integers M-codes: M05 is acceptable M05.5 is notUse of brackets can in some cases round to nearest integerIn some cases variables will automatically be roundedAlways refer to the manual to eliminate any doubtExample:M03 S1001.5 (an illegal statement as S-codes have to be integers)Example:M03 S[1000.5] (will be treated as M03 S1001)Example:#1 1000.5M03 S#1 (will be treated as M03 S1001)

Substituting Variable Values in Program G-codes present a special challenge As a rule NEVER USE VARIABLES TO EXPRESS THEVALUE OF A G-CODEDespite being able to use real numbers with Gcodes (G12.1, G52.1, etc) the control will round up avariable from one place to the right of the decimaland treat the value as an integer only

Variable That Contains No Value A variable with no value is considered “Null” Null does not necessarily equal zeroWhen a variable of null value is used, thecontrol will, in most cases, ignore thecommandThis can be dangerousExample:Variable 100 equals nullG97 M03 S#100 (The spindle will start clockwise at the last commanded value)

Safety An operator was killed by a boring head on amachining center where the RPM wasspecified by a variableThe variable was set to null, so the lastprogrammed RPM was used by the controlThe RPM exceeded the rating of the boringheadThe head came apart and the operator wasstruck by the debris and killed

Safety If you are using a variable and know that ifthe value is set outside a certain range thatdanger exists, then add safety checks to yourcode without fail.Example: Spindle can run up to 6000 RPM but the boring head in use is rated to2,500RPM#100 6000;M03 S#100;(RPM 6000, Boring Head Blows Up)#100 6000;IF [#100 GT 2500] THEN #3000 1 (RPM TOO HIGH); (Conditional statement thatM03 S#100;checks that the RPM does notexceed 2500. If it does“ALARM 3001 RPM TOO HIGH”will be generated)

Variable #0 #0 is a read only System variable permanently set to null so it can beused for comparison#0 can also be used to set another variable to null In the previous example the RPM check does not prevent a null valuebeing used which would cause the spindle to run at the lastprogrammed RPM. #1 #0 sets #1 to null#0 #1 illegal statement because #0 is read onlyIn the case of the boring head, this is what happened#0 can be used in a safety check below:#100 #0;IF [#100 GT 2500] THEN #3000 1 (RPM TOO HIGH);IF [#100 EQ #0] THEN #3000 2 (NO RPM SET IN #100);G97 M03 S#100;ALARM 3002 will begenerated.

How Null Variables Behave in Arithmetic All variables areassumed null in theseexamplesIn math operations null(no value) is looked atas zero#2 #1;#2 remains null becausethere is no math orevaluation in thisstatement#2 [#1];#2 remains null.Even though thebrackets make this anexpression no math orevaluation occurs#2 #1 #1#2 will equal zero. Novalue plus no value hasa value of zero#2 #1 * 5#2 will equal zero

How Null Variables Behave in Expressions In comparative expressions EQ (equal to)and NE (not equal to), null variables are notconsidered the same as 0Examples - #1 null[#1 EQ 0][#1 NE 0][#1 EQ #0][#2 NE #0]False, null variable is not equal to 0True, null variable is not equal to 0True, #0 value is always nullFalse, #0 value is always nullConditional Statement – IF [#1 EQ 0] THEN (some action)

How Null Variables Behave in Expressions In all other conditional expressions a nullvalue variable is considered 0 LT – less than, LE - less than or equal toGT – Greater than, GE - Greater than or equal to[#1 LT 0][#1 LE 0][#1 GT 0][#1 GE 0]False, 0 is not less than 0True, 0 is equal to 0False, 0 is not greater than 0True, 0 is equal to zero

Using Variables At this point you have enough knowledge touse macro variables in two of the mostcommon ways. Adjusting feature sizeFamily of part programming

Adjusting Feature Size Width of a groove T1414;G96 M03 S200;G50 S5000;G00 X.55 Z.3;G99 G01 X.4 F.003G00X.55Z[.307 #514]G01 X.4G00X1.18 T00.093” groove tool width0.10.40.30.5

Family of Part Programming T1414;G96 M03 S200;G00 X.55 Z.#514;G99 G01 X.4 F.003G00X1.18 T0Variable featurelocation 0.08” groove tool width0.080.4A0.5PN-1A.3-2-3.4.5

Types of Variables Read only permanent value (#0, 3100-3102)Local variables (#1 through #33)Common variables (#100 through #199)Permanent common variable (#500-#599) Can also be made “read only” by parametersettingSystem variables

Local Variables (#1 - #33) A local variable is used locally as opposed toglobally, that is to say that a local variablecalled by one macro call at a certain time isdifferent from the same variable called atanother time by a different macro call.Local variables are used to pass argumentsfrom a macro callVariable number #1-#33 are tied to letteraddresses in the macro call

Macro Call for Variable Feature Variable feature locationCall from main programG65 P9014 A.3O9014T1414;G97 M03 S2000;G00 X.55 Z.#1;G99 G01 X.4 F.003G00X1.18 T0M990.080.4A0.5PN-1A.3-2-3.4.5

Macro Argument Correlation

Variables

Common Variables #100-#199 These variables are global. They have the samevalue in any macro call.These variable are read/write unless protected byparameter change Parameter 6031 and 6032 on FS OiDThese variables are reset to null upon power down

Common Variables #500-#999 These variables are global. They have the same value in anymacro call.These variable are read/write unless protected by parameterchange Parameter 6031 and 6032 on FS OiDThese variables will retain their values upon power down,reset, etc.These variables are preferred when input from the operator isrequired Feature size adjustmentFamily of partsTool life management count values

System Variables Variable whose usage does not vary in the system The variable’s address will always return the sameinformation, though the value will varySystem variables can be Read only, Read/Write, orWrite only depending on the nature of the variableSystem Constants are system variables whosevalues are fixed. They are Read only.

Variables Omission of the decimal point Decimal points can be left out when the value is an integer. #1 123 will be treated the same as #1 123.0000

Specifying a Common Variable by its Name You can name common variables using the SETVNcommand. This is useful in that a name that correlates to the variablesvalue is more easily recognizable in the program than avariable number.Examples:X[#POS1] Y[#POS2] ; : Specifying a position by the variable name[#POS1] #100 #101 ; : Executing a assignment statement by the variable name#[100 [#ABS]] 500 ; : Same as above (by a variable number)#500 [1000 [#POS2]*10] ; : Reading a variable by a variable name

SETVN Command For the 50 common variables, #500 to #549, a nameof up to eight characters can be specified by using acommand as shown below.

System Variable Names Names can be used with system variablesThe name is fixed in the control and can notbe changedExample: Wear Offsets on a T Control

System Variable Overview:System variables allow you to determine andset machine information. This would includemachine position, skip signal position, work &tool offsets. You can also read current “G”, “M”,“S”, “T”, and “H” codes.There are also System Variables forprogrammable inputs and outputs.

Displaying System Variables Unlike common variables, there is no pageon the control that will display the value ofsystem variables.You can see the value of a system variableby returning it to a common variableFor example to see the system variable for time, command:#100 #3012The time will then be stored in variable 100 as Hour/Min/Sec

List of System Variablesn represents a subscript.R, W, and R/W are attributes of a variable and indicate read-only, write-only, andread/write enabled, respectively.

System Variable Overview: Descriptions#1000-#103

Example: Spindle can run up to 6000 RPM but the boring head in use is rated to 2,500RPM. #100 6000; M03 S#100; (RPM 6000, Boring Head Blows Up) #100 6000; IF [#100 GT 2500] THEN #3000 1 (RPM TOO HIGH); M03 S#100; (Conditional statement that checks that the RPM does not exceed 2500.