![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| Fanuc Discuss Fanuc controllers here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
I am working on a macro to quickly set Tool Length offsets . The program I have here uses 2 options for A. 1 - records tool lengths from a standard, 2 - sets offsets from part. B is the number of tools. % O99999 (TOOL LENGTH OFFSET MACRO) (SET A EQ 1. TO READ ORIGIN) (SET A EQ 2. TO SET OFFSET) (SET B EQ TO NUMBER OF TOOLS) IF [[ROUND[#1] NE 1] AND [ROUND[#1] NE 2]] GOTO 9101; IF [#2 LE 2] GOTO 9102; IF [ROUND[#1] EQ 1] GOTO 1; IF [ROUND[#1] EQ 2] GOTO 2; N1 #32 = #2; #103 = [#2001]; #101 = 1; WHILE [#32 GT 0] DO1; #[100 + #101] = [ #[2000 + #101]]; <----- gives illegal macro variable #101 = #101 +1; #32 = #32 -1; END1; GOTO 9999; N2 #32 = #2; #103 = #103 - [#2001]; #101 =2; WHILE [#32 GT 0] DO1; #[2000 +#101] = [#[100 + #101] + #103]; #101 = #101 + 1; #32 = #32 -1; END1; GOTO 9999; N9101 #3000 = 101 (EITHER 1 OR 2); N9102 #3000 = 102 (AT LEAST 2 TOOLS); N9999 M99; % I am getting an illegal macro variable reference at the indicated line starting when #101 = 2; Please help. When I use the same program but change it to the 2200 range for wear offset I get no error. |
|
#2
| |||
| |||
| Oops I see it now. Took a bit. #101 = 1 #[100 + #101] = [ #[2000 + #101]]; Resolves to: #[100 + 1] = [#[2000 + 1]]; #101 = #2001 Your counter is now = to the value of #2001 Which this incraments #101 = #101 + 1 You need to replace #101 in the counter loops with say #31 or something Dale |
|
#3
| |||
| |||
| The only thing I thought was that the #101 =1 line is outside of the DO/WHILE Loop. If I change the values to #[100 + 101] = [#[2100+#101]] I get no error. Same with [#[2200+#101]] but those are not the tool length offsets, they are wear offsets.
|
|
#4
| |||
| |||
| ... And I need the variable to remain after power - off. |
|
#5
| |||
| |||
| What model control are you using? I know it won't matter but try removing the brackets. #[100 + #101] = #[2000 + #101] you don't need them anyway. You are sure that you can set the geometry and wear by saying in MDI #2005=1, #2205=1 this changes the offset and wear of tool 5 to 1? You are on a machining center correct?? Stevo Last edited by stevo1; 05-27-2009 at 06:53 AM. Reason: asking machine type |
| Sponsored Links |
|
#6
| |||
| |||
I'm just running this on a HAAS simulator. I can enter the code #2001 = 5; and it sets it with no problem. I did try removing the brackets before. The only weird thing about it is I can use the program as written to do wear offsets. I think I have a calculation issue somewhere. Frustrating but I think I'll get it working sometime today. |
|
#7
| |||
| |||
| James, Depuch was correct with the issue that you are having. You are trying to set a tool offset length to your counter of #101 and it is getting all mugged up. So let’s run it through just 1 round of calculations. We will say that tool 1 offset is 10.3968 and tool 2 offset is 15.645. #101=1 WHILE #[100+#101]=[#[2000+#101]]----#101 is now equal to 10.3968 #101=#101+1----#101 is now equal to 11.3968 then it jumps back to the previous line and trys to set #111.3968 END1 I would use as Depuch suggested #31 or something other than the #100’s. Or you can change your #100 to say #110 as long as you won’t set more than 10 tools. I am a bit confused on exactly what you are trying to accomplish. All I see this program doing is setting variables equal to tool offsets at the N1 and then resetting the tool offsets back equal to the variables in N2. What exactly does this accomplish? Can you not just set your tool length in the geometry and leave it until you change or break a tool? You say you are running this in the Haas simulator? Are you going to be running this in a Haas or a Fanuc control?? Stevo |
|
#8
| |||
| |||
| Yeah, I saw that error also. The idea behind this macro -which was for practice more than anything else - was to record all the tool lengths initially. After they are set by running the macro with A = 1 their initial lengths are referenced. The next step would be to touch off tool # 1 on a workpiece and record the offset in the normal way. Then you run the macro with A=2 and it will reset the remaining tool lengths based on the difference between tool 1's second length minus tool 1's first length. If tool 1 were an indicator for example and all tools were set off a reference point then the macro could be used to accurately and quickly reset offsets when changing out multiple parts. |
|
#9
| |||
| |||
| % O99999 (TOOL LENGTH OFFSET MACRO) (SET A EQ 1. TO READ ORIGIN) (SET A EQ 2. TO SET OFFSET) (SET B EQ TO NUMBER OF TOOLS) IF [[ROUND[#1] NE 1] AND [ROUND[#1] NE 2]] GOTO 9101; IF [ROUND[#2] LT 2] GOTO 9102; IF [ROUND[#1] EQ 1] GOTO 1; IF [ROUND[#1] EQ 2] GOTO 2; N1 #32 = #2; #199 = [#2001]; #101 = 0; #33 =1; WHILE [#32 GT 0] DO1; #[100 + #33] = #[2000 + #33]; #33 = #33 +1; #32 = #32 -1; END1; GOTO 9999; N2 #32 = #2; #199 = [#2001] - #199; #100 =0; #33 = 2; WHILE [#32 GT 0] DO1; #[2000 +#33] = [#[100 + #33] + #199]; #33 = #33 + 1; #32 = #32 -1; END1; GOTO 9999; N9101 #3000 = 101 (EITHER 1 OR 2); N9102 #3000 = 102 (AT LEAST 2 TOOLS); N9999 M99; % There it goes |
|
#11
| |||
| |||
| % O99999 (TOOL LENGTH OFFSET MACRO) (SET A EQ 1. TO READ ORIGIN) (SET A EQ 2. TO SET OFFSET) (SET B EQ TO NUMBER OF TOOLS) IF [[ROUND[#1] NE 1] AND [ROUND[#1] NE 2]] GOTO 9101; IF [ROUND[#2] LT 2] GOTO 9102; IF [ROUND[#1] EQ 1] GOTO 1; IF [ROUND[#1] EQ 2] GOTO 2; N1 #32 = #2; #199 = [#2001]; #101 = 0; #33 =1; WHILE [#32 GT 0] DO1; #[100 + #33] = #[2000 + #33]; #33 = #33 +1; #32 = #32 -1; END1; GOTO 9999; N2 #32 = #2; #198 = #2001 - #199; #100 =0; #33 = 2; WHILE [#32 GT 0] DO1; #[2000 +#33] = #[100 + #33] + #198; #33 = #33 + 1; #32 = #32 -1; END1; GOTO 9999; N9101 #3000 = 101 (EITHER 1 OR 2); N9102 #3000 = 102 (AT LEAST 2 TOOLS); N9999 M99; % that does it... |
|
#12
| |||
| |||
| James, I would be careful of doing it this way. You are always relying on the fact that a tool never needs to be offset again. A lot could potentially go wrong with constantly changing and resetting tool offsets. The easiest practice is to offset your tools to a known position like the table or vise face. Then when changing out parts just put the part height in the work coordinates G54-G59 or program the part height. However if you choose to do it this way I would combine the macro to do everything all at once. What you initially have to do is offset all of your tools then run a quick 1 time macro to store all of the tool offsets in variables #101-?. Now you just re offset tool 1 when setting up a new job into the geometry and run the program below. You could even set it up to use a custom M or G code to call the program. I would set all of the tool lengths not just the ones that you want to use. If you are going to use a macro why not change every tool to fit the part on the machine. O99999(TOOL LENGTH OFFSET MACRO) #30=1---counter for tool offset setting #31=2---counter for variable storage of tool offset #32=[#2001-#101]---difference between new offset of tool 1 and old offset of tool 1 WHILE[#30LT50]DO1---will set 50 tools. change to suit the number of tools you have offsets for #[2000+#31]=#[100+#31]-[#32]---sets new tool geometry to tool 2(tool 1 is already set manually) #[100+#30]=#[2000+#30]---sets variable storage of tool 1 to new offset #30=#30+1 #31=#31+1 END1 M99 I did not test run it. Edit--missed your last post....see you got it to work. Good job!! Stevo Last edited by stevo1; 05-27-2009 at 10:31 AM. Reason: missed latest post |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem- Sinumeric Offset Value macro | sanjeevlj | Mastercam | 3 | 05-06-2009 05:05 AM |
| Changing tool diameter in the tool offset screen | Vern Smith | Haas Mills | 21 | 09-24-2008 09:54 AM |
| Need Help!- tool offset macro | cnc-king | Fanuc | 6 | 09-21-2008 10:43 PM |
| macro program for work offset | cncwhiz | Fanuc | 4 | 12-14-2007 06:28 AM |
| Macro for positive offset | qmas99 | General CAM Discussion | 0 | 02-11-2006 09:37 PM |