Macro Programming Fundamentals - Page 36
Close
Login to Your Account
Page 36 of 37 FirstFirst ... 2634353637 LastLast
Results 701 to 720 of 728
  1. #701
    Join Date
    Sep 2010
    Location
    Victoria Australia
    Posts
    3,655
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    1438

    Default

    Quote Originally Posted by sinha View Post
    If the idea is to help the new learners, it is desirable that macros be posted with detailed block-wise comments. Users would be able to find out how to use the macro, and under which conditions it would fail. The associated drawing would be an added help.

    Incorporating all error traps may not be practical. Using a macro as a black box can be dangerous.
    Hello sinha,
    An Error Trap that simply prevent the Control from raising an alarm and benignly halting is one thing; Error Trapping to prevent a Crash situation is mandatory in my opinion, particularly if the Macro is Posted where others are able to use it.

    Regards,

    Bill

  2. #702
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,401
    Post Thanks / Like
    Likes (Given)
    845
    Likes (Received)
    2803

    Default

    Quote Originally Posted by angelw View Post
    Hello sinha,
    An Error Trap that simply prevent the Control from raising an alarm and benignly halting is one thing; Error Trapping to prevent a Crash situation is mandatory in my opinion, particularly if the Macro is Posted where others are able to use it.

    Regards,

    Bill
    Agreed, you should also trap for out of range input variables. Not practical in all cases, but in most you can set them and then the user of the macro can set the limits to suit the particular application. (i.e. trap for a negative value when it should always be positive, or say trap for a number bigger than 10 when the input should not exceed that value.)

  3. #703
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,241
    Post Thanks / Like
    Likes (Given)
    72
    Likes (Received)
    223

    Default

    Actually, we all are saying the same thing. But, no matter how meticulously the macro has been written, it may not always be possible that all goof ups are taken care. It is, therefore, dangerous to blindly use the macro as a black box. Basic understanding is always desirable.

    A program may be made foolproof, but not idiotproof.

  4. Likes TeachMePlease, Tonytn36, PROBE, Fancuku liked this post
  5. #704
    Join Date
    Aug 2019
    Country
    UNITED KINGDOM
    Posts
    2
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Default

    What do you do to make it the last program to run? We have two pallet systems. Do you just set up a job with a low priority?

  6. #705
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,241
    Post Thanks / Like
    Likes (Given)
    72
    Likes (Received)
    223

    Default

    Quote Originally Posted by DronFee1 View Post
    What do you do to make it the last program to run? We have two pallet systems. Do you just set up a job with a low priority?
    You got no answer because your requirement is not very clear.

  7. #706
    Join Date
    Jan 2019
    Country
    SWEDEN
    Posts
    154
    Post Thanks / Like
    Likes (Given)
    52
    Likes (Received)
    18

    Default

    I created a circular interpolation elliptic pocket test program designed for HSM. (It works.) Going to turn it into a macro. Is there any interest in this?

  8. #707
    Join Date
    Jan 2014
    Country
    UNITED STATES
    State/Province
    Washington
    Posts
    4,417
    Post Thanks / Like
    Likes (Given)
    807
    Likes (Received)
    2374

    Default

    I'd be interested to see it. Mainly from an understanding point of view. I do not have a need, but like to how others do their macros.

  9. #708
    Join Date
    Jan 2019
    Country
    SWEDEN
    Posts
    154
    Post Thanks / Like
    Likes (Given)
    52
    Likes (Received)
    18

    Default

    Quote Originally Posted by Vancbiker View Post
    I'd be interested to see it. Mainly from an understanding point of view. I do not have a need, but like to how others do their macros.
    Okay, here goes.

    My first concern was that I'd want to get away from the abrupt forces caused by a tool turning 90' at the end of a corner, using a high feed mill. I'd also (primarily) want this to work with a tool designed to slice areal depth.

    The strategy would be to cut an ellipse matching the designed square pocket then to fill it out. As a side benefit you'd get the ability to, you know, make an elliptic pocket.

    The first part is to ramp down an ellipse of your choosing. The initial ellipse should be X-A and Y-A wide, with A being the required space to fill it out. To clarify/exemplify:

    Say we need a 100mmx50mm square pocket and we have a 10mm tool. First we'd then need the ramp pocket. Making a line pocket would be 60x10. For an ellipse we'll set that to, say, 68x18. Meaning once you ramp down that pocket you will need to swirl out at an increasing radius to get your decided size. Then you'd fill out the corners by clamping max/min X and Y for the motion while still expanding the radius.

    The problem with ellipses, especially with older systems, is one of computational speed. I run a Fanuc 21i, hardly fantastic. Sure you could just G1 between each angle but doing 360 such angles per rotation on an old mill isn't possible due to above reason. So I wanted circular interpolation of the motion to reduce the number of movements per rotation.

    This solution is designed for pockets where size X is greater than size Y. It has a ton of errors but, as an initial try, I'm quite pleased. It's managed to machine pretty well.

    Code:
    % 
    :0113(FIL=TC4) 
    (ELLIPTIC RAMP POCKET TEST)
    G49
    G05.1Q1
    G54X10Y0Z50G43H44
    S3750F300M3
    Z5 
    G1Z0F100M14
    #1=0(CURRENT ANGLE)
    #3=0(CURRENT X COORD)
    #4=0(CURRENT Y COORD)
    #5=15(START RADIUS X)
    #6=8(START RADIUS Y) 
    #7=#5(CURRENT RADIUS X)
    #8=#6(CURRENT RADIUS Y)
    #10=0(START PLANE Z) 
    #11=[1/36](Q RAMP) 
    #12=11.25(ANGLE INCREMENT) 
    #13=0.1(AE)
    #16=20(RADIUS INCREASE FROM START TO FINISH) 
    #17=#7+#16(FINISH RADIUS X)
    #18=#8+#16(FINISH RADIUS Y)
    #19=-10(FINISH PLANE Z)
    #20=2(Q PER PASS)
    #21=#10(TARGET Z IN PASS)
     
    F600 
    WHILE[#10GT#19]DO1 
    #1=#1+#12
    #10=#10-#11(Z) 
    G3X[COS[#1]*#5]Y[SIN[#1]*#6]Z[#10]R[#5*#6/[SQRT[[#5*COS[#1]*COS[#1]]+[#6*SIN[#1]*SIN[#1]]]]] 
    END1 
    F2000
    WHILE[#7LT#17]DO1
    #1=#1+#12
    #7=#7+#13
    #8=#8+#13
    G3X[COS[#1]*#7]Y[SIN[#1]*#8]R[#7*#8/[SQRT[[#7*COS[#1]*COS[#1]]+[#8*SIN[#1]*SIN[#1]]]]] 
    END1 
    WHILE[[#3LT#17]OR[#4LT#18]]DO1 
    #1=#1+#12
    #7=#7+#13
    #8=#8+#13
    #3=[COS[#1]*#7](X) 
    IF[#3GT#17]THEN#3=#17
    IF[#3LT-#17]THEN#3=-#17
    #4=[SIN[#1]*#8](Y) 
    IF[#4GT#18]THEN#4=#18
    IF[#4LT-#18]THEN#4=-#18
    G1X[#3]Y[#4]F1000
    END1 
    G0Z50M15 
    G5.1Q0 
    G91G28Y0Z0 
    M30
    %
    The "long" equation here

    R[#7*#8/[SQRT[[#7*COS[#1]*COS[#1]]+[#8*SIN[#1]*SIN[#1]]]

    is used to find the radius at any angle of an ellipse. In this case, the radius of the ellipse at the point we are travelling to. Ergo if we travel to a point where the radius is smaller than from where we start this will fail. This can of course be fixed.

    The thought for shouldering mills in this macro is ramp-ellipse-down, oscillate out, finish. The thought for high feeders who have limited DoC is rampdown, oscillate out, finish, ramp down, oscillate in, repeat. It's basically just a case of copying the while loops in the appropriate positions.

    I've tried to make this the least CPU intense I know of. Reason for the complicated formulae is precisely to require less computations per second.

    Let me know what you think.

  10. #709
    Join Date
    Sep 2010
    Location
    Victoria Australia
    Posts
    3,655
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    1438

    Default

    Quote Originally Posted by Tichy View Post

    Let me know what you think.

    Hello Tichy,
    The program, in terms of machining, becomes rather inefficient when the G1 stage is reached, with a lot of repeat territory covered. Dealing with each corner of the rectangle individually would be a more efficient method.

    Perhaps specifying the length and width of the pocket and passing these values as arguments to the Macro, where the various variables in use can be extrapolate from the specified arguments, would make the Macro more user friendly.

    ellipsemacro1.jpg



    Regards,

    Bill
    Last edited by angelw; 09-08-2019 at 09:18 AM.

  11. #710
    Join Date
    Jan 2019
    Country
    SWEDEN
    Posts
    154
    Post Thanks / Like
    Likes (Given)
    52
    Likes (Received)
    18

    Default

    Hi Bill,

    Yes, there's a fair amount of empty cutting at the end. Been thinking of the most elegant solution to that, considering as you said machining the corners separately. There are also a few uglinesses in it (example it doesn't "clean sweep" at each phase performing a full rotation after the ramp f.ex. It also doesn't use f.ex. Ramanujan's ellipse circumference approximation when ramping so ramps harder in the long sides thus it could potentially be dangerous to tools sensitive to that, exceeding max ramp angle.)

    It's been a fun one tho and I'll be able to turn it into a real working production macro. Also figuring out a better system for elliptic approximation will help me make the trochoidal feed macro a lot better. Got a thin slicing area contour macro out of it too, that one was easy.

    PS I see you use NCplot too.
    Last edited by Tichy; 09-09-2019 at 08:10 AM.

  12. #711
    Join Date
    Sep 2019
    Country
    CANADA
    State/Province
    British Columbia
    Posts
    3
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Default

    Hey guys, new to to this world but seem to be getting used to it quick. Im trying to write my first super simple macro and running into an issue. I have an old Mori MV-jr with MX3. I turned on the macro option this week and no calling programs woth arb Gcode, g65 m codes and t codes is working. At first it wasnt.

    My machine is not a full enclosure unit so the tool change operation will only execute if the y axis is in a safe range as to not crash the tool change arm into the rear of the splash guard.

    M6 by itself doesnt move the table to this safe area. My first macro was to relate M6 to call a routine to move the axis to the right machine coordinate spot before initiaing the actual m6 command which is valid in the macro.

    That worked, to my pleasure. However I was thnking if the y axis is alreay at or past the safe area I dont want the y axis moving unnecessarily wasting time. I wanted to try an IF statement. This is what I wrote:

    O9150
    IF[#5022LE#25] GOTO N3;
    G00 G53 Y-8.;
    T2;

    I ran it as a raw program and it seemed to work the first time, the Y axis was not at the machine coordinate -8. And it went there. It didnt initiate the tool carousel so maybe it didnt but the table definitely moved. Subsequent tests, leaving the table at or beyond -8. Resulted in erros 118 and or 013. I never could get the table to move again with the macro.

    Any insight would help. Once I understand what Im doing wrong I feel like I can work theough more macros as I see I need them.

  13. #712
    Join Date
    Jan 2014
    Country
    UNITED STATES
    State/Province
    Washington
    Posts
    4,417
    Post Thanks / Like
    Likes (Given)
    807
    Likes (Received)
    2374

    Default

    Quote Originally Posted by Zorkie View Post
    .....

    O9150
    IF[#5022LE#25] GOTO N3;
    G00 G53 Y-8.;
    T2;
    .....
    Is that the full extent of your code? If not, please post the entire program. If it is then you are missing some pieces.

  14. #713
    Join Date
    Sep 2019
    Country
    CANADA
    State/Province
    British Columbia
    Posts
    3
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Default

    LOL. This is all i got for my y axis move or not move code. My actual M6 macro im using is not using any arguments and moving the table to Y-8. Even if it is past (eg Y-9.)

    I am just trying to test and prove an if statement to move the table for anything large than y-8. If the table is at Y-5. For example the arm will crash if it werent for the alarm due to the lack of safe area.

    I wasnt sure if I needed to run as a macro or straight up as a program for testing.

    The yasnac manual speaks to defining arguments a - z as 1 - 26 but im not sure if im.supposed to put #25=8 or how to make it think in machine position as an argument... maybe im thinking too hard?

    Im sure im missing a lot more than I thought :p

  15. #714
    Join Date
    Sep 2010
    Location
    Victoria Australia
    Posts
    3,655
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    1438

    Default

    Quote Originally Posted by Zorkie View Post
    LOL. This is all i got for my y axis move or not move code. My actual M6 macro im using is not using any arguments and moving the table to Y-8. Even if it is past (eg Y-9.)

    I am just trying to test and prove an if statement to move the table for anything large than y-8. If the table is at Y-5. For example the arm will crash if it werent for the alarm due to the lack of safe area.

    I wasnt sure if I needed to run as a macro or straight up as a program for testing.

    The yasnac manual speaks to defining arguments a - z as 1 - 26 but im not sure if im.supposed to put #25=8 or how to make it think in machine position as an argument... maybe im thinking too hard?

    Im sure im missing a lot more than I thought :p
    As Kevin remarked, you should Post the whole of the program. But if I'm to comprehend the first sentence of you last Post, as this is all the program you have, then it will fail on more than one level.

    Passing Arguments to a Tool Change Macro is going to make for a messy Tool Change Call Block. #25 needs to have been specified a value, otherwise your Conditional Statement is always going to test true and branch to N3 (wherever that may be, as you've kept that a secret). You would be better off to either Hard Code the value for #25 in the Macro, or register it in a Common, Nonvolatile Variable (#500 Series Variables). Care should be taken when using these Variables that they're not being used by other programs.

    If I understand you requirement correctly, if the current Machine Position of the Y axis is less than -8.0, branch past the following Block:

    G00 G53 Y-8.

    at any position Greater than Y-8.0, the above Block will be executed.

    Therefore, your program should look something like the following:

    IF[#5022 LE -8.0] GOTO3; Note: GOTO3 not GOTO N3 as in your example
    G00 G53 Y-8.;
    N3 T2 M06;

    Regards,

    Bill
    Last edited by angelw; 09-14-2019 at 04:30 AM.

  16. #715
    Join Date
    Jan 2019
    Country
    SWEDEN
    Posts
    154
    Post Thanks / Like
    Likes (Given)
    52
    Likes (Received)
    18

    Default

    The "I don't want to post the whole code but I still want help" people...

    Honestly that's just the worst.

  17. #716
    Join Date
    Sep 2015
    Country
    SWEDEN
    Posts
    35
    Post Thanks / Like
    Likes (Given)
    15
    Likes (Received)
    7

    Default

    Mazatrol doesn't support SIN function.

    Likewise with ASIN.

    In a situation where one of those would be needed, how do I go around this problem?

    I find mazaks macroB to be very limited, makes no sense to exclude those and also IF THEN. Hard to grasp the reasoning behind it.

  18. #717
    Join Date
    Sep 2010
    Location
    Victoria Australia
    Posts
    3,655
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    1438

    Default

    Quote Originally Posted by MazatrolMatrix View Post
    Mazatrol doesn't support SIN function.

    Likewise with ASIN.

    In a situation where one of those would be needed, how do I go around this problem?

    I find mazaks macroB to be very limited, makes no sense to exclude those and also IF THEN. Hard to grasp the reasoning behind it.
    Hello MazatrolMatrix,
    Sure about that? The following picture is a screen capture straight from a Mazatrol Matrix EIA programming Manual.

    mazak-mazatrol-matrix1.jpg


    I've written numerous Macro Programs for this machine and have had no issues with the Arithmetic operation commands provided. IF works in much the same manner as Fanuc and other User Macro programs, but it doesn't have a THEN, or TH operation. This is really no limitation, for the following will work:

    IF[#1 > #2] #1=#2

    The GOTO branch function can be used with an IF conditional statement the same as other controls.

    Regards,

    Bill

  19. #718
    Join Date
    Sep 2015
    Country
    SWEDEN
    Posts
    35
    Post Thanks / Like
    Likes (Given)
    15
    Likes (Received)
    7

    Default

    Quote Originally Posted by angelw View Post
    Hello MazatrolMatrix,
    Sure about that? The following picture is a screen capture straight from a Mazatrol Matrix EIA programming Manual.

    mazak-mazatrol-matrix1.jpg


    I've written numerous Macro Programs for this machine and have had no issues with the Arithmetic operation commands provided. IF works in much the same manner as Fanuc and other User Macro programs, but it doesn't have a THEN, or TH operation. This is really no limitation, for the following will work:

    IF[#1 > #2] #1=#2

    The GOTO branch function can be used with an IF conditional statement the same as other controls.

    Regards,

    Bill
    Hello Bill,

    I apologize. It has been a while since I used the language. It's ASIN I'm talking about. I ran into a situation where I wanted to find an unknown angle and would have liked to use ASIN to do so.

    And I am pretty sure I can't use
    IF[#1 > #2] #1=#2 with Matrix2. You suggested this might work before, but got an error testing it. I'll try again. Would it be possible some parameter controls this?

    GOTO works fine, but IF THEN is simpler to use and requires less code. Still find it weird they neglected it.

  20. #719
    Join Date
    Sep 2015
    Country
    SWEDEN
    Posts
    35
    Post Thanks / Like
    Likes (Given)
    15
    Likes (Received)
    7

    Default

    I tested it again and it is not accepted.

  21. #720
    Join Date
    Jan 2014
    Country
    UNITED STATES
    State/Province
    Washington
    Posts
    4,417
    Post Thanks / Like
    Likes (Given)
    807
    Likes (Received)
    2374

    Default

    Quote Originally Posted by MazatrolMatrix View Post
    I tested it again and it is not accepted.
    Post the exact code you tried and also post the resulting alarm number or error code and associated text.


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
  •