586,471 active members*
3,736 visitors online*
Register for free
Login
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2008
    Posts
    85

    Macro Programming

    It has been sometime since I have written simple macros and was hoping to find a little help here.

    I seen this problem presented in another post but this would have strayed off topic.
    He was wanting to machine a profile to a depth of Z-2.55 in .05 depths of cuts.
    I have taken it one step farther to allow different depths and depth of cuts by using a macro.

    I have not had the chance to run this into a controller to see if it works or not but I would like imput on writing macros, I know there are other ways to accomplish but I am looking for information on macros.



    %
    O1001
    G65P1000 A-2.55 B-.05
    M30
    %

    %
    O1000
    (G65P1000A-2.55B-.05)
    #101=0 (ENSURE COUNTER IS CLEAR)
    #100=#1(DEPTH)
    #101=#2(STEP DEPTH)
    G0G20G40G80G90
    T21 M06
    (1.25 3 FLUTE)
    G90 G58 G00 X3.25 Y5.
    M88 ( I AM NOT FAMILIAR WITH M88)
    S1800 M03
    G43 H21 Z1. M08

    N100 (BEGIN LOOP ADDING TO - DEPTH
    #101+#2(COUNTER)

    IF[#101 LT #100] THEN [#101=#100]

    G01 Z#101 F15.
    G90 G41 G01 X2.375 Y4. D21
    G01 Y3.077
    G03 X2.7606 Y2.174 R1.25
    G02 X2. Y0.2794 R1.1
    G02 X1.2394 Y2.174 R1.1
    G03 X1.625 Y3.077 R1.25
    G01 Y3.7294
    G01 X2.5
    G40 X3.25 Y5. F25.

    IF[#101 EQ #100] GOTO200

    GOTO100

    N200
    G0Z2.M9
    G91G28Y0Z0
    G90
    M30
    %
    My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"

  2. #2
    Join Date
    Mar 2005
    Posts
    1498
    080118-0825 EST USA

    dapoling:

    #101 does not appear to be a counter by my normal definition, but rather the cummulative depth as you progress. Defining it as a counter really had me confused as to what you were doing.

    When you do #101 = 0 you are initiallizing Z to 0 relative to whatever G5x is active.

    #100 is your final depth, it has to be negative, and is based on G5x Z0. You assume no material above Z0.

    IF[#101 LT #100] THEN [#101=#100] this is OK now that I understand #101 is not what I expected for a counter. In a broad sense you can call this a counter but it is not what one initially would visualize as a counter.

    IF[#101 EQ #100] GOTO200
    GOTO100

    I might change this to
    IF[#101 GT #100] GOTO 100

    Why was I confused? When I look at code it is usually a whole mess of useless stuff cluttered around the basic logic. Thus, based on bits of information I jump into to it to see what the basic logic is. Here I started looking at #101 because it was defined as a counter. Then why would I want to set #101 to the value of #100 inside of the loop?

    Maybe if
    G01 Z#101 F15.
    G90 G41 G01 X2.375 Y4. D21
    G01 Y3.077
    G03 X2.7606 Y2.174 R1.25
    G02 X2. Y0.2794 R1.1
    G02 X1.2394 Y2.174 R1.1
    G03 X1.625 Y3.077 R1.25
    G01 Y3.7294
    G01 X2.5
    G40 X3.25 Y5. F25.

    Had been written as
    G01 Z#101 F15.
    (do cutting work)

    and

    #101=0 (ENSURE COUNTER IS CLEAR)
    #100=#1(DEPTH)

    had been
    #101=0 (cummulative depth from G5x Z0, initialize to start at Z0)
    #100=#1(final depth relative to G5x Z0)

    I would have converged on your logic sooner.

    .

  3. #3
    Join Date
    Jan 2008
    Posts
    85
    Gar thanks for responding as it seems you have a good grip on macros, but let me see if I can sum this up, it will work but you would prefer better notations and terminology?

    Your view on this maybe different then mine as I consider a counter a method to add a number to another coming up with a result.
    If you would post what you would feel a counter I can see the difference between the way we both look at it.

    When you do #101 = 0 you are initializing Z to 0 relative to whatever G5x is active.
    The variable is set to 0, at this point there is no other influence until G5x was called up.

    Then why would I want to set #101 to the value of #100 inside of the loop?
    if #101 reached a depth deeper then #100 it would revert to #100, thus preventing undercut area.
    My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"

  4. #4
    Join Date
    Mar 2005
    Posts
    1498
    080118-1124 EST USA

    dapoling:

    In computer programming and generic useage count usually means incrementing or decrementing by 1 or an integer multiple thereof. Although I can not disagree in a broad sense with count including any arbitrary incremental value. It is just that was not my expectation when first encountering your code.

    When looking at code I do not start at the beginning and walk thru it, but rather I may start in the middle and try to pick out a clue of the essential logic without a lot of detailed clutter. Thus, I did not catch some clues that might have altered my train of thought.

    When you set #101 to 0 you are really setting an inital dimension relative to whatever was the last (prior to the #101=0 line) assertion of a G5x. If there was a G5x in the loop somewhere or after the #101=0 line, then this would be the new reference for Z. I do not see any G5x in your code so it is whatever existed before. Now I found your G58. The value for #101 initialization could be 0.5645 and your program would work perfectly to take you to the same final depth of #100 but starting from 0.5645-#101.

    Since you are primarily using dimensions as your variable I would describe them as such rather than as a count.

    Once I determined what you were doing, then setting #101 to #100 in the if statement inside the loop made sense. But before I understood your code my initial question was why was this being done when I thought by my generic useage of count that #101 was an incrementing (by 1) counter. The function does exactly what you intended and is correct. You could use LE also.

    I responded because no one else had. It provides an interesting discussion, and it does not mean what you did was wrong.

    .

  5. #5
    Join Date
    Jan 2008
    Posts
    85
    Gar thanks for replying I find different opinions and views often lead to a well rounded knowledge.

    As I mentioned before it has been sometime since I have written a basic macro as this. I know this could have become more complex putting more safeguards in but with instructions to the user on how to use it, one would hope they would follow them.
    My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"

Similar Threads

  1. Fanuc Macro and G-Code Programming
    By kilogulf59 in forum Fanuc
    Replies: 3
    Last Post: 11-01-2006, 06:02 PM
  2. Do I need macro programming in future
    By koppis in forum Uncategorised CAM Discussion
    Replies: 3
    Last Post: 09-19-2006, 07:44 PM
  3. A2100 advanced (macro) programming
    By bender68 in forum G-Code Programing
    Replies: 0
    Last Post: 12-29-2005, 06:28 PM
  4. Macro/Parametric Programming
    By screensnot in forum Fadal
    Replies: 4
    Last Post: 03-29-2005, 03:45 AM

Posting Permissions

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