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 > Parametric Programing


Parametric Programing (custom macro b, fadal macro, okuma user task)


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 06-23-2009, 08:01 AM
 
Join Date: Jan 2009
Location: USA
Posts: 39
ggborgen is on a distinguished road
Using an IF statement inside a While looping

Gentlemen
I was wondering if I can put a IF conditional branching statement inside a While looping statement. The reason I want to do this is to make sure my radius in my tornado macro does not be come a negitive value. I wanted to fire an alarm if the radius got to small.

WHILE[#101LE#110]DO1
*****
*****
*****
*****
IF[#18LE.025]GOTO50
END1

N50
#3000=101(RADIUS TO SMALL)
Reply With Quote

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

You sure can. I do this all the time. When I write loops there is usually a pick size and a depth of some sort specified by the operator. The pick and the depth are not always divisible so I have an IF statement to set it equal to the final depth if it exceeds with the stack of the pick. Then it will end the loop. If it permits then set it up so if the next pass is going to be a negative radius number have it set itself to the minimum radius you specify, using the THEN statement.

A simple facing program from OD to ID
#1=0(Z-START)
#2=.354(FINAL DEPTH)
#3=.03(PICK SIZE)
#4=60(OD DIAMETER)
#5=59(ID DIAMETER)
G0G90G55X#4Z3.M4
WHILE[#1LT#2]DO1
#1=#1+#3
IF[#1GE#2]THEN#1=#2
G0Z-#1
G1X#5
G0U.025W.025
X#4M9
END1

Stevo
Reply With Quote

  #3   Ban this user!
Old 06-23-2009, 11:30 AM
 
Join Date: Jan 2009
Location: USA
Posts: 39
ggborgen is on a distinguished road

Stevo
Thanks for thr replie,but with your example you are not jumping out of the loop like I am and I could use a THEN statement if my control will let me. By the way it's a pro5 makino sorry about not tell you guys before. So I guess my question is can I jump out of the loop to fire an alarm?
Reply With Quote

  #4   Ban this user!
Old 06-23-2009, 11:41 AM
beege's Avatar  
Join Date: Feb 2008
Location: USA
Posts: 518
beege is on a distinguished road

Originally Posted by ggborgen View Post
Gentlemen
I was wondering if I can put a IF conditional branching statement inside a While looping statement. The reason I want to do this is to make sure my radius in my tornado macro does not be come a negitive value. I wanted to fire an alarm if the radius got to small.

WHILE[#101LE#110]DO1
*****
*****
*****
*****
IF[#18LE.025]GOTO50
END1

N50
#3000=101(RADIUS TO SMALL)
I would think a nested WHILE/DO loop would suit.
Where:
WHILE[#18LE.025]DO1
would start the whole thing off? (I don't program many macros, but this might inspire a better answer).
D
Reply With Quote

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

Beege,
That's a good idea, it will depend on what he is actually trying to acheive.

ggborgen,
The only way you are going to know is to try it. Do a simple WHILE loop moving the machine in incremental but cut in with the GOTO statement before the WHILE is satisfied.

#1=0
WHILE[#1LT5]DO1
G0G91X1.
#1=#1+1
IF[#1EQ3]GOTO100
END1
N100M30

If your machine incrementally moves 5” then it never jumped out. If it moved 3” and the program ended then it jumped out of the loop with the IF statement.

You don't need to actually move the machine. You could use a dwell or something if you wanted. Or just use variables to count +1 and compare values.

Stevo
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-23-2009, 12:11 PM
beege's Avatar  
Join Date: Feb 2008
Location: USA
Posts: 518
beege is on a distinguished road

Originally Posted by stevo1 View Post
Beege,
That's a good idea, it will depend on what he is actually trying to acheive.

ggborgen,
The only way you are going to know is to try it. Do a simple WHILE loop moving the machine in incremental but cut in with the GOTO statement before the WHILE is satisfied.

#1=0
WHILE[#1LT5]DO1
G0G91X1.
#1=#1+1
IF[#1EQ3]GOTO100
END1
N100M30

If your machine incrementally moves 5” then it never jumped out. If it moved 3” and the program ended then it jumped out of the loop with the IF statement.

You don't need to actually move the machine. You could use a dwell or something if you wanted. Or just use variables to count +1 and compare values.

Stevo
Is the control going to look for the END1 after the IF jumps you out of the loop?

Last edited by beege; 06-23-2009 at 12:13 PM. Reason: Reword query
Reply With Quote

  #7   Ban this user!
Old 06-23-2009, 12:40 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

Originally Posted by beege View Post
Is the control going to look for the END1 after the IF jumps you out of the loop?
Beege,

If the WHILE statement gets satisfied meaning it never jumps out of the loop with the IF statement then it just goes to the next block proceeding the END1 which is a M30. If the IF statement works and it jumps out of the loop it will go to N100 which is a M30.

WHILE statements only run between the WHILE and the END until the WHILE block is satisfied. Anything outside of that does not matter. Once it has left the loop it will not go back to it or care about any of its conditions unless you specify to return to it with a GOTO. To answer your question no it is not going to look for the END1. Good question...you are making me think for the first time today.

I have jumped out of loops before conditions were met and don't recall any problems but for 99% of the time I use THEN conditions when in a loop as wrote in post2.

This works on any machines I have worked on. Mainly Fanucs. It's macro programming so I see no reason why it should not work in this control.

IIRC with the Fanucs you can have up to 3 WHILE statements within 1.

Stevo
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
Is this a valid statement...IF[#19NE1]OR[#13NE1]GOTO3000?? theemudracer Fanuc 104 02-24-2009 08:18 AM
LOOPING? with Camsoft?? nelZ CamSoft Products 15 10-15-2008 03:56 PM
Need Help!- Fanuc O-T looping cycle Billet Sean General Metalwork Discussion 5 04-28-2008 02:11 PM
Program Looping Bohemund CamSoft Products 7 05-26-2007 11:08 AM
Sub Looping murphyspost Daewoo/Doosan 8 12-27-2006 10:28 AM




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