USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
I'm needing help with skipping around in a program using variables/and user input with out editing the program. The parts I am working with are core (used) parts, they get tore down and re used, these parts end up with broken bolts in some of the holes. We are using a HAAS vf4 to drill out the broken bolts and install helicoils. What I'm wanting to do is write a program that will allow the operator to select which bolt holes need to be repaired with out editing the program. I currently have it set up where they can change variables in the program to choose what operations they need to do and pick the bolt holes. I'm looking for a better way of doing it without having to edit the program. Any idea or help would be appreciated.
example of what I have now(not the whole program)
(1=YES 0=NO)
(MILL EXHUAST ) #828= 1
(SPOT DRILL ) #827= 0
(M12 BOLT HOLE REPAIR) #800= 0
(M10 BOLT HOLE REPAIR) #823= 0
(SELECT M12 X 1.75 BOLT HOLES)
(1 ) #801= 0
(2 ) #802= 0
(3 ) #803= 0
(4 ) #804= 0
(5 ) #805= 0
(6 ) #806= 1
(7 ) #807= 1
(8 ) #808= 0
(9 ) #809= 0
(10) #810= 0
(11) #811= 0
(12) #812= 0
(13) #813= 0
(14) #814= 0
(15) #815= 0
(SELECT M10 X 1.5 BOLT HOLES)
(1) #817= 1
(2) #818= 0
(3) #819= 0
(4) #820= 0
(5) #821= 0
IF [ #800 EQ 0 ] GOTO200 (NO M12 BOLT HOLE REPAIR GOTO N200)
N200 IF [ #827 EQ 0 ] GOTO2 (SPOT DRILL NOT NEEDED GOTO DRILL N2)
N1 (1/2 140 DEG SPOT DRILL)
G00 G90 G53 X-47. Y0 Z0
G20
G00 G17 G40 G49 G80 G90
T2 M06 (SPOT DRILL)
M01
T27
G00 G90 G55 X0. Y0. A90. S1069 M03
G43 H02 Z0.2
M08
G98 G81 Z0.199 R0.2 F8.6
N101 IF [ #801 EQ 0 ] GOTO102 (SKIP HOLE 1 GOTO 2)
X-32.471 Y-1.616 Z-0.05 (1)
N102 IF [ #802 EQ 0 ] GOTO118 (SKIP HOLE 2 GOTO M10 1)
X-31.091 Y1.798 Z-0.05 (2)
N118 IF [ #823 EQ 0 ] GOTO103 (SKIP M10 BOLT HOLES)
IF [ #817 EQ 0 ] GOTO103 (SKIP HOLE M10 2 GOTO 3)
X-29.039 Y1.831 Z-0.05 (M10 #1) (#3)
N103 IF [ #803 EQ 0 ] GOTO104 (SKIP HOLE 3 GOTO 4)
X-27.141 Y-1.616 Z-0.05 (3)
N104 IF [ #804 EQ 0 ] GOTO119 (SKIP HOLE 4 GOTO M10 2)
X-25.761 Y1.798 Z-0.05 (4)
N119 IF [ #823 EQ 0 ] GOTO300 (SKIP M10 BOLT HOLES)
IF [ #818 EQ 0 ] GOTO300 (SKIP HOLE M10 2 GOTO 5)
X-2.502 Y1.964 Z-0.05 (M10 #2) (#5)
N300 IF [ #805 EQ 0 ] GOTO105 (SKIP HOLE 5 GOTO 6)
X-23.67 Y1.831 Z-0.05 (5)
N105 IF [ #806 EQ 0 ] GOTO106 (SKIP HOLE 6 GOTO 7)
X-21.811 Y-1.616 Z-0.05 (6)
N106 IF [ #807 EQ 0 ] GOTO107 (SKIP HOLE 7 GOTO 8)
X-20.431 Y1.798 Z-0.05 (7)
N107 IF [ #808 EQ 0 ] GOTO109 (SKIP HOLE 8 GOTO 9)
X-16.481 Y1.798 Z-0.05 (8)
N109 IF [ #809 EQ 0 ] GOTO111 (SKIP HOLE 9 GOTO 10)
X-15.101 Y-1.616 Z-0.05 (9)
N111 IF [ #810 EQ 0 ] GOTO112 (SKIP HOLE 10 GOTO 11)
X-13.01 Y1.831 Z-0.05 (10)
N112 IF [ #811 EQ 0 ] GOTO113 (SKIP HOLE 11 GOTO 12)
X-11.151 Y-1.616 Z-0.05 (11)
N113 IF [ #812 EQ 0 ] GOTO114 (SKIP HOLE 12 GOTO 13)
X-9.771 Y1.798 Z-0.05 (12)
N114 IF [ #813 EQ 0 ] GOTO115 (SKIP HOLE 13 GOTO 14)
X-7.68 Y1.831 Z-0.05 (13)
N115 IF [ #814 EQ 0 ] GOTO116 (SKIP HOLE 14 GOTO 15)
X-5.821 Y-1.616 Z-0.05 (14)
N116 IF [ #815 EQ 0 ] GOTO120 (SKIP HOLE 15 GOTO M10 3)
X-4.441 Y1.798 Z-0.05 (15)
N120 IF [ #823 EQ 0 ] GOTO117 (SKIP M10 BOLT HOLES)
N158 IF [ #819 EQ 0 ] GOTO159 (SKIP HOLE M10 5 GOTO M10 6)
X-0.606 Y-1.491 Z-0.05 (M10 #3) (#19)
N159 IF [ #820 EQ 0 ] GOTO160 (SKIP HOLE M10 6 GOTO M10 7)
X2.123 Y-0.13 Z-0.05 (M10 #4) (#20)
N160 IF [ #821 EQ 0 ] GOTO117 (SKIP HOLE M10 7 GOTO N117 END)
X2.394 Y1.969 Z-0.05 (M10 #5) (#21)
G00 G80 Z1. M09
N117 G91 G28 Z0.
G00 G90 G53 X-47. Y0 Z0
M01
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
If it were me I think i would write a VBA macro in NCplot which asks the user to write a list of holes to drill separated by commas. 1,4,5,8. But then I'd have to save it to a flash drive and move it to my machine for each part being repaired.
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
Quote:
I currently have it set up where they can change variables in the program
hello buldozer, i have no experience with haas vf4, but isn't it there a interface, from where you could change the variable's values, like a table with variables?
i believe that there should be a table with local / common variables, so the operator to input values there, without editing the program
of course, in your program, you simply acces those variables, thus you skip the initialization step
i recomand writing a soubroutine that should check those values, to be within range, so to avoid "wrong" inputs / kindly :)
1 Attachment(s)
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
This ( FANUC) program drills 8 holes on a 100x100mm gridspace, first hole position X0. Y0.
The Local / Common / Macro variables #510 - #517 needs a [1] INPUT for drilling or a [0] for skipping the hole.
These values can be changed without editing the program.
#510=1
#511=0
#512=1
#513=1
#514=1
#515=1
#516=0
#517=1
%
O1150( TEST-PROGRAM )
N010 G54 G00 G17 G40 G80 G94( DRILL-10MM )
N015 G90 G49
N020 T01
N025 M06
N030 S1750 M03
N035 G00 G90 X0. Y0.
N040 G43 Z100. H01
N045
N050 #110=172 ( CALL SUB-PROGRAM )
N055 P8608 M98
N060
N065 G00 Z100. M09
N070 G28 G80 G91 Y0.Z0. M05
N075 M30
O172 ( DRILL-10MM )
N010 G00 X0. Y0. Z20.
N015 G73 Z-25. R5. Q5. F350
N020 G80
N025 M99
O8608 (-GRIDSPACE- 100MM X 100MM )
N010 IF[#510EQ0 ]GOTO20
N015 P#110 M98
N020 G52 X100. Y0. Z0.
N025 IF [#511EQ0 ]GOTO35
N030 P#110 M98
N035 G52 X200. Y0. Z0.
N040 IF [#512EQ0 ]GOTO50
N045 P#110 M98
N050 G52 X300. Y0. Z0.
N055 IF [#513EQ0 ]GOTO65
N060 P#110 M98
N065 G52 X0. Y100. Z0.
N070 IF [#514EQ0 ]GOTO80
N075 P#110 M98
N080 G52 X100. Y100. Z0.
N085 IF [#515EQ0 ]GOTO95
N090 P#110 M98
N095 G52 X200. Y100. Z0.
N100 IF [#516EQ0 ]GOTO110
N105 P#110 M98
N110 G52 X300. Y100. Z0.
N115 IF [#517EQ0 ]GOTO125
N120 P#110 M98
N125 G52 X0. Y0. Z0.
N130 M99
%
Regards,
Heavy_Metal.
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
Hi deadlykitten,
No, it's not created by CAM.
I backplotted the nc-code in CimcoEdit, thats the attached image.
I use these type of programming a lot for multiple fixtures.
By shifting the workoffsets by G52 I can create different options with different tools.
The single variable 00110101 I don't understand, how would that run the nc-code with different work coördinates or XYZ-locations.
Regards,
Heavy_Metal.
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
I think this comes down to how much and how you want the operator to alter the program
if the operator is to modify the program but you do not want them in the main program then i would give them a program to alter the #800's
o1234
(1=YES 0=NO)
(MILL EXHUAST ) #828= 1
(SPOT DRILL ) #827= 0
(M12 BOLT HOLE REPAIR) #800= 0
(M10 BOLT HOLE REPAIR) #823= 0
(SELECT M12 X 1.75 BOLT HOLES)
(1 ) #801= 0
(2 ) #802= 0
(3 ) #803= 0
(4 ) #804= 0
(5 ) #805= 0
(6 ) #806= 1
(7 ) #807= 1
(8 ) #808= 0
(9 ) #809= 0
(10) #810= 0
(11) #811= 0
(12) #812= 0
(13) #813= 0
(14) #814= 0
(15) #815= 0
(SELECT M10 X 1.5 BOLT HOLES)
(1) #817= 1
(2) #818= 0
(3) #819= 0
(4) #820= 0
(5) #821= 0
m98pxxxx(goto main program)
G00 G80 Z1. M09
N117 G91 G28 Z0.
G00 G90 G53 X-47. Y0 Z0
M01
if you as a programmer know what they are working on {you have the information of the machine op's)
you could write this and give it to them then they would not be altering any programs
this is from deadlykitten
i believe that there should be a table with local / common variables, so the operator to input values there, without editing the program
you would have to have a chart for the operator and he would access the #800's macro variables telling them what #800 variable is for what hole is for to alter the hole pattern
1 Attachment(s)
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
hello heavy metal :) please, what means to backplot ?
Quote:
The single variable 00110101 I don't understand, how would that run the nc-code with different work coördinates or XYZ-locations
method 1 ) check this : only 3rd 4th 6th & 8th holes will be drilled :
this sequence is sent as a "byte", or, more precisely, as a row of 0s & 1s; it has the benefit that it requires a single variable :)
method 2 ) another method, is to input directly the holes that need to be cut, using digits; for example, 2583 will mean that only 2 5 8 & 3 holes will be drilled; in some particular cases, this method is pretty fast, because it requires a single input :)
so far, these 2 examples are limited by the biggest number that the controler can handle, but there is a way arround it
method 3) let's say that the controller can handle numbers with only 10 digits, and you wish to cut 30 holes :) you may use the power of 2s, and input inside the machine the number 1073741823, which is < 999999999; pls check attached image
it does not make a lot of sense for drilling, but it does when you wish to make a difference between each number, considering that each number calls for a different operation :)
all these examples require additional code, but they are designed to make the operator life a bit more easier
let's consider 10 fixtures on the table of a vmc, and suddenly you need to avoid operation 2 on fixture 3, and also skip fixture 4, because it got damaged; how fast do you believe that it can be done ? it takes 3 keystrokes on a custom interface ( okuma ) / kindly :)
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
Quote:
Originally Posted by
Heavy_Metal
Hi deadlykitten,
No, it's not created by CAM.
I backplotted the nc-code in CimcoEdit, thats the attached image.
I use these type of programming a lot for multiple fixtures.
By shifting the workoffsets by G52 I can create different options with different tools.
The single variable 00110101 I don't understand, how would that run the nc-code with different work coördinates or XYZ-locations.
Regards,
Heavy_Metal.
Hello Heavy_Metal,
What he doesn't explain, is how its implemented; all gong and no dinner. Particularly with Haas, Fanuc, Mitsubishi and other controls, Variables are Decimal Numeric and not Binary. Accordingly, passing a Variable commencing with a "0", as in 00110101, may fail, as the control will see the value as 110101. However, if a number such as the following is passed to a Macro:
13426587
this number could be decoded to specify the order in which, holes 1 to 8 are to be machined, or with the following number:
13578
which numbered holes from 1 to 8 in the PCD are to be machined. The total number of holes in the PCD would also be passed so as to calculate the incremental angle between successive holes.
Following is an example:
G101 A13578 (OTHER ARGUMENTS RELATING TO THE MACHINING CYCLE WOULD BE INCLUED HERE)
O9010
(#1 = 13578 - NUMBER PASSED TO THIS MACRO TO SELECT HOLES TO BE MACHINED)
#2 = 1 (COMPARISON NUMBER)
(DECODING THE NUMBER STARTS HERE)
WHILE [#2 LE #1] DO1
#2 = [#2 * 10]
END1
#2 = #2 / 10 (THIS WOULD BE THE DIVISOR)
#3 = 1
WHILE [#2 / #3 GE 1] DO1
N1 #4 =FIX[[FIX[#1 / [#2 / #3]]] / 10]
N2 #5 = [FIX[#1 / [#2 / #3]]] - #4 * 10
(DECODING THE NUMBER STARTS HERE)
--------------------------
PCD HOLE POSITIONING AND MACHINING GOES HERE
-------------------------
END1
Sequence numbers N1 and N2 have only been used to identify these blocks for explanation. The MOD Function is not included in all Machine User Macro Executables. Accordingly, Blocks N1 and N2 is equivalent to:
#4 = [FIX[#1 / [#2 / #3]]] MOD 10
In the above example, each successive loop of the DO1 Loop would return the following results for Local Variable #5:
1
3
5
7
8
The above individual numbers are used to multiply the incremental angle between the points on the PCD to gain the angle from a specified Start Angle (Zero Degrees is 3 o'clock). Once the angle of the specified numbered point of the PCD is known, COS and SIN functions are used to calculate the X and Y coordinates respectively of the numbered point.
The above method requires only one argument (A) in the Call Block to be changed. If the operator can't get that right, there would be an even chance of getting the Macro Variable wrong also.
Regards,
Bill
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
Let me start by saying I'm new to macro/sub programing and the use of variables. I like the idea of being able to pick holes with the option of just typing in the numbers you want to do. Are any of you familiar with M109(user input), If so is there a way to get it to work with the option of just typing in the hole numbers to be done? It uses ANSI for variable inputs, but the only number options are 0-9 and I need to get 0-16. What id like to be able to do is set the control up where the operator can hit cycle start and answer a couple questions and run. Do you know any good links/videos to learn more about variables and macros? Thank you all for your input, very helpful in learning.
(example of M109, after the surface is milled it stops and asks if you want to rerun then if yes(Y) is selected it will offset the tool and rerun mill then repeat until no(N) is entered)
N6
N1001 G103 P1
#501= 0. (Clear the variable)
N5000 M109 P501(RERUN MILL?)
IF [ #501 EQ 0. ] GOTO5000 (Wait for a key)
IF [ #501 EQ 89 ] GOTO1000 (Y)
IF [ #501 EQ 78 ] GOTO2000 (N)
GOTO1001(Keep checking)
N1001(A Y was entered)
#2211=#2211-.005(ADD -.005 TO TOOL 11 LENGTH OFFSET)
GOTO6(RERUN MILL)
N2000(A N was entered)
#2211=0 (SET TOOL WEAR T11 BACK TO 0)
G103
M30
Example 2 (update)
haven't tested but it should keep asking to select bolt holes until the EOB key is pressed but I haven't figured out a way to use double digits.
#801=0
#802=0
#803=0
#804=0
#805=0
#806=0
#807=0
#808=0
#809=0
#810=0
#811=0
#812=0
#813=0
#814=0
#815=0
#816=0
N2006 G103 P1;(LOOK AHEAD LOWERED TO 1 BLOCK)
#501= 0. (Clear the variable)
N1015 M109 P501(select bolt holes)
IF [ #501 EQ 0. ] GOTO1015 (Wait for a key)
IF [ #501 EQ 49 ] GOTO3001 (1)
IF [ #501 EQ 50 ] GOTO3002 (2)
IF [ #501 EQ 51 ] GOTO3003 (3)
IF [ #501 EQ 52 ] GOTO3004 (4)
IF [ #501 EQ 53 ] GOTO3005 (5)
IF [ #501 EQ 54 ] GOTO3006 (6)
IF [ #501 EQ 55 ] GOTO3007 (7)
IF [ #501 EQ 56 ] GOTO3008 (8)
IF [ #501 EQ 57 ] GOTO3009 (9)
IF [ #501 EQ 59 ] GOTO3000 (EOB)
GOTO2006(Keep checking)
N3001(A 1 WAS ENTERED)
#801=1
GOTO2007
N3002(A 2 WAS ENTERED)
#802=1
GOTO2007
N3003(A 3 WAS ENTERED)
#803=1
GOTO2007
N3004(A 4 WAS ENTERED)
#804=1
GOTO2007
N3005(A 5 WAS ENTERED)
#805=1
GOTO2007
N3006(A 6 WAS ENTERED)
#806=1
GOTO2007
N3007(A 7 WAS ENTERED)
#807=1
GOTO2007
N3008(A 8 WAS ENTERED)
#808=1
GOTO2007
N3009(A 9 WAS ENTERED)
#809=1
GOTO2007
N2007 G103(LOOK AHEAD RESET TO DEFAULT 15 BLOCK)
IF [ #501 EQ 0=59 ] GOTO3000
GOTO2006
N3000
M99
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
hello bulldozer :)
Quote:
we are not aloud to have a print out of what variable is what op (uncontrolled document)
why is this forbidden ? it sounds like it is not allowed to have a document with extra-information ?!
for some setups that i prepare, i create a document with 2 types of things:
... how to run the setup : program specific inputs, how&when to measure, calibration values, etc
... how to prepare the setup : material, jaw position, hydra pressure, tooling & offsets, axis zeros, etc
Quote:
There is no need to check values since anything other then a 0 will go ahead and drill the hole, which isn't that big of deal with the work we are doing
yup, in this case, maybe anything <>0 will drill something :)
i was sugesting checking for more sensitive inputs; an operator, one day, may input 0.1 instead of 0.01; on many setups, i check operator inputs as default; it is a nice safety feature, against tired and/or less-experienced operators
your code is about boolean behaviours, yes/no,etc : i can handle such things without requesting numerical input, or without generating yes/no questions, but simply with a click or a drag gesture, just like when using a smartphone
maybe it seems too much for drilling, but is good to know what can be done / kindly :)
hi angel :)
Quote:
What he doesn't explain, is how its implemented
at first, is enough to share the idea; details, on request :)
Quote:
Accordingly, passing a Variable commencing with a "0", as in 00110101, may fail, as the control will see the value as 110101
even if the controller will shave the leading zeros, they can still be found by trying to read as many extra digits as you like
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
Quote:
Originally Posted by
deadlykitten
why is this forbidden ? it sounds like it is not allowed to have a document with extra-information ?!
This is customer requirements we have to have all our documents on the floor approved and controlled by our quality department/customer. If we were to have a uncontrolled document on the floor and it is found during a yearly audit we could loose business. We deal mostly with OEM, the products we run across our machines are mainly salvage type processes.
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
yup, i was thinking of something like that
in some places, such 'suportive' documents are a must, and they help a lot with production integration
simply, they link togheter entire production chain, or as many important aspects as possible
machine setup does not matter, as long as final control & quality aspects are checked
however, in other kinds of industries is not allowed to deviate from a specific machine setup
it is up to you to 'oficialize' whatever you believe is necessary, of course, at the most apropiate level :) some places have official low tolerance level, but unoficially some things may be allowed
try to do what you believe that must be done; sometimes is hard to convince someone about some details being necessary; things evolve / kindly :)
Re: USING MACRO/SUBROUTINES TO SELECT BOLT HOLES IN A PROGRAM
Okay, your code is pretty long. I'm not going to replicate what you've done, but I will show how I'd do it. I assume your machine is Fanuc Custom Macro B compatible.
Say I have two concentric bolt circles and I want to fix separate holes in these, just as you said. I know the radius of both and their center is origo. (If it's not, you can G52 your way out of it just ask.)
Say the M12 radius is 60 and the M10 radius is 30. Both have initial hole angle zero. M12 has 15 holes M10 has 5.
We're using parameter format B: meaning A, B, C, I, J, K are allowed. We only use I and J.
This would be an outline of the code off the top of my head (sitting at home.)
%
:0100(M12+10 BOLT CIRCLE FIX)
G16
#101=4 (PARSE THE I VARIABLES. THIS IS THE M12 FIX.)
WHILE[#100LT33]DO1
X60Y[360/15*#[#100]] (RADIUS 60 15 holes)
G81 Z-10 F500 (WHATEVER YOUR FIXING OPERATION IS, INSERT HERE)
G80
#100=#100+3
END1
#100=5
WHILE[#100LT33]DO1 (PARSE THE J VARIABLES FOR THE M10 HOLES.)
X60Y[360/5*#[#100]] (RADIUS 30 5 holes)
G81 Z-10 F500 (WHATEVER YOUR FIXING OPERATION IS, INSERT HERE)
G80
#100=#100+3
END1
M15
M99
%
How to use?
G65 P100 I0 I4 I9 I13 J1 J2 (fixes the m12 holes 0 4 9 and m10 holes 1 and 2.)
Might be some silly error in the above since I don't have any editors here but for what it's worth. Oh and you can't fix more than 10 holes of each this way at one time since you can only have 10 J and 10 K in the command but you could just run it again...