if/while ?

More
15 years 8 months ago #7212 by BigJohnT
Replied by BigJohnT on topic Re:if/while ?
It draws a saw tooth shape.

John

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

More
15 years 8 months ago #7213 by piasdom
Replied by piasdom on topic Re:if/while ?
Thanks for a better example BigJohnT !
but now you threw in "if" and "lt" (guessing "less than")
i understand that "if "this" is "less than" "that" do something.
but i can't see where it(while) knows to move xy or z.
Thanks again !

BigJohnT wrote:

There are quite a few examples in the subroutines section of the do while loop.

Here is one from the ID subroutine.

o100 while [#<Current-Diameter> lt #<Final_Dia>]

O101 if [#<Current-Diameter> + #<Depth_Cut> lt #<Final_Dia>]
#<Current-Diameter> = [#<Current-Diameter> + #<Depth_Cut>]
O101 else
#<Current-Diameter> = #<Final_Dia>
O101 endif

X#<Current-Diameter>
G1 Z#<Z_EndOfCut> F#<FeedRate>
G0 X[#<Current-Diameter>-0.010]
Z#<Z_StartOfCut>
o100 endwhile


John

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

More
15 years 8 months ago #7214 by BigJohnT
Replied by BigJohnT on topic Re:if/while ?
The [a + c + d] the equation inside of the square brackets is evaluated and the result is returned so,

G0 X[3 + 5]

would send the X axis to X8

John

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

More
15 years 8 months ago #7215 by BigJohnT
Replied by BigJohnT on topic Re:if/while ?
Here is the binary operators like LT

www.linuxcnc.org/docview/html/gcode_over...html#sub:Expressions

The basic syntax of a while loop is:

while test is true

do code between while and endwhile

endwhile

So when the while test evaluates to false jump to the endwhile line. and carry on without executing any code between while and endwhile.

John

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

More
15 years 8 months ago #7217 by piasdom
Replied by piasdom on topic Re:if/while ?
i understand the [ ].
it could be G0 x[3+5+9-10] and X would go to 7


BigJohnT wrote:

The [a + c + d] the equation inside of the square brackets is evaluated and the result is returned so,

G0 X[3 + 5]

would send the X axis to X8

John

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

More
15 years 8 months ago #7218 by piasdom
Replied by piasdom on topic Re:if/while ?
i understand #<Current-Diameter> and #<Final_Dia>, they can be whatever you set about.
i don't understand how the "while" knows which to move, xy or z.
and i'll got look at these binaries. thanks for that.


as in this example;
o100 while [#<Current-Diameter> lt #<Final_Dia>]

O101 if [#<Current-Diameter> + #<Depth_Cut> lt #<Final_Dia>]
#<Current-Diameter> = [#<Current-Diameter> + #<Depth_Cut>]
O101 else
#<Current-Diameter> = #<Final_Dia>
O101 endif

X#<Current-Diameter>
G1 Z#<Z_EndOfCut> F#<FeedRate>
G0 X[#<Current-Diameter>-0.010]
Z#<Z_StartOfCut>
o100 endwhile



BigJohnT wrote:

Here is the binary operators like LT

www.linuxcnc.org/docview/html/gcode_over...html#sub:Expressions

The basic syntax of a while loop is:

while test is true

do code between while and endwhile

endwhile

So when the while test evaluates to false jump to the endwhile line. and carry on without executing any code between while and endwhile.

John

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

Time to create page: 0.126 seconds
Powered by Kunena Forum