|
| |||||||
| Home | Recent Posts | HELP-FORUMS (ask/answer) | Classifieds-free | File Sharing / Documents | Photo Galleries | Polls | Newsletter | Machinetoolhelp.com. |
| Programming / Applications All CNC programming, CNC applications, milling, turning, tooling, macro programming, and other CNC machine tool related questions. |
![]() |
| | Bookmark or Share | Thread Tools | Search this Thread | Display Modes |
| |||
| Quote:
Regards, Bill |
| |||
| Sorry to drag this out, but if your control has POLAR COORDINATE INTERPOLATION (G12.1, G13.1) it will greatly influence the way in which the Macro Program is structured. If the control has this function, you will have the choice of two methods. 1. Polar Coordinate Interpolation allows the program to be written as if programming a machining centre without any regard to an angular move. or, 2. Simply positioning the tool at the correct X coordinate and indexing the "C" axis the required angular move, 22.5 degrees for your 16 holes. Which ever method is used, the Macro program should be written in such a way that the number of holes can be specified as an argument. If you were to create a Macro program to do 16 holes only, you may as well just long hand code the CNC program. Both methods are quite easy to create a Macro program for. With the "C" axis index method, the only math required will be to divide 360 by the number of holes required, so as to obtain the incremental "C" axis index to apply in the Macro program. Post back if you control has Polar Coordinate Interpolation. If so, I'll give you an example of both methods. Regards, Bill |
| |||
| Example code for method 2, where the tool is positioned at the PCD and the "C" axis indexed to next position; I'll do method 1 when I get a bit of time. Instead of calling the Macro program with G65, you could create a Custom "G" code by registering the number of the "G" code in parameter #6050 so as to call Macro program O9010. For example, if 101 is registered in #6050, the Macro program will be called as follows: G101 D100.0 A0.0 B30.0 K6 C83 Q0 R1.0 S0 Z-8.0 F150 Where: D = PCD A = Start angle B = Incremental index angle K = Number of indexes C = Cycle number. in the following example, cycles from G83 to G85 are accommodated. The Macro program could be expanded to accommodate more. Q = Peck amount for G83 cycle R = Retract level S = Dwell at bottom of hole cycle Z = Final Z coordinate F = Feed Rate or the Macro program can be called as follows using G65 G65 P9010 D100.0 A0.0 B30.0 K6 C81 Q0 R1.0 S0 Z-8.0 F150 Regards, Bill % O9010 (A=#1) (B=#2) (C=#3) (D=#7) (F=#9) (K=#6) (Q=#17) (R=#18) (S=#19) (Z=#26) IF[#1EQ#0]OR[#2EQ#0]OR[#3EQ#0]OR[#7EQ#0]OR[#6EQ#0]GOTO100 (ERROR TRAP FOR MISSING DATA) G00 X#7 C#1 M? (C AXIS CLAMP M CODE IF REQUIRED) IF[#3LT83] OR [#3GT83]GOTO10 IF[#9EQ#0]OR[#26EQ#0]OR[#17EQ#0]OR[#18EQ#0]OR[#19EQ#0]GOTO100 G98 G83 Z#26 R#18 P#19 Q#17 F#9 GOTO30 N10 IF[#3LT84]OR[#3GT84]GOTO20 IF[#9EQ#0]OR[#18EQ#0]OR[#26EQ#0]GOTO100 G98 G84 Z#26 R#18 F#9 GOTO30 N20 IF[#3NE85]GOTO110 (INVALID CYCLE) IF[#9EQ#0]OR[#18EQ#0]OR[#26EQ#0]GOTO100 G98 G85 Z#26 R#18 F#9 N30 #4=1 (COUNTER) WHILE[#4LT#6K]DO1 #1=#1+#2 C#1 M? (C AXIS CLAMP M CODE IF REQUIRED) #4=#4+1 END1 G80 GOTO120 N100 #3000=1(MISSING ADDRESS DATA) GOTO120 N110 #3000=2(INVALID CYCLE) N120 M99 % Last edited by angelw; 02-15-12 at 08:43 PM. |
| |||
| Here is an example of PCD calcs used in conjunction with POLAR COORDINATE INTERPOLATION. I have not tested this, or the Macro in my previous Post. Accordingly, test in fresh air and in single block to check the tool positioning. In both examples, its a requirement that the Tool be positioned at the Initial Z level before calling the Macro program. With both Macro programs, you could launch the required cycle in the main program before calling the Macro program, and only pass arguments relating to the PCD. In this case reference to the cycles and the associated error trapping would be deleted from the Macro program. Ask any questions if you don't understand any part. Regards, Bill G65 P9010 D100.0 A0.0 B30.0 K6 C81 Q0 R1.0 S0 Z-8.0 F150 % O9010 (A=#1) (B=#2) (C=#3) (D=#7) (F=#9) (K=#6) (Q=#17) (R=#18) (S=#19) (Z=#26) IF[#1EQ#0]OR[#2EQ#0]OR[#3EQ#0]OR[#7EQ#0]OR[#6EQ#0]GOTO100 (ERROR TRAP FOR MISSING DATA) G00 X#7 C#1 M? (C AXIS CLAMP M CODE IF REQUIRED) IF[#3LT83] OR [#3GT83]GOTO10 IF[#9EQ#0]OR[#26EQ#0]OR[#17EQ#0]OR[#18EQ#0]OR[#19EQ#0]GOTO100 G98 G83 Z#26 R#18 P#19 Q#17 F#9 GOTO30 N10 IF[#3LT84]OR[#3GT84]GOTO20 IF[#9EQ#0]OR[#18EQ#0]OR[#26EQ#0]GOTO100 G98 G84 Z#26 R#18 F#9 GOTO30 N20 IF[#3NE85]GOTO110 (INVALID CYCLE) IF[#9EQ#0]OR[#18EQ#0]OR[#26EQ#0]GOTO100 G98 G85 Z#26 R#18 F#9 N30 G12.1 Start of polar coordinate interpolation #4=1 (COUNTER) #1=0 WHILE[#4LT#6K]DO1 #1=#1+#2 You could have the following block X[COS[#1 * #7]] C[SIN[#1*[#7/2]]] M? (C AXIS CLAMP M CODE IF REQUIRED) or the following instead of the above block #24=[COS[#1 * #7]] #25=[SIN[#1*[#7/2]]] X#24 C#25 M? (C AXIS CLAMP M CODE IF REQUIRED) #4=#4+1 END1 G80 G13.1 Cancellation of polar coordinate interpolation GOTO120 N100 #3000=1(MISSING ADDRESS DATA) GOTO120 N110 #3000=2(INVALID CYCLE) N120 M99 % Last edited by angelw; 02-15-12 at 11:50 PM. |
| |||
| Quote:
I have never used an IF statement with a string of OR before like that. Is there any controls that are specific to this or is this SOP for most Fanucs. Steve (The opinions in this post are my own and not those of machinetoolhelp.com and its management) |
| |||
| Quote:
To tell the truth, I've not used that number of OR's in one string before, however, I've used IF[#1EQ#0]OR[#2EQ#0]OR[#3EQ#0]TH (whatever) many times with all manner of Fanuc controls. In terms of logic, there should be no reason why IF[#1EQ#0]OR[#2EQ#0]OR[#3EQ#0]OR[#7EQ#0]OR[#6EQ#0]GOTO100 would not work. Whatever is legal in a High Level language such as BASIC and all its derivatives, or Pascal, will work just fine in Fanuc User Macro. The above conditional block is quite legal in any of the aforementioned languages. Therefore, it would be SOP for all Fanuc controls equipped with User Macro B. As you well know, the above conditional block could be broken up into a number of single conditional blocks: IF[#1EQ#0]GOTO100 IF[#2EQ#0]GOTO100 etc or, a number conditional ORs: IF[#1EQ#0]OR[#2EQ#0]GOTO100 IF[#3EQ#0]OR[#7EQ#0]GOTO100 etc In my opinion, the single, multiple OR's is a tidier way of doing it, but a number of single conditional blocks is marginally easier to debug. In single block, you can tell easily which block tests true. In the single, multiple OR conditional block, any bracketed comparison set testing True will trigger the GOTO100 statement. Having said that, its not much of a chore to look up the variable values in the Macro Variable page to see which variable is <vacant>. Regards, Bill Last edited by angelw; 02-17-12 at 01:56 AM. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
| |