if/while ?

More
15 years 8 months ago #7219 by BigJohnT
Replied by BigJohnT on topic Re:if/while ?
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.

More
15 years 8 months ago #7220 by piasdom
Replied by piasdom on topic Re:if/while ?
Thanks for ya'll time.

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.

More
15 years 8 months ago - 15 years 8 months ago #7221 by andypugh
Replied by andypugh on topic Re:if/while ?
piasdom wrote:

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)?

Exactly.

but no idea what [#2 GT #1]
i'm guessing GT is GoTo. what does the While ? xy or z?

No, GT means "Is Greater Than"
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.
Last edit: 15 years 8 months ago by andypugh.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago - 15 years 8 months ago #7222 by piasdom
Replied by piasdom on topic Re:if/while ?
well, i ran this. had to change <> to () at end to be able to run.
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
Last edit: 15 years 8 months ago by piasdom.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #7223 by andypugh
Replied by andypugh on topic Re:if/while ?
piasdom wrote:

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.

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 ?

Not the way it is written. I think that is my mistake, you need #1 = -0.4

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #7415 by piasdom
Replied by piasdom on topic Re:if/while ?
why does the first "do" go to a depth of .065 instead of #1 = -.06
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.

Time to create page: 0.146 seconds
Powered by Kunena Forum