Sei sulla pagina 1di 25

1

Custom Macro B
There are no real definitive courses on custom Macros or custom Macro assembly for specific requirements. The title even suggests the reason; Custom. Most everyone has different requirements and approach theyre machining differently, so one standard routine for a given operation might not be the answer for everyone. There are custom macros available that have been made for specific tasks such as Thread milling, Pocket milling, Pallet change and Engraving. This handout is not meant to provide you with all of the routines available, but to help you to understand why macros were created and how macros are developed through definitions and examples, and to assist you in creating your own Custom Macros. Custom Macros were originally designed for the ability to enter and run fairly complex, and normally large programs, in a relatively small program storage area. Memory storage, at the time, was very limited, and additional memory options were at a premium. The purpose of custom macro is for the ability to program either simple movements whose values are constantly changing (such as a family of parts), value substitution, or for complex programs where multiple math calculations and special functions must be checked, added to, looped and or re-evaluated. Custom Macro B may also be defined as variable programming. There are areas of the control, called registers, where values may be written to, read from, added to or subtracted from, combined together for calculations or for checking machine functions. Normally, all macro programs will run continuously when cycle start is pushed (single block has no bearing on Macro calculations). If a single block condition is desired to help with trouble shooting a new macro program, change the following parameters: 2201.2 = 1 (effects only programs O9000 O9999) 0010.3 = 1 (effects only programs O7000 O7999) 0010.4 = 1 (effects only programs O8000 O8999) 0010.5 = 1 (effects all programs) 6000.5 = 1 (effects all programs) There are some manuals and software available to assist you in writing your own Custom Macros as well as providing sample programs. One source of valuable information comes from a company called Programming Unlimited. This source provides a fairly comprehensive manual, as well as a software program called Macro Pro. For more information write to: Programming Unlimited 5320 Covina Place Ranch Cucamonga, CA 91739

2
Variables of Macro B: There are four types of variables: 1) #0 This variable is always null (vacant of any value). No value may be written to it, but it may be read. 2) #1-#30 These are local variables. Local variables are used within a macro to hold data and or the results of calculations. When a macro is called, arguments are assigned here. Therefore it is not advisable to write values to these locations for later retrieval unless macro calls are not to be used. If macro calls are not used, values may be written to them, and called later. This feature is handy if a value or co-ordinate in a program is repeated often. If an often-repeated value (such as a feed rate) needs to be changed, rather than search and change each value individually, one variable may be changed at the head of the program to effect all similar calls. When power is turned off, local variables are cleared out and emptied. Samples of local variable usage: #1=5.00 (WRITE 5.00 TO REGISTER 1) #2=2.00 (WRITE 2.00 TO REGISTER 2) #3=.100 (WRITE .1 TO REGISTER 3) G00 X#1 Y-#2 Z#3; (G0 X5.00 Y-2.00 Z.1) or G00 X[#1+#2]; (G00 X7.00) Or G00X[#1+#2]/#3; (G00 X70.) Note: Variables may not be used in the following ways: O#1; = no variable program calls. /#2G00X1.00; = no variable optional block delete calls. N#3Z-5.0; = no variable line numbers. 3)#100 - #149 and #500 - #531 These are common variables. Common variables can be shared among different macro programs. Variables #100 - #149 are cleared and emptied when power is turned off. Variables #500 - #531 hold theyre data even after power has been lost, and may be cleared out only through MDI or a program. The machine control also keeps track of pallet location (#147). The machine control also keeps track of tool number (#148). Samples of common variable usage: #100=5.00 (WRITE 5.00 TO REGISTER 100)

3
#101=2.00 (WRITE 2.00 TO REGISTER 101) #102=.100 (WRITE .1 TO REGISTER 102) G00 X#100 Y-#101 Z#102; (G0 X5.00 Y-2.00 Z.1) or G00 X[#100+#101]; (G00 X7.00) Or G00 X[#100+#101]/#102; (G00 X70.) Loop routine to easily clear registers #100-#149 and #500-#531: #1=100 WHILE[#1LE149]DO1 #[#1]=#0 #1=#1+1 END1 #1=500 WHILE[#1LE531]DO1 #[#1]=#0 #1=#1+1 END1 3) #1000-20000 These are system variables. System variables are used to read and write a variety of NC data items such as current position, modal states, tool compensation and work co-ordinate values. #1000 series: These registers are used to pass signals between the machine controller and custom macro (Interface signals). #2000 2400: These are system variables used for tool compensation, when the compensation pairs are not greater than 200. #3000: Used to generate an alarm state with or without a message. Alarm use of Macro B: Custom alarms may be generated using #3000. The statement below states: If register #147 does not equal 1, go to line number 9999. N9999 says display this alarm. If #147 equals 1, the program continues to the next line. O0777; IF[#147NE1]GOTO9999; (checks for pallet 1 position) (MAIN PROGRAM BODY); M30;

4
N9999#3000=1(***WRONG PALLET***); Sample alarm statements: N199#3000=1(USE G329 FOR Z WORK OFFSET PROBING) N200#3000=2(WRONG WORK OFFSET PROGRAMMED) N201#3000=3(USE T99 SENSOR TOOL ONLY) N202#3000=4(SET G54-G59 OR G54.1 P1-48) N203#3000=5(PROBE INTERFERENCE) N204#3000=6(PROBE DID NOT TOUCH IN Z) N205#3000=7(C MUST = 2,1,0 OR OMITTED) N206#3000=8(Z POS. OUT OF TOL.) Variable registers for time information. #3001 = counts milliseconds #3002 = counts 1 hour increments #3011 = reads current year/month/day #3012 = reads current hour/minute/second Variable registers for automatic operation control. #3003 = single block / completion of auxiliary function #3004 = feed hold / feedrate override / exact stop #3005 = settings #3007 = mirror image Variable registers for the number of machined parts. #3901 = Number of machined parts #3902 = Number of required parts Variables for modal information: (register of preceding blocks) #4000 = active program #4001 = G00, G01, G02, G03, G33 (GROUP 01) #4002 = G17, G18, G19 (GROUP 02) #4003 = G90, G91 (GROUP 03) #4004 = G22, G23 (GROUP 04) #4005 = G94, G95 (GROUP 05) #4006 = G20, G21 (GROUP 06) #4007 = G40, G41, G42 (GROUP 07) #4008 = G43, G44, G49 (GROUP 08) #4009 = G73, G74, G76, G80-G89 (GROUP 09) #4010 = G98, G99 (GROUP 10) #4011 = G50, G51 (GROUP 11) #4012 = G65, G66, G67 (GROUP 12) #4013 = G96, G97 (GROUP 13) #4014 = G54-G59 (GROUP 14) #4015 = G61, G64 (GROUP 15)

5
#4016 = G68, G69 (GROUP 16) #4017 = G15, G16 (GROUP 17) #4018 = (GROUP 18) #4019 = G40.1, G41.1, G42.1 (GROUP 19) #4020 = G160, G161 (GROUP 20) #4021 = (GROUP 21) #4022 = G50.1, G51.1 (GROUP 22) #4023 = (GROUP 23) #4024 = G25, G26 (GROUP 24) #4025 = G12.1, G13.1 (GROUP 25) #4102 = B code #4107 = D code #4109 = F code #4111 = H code #4113 = M code #4114 = N number #4115 = Program number #4119 = S code #4120 = T code #4130 = P code (additional work co-ordinate system) Example use for modal information: :9006 (M106 TOOL CHANGE CYCLE) #100=#4003 (stores G90/G91) #101=#4001 (stores G00/G01) #103=#4119 (stores spindle speed) #104=#4000 (stores active program) IF[#103GT5000]GOTO10 (if the spindle speed is greater than 5000, jump to 10) (if the value is not greater than 5000, continue to the next line) #103=6500 (sets #103 to 6500) N10G80M89 G40M9 G91G30G0Z0M5 IF[#4120EQ#148]GOTO11 (if the tool no. = the value in #148, jump to N11) (if the value does not = the value in #148, continue to the next line) G91G30G0X0Y0M6 N11 S#103 (restore original speed) G#100G#101 (restore original G90/G91 G00/G01) M99

6
% #5000 - #5108 (active axis position registers): These may be read only. Block end point (work piece co-ordinate system): #5001 = X #5002 = Y #5003 = Z #5004 = B #5005 = A Current position (machine co-ordinate system): #5021 = X #5022 = Y #5023 = Z #5024 = B #5025 = A Current position (work piece co-ordinate system): #5041 = X #5042 = Y #5043 = Z #5044 = B #5045 = A Skip Signal position: #5061 = X #5062 = Y #5063 = Z #5064 = B #5065 = A Tool length offset value active: #5081 = GEO #5082 = GEO WEAR #5083 = RADIUS #5084 = RADIUS WEAR Deviated servo position: #5101 = X #5102 = Y #5103 = Z #5104 = B #5105 = A

#5201 - #7948 and #14001 - #19988 (work co-ordinate registers): These may be read from and or written to. Work shift #5201 = X #5202 = Y #5203 = Z #5204 = B G54.1 P1 #7001 = X #7002 = Y #7003 = Z #7004 = B G54 #5221 = X #5222 = Y #5223 = Z #5224 = B G54.1 P2 #7021 = X #7022 = Y #7023 = Z #7024 = B G55 #5241 = X #5242 = Y #5243 = Z #5244 = B G54.1 P3 #7041 = X #7042 = Y #7043 = Z #7044 = B

Example of writing values to fixture offset G54: (write to register #_____ the value of_____) #5221 = -10.55 #5222 = -6.75 #5223 = -13.875 Example of reading values from fixture offset G54: (write to common variable #_____ the values from G54) #500 = #5221 #501 = #5222 #502 = #5223 #10001 - #10999 Tool offset registers (memory C): These registers may be read from and or written to. T1 T2 T3 GEO #11001 #11002 #11003 WEAR #10001 #10002 #10003 RADIUS #13001 #13002 #13003 WEAR #12001 #12002 #12003

To change the Radius for T1: #13001 = .250 To adjust the Radius wear for T2: #12002 = -.0025 To zero or cancel the GEO wear for T3: #10003 = 0

8
Sub program call with M-code: Rather than write the tool change positioning section of the program for each tool, a macro call may be set for M6. (set parameter 6071 6079 = M-code to be used; i.e. 6071 = 6) T1 M6 (calls sub program 9001) % :9001 (TOOL CHANGE SUB) G0G91G28Z0 G30X0Y0 G90 M6 M99 % Correspondence between parameter numbers and program numbers: Program number Parameter number O9001 6071 O9002 6072 O9003 6073 O9004 6074 O9005 6075 O9006 6076 O9007 6077 O9008 6078 O9009 6079 Macro Calls: G65 (simple call) G65 P9100 X1. Y.75 Z.75 R.1 F10. (writes new values to argument registers and runs program 9100) (or, used in conjunction with M98 calls, G65P___ can expand nesting capabilities for sub program calls up to eight levels deep) G66, G67 (modal call) Macro call with G code: (set parameter 6050 6059 = G-code used; i.e. 6050 = 81) G81 X___ Y____ Z____ R____ F____ (writes new values to argument registers and runs program 9010) Correspondence between parameter numbers and program numbers: Program number Parameter number O9010 6050

9
O9011 O9012 O9013 O9014 O9015 O9016 O9017 O9018 O9019 6051 6052 6053 6054 6055 6056 6057 6058 6059

Macro call with M code: (set parameter 6080 6089 = M-code to be used; i.e. 6080 = 50) M50 X___ Y____ A_____ F_____ (writes new values to argument registers and runs program 9020) Correspondence between parameter numbers and program numbers: Program number Parameter number O9020 6080 O9021 6081 O9022 6082 O9023 6083 O9024 6084 O9025 6085 O9026 6086 O9027 6087 O9028 6088 O9029 6089 Most any M-code (1-99999999) may be assigned to call and run a sub program as long as it is not already assigned to a specific task. Subprogram call with T code Arguments of Macro B: The argument variable uses registers #1 - #26 for having values written to them for later access for calling and running macro cycle routines. These registers are written to with a macro call statement: A = #1 B = #2 C = #3 D = #7 E = #8 F = #9 H = #11 Q = #17 R = #18 S = #19 T = #20 U = #21 V = #22 W = #23

10
I = #4 J = #5 K = #6 M = #13 X = #24 Y = #25 Z = #26

Example: G65 P9100 X1. Y.75 Z-.75 R.1 F10. #24 = 1. #25 = .75 #26 = -.75 #18 = .1 #9 = 10. Conditional expressions: EQ = Equal to NE = Not equal to GT = Greater than GE = Greater than or equal to LT = Less than LE = Less than or equal to Unconditional Branch: GOTO Example: GOTO55 (JUMP TO N55) Conditional Branch: IF Example: #1=0 (REGSTER 1 = 0) #2=1 (REGISTER 2 = 1) N1IF[#1GT10]GOTO2 (if #1 > 10 JUMP TO N2 / IF NOT CONTINUE) #1=#1+#2 (REGISTER 1 = REGISTER 1 + REGISTER 2) #2=#2+1 (REGISTER 2 = REGISTER 2 + 1) GOTO1 (JUMP BACK TO N1) N2M30 Branch repetition: WHILE[ ____ ]DO__ Example of looping (repeating): % O0001 #1=0 (REGISTER 1 = 0)

11
#2=1 (REGISTER 2 = 1) WHILE[#2LE10]DO1 (IF #2 is < 10, RUN THROUGH END1 AND REPEAT) #1=#1+#2 (REGISTER 1 = REGISTER 2 + REGISTER 2) #2=#2+1 (REGISTER 2 = REGISTER 2 + 1) END1 (IF REGISTER 2 IS NOT LE 10 GO TO NEXT LINE DOWN) M30 % Arithmetic and Logic: The following illustrations use variables listed as #I, #j, #k to simulate the use of local and or common variable registers. + = Add - = Subtract * = Multiply / = Divide ( ) = Comment / Message [ ] = Do this operation first ABS = Value regardless of sign #i = ABS[#j] Definition: #i = #j Sum: #i - #j + #k Difference: #i = #j - #k Product: #i = #j * #k Quotient: #i = #j / #k Sine: #i SIN [#j] Arcsine: #i = ASIN [#j] Cosine: #i = COS [#j] Arccosine: #i = ACOS [#j] Tangent: #i = TAN [#j] Arctangent: #i = ATAN [#j] / [#k] Square root: #i = SQRT [#j] Absolute value: #i = ABS [#j] Rounding off (above .5 next higher number): #i = ROUND [#j] Rounding down (discard fractions): #i = FIX [#j] Rounding up all decimals: #i = FUP [#j] External output commands: BPRNT (outputs characters and variable information in binary to port) DPRNT (outputs characters and variable information in EIA/ISO to port) POPEN (open port for communication) PCLOS (close port) * = Space [24] = Two decimal places to the left, four decimal places to the right Example: POPEN BPRINT [ C** X#100[24]*Y#101[24]*M#10[2] ]

12
PCLOS Example: POPEN DPRINT[X*CENTER*#100[24]*Y*CENTER*#101[24]*T#30*[2]] DPRINT[Z*VALUE*IS*#106[24]] PCLOS Anatomy of a Macro: This is a sample of the process to create a Macro program. You may wish to start off with a simple process, such as altering tool offsets or writing to fixture offsets from your program. The next step might be to convert a circle or square path such as a counter bore routine or a finish path around a boss with variables. Start off slowly with basic processes until you become comfortable with the logic and expressions used within the control, then proceed to a little more advanced steps. If you take your time to learn slowly, macros can be exciting to create and use, then only your imagination will be the limit. On the other hand, if you jump in to a complex problem right off, you may find yourself spending days trying to unravel a mystery and become a frustrated, warped unhappy machinist who will never wish to see this mess again! First: Decide what operation will need to be converted to macro form. Second: Write that operation down in normal G-code format, keeping everything in its simplest form. Third: Make a list of the values that will change or need to be altered. Fourth: Assign the list the appropriate register numbers if applicable. Fifth: Start substituting G-code values with register numbers if known. Sixth: Add logic expressions if applicable. Seventh: Re-arrange register numbers if calculations are added by assigning new register numbers. Eighth: Assign a Macro call statement and separate the call section of the program from the actual macro path by creating a new program number Ninth: Enter the program into the machine and de-bug. Tenth: Unless you are very good with logic, math and the way the control calculates and reacts, you may need to re-evaluate and re-arrange portions of your logic and where they are performed. First: THREAD MILLING Second: % O777(THREAD MILLING) (THREADS A 2 .00 DIAMETER POCKET) G0G17G40G49G80G90 T1 M6

13
G0G54X0Y0S1000M3 G43H1Z.1 G1Z-.5F30. X.25 G1G41D1X.25Y-.75F10. G3X1.Y0R.75Z.4875 G3X1.Y0I-1.J0Z.4375 G3X.25Y.75R.75Z.425 G1G40X.25Y0 G0X0Y0 Z.1 G0G91G28Z0 G28Y0 G90 M30 % Third: (X = POCKET CENTER) (Y = POCKET CENTER) (Z = THREAD DEPTH) (T = TOOL NUMBER) (F = FIXTURE OFFSET) (D = POCKET DIAMETER) (K = THREADS PER INCH) (S = RPM) Fourth: (X = #24 = POCKET CENTER) (Y = #25 = POCKET CENTER) (Z = #26 = THREAD DEPTH) (T = #20 = TOOL NUMBER) (F = #9 = FIXTURE OFFSET W/DEC.) (D = #7 = POCKET DIAMETER) (K = #6 = THREADS PER INCH W/DEC.) (S = #19 = RPM) Fifth: % O777(THREAD MILLING) (THREADS A 2 .00 DIAMETER POCKET) G0G17G40G49G80G90 T1 M6 G0G#9X#24Y#25S#19M3 G43H#20Z.1

14
G1Z-#26F30. X.25 G1G41D#20X.25Y-.75F10. G3X1.Y0R.75Z.4875 G3X1.Y0I-1.J0Z.4375 G3X.25Y.75R.75Z.425 G1G40X.25Y0 G0X#24Y#25 Z.1 G0G91G28Z0 G28Y0 G90 M30 % Sixth: In the last process, it has been determined that the actual cutting path cannot be generated using the current register numbers and values assigned. Therefore calculation statements must be assigned to new register numbers, and the new register numbers assigned to the cutting path. #100=#7/2 (POCKET DIAMETER / 2) #101=[#7*.25]/2 (CALCULATE THE POSITION FOR X START POINT) #102=[#7*.75]/2 (CALCULATE THE POSITION FOR Y START POINT) #103=1.0/#6 (1.00 / THREADS PER INCH - FOR Z UP ONE PITCH) #104=#103/4 (THREAD ENTRY FOR Z UP PITCH) Seventh: % O777(THREAD MILLING) (THREADS A 2 .00 DIAMETER POCKET) G0G17G40G49G80G90 T1 M6 G0G#9X#24Y#25S#19M3 G43H#20Z.1 G1Z-#26F30. X#101 G1G41D#20X#101Y-#102F10. G3X#100Y#25R#102Z#104 G3X#100Y#25I-#100J0Z#103 G3X#100Y#102R#102Z#104 G1G40X#101Y#25 G0X#24Y#25 Z.1 G0G91G28Z0 G28Y0

15
G90 M30 % Eighth: % O777(THREAD MILLING) (CHANGE PARAM 6050 = 100) (THREADS A 2 .00 DIAMETER POCKET) G0G17G40G49G80G90 T1 M6 G100X0Y0Z.5T1D2.K20.S1000 Z.1 G0G91G28Z0 G28Y0 G90 M30 :9010 #100=#7/2 #101=[#7*.25]/2 #102=[#7*.75]/2 #103=1.0/#6 #104=#103/4 G0G#9X#24Y#25S#19M3 G43H#20Z.1 G1Z-#26F30. X#101 G1G41D#20X#101Y-#102F10. G3X#100Y#25R#102Z#104 G3X#100Y#25I-#100J0Z#103 G3X#100Y#102R#102Z#104 G1G40X#101Y#25 G0X#24Y#25 M99 % Ninth: It was found that although the program worked fine at X0 Y0, when the new pocket center was specified elsewhere, the initial position move became incorrect, which affected the thread start location, which affected the cutter comp move, which affected the pocket size and shape Though absolute programming is desirable, and in most cases works fine, when calling and running sub-routines in different locations, it is expedient and preferable to convert them to Incremental.

16
Tenth: % O777(THREAD MILLING) (CHANGE PARAM 6050 = 100) (X = #24 = POCKET CENTER) (Y = #25 = POCKET CENTER) (Z = #26 = THREAD DEPTH) (T = #20 = TOOL NUMBER) (F = #9 = FIXTURE OFFSET W/DEC.) (D = #7 = POCKET DIAMETER) (K = #6 = THREADS PER INCH W/DEC.) (S = #19 = RPM) G0G17G40G49G80G90 T1 M6 G100X0Y0Z.5T1F54.D2.K20.S1000 G0Z.1 G91G28Z0 G28Y0 G90 M30 :9010(THREAD MILLING MACRO) #100=#7/2 #101=[#7*.25]/2 #102=[#7*.75]/2 #103=1.0/#6 #104=#103/4 G0G#9X#24Y#25S#19M3 G43H#20Z.1 G1Z-#26F30. G91 X#101 G1G41D#20Y-#102F10. G3X#102Y#102R#102Z#104 G3X0Y0I-#100J0Z#103 G3X-#102Y#102R#102Z#104 G1G40Y-#102 G90 G0X#24Y#25 M99 % Spindle Break in:

17
% O0001(MILL SPINDLE BREAK IN) (#100=STARTING RPM) (#101=MAXIMUM RPM) (#102=DWELL CHANGE RPM) #100=500 #101=10000 #102=8000 WHILE[#100LT#101]DO1 S#100M03 IF[#100EQ#102]GOTO2 #100=#100+500 G04X1800. END1 N2G04X900 WHILE[#100LT#101]DO2 #100=#100+500 S#100M03 G04X900 END2 WHILE[#100GT0]DO3 S#100 #100=#100-500 G04X900. END3 M30 % Tool probe touch-off macro: The following are two different examples of the same routine used on SH series machines. % O8777(TOOL PROBE TOUCH OFF MACRO) (#100=ENTER BEGINNING TOOL) (#101=ENTER ENDING TOOL) #100=1 #101=30 #500=#100 T#500 M6 G324 M1 IF[#500EQ#101]GOTO2 WHILE[#500LT#101]DO1 #500=#500+1. T#500

18
M6 G324 M1 END1 N2G0G91G28Z0 G90 M30 % or % O8777(TOOL PROBE TOUCH OFF) (B = ENTER BEGINNING TOOL) (E = ENTER ENDING TOOL) (T = LARGE TOOL) (R = RADIUS VALUE OF LARGE TOOL) G65 P9800 B1. E5. T2. R1.0 M30 O9800(TOOL PROBE TOUCH OFF MACRO) #500=#2 IF[#500 EQ #20]GOTO2 T#500 M6 G324 M6 N1IF[#500 GE #8]GOTO3 #500=#500+1. IF[#500 EQ #20]GOTO2 IF[#500 GT #8]GOTO3 T#500 M6 G324 M1 GOTO1 N2T#500 M6 G324X#18 M1 GOTO1 N3G0G91G28Z0 G90 M99 %

19
Pocket milling: (Circle pocket / Spiral cutting) % O2(SPIRAL POCKET) (CHANGE PARAM 6050=113) G0G17G40G49G80G90 T1 M6 G0G90G54X0Y0S3000M3 G43H1Z.1 (X #24 = POCKET CENTER) (Y #25 = POCKET CENTER) (Z #26 = POCKET DEPTH) (R #18 = POCKET RADIUS) (Q #17 = SIDE CUT) (S #19 = Z STEP) (E #8 = PLUNGE FEED) (F #9 = MILLING FEED) (D #7 = SPIRAL FACTOR) (K #6 = DIAMETER OF CIRCLE) G113X0Y0Z.5R1.Q.3S.1E2.F20.D20K4. G0G91G28Z0 G28Y0 M30 :9010(SPIRAL MACRO) #102=0 #27=#5043 G0X#24Y#25 #102=0 #102=#102+#19+.1 N1G1Z-#102F#8 #32=#17/72 #33=0 #18=#18-#[13000+#7] WHILE[#32LT#18]DO1 #30=[#32*COS[#33]]+#24 #31=[#32*SIN[#33]]+#25 G1#30Y#31F#9 #32=#32+[#17/72] #33=#33+5 END1 #30=#18*COS[#33] #31=#18*SIN[#33] X#30Y#31 #29=#24-#30

20
#28=#25-#31 G3X#30Y#31I#29J#28 WHILE[#6NE#1]DO1 G3#30Y#31I#29J#28 #1=#1+1 END1 #18=#18*.9 #30=#24+#18*COS[#33+10] #31=#25+#18*SIN[#33+10] G3#30Y#31R#18 G0G91Z.1 G90X#24Y#25 IF[#102GE#26]GOTO3 #102=#102+#19+.1 IF[#102LT#26]GOTO2 IF[#102EQ#26]GOTO2 #102=#26 N2GOTO1 N3G0G90Z.1 M99 %

Bolt hole circle: % O2(BOLT CIRCLE) G0G17G40G49G80G90 T1 M6 G0G90G54X0Y0S3000M3 G43H1Z.1 (X: #24 X CIRCLE CENTER) (Y: #25 Y CIRCLE CENTER) (R: #18 RADIUS OF BOLT CIRCLE) (A: #1 ANGLE OF FIRST HOLE) (H: #11 NUMBER OF HOLES) G90G99G81Z___R___F___L0(MUST USE L0) G65 P9111 X0 Y0 R2.5 A30. H7. G0G80Z.1 G0G91G28Z0 G28Y0 G90 M30 O9111 (BOLT CIRCLE MACRO)

21
IF[#24EQ#0]GOTO1 IF[#25EQ#0]GOTO1 IF[#18EQ#0]GOTO1 IF[#11EQ#0]GOTO1 #32=1 WHILE[#32LE#11]DO1 #33=#1+360*[#32-1]/#11 #30=#24+#18*COS[#33] #31=#25+#18*SIN[#33] X#30Y#31 #32=#32+1 END1 G80G0X#24Y#25 GOTO2 N1#3000=140(ADDRESS VALUE IS MISSING) N2M99 % Reducing peck cycle: % O9004(REDUCING PECK MACRO) (THIS PROGRAM IS DESIGNED TO RUN FROM A PRE-DRILLED HOLE) (USED FOR A DEEP HOLE WHERE TWO DIFFERENT DRILL LENGTHS ARE NEEDED) (USED WITH G184 CUSTOM MACRO CANNED CYCLE) (EX. G184Z-9.65R.01F6.I.3J.5Q.1E-6.3) (#18 "R" RAPID PLANE) (#4 "I" 1ST PECK) (#17 "Q" MINIMUM PECK) (#26 "Z" FINAL DEPTH) (#5 "J" REDUCTION MULTIPLIER) (#9 "F" FEEDRATE) (#3 "C" PECK RETRACT COUNT) (#100 INITIAL PLANE STORAGE) (#101 REMAINING DISTANCE CHECK) (#102 "Z" TARGET VALUE) (#103 "Z" FEED/RAPID VALUE) (#8 "E" SUB RAPID PLANE) #10=#4 (ERROR CHECKS) IF[#3EQ#0]GOTO5 #3=FIX[#3] GOTO6 N5#3=1 N6IF[#26EQ#0]GOTO50 IF[#18EQ#0]GOTO51

22
IF[#9EQ#0]GOTO52 IF[#4EQ#0]GOTO53 IF[#18LT#26]GOTO54 IF[#5NE#0]GOTO7 #5=1 N7IF[#5GT1]GOTO55 IF[#17GE.2]GOTO8 #17=.2 N8#100=#5003(STORE CURRENT Z POSITION) G0Z#18(RAPID TO R PLANE) #101=ABS[#5003-#26](CHECK FOR REMAINING DISTANCE #101=FINAL DEPTH) #103=#18(SET 103 TO R PLANE, #103=NEW "R" IN PART) WHILE[#101GT[#4+.02]]DO1(TEST 101 FOR FINAL DEPTH) #149=0 WHILE[#3NE#149]DO2(CHECK FOR RETURN TO "R") G0Z#103(RAPID INTO NEW "R" PLANE) IF[#101LE[#4+.02]]GOTO2 #103=[#5003-#4](NEW DEPTH) G1Z#103F#9(FEED TO "Z") #101=ABS[#5003-#26](RECALIBRATE DISTANCE TO GO) #103=#103+.1(RETURN PECK IN "R" PLANE) G0Z#103(RAPID TO NEW "R") #4=[#4*#5](RECALCULATE FEED DISTANCE) #149=#149+1(INCREMENT COUNTER) IF[#4GT#17]GOTO1(CHECK FOR MINIMUM PECK) #4=#17(SET TO MINIMUM PECK) N1END2 G0Z#18(RAPID TO ORIGIONAL "R" PLANE) END1 G0Z#103(RAPID TO PECK RETURN PLANE) N2G1Z#26(FEED TO FINAL Z) GOZ#18 N3G0Z#100 #4=#10 GOTO4 (ERROR STATEMENTS) N50#3000=1(NO VALUE IN Z) N51#3000=2(NO VALUE IN R) N52#3000=3(NO VALUE IN F) N53#3000=4(NO VALUE IN I) N54#3000=5(R IS DEEPER THAN Z) N55#3000=6(J VALUE MUST BE LE 1.) N4M99 %

23
Simple Counting: #2 = 0 (zero the counter) #1 = #2 (variable 1 = variable 2) #1 = #2 +1 (add 1 to variable 2) Recording tool cutting time: Records the time for each tool in the program and stores it in the common variables starting at #511. Used to compare CAM system time to actual machine time. Store it as a sub-program. To use, insert #3001=0 at the start of the tool and G65P9100 at the end. % :9006(M106 TOOL CHANGE CYCLE) #100=#4003 #101=#4001 #103=#4119 #104=4000 IF[#103GT5000]GOTO10 #104=#0 N10G80M89 G40M9 G91G30G0Z0S#104 IF[#4120EQ#148]GOTO11 G91G30G0X0Y0M6 N11 S#103 G#100G#101 M99 O9100 #2=#51999(ACTIVE TOOL) #100=#3001(TIMER VALUE) #100=#100/1000 #[510+#2]=#100(WRITE TIME) M99 % Peck drilling for SL-Lathes: % O7(SL-PECK DRILL) (SIMULATES G83 CYCLE) G0G17G40G49G80G90 G0G53X0Z-5. T0101

24
G97S1000M3 (Z:#26 - INITIAL Z POSITION) (W:#23 - FINISH DRILLING DEPTH) (K:#6 - PECK AMOUNT) (F:#9 - FEED RATE) G65P9001Z.1W1.25K.2F.004 G0Z.1 G53X0Z-5. M30 O9001(PECK MACRO) IF[#26EQ#0]GOTO100 IF[#23EQ#0]GOTO101 IF[#6EQ#0]GOTO102 IF[#9EQ#0]GOTO103 #100=#6 #23=ABS[#23] G0Z#26 X0 WHILE[#100LE#23]DO1 G1Z-#100F#9 G0Z#26 IF[#100EQ#23]GOTO15 G1Z-[#100-.05]F[#9*5] #100=#100+#6 END1 N10#100=#100-#6 G1Z-[#100-.05]F[#9*5] Z-#23F#9 G0Z#26 N15M99 N100#3000=1(NO Z CLEARANCE VALUE) N101#3000=2(NO W FINISH DRILLING DEPTH) N102#3000=3(NO K PECK AMOUNT) N103#3000=4(NO F FEED RATE) % SETVN: This command offers the ability to assign a name to common variables #500#520, on the control screen, to help clarify which variable is what. The name may be up to eight characters long. Example: SETVN505 Will start the naming at 505 [NAME,NAME6,NAME7] = Enter singularly or multiples.

25
SETVN500[ZVALUE,XCENTER1,YPOS2] #500 = ZVALUE #501 = XCENTER #502 = YPOS Spindle Probe Check: Keeps the spindle from starting when the probe is present. % O9005 (PARAM 6075 = 3) IF [#4120 EQ 1] GOTO2 (#4120 IS PROBE TOOL #) M3 GOTO3 N2 M5 N3 M99 %

Potrebbero piacerti anche