CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > Fanuc


Fanuc Discuss Fanuc controllers here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 05-26-2009, 08:51 PM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road
Tool Offset Macro needing an extra set of eyes

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.
Reply With Quote

  #2   Ban this user!
Old 05-26-2009, 10:12 PM
 
Join Date: Feb 2006
Location: United States
Posts: 273
dpuch is on a distinguished road

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
Reply With Quote

  #3   Ban this user!
Old 05-27-2009, 12:16 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road

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.


Originally Posted by dpuch View Post
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
Reply With Quote

  #4   Ban this user!
Old 05-27-2009, 12:18 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road

... And I need the variable to remain after power - off.

Originally Posted by James L View Post
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.
Reply With Quote

  #5   Ban this user!
Old 05-27-2009, 06:51 AM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

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
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 05-27-2009, 08:05 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road
Control

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.
Reply With Quote

  #7   Ban this user!
Old 05-27-2009, 09:04 AM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

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
Reply With Quote

  #8   Ban this user!
Old 05-27-2009, 09:31 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road

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.
Reply With Quote

  #9   Ban this user!
Old 05-27-2009, 10:01 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road

%
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
Reply With Quote

  #10   Ban this user!
Old 05-27-2009, 10:09 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road

and an oops again.. works only for 1 setting. working on an addition to fix that
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 05-27-2009, 10:13 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road

%
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...
Reply With Quote

  #12   Ban this user!
Old 05-27-2009, 10:29 AM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

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
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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




All times are GMT -5. The time now is 09:47 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361