587,751 active members*
3,004 visitors online*
Register for free
Login
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jun 2014
    Posts
    89

    Re: Passing arguments through layered macros

    Thanks Deadlykitten for the long winded answer. I am very aware how to code and how linear progs are more processing power efficient than parametric etc, and how variables are used .. I am merely asking if anyone know how to pass arguments thought multiple layers or if anyone does it. As stated it is not something i would ever use (i think), and just interested to know how it can be done.
    The prog supplied was purely for an example cause im not going to post a massive code that will take ages to read.
    Essentially if a have a program that cuts a square, and a macro to cut a smaller square within, at first layer of macro called i know i can pass arguments to define (what ever i want) the size of the sqaure and the position for example. however if i was to call a macro from within the macro to make another smaller sqaure, how do i pass the argument to the second layer to define its size and location (using the same example). What im getting at is the idea of using macros is so you dont have to alter the macro program from itself and rather give it arguments to define its 'what ever'. However once you get to a second level, i see no way to define the arguments unless it comes directly from the 1st layer macro. The machine i have says it can go upto 16 levels of macro/subroutines. While this is good its has capability, is it really of any use?

    Hanermo - I think the best and easiest way is by writing the vars to a file.
    Adding some datestamp and sanity checking, and one has a very robust system.

    Endless details abound like checking for the name/existence of the file, ability to create it, etc.

    can you elaborate on this at all? do you mean a file with all the variables (#1-#999 or what ever you use) defined, which loads the memory with this info, then run the programs?
    how do you add date stamps and 'sanity checking'?
    not really sure what your getting at here.

    thankyou both

  2. #2
    Join Date
    Jun 2015
    Posts
    4160

    Re: Passing arguments through layered macros

    hello zedodia

    linear progs are more processing power efficient than parametric
    depending on controller, there may exist the possibility to remove or reduce drastically this gap, thus allowing to keep the versatility of a parametric program, without infusing downtime

    The prog supplied was purely for an example
    somehow i was not sure about your intention, and i can't give a good advice without knowing the purpose ... i mean if i think of too many ways, i can't decide which one is better hoping that there is a 'better' way

    Essentially if a have a program that cuts a square, and a macro to cut a smaller square within
    for such a part, you don't need to go over nesting level 1; program would be like this :

    Code:
        [ main program ]
        preparatory codes ( tool-change offset fixture rpm etc )
        call square_soubroutine var_1 = a1 var_2 = a2 ... var_n = an
        call square_soubroutine var_1 = b1 var_2 = b2 ... var_n = bn
        call square_soubroutine var_1 = c1 var_2 = c2 ... var_n = cn
        end
    
        [ square_soubroutine ]
        content optimized for cutting a square, using var_1, var_2 ... var_n
        end
    i can try to suggest ideas, but i can't share a real solution, unless i see a real reason to pass through multi nesting levels

    ok ... now, i will share an example about a code that i use, where variables are passed through levels :

    Code:
        [ main program ]
        preparatory codes ( home position, fixture )
        call operation_1 var = 04
        call operation_2 var = 53
        call operation_3 var = 17
        end
    
        [ operation_1 ]
        call verify_offset
        call prepare_tool
        content for operation 1
        end
    
        [ operation_2 ]
        call verify_offset
        call prepare_tool
        content for operation 2
        end
    
        [ operation_3 ]
        call verify_offset
        call prepare_tool
        content for operation 3
        end
    
        [ verify_offset ]
        checking if offset for tool [ var ] is within some safe limits, otherwise stop the cnc
        end
    
        [ prepare_tool ]
        go to safe position, and index to tool [ var ]
        end
    i hope that this example helps; there are also other cases when i go 'through nesting levels'

    However once you get to a second level, i see no way to define the arguments unless it comes directly from the 1st layer macro
    yes, this is true, but, more precise, the argument must "allready exist at 1st layer" ; this means :
    ... argument was created inside 1st layer ( pls check sample 1 )
    ... argument was created before 1st layer ( pls check sample 2 )
    * another option, is that the argument is created when the 2nd soubroutine is called ( pls check sample 3 )

    Code:
    
    ( sample 1 )
    
        [ main program ]
        call soubroutine_1
        end
    
        [ soubroutine_1 ]
        variable = 500
        call soubroutine_2
        end
    
        [ soubroutine_2 ]
        do something with 'variable'
        end
    
    ( sample 2 )
    
        [ main program ]
        variable = 500
        call soubroutine_1
        end
    
        [ soubroutine_1 ]
        call soubroutine_2
        end
    
        [ soubroutine_2 ]
        do something with 'variable'
        end
    
    ( sample 3 )
    
        [ main program ]
        call soubroutine_1
        end
    
        [ soubroutine_1 ]
        call soubroutine_2 variable = 500
        end
    
        [ soubroutine_2 ]
        do something with 'variable'
        end
    The machine i have says it can go upto 16 levels of macro/subroutines. While this is good its has capability, is it really of any use?
    this depends how you see things, and how far you wish to go, and how much time you have to experiment

    not everybody is using soubroutines, but those ones that do it right, have more skills and more control over the machine, and their programs perform better

    so far i have reached nesting level 6 or 7, but most operations are executed inside nesting level 2 or 3 i use deeper nesting levels for general soubroutines, that target optimizations that are not related to cutting; for example : checking axis positions, computing home positions, checking machine states, checking offsets, etc .... well, i have a few / kindly
    Ladyhawke - My Delirium, https://www.youtube.com/watch?v=X_bFO1SNRZg

  3. #3
    Join Date
    Sep 2010
    Posts
    1230

    Re: Passing arguments through layered macros

    Quote Originally Posted by zedodia View Post
    Thanks Deadlykitten for the long winded answer.
    Hello zedodia,
    Empty vessels make the most noise.

    With regards to your question,

    In your example code below, there would be no requirement to pass #100 and #101 in MACRO1 PROG and MACRO2 PROG respectively, as they are Common Variable, seen by all programs.

    MAIN PROG
    #100=40
    #101=60
    G0 X0 Y0 Z0
    G1 X100 Y100 Z0
    G65 <MACRO1> A20 <----A20 MAKES LOCAL VARIABLE #1=20
    G0 X0 Y0
    M2

    MACRO1 PROG
    G1 Z#1
    G1 Z0
    G65 <MACRO2> B#100
    M99

    MACRO2 PROG
    G1 Z#2
    G1 Z0
    G65 <MACRO3> C#101
    M99

    MACRO3 PROG
    G1 Z#3
    G1 Z0
    M99

    If you wanted to pass Local Variables through Nested Macro Programs and not set Common Variables in your Main program, you could pass all of the Local Variables used in MACRO1 PROG, MACRO2 PROG and MACRO3 PROG via the Call Block in MAIN PROG.

    G65 A20 B40 C60 (IN MAIN PROG)

    then

    G65 B#2 C#3 (IN MACRO1 PROG)

    and

    G65 C#3 (IN MACRO2 PROG)


    Regards,

    Bill

Similar Threads

  1. Passing parameter as arguments in G65
    By biqut2 in forum G-Code Programing
    Replies: 0
    Last Post: 07-31-2015, 04:31 PM
  2. Passing parameter as arguments in G65
    By biqut2 in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 0
    Last Post: 07-31-2015, 04:18 PM
  3. Plasma- Multiple layered AL thin sheet cutting?
    By diyengineer in forum Waterjet General Topics
    Replies: 2
    Last Post: 08-22-2011, 12:06 AM
  4. Foil layered foam
    By webdude12 in forum Composites, Exotic Metals etc
    Replies: 0
    Last Post: 10-23-2009, 08:15 PM
  5. passing arguments to a sub program
    By kiprip in forum Mazak, Mitsubishi, Mazatrol
    Replies: 1
    Last Post: 07-13-2006, 05:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •