- Posts: 3981
- Thank you received: 994
if/while ?
- BigJohnT
- Offline
- Administrator
-
John
Please Log in or Create an account to join the conversation.
- piasdom
- Offline
- Banned
-
- Posts: 145
- Thank you received: 9
BigJohnT wrote:
All the "while" knows is to execute what ever code you have between the while/endwhile or to skip the code between the while/endwhile.
John
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
-
- Posts: 19899
- Thank you received: 4655
Exactly.thanks andypugh, but i can't figure out what goes in the [ ].
i understand #2 = [#2 - #3] equaling -.01, so it would move down .01 each pass(or run of code)?
No, GT means "Is Greater Than"but no idea what [#2 GT #1]
i'm guessing GT is GoTo. what does the While ? xy or z?
So, that loop which I wrote out carries on looping between the DO and the WHILE as long as #3 (a variable) hasn't hit the limit depth stored in #1
The two O100 codes indicate that the DO and the WHILE are a pair. They could be any number, but it seems traditional to use O100, O101 and so on.
DO / WHILE always runs once, and then runs again if the conditional statement in the brackets after the WHILE is true. There is an alternative form, WHILE / ENDWHILE which checks first, and can run zero times.
Other bits of G-code between the DO and WHILE or the WHILE and ENDWHILE alter the variables and use them to set the Z depth, or anything else. All the loop does is repeat a block of code "while" a condition is true.
Please Log in or Create an account to join the conversation.
- piasdom
- Offline
- Banned
-
- Posts: 145
- Thank you received: 9
it ran but only once at z-.1, which is right.
but shouldn't it have ran till Z got to -.4
cutting the square at each level of .1 ,.2, .3 and .4 ?
#1 = .4
#2 = 0
#3 = 0.1
O100 DO
#2 = [#2 - #3]
G1 f20 Z#2
x1
y1
x0
y0
O100 WHILE [#2 GT #1]
(finishing pass at Z = #1) this was <finishing pass at Z = #1>, but got an error.
figured out i needed to change .4 to -.4 ....... works THANKS
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
-
- Posts: 19899
- Thank you received: 4655
well, i ran this. had to change <> to () at end to be able to run.
Ah, well, you see, the stuff I put in <> characters was meant to indicate where the actual G-code to do the machining was meant to go, I rather assumed you already had that written.
Not the way it is written. I think that is my mistake, you need #1 = -0.4it ran but only once at z-.1, which is right.
but shouldn't it have ran till Z got to -.4
cutting the square at each level of .1 ,.2, .3 and .4 ?
Please Log in or Create an account to join the conversation.
- piasdom
- Offline
- Banned
-
- Posts: 145
- Thank you received: 9
and the second goes to .04" as it should ? i've ran it three times and it goes to .065".
as far as i can see, they are only different by the depth. #1 & #4. Thanks
%
g17 g20 g40 g49 g54 g80 g90 g94 g92.1
#1 = -.06
#2 = 0
#3 = .005
#4 = -.04
#5 = 0
#6 = .005
g0 z.2
O100 DO
#2 = [#2 - #3]
G1 f6 Z#2
x-1
y-1
x0
y0
O100 WHILE [#2 GT #1]
g0 z.2
x-2
O101 DO
#5 = [#5 - #6]
G1 f6 Z#5
x-3
y-1
x-2
y0
O101 WHILE [#5 GT #4]
g0 z3.4
x0 y0
m2
%
Please Log in or Create an account to join the conversation.