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 > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 11-04-2009, 02:25 PM
 
Join Date: Jul 2009
Location: USA
Posts: 25
mcmachining is on a distinguished road
Proofreading a Bit of Code

I'm trying to write a simple macro to cut a series of through holes at variable depths based on the number of cycles, basically trying to use all the flutes on my endmill before changing it.

I'm running it on a Haas TM-1P. The maximum depth is .650, the initial depth is .05, and the number of cycles before the step down is 20. #100 is my cycle counter and #101 is my depth variable. Here's the code:

IF [#101 LT 0.05] THEN #101=0.05
#100=#100+1
IF #100=20 THEN #101=#101+0.05
IF #100=20 THEN #100=0
IF [#101 GE 0.650] THEN GOTO 10

...

(This represents the cutting routines)
G13 Z-#101 I0.14 D03 F12.

...

N10
(ALARM MACRO)
#3000=115 (CHANGE TOOL)
M30



Does it look sound or does it need changes?
Reply With Quote

  #2   Ban this user!
Old 11-04-2009, 04:57 PM
 
Join Date: Feb 2006
Location: United States
Posts: 273
dpuch is on a distinguished road

The code and logic look good to me.
Reply With Quote

  #3   Ban this user!
Old 11-04-2009, 10:07 PM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

Wish we had a Haas just so I would know how the code works on that brand. That code wouldn't work on a Fanuc control. It would have to read

IF [#101 LT 0.05] THEN #101=0.05
#100=#100+1
IF [#100EQ20] THEN #101=#101+0.05
IF [#100EQ20] THEN #100=0
IF [#101 GE 0.650] GOTO10
Reply With Quote

  #4   Ban this user!
Old 11-04-2009, 11:39 PM
 
Join Date: Feb 2006
Location: United States
Posts: 273
dpuch is on a distinguished road

wow, that slipped right by me. g-codeguy is right.
[] around if conditions, and EQ instead of = inside them.
Reply With Quote

  #5   Ban this user!
Old 11-04-2009, 11:57 PM
 
Join Date: Feb 2007
Location: USA
Posts: 531
skullworks is on a distinguished road
Exclamation

Also - if .65 is a usable depth you will never cut at .65 as is.

Need to replace the "GE" with "GT".
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 11-05-2009, 06:11 AM
 
Join Date: Jul 2009
Location: USA
Posts: 25
mcmachining is on a distinguished road

Good points.

You're probably right about the syntax for Haas as well. I just cobbled this together out of examples they had in the manual. They do require you to bracket statements using Booolean operators, but in some samples they wrote it simply using "=" in others it was bracketed with "EQ" representing the operator. I suppose I'll find out if the processor doesn't like it when I run it the first time.

And yeah, I shouldn't have used GE in the maximum depth statement. Good call.

Thanks for the feedback fellas.
Reply With Quote

  #7   Ban this user!
Old 11-05-2009, 04:45 PM
Medm's Avatar  
Join Date: Nov 2009
Location: Canada
Posts: 23
Medm is on a distinguished road

I think HAAS uses mostly Fanuc code anyways -with a few alterations.

Don't forget to reset the one common variable at the end, otherwise it could start as 0.65 on the next run -right? Or am I looking at it wrong?

N20 #101=0; ~before the M30.
Reply With Quote

  #8   Ban this user!
Old 11-05-2009, 05:40 PM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

Originally Posted by Medm View Post
I think HAAS uses mostly Fanuc code anyways -with a few alterations.

Don't forget to reset the one common variable at the end, otherwise it could start as 0.65 on the next run -right? Or am I looking at it wrong?

N20 #101=0; ~before the M30.

You are absolutely right. I am guilty of looking at the syntax and not the logic. Good catch.
Reply With Quote

  #9   Ban this user!
Old 11-05-2009, 05:41 PM
 
Join Date: Feb 2006
Location: United States
Posts: 273
dpuch is on a distinguished road

Originally Posted by Medm View Post
Don't forget to reset the one common variable at the end, otherwise it could start as 0.65 on the next run -right? Or am I looking at it wrong?

N20 #101=0; ~before the M30.
You don't generally want to use automatic resets. As it is it will track usage across parts. If he just changed it for the last hole of a part it would still keep the correct count on the next part rather than reset automatically.
Reply With Quote

  #10   Ban this user!
Old 11-05-2009, 07:44 PM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

Originally Posted by dpuch View Post
You don't generally want to use automatic resets. As it is it will track usage across parts. If he just changed it for the last hole of a part it would still keep the correct count on the next part rather than reset automatically.
I'm not following you. Maybe because I am so tired I can't think straight. I'm not familiar with mills. On our lathes if it machined 20 holes to .650 depth, and then alarmed, another operation or 2 or whatever was run, and then came back to this operation on the next part, the #101 would still read .650 unless the machine had been powered off.

What am I missing?
Reply With Quote

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

Medm was suggesting to automatically reset #101 (effectively the life counter) at the end of the program. Thus you lose track of the tool usage at the end of each cycle. Even if my tool SHOULD always end it's life at the end of the program, I would not automatically reset it. That just means if they forget to change the tool it will NOT alarm, and produce bad parts and/or break.
Reply With Quote

  #12   Ban this user!
Old 11-05-2009, 09:36 PM
Medm's Avatar  
Join Date: Nov 2009
Location: Canada
Posts: 23
Medm is on a distinguished road

If you properly examine the code, the variable #101 is not the life counter. That is variable #100 -which is reset in the line;

IF [#100EQ20] THEN #100=0


The role of #101 is to change the 'Z' depth. If it is not reset, you will eventually run into a situation where the 'Z' is beyond the usable flute length and therefore a potential crash situation.
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
Need Help!- My Milling OKK with fanuc 6M can't recognize G-code & M-code nessei Fanuc 4 03-29-2011 08:39 AM
Newbie- Takeout Unused G Code commands in Mastercams Generated G Code shneek Mastercam 8 12-15-2010 02:32 PM
learning g code or cad-cam code output? slow_rider G-Code Programing 3 02-27-2010 08:48 PM
Need Help!- G-Code viewing source code Hussam Visual Basic 3 03-15-2009 12:15 PM
looking for g code 3d from bobcadcam or simmilar for indexer lpt v5 with g code soft troyswood Ability Systems - LPT Indexer and G-Code 2 12-24-2006 09:21 PM




All times are GMT -5. The time now is 12:23 AM.





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