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 06-03-2011, 04:45 PM
 
Join Date: Mar 2010
Location: USA
Posts: 12
CNC_Monkey is on a distinguished road
What am I missing?

I am working on a macro to drill holes. My problem (with this macro) is that it drills holes twice when it moves in a different axis. The code is below.

I would appreciate any advice I can get on solving this problem.

Thanks in advance,

James

%
O9517(PERF AND GROOVE CALL)
(V1.00.000)

(TRANSLATE)
#106=#105 (Y GROOVE SPACING)
#101=#105 (HOLE X START)
#102=#105 (HOLE Y START)
#1=[#105*4] (PERF SPACING X)
#2=[#106*3] (PERF SPACING Y)

(ERROR)
IF [#124 GT 120] GOTO 300 (TOO LARGE X)
IF [#125 GT 60] GOTO 300 (TOO LARGE Y)
IF [#126 GT 5] GOTO 300 (TOO LARGE Z)
IF [#124 LT .75] GOTO 301 (TOO SMALL X)
IF [#125 LT .75] GOTO 301 (TOO SMALL Y)
IF [#126 LT .125] GOTO 301 (TOO SMALL Y)
GOTO 31

N300#3000=3 (MATL TOO LARGE)
N301#3000=17 (MATL TOO SMALL)

(MATERIAL TYPE)
N31IF [#103 EQ 999] GOTO 53 (BROKEN DRILL)
N32IF [#103 LT 2] GOTO 150
N33#3000=1 (ERROR)

(N31IF [#123 EQ 10] GOTO (A500 FOAM)(FOR FUTURE USE)
(N32IF [#123 EQ 20] GOTO (20# HD FOAM)
(N33IF [#123 EQ 30] GOTO (30# HD FOAM)
(N40IF [#123 LT 10] GOTO 42)
(N41IF [#123 GT 20] GOTO 42)
(N42#3000=16 (MATERIAL NOT RECOGNIZED)


(BROKEN DRILL)
N53#3006=1(RECOVER FROM BROKEN TOOL?)
(N54#1=[#105*3] (PERF SPACING X)
(N55#2=[#105*4] (PERF SPACING Y)(CAN THIS BE CHANGED?????????TO SCALE)
(N56#107=600. (GROOVE FEED)
(N57#109=16000 (GROOVE SPEED)
(N58#108=150. (DRILL FEED)
(N59#111=3600 (DRILL SPEED)
N60#101=#500 (STORED X POSITION)
N61#102=#501 (STORED Y POSITION)
N62GOTO 150

N150IF [#103 EQ 0] GOTO 31

(2MM_DRILL.)
G28G91Z0M05
G90T2009M06
T102
G90G0G17G55X[#101]Y[#102]M03S3600
#500=#101
#501=#102
G0G43H9Z[#126+.25]

N1WHILE [#101 LT [#124-#1]] DO 1 (X POSITION LESS THAN MATERIAL SIZE)

N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
G1Z0.F150.
Z[#126+.25]F3150.
#102=[#102+#2]
IF[#102 GE [#125-#2]]GOTO 2
#501=#102
Y[#102]
END 2 (END ASCENDING Y HOLES)

IF [#101 GE [#124-#1]] GOTO 1
#101=[#101+#1]
G1X[#101]F3150.
#500=#101

N3WHILE [#102 GE #2] DO 3 (Y POSITION GREATER THAN Y START)
IF[#102 LE #2]GOTO 3
G1Z0.F150.
Z[#126+.25]F3150.
#102=[#102-#2]
IF[#102 LE #2]GOTO 3
#501=#102
Y[#102]
END 3 (END DESCENDING Y HOLES)

IF [#101 GE [#124-#1]] GOTO 1
#101=[#101+#1]
G1X[#101]F3150.
#500=#101
N100END 1

N500G28G91Z0M5
N505G90

N1250M99
%
Reply With Quote

  #2   Ban this user!
Old 06-04-2011, 07:20 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

Post your drawing and indicate where the problem is.
Are you sure that this program is otherwise OK?
Reply With Quote

  #3   Ban this user!
Old 06-04-2011, 05:05 PM
 
Join Date: Mar 2010
Location: USA
Posts: 12
CNC_Monkey is on a distinguished road
RE: What am I missing?

Sinha,

There is no drawing. The program is designed to drill a "Grid" of holes with variable spacing based on grooves in the nmaterial to be drilled. The program works as I intend as far as the math is concerned. The issue is in the code here:
N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
G1Z0.F150.
Z[#126+.25]F3150. (it drills the first hole in the Y axis series twice then moves on drilling each hole once and incrementing as i expect.)
#102=[#102+#2]
IF[#102 GE [#125-#2]]GOTO 2
#501=#102
Y[#102]
END 2 (END ASCENDING Y HOLES)

IF [#101 GE [#124-#1]] GOTO 1
#101=[#101+#1]
G1X[#101]F3150.
#500=#101
(when the code reaches this point and moves in the Y Axis, it drills the first hole in the row twice.)
Reply With Quote

  #4   Ban this user!
Old 06-05-2011, 10:29 AM
 
Join Date: Feb 2009
Location: Engerland
Posts: 22
jay4389 is on a distinguished road

I think you need to tell us what #155,#124,#125#126 ect are set to 1st.
They are not being written at the start of thev program
Reply With Quote

  #5   Ban this user!
Old 06-05-2011, 12:15 PM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

Programming relatively simple parts on lathes, I don't nest WHILE statements. I looked up the format. Your program doesn't meet the format. This is for a Fanuc lathe control. Are you running a Fanuc? Do Fanuc mills have a different format than lathes? Normally I'd say "No".

Format is

WHILE[....]DO1
WHILE[....]DO2
WHILE[....]DO3
END3
END2
END1

Could this be part of the problem?

I think Jay meant #105 instead of #155. I personally don't need to know those values to understand the program (somewhat ) However #103 has me confused. Seems to me it has to equal 1 or the program will run in a continuous loop.

Looks to me like the only way the program will read blocks N60 thru N63 is if #103 is between 3-998 and you push RESET & CYCLE START a couple times to get past the block N33 and N53 alarm messages. In less, of course, you manually call block N60 up from the control.

I also have a question on the use of IF statements within the WHILE statement, but will study the program a bit more first. Maybe I can avoid showing my ignorance.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-05-2011, 04:35 PM
 
Join Date: Feb 2009
Location: Engerland
Posts: 22
jay4389 is on a distinguished road

Hi g-codeguy / cnc monkey

It could be me (or the glass of red wine i have had) but i can not make headway through this part of the program to see why it doubles drills the 1st hole without needing to know the value of some #variables ie #102, #105

N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
G1Z0.F150.
Z[#126+.25]F3150.
#102=[#102+#2]
IF[#102 GE [#125-#2]]GOTO 2
#501=#102
Y[#102]
END 2 (END ASCENDING Y HOLES)

I willm have another look tomorrow, with a clearer head.
Reply With Quote

  #7   Ban this user!
Old 06-05-2011, 09:21 PM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

Well, Jay, I don't drink so I can't use that as an excuse!


Would this work? My 1st attempt at nesting WHILE statements, so please be gentle with me.

WHILE[#101LT[#124+#2]]DO1

WHILE[#102LE[#125-#2]]DO2
G1Z0F150.
Z[#126+.25]F3150.
#102=#102+#2
#500=#102
Y#102
END2

#101=#101+#1
#500=#101
X#101

WHILE[#102GE#2]DO3
Z0F150.
Z[#126+.25]F3150.
#102=#102-#2
#501=#102
Y#102
END3

#101=#101+#1
#500=#101
X#101
END1

Can I use the excuse that it is late, and I'm pretty tired. Working 2 jobs keeps me that way.

EDIT: Actually I would move the G1 to a block in front of the 1st WHILE statement. That way it would always be active no matter where the program started should it be interrupted before finishing the part. I'm always looking for the least amount of typing on my part

Last edited by g-codeguy; 06-06-2011 at 05:00 AM.
Reply With Quote

  #8   Ban this user!
Old 06-06-2011, 07:20 AM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

If I'm thinking correctly, the addition of another variable is necessary. Naturally I don't know if this would work since I've never nested WHILE statements.

G1
WHILE[#101LT[#124+#2]]DO1
IF[#502EQ2]GOTO2
IF[#502EQ3]GOTO3

N2WHILE[#102LE[#125-#2]]DO2
#502=2
Z0F150.
Z[#126+.25]F3150.
#102=#102+#2
#500=#102
Y#102
END2

#101=#101+#1
#500=#101
X#101

N3WHILE[#102GE#2]DO3
#502=3
Z0F150.
Z[#126+.25]F3150.
#102=#102-#2
#501=#102
Y#102
END3

#101=#101+#1
#500=#101
X#101
END1
Reply With Quote

  #9   Ban this user!
Old 06-06-2011, 09:57 AM
 
Join Date: Mar 2010
Location: USA
Posts: 12
CNC_Monkey is on a distinguished road
RE: What am I missing?

Thanks for all of the help so far. To fill in some of the gaps I left...

We are using a FANUC 210i control.

The goal of this program is to drill holes in a grid pattern. First it incrments the X material size (DO1), then it increments the Y material size and starts driling in Y positive (DO2) when it hits the end in Y positive it increments X and drills Y negative (DO3), Since there is still X material remeing to be drilled, it steps off an increment in X and starts (DO2) and (DO3) again.

Here are the missing variables:

%
:1234(CALL MACRO)
G00G17G20G40G64G80G90
G0G28G91Z0M5
G49G90
G52X0Y0Z0
G08P1

(MATERIAL SIZE X)#124=40. (120.00 LIMIT)
(MATERIAL SIZE Y)#125=20. (60.00 LIMIT)
(MATERIAL SIZE Z)#126=2.0 (6.00 LIMIT)

(MATERIAL TYPE)#123=10 (CURRENTLY DISSABLED)
(MATERIAL TYPE: A500=10, 20LB.HD FOAM=20, 30LB.HD FOAM=30)

(DRILL ON)#103=1 (DRILLS ON=1, DRILLS OFF=0, BROKEN TOOL RESUME PROGRAM=999)
(GROOVE ON)#104=1 (GROOVE ON=1, GROOVE OFF=0)

(SPACING)#105=1. (DISTANCE BETWEEN CENTER OF GROOVES)
(ASSUMES EQUAL DISTANCE X AND Y)


N10G65P9517 (MACRO CALL)




N118G90G52X0Y0Z0
N119G08P0
N120G00G28G91Z0M05
N121G28G91X0
N122 G90
N123M30
%
Reply With Quote

  #10   Ban this user!
Old 06-06-2011, 12:55 PM
 
Join Date: May 2007
Location: USA
Posts: 913
g-codeguy is on a distinguished road

cnc, how much trouble would it be to test (in air) my sample? I added #502 variable so you could start in the middle of the job, and it would still move in the right direction for the next hole.

I'm interested in knowing if it'll work, but have no place to test it out. Yes, we have mills, but they are always behind schedule even if I could talk the foreman into trying this program.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 06-06-2011, 01:30 PM
 
Join Date: Mar 2010
Location: USA
Posts: 12
CNC_Monkey is on a distinguished road
RE: What am I missing.

g-code,

I ran the test.

The code only moves in X, it doesn't drill or move in Y.

James
Reply With Quote

  #12   Ban this user!
Old 06-06-2011, 02:30 PM
 
Join Date: Mar 2010
Location: USA
Posts: 12
CNC_Monkey is on a distinguished road
RE: What am I missing?

The problem seems to be in the IF statement. If I remove it, I get an extra hole in the Y axis because of the command Y[#102]. (That's why I added it to the fisrt place...) Can anyone think of a way to check to see if incrementing the counter pushes me over the material boundaries? (#102=[#102+#2])

Thanks in advance.

James


N2WHILE [#102 LE [#125-#2]] DO 2 (Y POSITION LESS THAN MATERIAL SIZE)
G1Z0.F150.
Z[#126+.25]F3150.
#102=[#102+#2]
IF[#102 GE [#125-#2]]GOTO 2
#501=#102
Y[#102]
N20END 2 (END ASCENDING Y HOLES)
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!- all missing istotel Fanuc 2 01-21-2010 03:17 AM
Need Help!- X3: Missing V in my VFD imprez55 Benchtop Machines 0 01-02-2010 08:02 PM
Newbie- SX3 Missing BlueFin Syil Products 2 04-14-2008 01:05 PM
Missing .DLL??? CyborgCNC Surfcam 6 05-25-2007 12:41 PM
Am i missing anything here? phantomcow2 General Electronics Discussion 7 08-11-2005 10:36 PM




All times are GMT -5. The time now is 07:57 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