if/while ?

More
18 Aug 2011 12:06 #12577 by piasdom
Replied by piasdom on topic Re:if/while ?
can i get z to move up(from present depth) .1" and move to another position and start
another cut ? like z at -.4.... move z up .1"(-.3").....move to new position.... z-.5. or
do i need a script or mcode ?


o100 if [#<fin_depth> lt #<depth_of_cut>]
z[.1/1]
o100 else
z#<_safeheight>
o100 endif
g0 x.1 y-.1

Thanks
kenneth

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

More
18 Aug 2011 13:37 #12580 by andypugh
Replied by andypugh on topic Re:if/while ?
piasdom wrote:

can i get z to move up(from present depth) .1" and move to another position and start
another cut ? like z at -.4.... move z up .1"(-.3").....move to new position.... z-.5.

Yes.

o100 if [#<fin_depth> lt #<depth_of_cut>]
z[.1/1]
o100 else
z#<_safeheight>
o100 endif
g0 x.1 y-.1

You probably need to learn to program in a real programming language, and not G-code. But, this is how I do what I think you want to do.
#<safeheight> = 2
#<startdepth> = 1
#<fin_depth> = 0.5
#<cut> = 0.1

#1 = #<startdepth> Note the use of #1 as a "working" variable to hold current_Z

O100 WHILE [#1 GT #<fin_depth>]
    G0 Z #1
    #1 = [#1 - #<cut>]
    O101 IF [#1 < #<fin_depth>] ; allow for the last cut being less than <cut> above <fin>
        #1 = #<fin_depth>
    O101 ENDIF
    G1 Z#1
   ....
    Various G-code moves go here
    ....
O101 ENDWHILE

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

More
18 Aug 2011 14:53 #12586 by piasdom
Replied by piasdom on topic Re:if/while ?
won't this make the end mill go down with each run ? i want the end mill to
come up from current position(-.4 to -.3") - move to new position(x.1 y.1) - go down .1" from
last current position(-.5).

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

More
18 Aug 2011 15:18 #12589 by andypugh
Replied by andypugh on topic Re:if/while ?
piasdom wrote:

won't this make the end mill go down with each run ? i want the end mill to
come up from current position(-.4 to -.3") - move to new position(x.1 y.1) - go down .1" from
last current position(-.5).


Why do you need an "if" then?

I really don't get what you are trying to achieve, but you probably need to use a variable for Z (like I did with #1), and keep modifying that before you use it.

#1 = 0.4
G1 Z#1
...some moves...
G0 z -0.3
G0 X0.1 Y0.1
#1 = [#1 - 0.1]
G0 Z#1
...

I still don't understand what you are wanting to do, though.

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

More
18 Aug 2011 15:32 #12591 by piasdom
Replied by piasdom on topic Re:if/while ?
i didn't know which to use ... if ....do ... else.. whoever don't even know if possible
i'm cutting pockets and i don't want the end mill moving along the bottom
as it goes to the next depth. that's it, want to to come up .1" from whatever depth,
move to x.1 y.1 and go deeper .1".

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

More
18 Aug 2011 15:49 #12592 by andypugh
Replied by andypugh on topic Re:if/while ?
piasdom wrote:

i didn't know which to use ... if ....do ... else.. whoever don't even know if possible
i'm cutting pockets and i don't want the end mill moving along the bottom
as it goes to the next depth. that's it, want to to come up .1" from whatever depth,
move to x.1 y.1 and go deeper .1".


So, you want to do it every time? In that case, there is no need for any logic structure at all. Inserted into my code it is just

O100 WHILE [#1 GT #<fin_depth>]
G0 Z #1
#1 = [#1 - #<cut>]
O101 IF [#1 < #<fin_depth>] ; allow for the last cut being less than <cut> above <fin>
#1 = #<fin_depth>
O101 ENDIF
G1 Z#1
....
Various G-code moves go here
....
G0 Z[#1 + 0.1]
O101 ENDWHILE

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

More
18 Aug 2011 17:55 #12601 by piasdom
Replied by piasdom on topic Re:if/while ?
Thanks andy !
but i'm not very clear, i'm sorry. i had that before and it works great for what i wanted then.
now i cutting a pocket -.941 deep with a step at -.866. i make a rough cut along the inside edge
(about .02" away from fin) at -.1. then i go to -.2 and do the same. THEN i want to clean center.
so i thought there may be 'something' i could use every .2. i clean from out to inside, so the end mill
ends up at the center. i wanted something(if possible) to put every .2 deep that would raise the end mill .1
from where it's at then move to x.1 y.1, go another -.1 and then start .1(would be -.3) then .2 (-.4) then clean again.


Thanks !
kenneth

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

More
18 Aug 2011 21:26 #12602 by BigJohnT
Replied by BigJohnT on topic Re:if/while ?
You just have to program what you want. You can use subroutine for your clean center part just program your tool to be in the correct position then call your subroutine.

o100 sub
lots of code to cut the center out
o100 endsub

code to cut the outside of the box

code to put the cutter in the correct position for XY&Z

o100 call

code to put the cutter in the correct position for XY&Z

o100 call

repeat for each level

M2

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

More
19 Aug 2011 00:55 #12605 by piasdom
Replied by piasdom on topic Re:if/while ?
Thanks BigJohnT and andy,
that's what i've been doing, just thought there was a command,script or something that
would do that. i'll keep what i have.

Thanks
kenneth

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

More
01 Mar 2012 15:35 - 01 Mar 2012 15:40 #18236 by piasdom
Replied by piasdom on topic Re:if/while ?
shouldn't this work ?
been trying if/else and do/while. but to me this should work.
it only goes to 1" then 0". and stops. i think it should go to 1"
then 0", then 2" then 0 ....etc. to 6". and i tried all
the operators. most freezes emc2.5.

g17 g20 g40 g49 g54 g80 g90 g94 g92.1

#<start> = 2
#<travel_ing> = 1
#<final_distant> = 6
#<feed_rate> = 18

o100 do
#<start> = [#<start> - #<travel_ing>]
g1 f#<feed_rate> x#<start>
x0

o100 while [#<start> ge #<final_distant>]

m2

Thanks for looking.
kenneth
Last edit: 01 Mar 2012 15:40 by piasdom.

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

Time to create page: 0.255 seconds
Powered by Kunena Forum