Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

How to add max head height rectract to post


Recommended Posts

I often work with large parts/fixtures that require moving the Z axis to its max height limit before moving over top of the part. On our HAAS VF8 that max height is actually about 4.25 above the tool change home. The move is done by  switching to mach cords G53 Z4.25

 

I have incorporated it into my post at each tool change:

N1 T01 M06 (4.0 FACE MILL | H01)
N2 G00 G90 G53 Z4.25 (RECTRACT HEAD)
N3 G00 G90 G54 X-13.0399 Y-13.5563 A0. S4000 M03
N4 G43 H01 Z11.1563

 

But I need help also adding the same move immediately after the Z rapid rectract after each operation. I've added the same post line at the beginning of  the "pretract" section, but it doesn't post the line until after the moves to the reference pos.:

 

N15 X-3.3401
N16 Y11.5563
N17 X-.9151
N18 Y-13.5563
N19 G00 Z11.1563
N20 Z20.
N21 X-23. Y16.
N22 G00 G90 G53 Z4.25 (RECTRACT HEAD)
N23 M09
N24 G91 G28 Z0 M05
N25 A0.
N26 M01

 

pretract        #End of tool path, toolchange
      pbld, n$, "G00 G90 G53 Z4.25", sopen_prn, no_spc$, "RECTRACT HEAD", no_spc$, sclose_prn, e$
      sav_absinc = absinc$
      absinc$ = one
      sav_coolant = coolant$
      coolant$ = zero
            

#      if nextop$ = 1003, #Uncomment this line to leave coolant on until eof unless
        [                 #  explicitely turned off through a canned text edit
        if all_cool_off,
          [
          #all coolant off with a single off code here
          if coolant_on, pbld, n$, sall_cool_off, e$
          coolant_on = zero
          ]
        else,
          [
          local_int = zero
          coolantx = zero
          while local_int < 20 & coolant_on > 0,
            [
            coolantx = and(2^local_int, coolant_on)
            local_int = local_int + one
            if coolantx > zero,
              [
              coolantx = local_int
              pbld, n$, scoolantx, e$
              ]
            coolantx = zero
            ]
          coolant_on = zero
          ]
        ]
       
      #cc_pos is reset in the toolchange here
      cc_pos$ = zero
      gcode$ = zero
      pbld, n$, sccomp, scoolant, psub_end_mny, e$
      if nextop$ = 1003 | tlchg_home, pbld, n$, "X0", sm05, e$
      pbld, n$, sgabsinc, sgcode, *sg28ref, "Z0", sm05, e$
      if nextop$ = 1003 | tlchg_home, pbld, n$, *sg28ref, "Y0", sm09, protretinc, e$
      else, pbld, n$, protretinc, e$
      if (subactv = zero & use_g52_shft & wrkofs_num = zero) | shft_flg = one,
        [
        n$, *sg52, "X0. Y0. Z0.", e$ #Cancel Work Shift
        shft_flg = zero
        ]
      absinc$ = sav_absinc
      coolant$ = sav_coolant

 

Is this a post issue, or some way I could work this out in MMD or the operation itself?

Link to comment
Share on other sites

retract is too late to call it. You need to look in the null tool change section. You will need to call the process from there and it can get a little tricky. The posts we get from post builders all ready have this logic supported in them,

Could I add it to the null tool change section in a non-logic form, just a forced output? This is going to be a separate saved post from my normal one, where every toolchange and end of operation has the head retract move

Link to comment
Share on other sites

Hi J,

 

Your problem is that the Z retract, and the XY clearance move both come from the Motion of the Operation itself. These moves are coded as G0 moves in the NCI.

 

Luckily, there is a switch inside the Control Definition that allows you to "break" the rapid motion, which is what you've got turned on. This "break" option tells MP that for "retract motion", do "Z", then "XY" for retracts. (XY, then Z, for approach).

 

So what we need to do is "flag" the retract motion. That's where it gets a little tricky, but fortunately for you, MP has already done the "heavy lifting" for you.

 

It does this by "tracking" the cut motion. There is a pre-defined variable called 'cutpos2$'. This variable gets calculated auto-magically by MP for you, based on the values of the 'cstart$' and 'cend$' variables. The 'cstart$' and 'cend$' variables are "contour start" and "contour end", and have different values depending on if you are using Compensation, or not using Compensation. But basically, regardless of Comp or No Comp, the 'cutpos2$' variable gets assigned different values.

 

Here are the different values for 'cutpos2$':

 

0 = Before start point; reset at each tool change, including Null

1 = Start point, first point on the surface, chained contour, ect.

2 = in cut

3 = On end of cut, last point on surface, chained contour, ect.

4 = After end of cut.

 

Ok, great. We've got a tool inside MP that gets set auto-magically by the NCI file to indicate "where we are" inside the MOTION output of each operation.

 

So, now we need some code to output the special retract, but only once. That is the only tricky part. We'll not that tricky...

 

First, define a numeric variable, in the "user-defined" variable section at the beginning of the post:

cutflag  : 0

Then, we need to modify the "motion" output post blocks, to give you the output you want:

prapidout       #Output to NC of linear movement - rapid               
      if use_g52_shft & subactv = zero & wrkofs_num = zero,
        [
        n$, *sg52, sub_trnsx$, sub_trnsy$, e$
        ]
      else,
        [
        if convert_rpd$, pconvert_rpd
        pcan1, pbld, n$, [if gcode$, `sgfeed], sgplane, `sgcode, sgabsinc, pwcs, pccdia,
          pxout, pyout, pzout, pcout, [if gcode$, `feed], strcantext, pscool, e$
        ]
      if cutpos2$ = four & cutflag = one,
        [
        n$, *sgcode, *sgabsinc, "G53", "Z4.25", e$
        cutflag = zero
        ]
      #Modify following line to customize output for high-speed toolpath
      #tool inspection/change points
      if rpd_typ$ = 7, pbld, n$, "M00", "(TOOL INSPECTION POINT - POST CUSTOMIZATION REQUIRED)", e$

plinout         #Output to NC of linear movement - feed
      cutflag = one
      pcan1, pbld, n$, sgfeed, sgplane, `sgcode, sgabsinc, pwcs, pccdia,
        pxout, pyout, pzout, pcout, feed, strcantext, pscool, e$
      #Modify following line to customize output for high-speed toolpath
      #tool inspection/change points
      if rpd_typ$ = 7, pbld, n$, "M00", "(TOOL INSPECTION POINT - POST CUSTOMIZATION REQUIRED)", e$

pcirout         #Output to NC of circular interpolation
      cutflag = one
      pcan1, pbld, n$, `sgfeed, sgplane, sgcode, sgabsinc, pwcs, pccdia,
        pxout, pyout, pzout, pcout, parc, feed, strcantext, pscool, e$

Your 'prapidout' post block might look a little different. Just add the "retract" output condition after the main parameter output line.

 

This stuff:

      if cutpos2$ = four & cutflag = one,
        [
        n$, *sgcode, *sgabsinc, "G53", "Z4.25", e$
        cutflag = zero
        ]

Notice that I've put two conditions on the "if" line. The first condition 'cutpos2$ = four', checks the value of 'cutpos2$'. It is only true at the "end" of the operation during retract (condition 4). The next condition 'cutflag = one' is a "tracking" variable we use to make sure the G53 retract is only done on the "Z" retract move. Notice that after we output that G53 line, we reset the value of 'cutflag' back to zero. That prevents a duplicate G53 move on the next 'G0 Xx Yy' move. I also added two lines of code, one to 'plinout' and one to 'pcirout'. In both of these motion blocks we set the 'cutflag' to '1'. We do this to "set" the value of 'cutflag', so that when the next operation is processing, we will get our special 'if' condition to trigger during the retract motion.

 

Note that we could also choose to "set" the value of 'cutflag' in 'ptlchg1002'. (ptlchg1002$ is called before the start of every Tool Change motion (psof$, ptlchg$', ptlchg0$)).

 

But that's the basics of it. Set a "flag" variable that get "set" at the start of motion, and gets "reset" when the G53 retract is output. This prevents the "if cutpos2$ = four" from outputting twice. Since potentially both "G0" move could have 'cutpos2$' set to '4'.

 

Hope that helps,

 

Colin

  • Like 3
Link to comment
Share on other sites

Colin,

 

Thank you so much! that worked perfectly. It solved the issue and I learned alot too.

 

The only thing is, it puts the special rectract line on every rapid move to the "clearance" plane. So every time it retracts, to go in for another depth cut, it posts that line.

Can we add another condition that checks for a forced tool change, so that it only has the special retract when it is completely done with a tool?

Link to comment
Share on other sites

That's the problem. You want to check for a "Force Tool Change", but the post hasn't gotten to the "tool change event" yet. You are processing Motion commands, and trying to "tack on" the special retract, but we don't know how many depth cuts you are doing.

 

The way the NCI data is structured, you get a "Tool Change" event (NCI Gcode 1001 or 1002. 1001 is SOF, 1002 is "actual tool change") that changes your tool, then then the motion of the first depth cut. Then the NCI Gcode posts a 1001 "null tool change" for each depth cut.

 

So when we are processing "prapidout", that data in the NCI comes before the Null Tool Change and Actual Tool Change events.

 

You can't really search forwards or backwards during processing of the NCI file. Especially because of the fact that you have two "NCI Gcode 0" lines, (the Z move, then the XY), and you want to insert this G53 move in between the two moves. Since the MP language is a "scripting" language, you'd have to be able to "peek" ahead and see if the operation has really changed, or if we are just processing a depth cut.

 

I can suggest some things to try, but I'm not sure if any of them will really work.

 

First, check to make sure the "getnextop$" variable is defined in your post, and is set to '1'. This is the "get next op" variable switch, that builds the "next variable" list during the pre-read loop.

 

In your "if" statement, add some "debugging code" to output some values. See when/if they change, and if you can use that in your condition.

      if cutpos2$ = four & cutflag = one,
        [
        "DEBUG: ", ~nextop$, e$
        "DEBUG: ", ~op_id$, e$
        n$, *sgcode, *sgabsinc, "G53", "Z4.25", e$
        cutflag = zero
        ]

The problem is that I don't think those values will change until you actually hit the Tool Change event. So you won't be able to see "ahead" without involving the use of a buffer file.

 

The other option would be to try and calculate the total number of paths that are being cut in that operation, and passing that to the Tool Change event, and creating a counter variable that you can use to count down until you need to output the event.

 

But all that is a pain in the butt, and I don't recommend going those routes.

 

So, what's the solution then?

 

I'd recommend using the Tool Path Editor, and modifying the operation inside Mastercam to output the special retract where you want it. How do you do that? You use Canned Text to output a "flag" in the NCI at that point. The edit made inside the Tool Path Editor inserts an extra line into the NCI output (1025 NCI Gcode), and it processes through the normal "pcan, pcan1, and pcan2" post blocks. These are the "before, with, and after" calls.

 

Wait. What??? What does all that mean?      <<< I know that's what your thinking, right?

 

Ok, it's not so hard once you understand how the whole mechanism works inside MP.

 

The "Canned Text" function inside Mastercam is extremely powerful and flexible, but not many people understand how it works, or what it's used for.

 

Canned Text is a mechanism to output "Strings", at any point along the tool path.

 

In fact, there are two methods of "editing" a tool path:

  1. Use the "Change at Point" function in the Chain Manager, by Right-Clicking on a Chain. This function then allows you to click on "points" along the chain, where you can insert things like Feed Rate changes, M01/M00 stops, Spindle Speed changes, Coolant options, and Canned Text. The advantage of "Change at point" edits is that they are "associative" inside the Chain Manager. This allows you to do things like edit the parameters inside the operation, and regenerate. The limitations are it only works on chained geometry.
  2. Use the "Tool Path Editor". This is done as "secondary" edit to your operation. You need to make sure your operation is setup the way you want it. You're done editing the depth cuts/passes, speeds, feeds, everything. That's because once you use the "Tool Path Editor", the operation is now "Locked". You can "unlock" it using a button in the Ops manager, but if you go and make an edit that requires a regeneration, then your Edits are lost. To use the Tool Path Editor, Right-Click on any operation in the Operations Manager. Choose "Toolpath Editor" at the bottom of the list. You'll get a dialog box that allows you to step through the points and passes that make up all the Tool Path Motion. That way you can "edit" the tool path at any point along the path itself. You'll want to step to the end of the path, and insert your Canned Text on the Z retract move. Use the "After" option.

 

You need to know how Canned Text works, but I'll explain that in a second post...

  • Like 2
Link to comment
Share on other sites

Ok, so how does Canned Text work?

 

You enable the Canned Text options inside the Control Definition Manager. (or in our case, we just edit the text strings inside the post)

 

First, edit the text strings at the end of the post. Find any section that says [canned text], and edit the entries:

[canned text]
1. "Stop"
2. "Ostop"
3. "Bld on"
4. "bLd off"
5. "M5"
6. "M6"
7. "M7"
8. "M8"
9. "M9"
10. "M10"
11. "FULL Z RETRACT"

Above, I added option #11, to output "Full Z Retract". We can name the function whatever we want, but make it something that make sense for what you are actually doing.

 

Notice that options 1-4 already perform specific functions. For example. 1-2 are Machine Stops (M00 and M01), and 3-4 enable/disable Block Delete. Options 5-10 actually output M5 through M10.

 

So, how does the Canned Text option work?

 

Canned Text is an option that is available on every tool path dialog. You can have up to 200 different individual options to trigger different things. The 1025 line has up to 20 different variables that can be output on the same line. Each of these 20 values could be numbered 1-199. The 1025 line is always output at the Tool Change events, but could be output with no data in the parameter on the line.

 

So, to further complicate things, the value that is output can be output "before", "with", or "after". For the "before", the value is output normally. In our edit above, we are using option #11, so let's continue with that.

 

If we are using "before", the value is just output as "11". If we are outputting "with", then the value has "1000" added to it, so we would output "1011". For "After", we add "2000". So "2011", is "output option #11, using Canned Text After".

 

So how does the Before, With, and After functionality work?

 

There are B/W/A options at every Tool Change event. There are three specific post blocks that call "Canned Text" output. It was created this way to allow you to move these post blocks around, and change the output of Canned Text.

 

But...

 

The "with" option works a bit differently than the other two...

 

Ok, there are three post block that output Canned Text:

 

pcan  =  before

pcan1  =   with

pcan2  =   after

 

But 'pcan' and 'pcan2' are designed to output an "independent line" of NC code. So you can move the post block call around, and move the line of NC code output pretty easily.

 

pcan, pcan1, pcan2 all work by eventually calling 'pcant_out'. Don't worry too much about the details, but what eventually happens is this; inside 'pcant_out', the post block builds a string into this variable:

 

strcantext

 

So the 'strcantext' variable is the key. For 'pcan' and 'pcan2', the variable gets set, then output on a separate line of NC code, and then the variable gets flushed back to an "empty" string.

 

Ok, with 'pcan1', it works just a little differently. You always put 'pcan1' at the beginning of the line of NC code output, and then include "strcantext" at the end of the line of code output. This allows you to build extra strings (typically just M codes), and output them at the end of any line of NC Code.

 

So, for your options, use the Tool Path Editor, on the Z retract move, and output "option #11", after the line of output.

 

-----------------------

 

If you are making edits to Canned Text output at the Tool Change, you move 'pcan'. (pcan2) is at the start of 'pcom_movea'.

 

But we aren't concerned at this moment with "Tool Change" Canned Text. We are outputting Canned Text using the Tool Path Editor.

 

So this output would be in the middle of Motion Gcode.

 

All motion in a modern post comes from 'pncoutput'. This gets called by all of the "Entry" post blocks.

 

If you look at 'pncoutput', you'll see the call to 'pcan', then the calls to 'prapidout', 'plinout', and 'pcirout'. Then after these calls, you'll see the call to 'pcan2'.

 

All of the motion output blocks; 'prapidout', 'plinout', and 'pcirout', have 'pcan1' and 'strcantext' at the beggining/end of the output lines.

 

So that is the rather convoluted flow of logic. Other than making the edits to the [canned text] section, and making the edits in the Tool Path Editor, you just have to edit the 'pcant_out' post block like so:

pcant_out       #Canned text - build the string for output
      #Assign string select type outputs
      if cant_pos < three, #cant_pos indicates canned text output
        [
        if cantext$ = three, bld = one
        if cantext$ = four, bld = zero
        #Build the cantext string
        if cantext$ = one, strcantext = strcantext + sm00
        if cantext$ = two, strcantext = strcantext + sm01
        if cantext$ > four,
          [
          if cant_val1$ = 11, strcantext = "G0 G90 G53 Z4.25"
          else,
            [
            strtextno = no2str(cantext$)
            strcantext = strcantext + strm + strtextno
            ]
          ]
        ]

Original code:

pcant_out       #Canned text - build the string for output
      #Assign string select type outputs
      if cant_pos < three, #cant_pos indicates canned text output
        [
        if cantext$ = three, bld = one
        if cantext$ = four, bld = zero
        #Build the cantext string
        if cantext$ = one, strcantext = strcantext + sm00
        if cantext$ = two, strcantext = strcantext + sm01
        if cantext$ > four,
          [
          strtextno = no2str(cantext$)
          strcantext = strcantext + strm + strtextno
          ]
        ]
  • Like 4
Link to comment
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...