Macro Programming Fundamentals - Page 2
Close
Login to Your Account
Page 2 of 27 FirstFirst 123412 ... LastLast
Results 21 to 40 of 539
  1. #21
    Join Date
    May 2004
    Location
    Zellwood, Fl.
    Posts
    1,433
    Post Thanks / Like
    Likes (Given)
    561
    Likes (Received)
    277

    Default

    Macros and sub programs gotta love them and I wish I was a bit better educated in the use of macros but then I would not have to reason to ask a question. Here goes I currently have setup a main program to run part programs with looks something like this:

    %
    O12

    (MASTER PROGRAM)
    (MODIFIED: 06/28/05 REV B)


    #2=1(SELECT TYPE =1 NEW =2 OLD)
    #1=1(ENTER NUMBER OF PROGRAMS)

    IF[#2EQ1]GOTO10
    IF[#2EQ2]GOTO20
    GOTO100
    N10
    IF[#1LT1]GOTO100
    IF[#1GT4]GOTO100

    (*********** PROGRAM 1 ***********)
    G65P9010W54(ENTER WORK LOCATION)
    M198P21502(ENTER PROGRAM NUMBER)
    IF[#1EQ1]GOTO100
    (*********** PROGRAM 2 ***********)
    G65P9010W40(ENTER WORK LOCATION)
    M198P393759(ENTER PROGRAM NUMBER)
    IF[#1EQ2]GOTO100
    (********************************)
    N100(END PROGRAM)
    G10L2P1X0Y0Z0B0C0
    GOTO999
    N20
    (********************************)
    G90G80
    M14
    G00G53Z-15.
    X10.B0.C0.
    G90G80
    G5.1Q1R1

    M14(TABLE)
    G55(OFFSET)
    M98P92(PROGRAM)

    G53Z-15.
    G53X10.Y50.
    M05

    N999

    Then I use the header in the part program to relate work coordinate something like this.

    %
    O3000
    G65 P9011 (PARK POSITION OF MILLING HEAD)
    G5.1 Q1 R1
    G65 P9010 W11 (WORK COORDINATE CALL)

    P9010 (WORK COORDINATE LISTING)
    %
    O9010(SET WORK POSITION)

    IF[#23EQ11]GOTO11
    IF[#23EQ12]GOTO12
    IF[#23EQ13]GOTO13

    N11(M15)
    M15
    G10L2P1X15.45Y10.23Z-47.17
    GOTO999
    N12(M14)
    M14
    G10L2P1X15.45Y70.23Z-47.17
    GOTO999

    M30

    N999
    M99
    %

    Now what I would like to do is set up the same type of call for tool length variables. The part I am not sure of is the syntax necessary to do this. Not real sure that

    P9015 (tool compensation listing)
    G10 L2 P1 H3 would work in the part program looking for

    IF[#23EQ11]GOTO11

    N11(T1)

    G10 L2 P1 H3= 3.25
    GOTO999

    Anyway hope this gets the idea across of what I am looking to do. And yes this is a mill as opposed to a lathe.

    Scott

  2. #22
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,080
    Post Thanks / Like
    Likes (Given)
    652
    Likes (Received)
    2404

    Default

    Quote Originally Posted by scojen View Post
    Now what I would like to do is set up the same type of call for tool length variables. The part I am not sure of is the syntax necessary to do this. Not real sure that

    P9015 (tool compensation listing)
    G10 L2 P1 H3 would work in the part program looking for

    IF[#23EQ11]GOTO11

    N11(T1)

    G10 L2 P1 H3= 3.25
    GOTO999

    Anyway hope this gets the idea across of what I am looking to do. And yes this is a mill as opposed to a lathe.

    Scott
    Basically, anywhere you can put a value (number) you can put a variable (#).
    You can go so far as to actually read out your tool length from the control via system macro and assign it to a variable.

    Here is one where I'm getting the tool currently in the spindle at cycle start, to make sure the correct tool is in the spindle...
    It's using tool groups (9xx), but would work the same for individual tools, provided your control has a system variable available for "tool in spindle".

    (O8011 INITIALIZATION SUB)
    N5 #800=#3700 (GET TOOL IN SPINDLE)
    N10 IF [#800 EQ 1] GOTO 400 (2.3 DRILL)
    N15 IF [#800 EQ 2] GOTO 400 (2.3 DRILL)
    N20 IF [#800 EQ 3] GOTO 400 (2.3 DRILL)
    N25 IF [#800 EQ 4] GOTO 500 ( END MILL)
    N30 IF [#800 EQ 5] GOTO 500 (.375 END MILL)
    N35 IF [#800 EQ 6] GOTO 500 (.375 END MILL)
    N40 IF [#800 EQ 7] GOTO 600 (BORING BAR)
    N45 IF [#800 EQ 8] GOTO 600 (BORING BAR)
    N50 IF [#800 EQ 9] GOTO 700 (3.0 DRILL)
    N55 IF [#800 EQ 10] GOTO 700 (3.0 DRILL)
    N60 IF [#800 EQ 11] GOTO 800 (BULL NOSE END MILL)
    N65 IF [#800 EQ 12] GOTO 800 (BULL NOSE END MILL)
    N100 GOTO 900 (ERR0R)
    N400 #801 = 901
    N405 GOTO 990
    N500 #801 = 902
    N505 GOTO 990
    N600 #801 = 903
    N605 GOTO 990
    N700 #801 = 904
    N705 GOTO 990
    N800 #801 = 905
    N805 GOTO 990
    N900 #3000 = 34 (LOGIC ERR 8011)
    N990 M99

    Now, I call the correct offsets for that tool before I do much of anything else....

    N26 G55 G0 X#590 Y0. Z200. G43 T#801 H#801 D#801

    In this one....
    I'm getting the tool life counter value from the control, and checking to see if the tool life is up. If the tool life is still good, I'm skipping the tool call.

    N401 #850 = #3700 ( SET #850 TO TOOL NUMBER )
    N402 #851 = [#850+5800] ( ADD 5800 TO TOOL NUMBER )
    N403 #852 = #[#851] ( SET #852 TO REMAINING TOOL LIFE )
    N404 #590 = #629
    N405 IF [#801 NE 901] GOTO 410
    N407 IF [#901 NE #900] GOTO 410
    N408 IF [#852 NE 0] GOTO 412 ( IF TOOL LIFE DOESN'T EQUAL 0 SKIP TOOL CALL)
    N410 G100 X#590 Y0. Z120. G43 T901 H901 D901 (TOOL CHANGE - DRILL)

  3. #23
    Join Date
    Jan 2007
    Location
    Ohio
    Posts
    1,153
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    2

    Default

    Quote Originally Posted by Bluechip View Post
    QUOTE : "Bluechip, are you saying that the converter changes the Fanuc macro into a common variable program for the Okuma? "

    Yes ... CNC XChange will auto-convert all areas of the Fanuc Macro B language including Common Variables, System Variables, Arithematic Operations, Control Commands ( While / Do loops, If, etc., Conditional Expressions ( EQ, LT, etc. ) ... into the compatible Okuma User Task commands / variables ... and REVERSE.

    CNC XChange also has an unlimited user defined area where users can set-up their own "what-to-convert-into-what" in case their control does some specific functions not covered in the hard-coding.

    Of course .. our standard version of CNC XChange will also convert standard Fanuc G code to Okuma OSP code ... and REVERSE.

    Again ... info and video presentations at www.KentechInc.com
    Have you tried to sell to MasterCam? Seems as if they and Okuma have a communication problem, and I don't mean from CPU to contol. Possible to get a copy sold per MasterCam rep and tech out there. Just a thought.

  4. #24
    Join Date
    Dec 2002
    Location
    Granville,NY,USA
    Posts
    3,854
    Post Thanks / Like
    Likes (Given)
    255
    Likes (Received)
    365

    Default

    Quote Originally Posted by Tonytn36 View Post
    G43 T#801 H#801 D#801
    I like the looks of this. Very much like the H&T agreement setting in the Haas control.

    Thanks again Tony for sharing your knowledge in an easy to understand way.


  5. #25
    Join Date
    May 2004
    Location
    Zellwood, Fl.
    Posts
    1,433
    Post Thanks / Like
    Likes (Given)
    561
    Likes (Received)
    277

    Default

    Tony,
    Thanks for the explanation, but I do have a question is there a difference between calling a tool from an existing register and assigning a value to a tool thus changing the value in the register, which is really what I would like to do. Reason is I have programs that use the same tool but the tool length may change from part to part.

    Scott

  6. #26
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,080
    Post Thanks / Like
    Likes (Given)
    652
    Likes (Received)
    2404

    Default

    scojen,
    Get out your macro programming book for your control. You should be able to write to the offset register, as well as read from it. You are looking for the system macro values for the tool offsets. It will tell you if you can write them or not.

  7. #27
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,080
    Post Thanks / Like
    Likes (Given)
    652
    Likes (Received)
    2404

    Default

    Quote Originally Posted by scojen View Post
    Tony,
    Thanks for the explanation, but I do have a question is there a difference between calling a tool from an existing register and assigning a value to a tool thus changing the value in the register, which is really what I would like to do. Reason is I have programs that use the same tool but the tool length may change from part to part.

    Scott
    Scojen,
    As an example, lets look at a Fanuc 16-18-21 series control.

    From the table in the operating/programming manual, for a mill, the control uses the table: compensation memory 3 (H,D).
    In this instance,

    OFFSET Comp Amount(H) Wear(H) | Comp Amount(D) Wear(D)
    NUMBER Variable Variable | Variable Variable
    1 #11001 #10001 | #13001 #12001
    .....
    999 #11999 #10999 | #13999 #12999
    These can be written and read.

    You have another situation, if the control only has the standard 199 offsets, you can alternatively use the following:
    OFFSET Comp Amount(H) Wear(H) | Comp Amount(D) Wear(D)
    NUMBER Variable Variable | Variable Variable
    1 #2201 #2001 | #13001 #12001
    .....
    200 #2400 #2200 | #13200 #12200

  8. #28
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,080
    Post Thanks / Like
    Likes (Given)
    652
    Likes (Received)
    2404

    Default Finally time for another post

    Ok, where were we?.. It's been a busy couple of weeks... oh yea, calculations...
    (Btw, if I screw this up, someone let me know, I'm doing this "off the cuff" as I go, and I've got a "cold from hell". It won't go away , and I've been up since 2:30 am because of it.)
    So, we have determined that the number of holes is either even or odd in the previous post. Now we do a couple of the more simple calculations:

    #603 = 360/#500
    This result gives us the number of degrees between holes which we will need later.
    #604 = #501/2
    This result gives us the radius of the BC which we also need later.

    NOTE (Outtake):
    We'll put all of this stuff in and in order in some semblance program later. What I do to make things easier (and maybe you can see why later on), is to break the job down into little jobs, just like a machine set-up.

    In a machine set-up, you are typically going to look at the print to get an overall picture of what you are making. Then you are going to look closer, and determine what tools and materials you need to make the part. Then you are going to look at how to fixture the part for each operation. The final step before actually cutting chips is to determine in what _order_ you are going to perform the different operations.

    Programming is the same way, you look at the overall functionality you need (picture), then the calculations, routines, etc (Tools & material) you need to do the job. Then you write each little segment (fixturing), and finally, you put them all together with the logic to make them work (order of operations).

    And now, back to our regularly scheduled programming:
    We will need to determine if a hole starts on the 0° machine axis.

    IF [#502 GT 0] GOTO XXX
    This says "If our start angle is anything but 0°, we'll go to our non-zero start angle calculations.
    Using the first calculation we did in this post, we need to get our trig components. I just do all three as a matter of course, even if one won't be used. If I happen to later decide I need one, I already have it.
    #605 = TAN[#603]
    #606 = SIN[#603]
    #607 = COS[#603]

    NOTE (Outtake #2):
    I keep a spreadsheet (excel or OO Calc), with a list of all variables. I use this to identify what variable is assigned to what for each program. I am attaching a sample spreadsheet in both *.ods and *.xls format (see zip file).

    Til the next post.....

    Safety tip of the day:
    Never turn your back on a machine - It keeps the hot chips out of the crack of your ass....
    Attached Files Attached Files

  9. Likes Road HOG Mill liked this post
  10. #29
    Join Date
    Mar 2007
    Location
    MA.
    Posts
    103
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Thumbs up Great thread Thank you !

    Tony thanks for starting this thread, and thanks to all who have contributed ! I don't use Macros enough to contribute but I'm really getting a lot out of this. Thanks for taking the time.
    regards,
    Dick

  11. #30
    Join Date
    Feb 2007
    Location
    Worcester, MA
    Posts
    9
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Exclamation Warning on look ahead on Fanuc 30 series controls!

    If you guys have parameter 1604 bit 0 set to a 1 - Which enables high speed machining mode automaticly in feed or plan to use macro statements in high-speed machining modes, the look-ahead of the control will process macro statements WAY ahead of the actual block of code you are running. Which can give some interesting and annoying results! The Robodrill and Matsuuras (and I believe all Fanuc 30 series controls do this) I work on we use "G5.1 Q0" to suspend automatic high speed machining. The Siemens controls have the "STOPRE" command to stop pre-processing so the look ahead doesn't turn your macro logic into mud!

  12. #31
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,080
    Post Thanks / Like
    Likes (Given)
    652
    Likes (Received)
    2404

    Default

    This is very true Noah888. If the control doesn't have the stop pre-processing commands, you can use blank blocks to do it.

  13. #32
    Join Date
    Jan 2003
    Location
    Tel Aviv, Israel
    Posts
    480
    Post Thanks / Like
    Likes (Given)
    57
    Likes (Received)
    78

    Default Look ahead (buffering) problem

    Quote Originally Posted by Noah888 View Post
    If you guys have parameter 1604 bit 0 set to a 1 - Which enables high speed machining mode automaticly in feed or plan to use macro statements in high-speed machining modes, the look-ahead of the control will process macro statements WAY ahead of the actual block of code you are running. Which can give some interesting and annoying results! The Robodrill and Matsuuras (and I believe all Fanuc 30 series controls do this) I work on we use "G5.1 Q0" to suspend automatic high speed machining. The Siemens controls have the "STOPRE" command to stop pre-processing so the look ahead doesn't turn your macro logic into mud!
    The look ahead (buffering) problem exists on 16, 18, 21 and newer controls regardless of using or not using the high speed machining. The G53 command or dedicated M functions (parameters 3411-3420) prevent buffering.

    Probe

  14. #33
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,080
    Post Thanks / Like
    Likes (Given)
    652
    Likes (Received)
    2404

    Default

    Just an update note, I've finally got some time off (10 days worth ) so I should be able to get some more stuff down on screen, in between the must-do's already planned.

  15. #34
    Join Date
    Sep 2006
    Location
    Long Island, New York
    Posts
    479
    Post Thanks / Like
    Likes (Given)
    95
    Likes (Received)
    49

    Default

    Thanks for this thread Tony!

    I have a Fanuc 11M here and I would like to make a simple parts counter. I can't figure out where these variables are stored. Is it somewhere in the menus after hitting the NC/PC button?

  16. #35
    Join Date
    May 2008
    Location
    Great State Of Wisconsin
    Posts
    444
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    5

    Default

    They shold be listed under your Settings button labeled (variables/common variables). Not 100% how to get there on the 11M control but if you press your settings key you should be able to over arrow until you see options like Offset/Macro/Tool ect. should be under macro. You also might just have to press the settings until they are displayed.

    Stevo

  17. #36
    Join Date
    Sep 2006
    Location
    Long Island, New York
    Posts
    479
    Post Thanks / Like
    Likes (Given)
    95
    Likes (Received)
    49

    Default

    Found it, thanks. I had the wrong book out.

    The page for macro variables just says "No Option" and I can't get any values to come up. Same thing with a "Tool Life" page. I assume that means those are options not bought with this machine?

  18. #37
    Join Date
    Nov 2004
    Location
    WI
    Posts
    4,530
    Post Thanks / Like
    Likes (Given)
    351
    Likes (Received)
    990

    Default

    Understanding "Vacancy"
    There was yet another excellent article this month by Mike Lynch on Macro programming.
    Here he describes when variables are not initialized, they are not equal to zero, they are in fact "vacant" and do not contain ANY number. There is a an easy test for "vacancy"

    This is useful if you have a subroutine that you can pass variables to. If one of the variables is not used, it is vacant, and your program can ignore that "option" or use a default setting.
    I can post an example from on of my own programs later..

    Here is this month's article.

    http://www.mmsonline.com/columns/und...g-vacancy.aspx

  19. #38
    Join Date
    Apr 2009
    Location
    Michigan, USA
    Posts
    1
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Default 12 hole bolt circle with each hole 30 degrees Apart

    My friend has a shop with a Monarch CNC milling machine and needs code for a bolt circle with 12 holes 30 degrees from each other. Could someone suggest how to code this very simply?

  20. #39
    Join Date
    Jul 2006
    Location
    Clover Hill district, WI
    Posts
    2,304
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    7

    Default Wow , what a thread.

    I have to get with the program.

    Thanks Proffessors!

    M1M

  21. #40
    Join Date
    Jul 2006
    Location
    Clover Hill district, WI
    Posts
    2,304
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    7

    Default

    Hi!
    On a ? 1996? or so Mitsubishi Bar,
    with a little Mitsubishi control.
    Small mono skreen but newer keypad.
    The darn kind where the charactors on the buttons wipe off over time.

    Some of the bars I have used had a M6 call a complete macro(correct?).
    Just T4 M6 .
    Others ya had to type all the comands.
    Also for the 'B' axis a G100 (a macro true?) on some;
    G100 B180 * degrees being absolute or incremental depending on the shop.
    Others ya had to do the M11's & M10's.

    How can I tell if this mill.....
    (I don't think they have gone beyond powering it up)
    Has Tool-change & B-rotate as macros?
    That is without just trying it.

    And if not I will want to install such macro's.
    Pardon my ignorance, usually this was all done
    before I was involved.
    Thanks kindy
    if ya can help.

    M1m


Tags for this Thread

Bookmarks

Posting Permissions

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