calling subroutines

More
07 Mar 2023 23:01 #266083 by foam man
calling subroutines was created by foam man
Hi
I am writing my own code with variables and would like to call up different programs in a certain sequence. I have read the subroutine calling page in one of the linux guides but can not seem to grasp it. I am wondering if someone can show me an example. or if someone could show me on the 2 examples included here. thanks


( THIS WILL MAKE 1 RECTANGLE WITH 2x1.5" HOLES )


#<1width>=20.96875          ( ENTER WIDTH OF RECTANGLE #1 )
#<1height>=5.46875     ( ENTER HEIGHT OF RECTANGLE #1 )
#<startpoint>= 7      ( absolute Y&A point where wire will start cutting )

#<wire>=0.0625        ( ENTER OF WIRE CUT )
#<lspace>=0.25           ( ENTER LATERAL WIRE MOVE BEFORE CUT )

( DON'T MODIFY ANY NUMBERS BELOW THIS LINE )
   
G90
G4 P2
G1 X 1.75   Z 1.75   f100
G1 Y #<startpoint>                       A  #<startpoint>
G1 X 0   Z 0   f35
G91

G1 X- #<lspace>               Z- #<lspace>
G1 Y [#<1height>+#<wire>]                     A [#<1height>+#<wire>]
G1 X-[#<1width>/4]                            Z-[#<1width>/4]
G1 Y- [[#<1height>/2]-0.71875]          A- [[#<1height>/2]-0.71875]
g1 x-.11735  Z- .11735  f35
g1 x- .2232  Y- .0725   Z- .2232   A- .0725
g1 x- .1898  y- .1379   Z- .1898   A- .1379
g1 x-.1379   y- .1898   Z- .1379   A- .1898
g1 x- .0725  y- .2232   Z- .0725   A- .2232
g1 y- .2347  A- .2347
g1 x .0725   y- .2232   Z .0725    A- .2232
g1 x .1379   y- .1898   Z .1379    A- .1898
g1 x .1898   y- .1379   Z .1898    A- .1379
g1 x .2232   y- .0725   Z .2232    A- .0725   
g1 x .2347   Z  .2347
g1 x .2232   y  .0725   Z .2232    A .0725
g1 x .1898   y  .1379   Z .1898    A .1379
g1 x .1379   y  .1898   Z .1379    A .1898
g1 x .0725   y  .2232   Z .0725    A .2232
g1 y .2347   A  .2347
g1 x- .0725  y  .2232   Z- .0725   A .2232
g1 x- .1379  Y  .1898   Z- .1379   A .1898
g1 x- .1898  y  .1379   Z- .1898   A .1379
g1 x- .2232  y  .0725   Z- .2232   A .0725
g1 x- .11735 Z- .11735
G1 Y [[#<1height>/2]-0.71875]         A [[#<1height>/2]-0.71875]

G1 X-[#<1width>/4*2]                        Z-[#<1width>/4*2]
G1 Y- [[#<1height>/2]-0.71875]       A- [[#<1height>/2]-0.71875]
g1 x-.11735  Z- .11735  f35
g1 x- .2232  Y- .0725   Z- .2232   A- .0725
g1 x- .1898  y- .1379   Z- .1898   A- .1379
g1 x-.1379   y- .1898   Z- .1379   A- .1898
g1 x- .0725  y- .2232   Z- .0725   A- .2232
g1 y- .2347  A- .2347
g1 x .0725   y- .2232   Z .0725    A- .2232
g1 x .1379   y- .1898   Z .1379    A- .1898
g1 x .1898   y- .1379   Z .1898    A- .1379
g1 x .2232   y- .0725   Z .2232    A- .0725   
g1 x .2347   Z  .2347
g1 x .2232   y  .0725   Z .2232    A .0725
g1 x .1898   y  .1379   Z .1898    A .1379
g1 x .1379   y  .1898   Z .1379    A .1898
g1 x .0725   y  .2232   Z .0725    A .2232
g1 y .2347   A  .2347
g1 x- .0725  y  .2232   Z- .0725   A .2232
g1 x- .1379  Y  .1898   Z- .1379   A .1898
g1 x- .1898  y  .1379   Z- .1898   A .1379
g1 x- .2232  y  .0725   Z- .2232   A .0725
g1 x- .11735 Z- .11735
G1 Y [[#<1height>/2]-0.71875]          A  [[#<1height>/2]-0.71875]
G1 X- [[#<1width>/4]+#<wire>]                 Z- [[#<1width>/4]+#<wire>]
G1 Y- [#<1height>+#<wire>]                    A- [#<1height>+#<wire>]
G1 X [#<1width>+#<wire>]                      Z  [#<1width>+#<wire>]


G90 
G1 X 0.25 Z 0.25          
m2








( 2 RECTANGLES ANY SIZE. #1, 2- 1.5" HOLES,  #2, 1- 1.5" HOLE )



#<1width>=30          ( ENTER WIDTH OF RECTANGLE #1 )
#<1height>=5.4375     ( ENTER HEIGHT OF RECTANGLE #1 )
#<2width>=8           ( ENTER WIDTH OF RECTANGLE #2 )
#<2height>=5.4375     ( ENTER HEIGHT OF RECTANGLE #2 )
#<startpoint>= 7      ( absolute Y&A point where wire will start cutting )


#<wire>=0.0625        ( ENTER OF WIRE CUT )
#<space>= 0.25

( DON'T MODIFY ANY NUMBERS BELOW THIS LINE )
   
G90
G4 P2
G1 X 0.25   Z 0.25   f100
G1 Y #<startpoint>                       A  #<startpoint>
G1 X 0   Z 0
G91

G1 X- .1875                               Z- .1875
G1 Y [#<1height>+#<wire>]                     A [#<1height>+#<wire>]
G1 X-[#<1width>/4]                            Z-[#<1width>/4]
G1 Y- [[#<1height>/2]-0.71875]          A- [[#<1height>/2]-0.71875]
g1 x-.11735  Z- .11735  f35
g1 x- .2232  Y- .0725   Z- .2232   A- .0725
g1 x- .1898  y- .1379   Z- .1898   A- .1379
g1 x-.1379   y- .1898   Z- .1379   A- .1898
g1 x- .0725  y- .2232   Z- .0725   A- .2232
g1 y- .2347  A- .2347
g1 x .0725   y- .2232   Z .0725    A- .2232
g1 x .1379   y- .1898   Z .1379    A- .1898
g1 x .1898   y- .1379   Z .1898    A- .1379
g1 x .2232   y- .0725   Z .2232    A- .0725   
g1 x .2347   Z  .2347
g1 x .2232   y  .0725   Z .2232    A .0725
g1 x .1898   y  .1379   Z .1898    A .1379
g1 x .1379   y  .1898   Z .1379    A .1898
g1 x .0725   y  .2232   Z .0725    A .2232
g1 y .2347   A  .2347
g1 x- .0725  y  .2232   Z- .0725   A .2232
g1 x- .1379  Y  .1898   Z- .1379   A .1898
g1 x- .1898  y  .1379   Z- .1898   A .1379
g1 x- .2232  y  .0725   Z- .2232   A .0725
g1 x- .11735 Z- .11735
G1 Y [[#<1height>/2]-0.71875]         A [[#<1height>/2]-0.71875]

G1 X-[#<1width>/4*2]                        Z-[#<1width>/4*2]
G1 Y- [[#<1height>/2]-0.71875]       A- [[#<1height>/2]-0.71875]
g1 x-.11735  Z- .11735  f35
g1 x- .2232  Y- .0725   Z- .2232   A- .0725
g1 x- .1898  y- .1379   Z- .1898   A- .1379
g1 x-.1379   y- .1898   Z- .1379   A- .1898
g1 x- .0725  y- .2232   Z- .0725   A- .2232
g1 y- .2347  A- .2347
g1 x .0725   y- .2232   Z .0725    A- .2232
g1 x .1379   y- .1898   Z .1379    A- .1898
g1 x .1898   y- .1379   Z .1898    A- .1379
g1 x .2232   y- .0725   Z .2232    A- .0725   
g1 x .2347   Z  .2347
g1 x .2232   y  .0725   Z .2232    A .0725
g1 x .1898   y  .1379   Z .1898    A .1379
g1 x .1379   y  .1898   Z .1379    A .1898
g1 x .0725   y  .2232   Z .0725    A .2232
g1 y .2347   A  .2347
g1 x- .0725  y  .2232   Z- .0725   A .2232
g1 x- .1379  Y  .1898   Z- .1379   A .1898
g1 x- .1898  y  .1379   Z- .1898   A .1379
g1 x- .2232  y  .0725   Z- .2232   A .0725
g1 x- .11735 Z- .11735
G1 Y [[#<1height>/2]-0.71875]          A  [[#<1height>/2]-0.71875]
G1 X- [[#<1width>/4]+#<wire>]                 Z- [[#<1width>/4]+#<wire>]
G1 Y- [#<1height>+#<wire>]                    A- [#<1height>+#<wire>]

          ( START OF RECTANGLE #2 )


G1 X- #<space>                                Z-  #<space>
G1 Y [#<2height>+#<wire>]                     A  [#<2height>+#<wire>]
G1 X- [#<2width>/2]                           Z-  [#<2width>/2]     
G1 Y- [[#<2height>/2]-0.71875]         A- [[#<2height>/2]-0.71875]
g1 x-.11735  Z- .11735  
g1 x- .2232  Y- .0725   Z- .2232   A- .0725
g1 x- .1898  y- .1379   Z- .1898   A- .1379
g1 x-.1379   y- .1898   Z- .1379   A- .1898
g1 x- .0725  y- .2232   Z- .0725   A- .2232
g1 y- .2347  A- .2347
g1 x .0725   y- .2232   Z .0725    A- .2232
g1 x .1379   y- .1898   Z .1379    A- .1898
g1 x .1898   y- .1379   Z .1898    A- .1379
g1 x .2232   y- .0725   Z .2232    A- .0725   
g1 x .2347   Z  .2347
g1 x .2232   y  .0725   Z .2232    A .0725
g1 x .1898   y  .1379   Z .1898    A .1379
g1 x .1379   y  .1898   Z .1379    A .1898
g1 x .0725   y  .2232   Z .0725    A .2232
g1 y .2347   A  .2347
g1 x- .0725  y  .2232   Z- .0725   A .2232
g1 x- .1379  Y  .1898   Z- .1379   A .1898
g1 x- .1898  y  .1379   Z- .1898   A .1379
g1 x- .2232  y  .0725   Z- .2232   A .0725
g1 x- .11735 Z- .11735
G1 Y [[#<2height>/2]-0.71875]          A  [[#<2height>/2]-0.71875]
G1 X- [#<2width>/2+#<wire>]                   Z-  [#<2width>/2+#<wire>]     
G1 Y- [#<2height>+#<wire>]                    A- [#<2height>+#<wire>]
G1 X #<2width>+#<wire>]+#<space>+[#<1width>+#<wire>           Z #<2width>+#<wire>]+#<space>+[#<1width>+#<wire>

           
G90 
G1 X 0.25 Z 0.25          
m2

  
 

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

More
10 Mar 2023 12:31 #266283 by andypugh
Replied by andypugh on topic calling subroutines
I don't really know what you are asking (which is maybe why you have no replies)

Can you say what you tried, and how you know it didn't work?

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

More
10 Mar 2023 14:43 #266289 by foam man
Replied by foam man on topic calling subroutines
i'm cutting foam pieces out of blocks 3'x4'x8'
my pieces are 5.5" thick by varying widths
i place the block with the 8' parallel to the wire
i enter the width of the piece i want and start cutting
when the first layer is done i change the width parameter and cut the 2nd
same thing for 3,4,5,6
what i would like to do is plan for what pieces need to come from this block, cut the 1st layer and call up the other programs from the first one, which I think would essentially be the main program calling the rest in the order you specified

I have not tried anything. I read the section on calling subs in the instruction manual for linux that I found, but I'm not understanding how I start writing the commands
i know of guys doing exactly what I described here with different opperating systems, so I feel it should be possible
hopefully this helped
thanks

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

More
10 Mar 2023 15:31 #266293 by andypugh
Replied by andypugh on topic calling subroutines
You would write a G-code program looking a bit like
O<block> SUB
    G0 X #1 Y#2
    F100
    G1 X[#1 + 100] Y#2
    G1  X[#1 + 100] Y[#2 + 100]
    G1 X#1 Y[#2 + 100]
    G1 Z#1 Y#2
O<block> ENDSUB

O<block> CALL [0] [0]
O<block> CALL [100] [0]
O<block> CALL [0] [100]
O<block> CALL [100] [100]

M2

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

More
11 Mar 2023 00:27 #266359 by foam man
Replied by foam man on topic calling subroutines
i have 15 different programs. Do they have to be set up as a subroutine that can be called up? meaning, do I have to give them all a begin and end sub? and if this is right, where do I declare which one I want to call up next? do they all have their own names

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

More
11 Mar 2023 02:22 #266364 by andypugh
Replied by andypugh on topic calling subroutines
Again, we seem to be so far apart in our understanding that I don't even understand the question.

If you have 15 different programs to do 15 different things, then why do you think they should be subroutines?

Do you want to call them in sequence from one "top level" program?

My example was a way to do the same basic thing, but with different parameters (in this case cutting squares all of the same size, but in different places)

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

More
11 Mar 2023 03:32 #266366 by spumco
Replied by spumco on topic calling subroutines
Maybe the OP needs to back way, way up and describe his machine and existing control? Or the controls he referenced 'that guys used on other controls'

It looks like he's using a hot-wire cutter, but I don't understand why there's an A-axis command on every Y-line... unless the wire is not in a straight line?

OP - do you have a picture of your machine?  or a description of how it moves the wire?

I'm guessing once that's a bit more clear someone can help you work out how to achieve the programming you want.

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

More
11 Mar 2023 04:56 #266369 by foam man
Replied by foam man on topic calling subroutines
this is a hot wire cutter that has 2 operating modes.
2 axis XY
4 axis XYZA
the only reason I use 4 axis mode for cutting these straight forward shapes, is because in 2 axis mode ZA don't use their own motor cal # but slave of XY, making them not quite accurate. the guy I bought this cutter from new does not know how to work the programming so that i can work in 2 axis mode with each stepper using their own cal #. I've tried asking on this forum but have a hard time explaining what i'm trying to fix.

as far as the other guy I know, he starts with a main program and calls up subprograms as needed to cut the rest of the block. he's got a frogwire machine ,but this should be able to do the same thing?

am I making any sense?

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

More
11 Mar 2023 04:59 #266370 by foam man
Replied by foam man on topic calling subroutines
yes i want to call them up in whichever sequence from a main program
these programs i'm talking about might be calling for all different sizes rectangles to be cut

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

More
11 Mar 2023 06:26 #266375 by spumco
Replied by spumco on topic calling subroutines

this is a hot wire cutter that has 2 operating modes.
2 axis XY
4 axis XYZA
the only reason I use 4 axis mode for cutting these straight forward shapes, is because in 2 axis mode ZA don't use their own motor cal # but slave of XY, making them not quite accurate. the guy I bought this cutter from new does not know how to work the programming so that i can work in 2 axis mode with each stepper using their own cal #. I've tried asking on this forum but have a hard time explaining what i'm trying to fix.

as far as the other guy I know, he starts with a main program and calls up subprograms as needed to cut the rest of the block. he's got a frogwire machine ,but this should be able to do the same thing?

am I making any sense?
 

A little, but I'm having a hard time visualizing the mechanics.  A picture of the machine with the axes labeled - or even a sketch - would help.

Is this a frogwire machine, or very similar?  Like a stationary bed with two independent posts, and two independent 'heads' that hold the wire between them?

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

Time to create page: 0.191 seconds
Powered by Kunena Forum