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:

Haas peck tapping


Recommended Posts

I want to add peck tapping functionality to all of our Haas machines. We have modified posts based on both the Generic 3X and MPMASTER.

The g code has to generate a new line of code for each peck with an  XY position followed by the Z depth for the peck depth. Like this:

 

G0 G90 G94 G54 X0. Y0. S320 M3

G98 G84 Z-.1 R.1 F10.

X 0. Z-.2

X0. Z-.3

X1. Z-.1

X1. Z-.2

X1. Z-.3

X2.5 Y1. Z-.1

X2.5 Z-.2

X2.5 Z-.3

G80

 

I want to add a new postblock named ppecktap and have this at  the beginning of my pdrlcommonb:

if sav_dgcode = 81,
        if drillcyc$ = three & peck1$ > 0
        [
        ppecktap
        ]
      else

I know I need to create some format labels to calculate the peck depths and to create the logic in ppecktap, but I am not very good at creating the logic. Its been kicking my butt for 2 days.

Can anyone give me some guidance on how to create the logic to make this work?

 

Link to comment
Share on other sites

This is what I've come up with so far.

ppecktap         #Canned Peck tapping for Haas
      if drillcyc$ = three & peck1$ > 0
      [
      calc_depth = (depth$ - tosz$)               # The total caculated cutting depth
      peck_depth = peck1$                         #Incremental peck depth
      strt_depth = (tosz$+ peck_depth)            # the first peck depth
      cur_depth = (strt_depth + peck_inc)         #subsequent depths
      ]
        while cur_depth <> calc_depth
          [
          cur_depth = (prv_cur_depth + peck_inc)
          ]

 

How can I make logic that will ensure that my while loop doesn't loop forever when the peck_depth is not an integer value of the calc_depth?

Link to comment
Share on other sites

Getting closer, this is my ptap & ppecktap postblocks:

ptap$            #Canned Tap Cycle
      pdrlcommonb
      #RH/LH based on spindle direction
      if drillcyc$ = three & peck1$ > 0, pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, prdrlout, ppecktap,
           strt_depth, feed, e$
          n$, *pdrlxy, cur_depth, e$
          n$, *pdrlxy, last_peck, e$
      else,
#      if rigid_tap, pbld, n$, *sm29, *speed, e$           #Rigid Tapping
#      if use_pitch = 0,
#        [
#        pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
#          prdrlout, [if peck1$, *peck1$], *feed, strcantext, e$
#        ]
#      else,
        [
        if metvals, pitch = n_tap_thds$  # Tap pitch (mm  per thread)
        else, pitch = 1/n_tap_thds$       # Tap pitch (inches per thread)
        pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
          prdrlout, [if peck1$, *peck1$], *pitch, !feed, strcantext, e$
        ]
      pcom_movea

ppecktap         #Canned Peck tapping for Haas
      
        calc_depth = (depth$ - tosz$)               # The total caculated cutting depth
        peck_depth = peck1$                         # Incremental peck depth
        strt_depth = (tosz$ - peck_depth)            # The first peck depth
        cur_depth = (strt_depth - peck_depth)         # Subsequent depths
        last_peck = calc_depth                      # The last peck depth

          while cur_depth < calc_depth, cur_depth = (prv_cur_depth - peck_depth), e$
          if cur_depth < calc_depth, last_peck

 

And this is what its outputting:

G98 G84 X.3337 Y1.9335 R.1 Z-.05 F10.
X.3337 Y1.9335 Z-.1
X.3337 Y1.9335 Z-.3
X10.9337 Y1.9335 Z-.3
X21.5337 Y1.9335
X29.9337 Y1.9335
G80
M9
M05

Its only outputting the 1st cur_depth and the there's no Z output at all after the 1st hole.

 

Link to comment
Share on other sites

Ok, I got rid of the ppecktap section and changed the ptap$ to this:

ptap$            #Canned Tap Cycle <<PST LINE (2895) - Missing a matching open bracket
      pdrlcommonb
      #RH/LH based on spindle direction
      calc_depth = (depth$ - tosz$)               # The total caculated cutting depth
      peck_depth = peck1$                         # Incremental peck depth
      strt_depth = (tosz$ - peck_depth)            # The first peck depth
      rem_depth = (calc_depth-strt_depth)
      if drillcyc$ = three & peck1$ > 0,
        [
        pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, prdrlout, strt_depth, feed, e$
          n$, *pdrlxy, *rem_depth, e$
          while rem_depth <> 0
            [                      <<PST LINE (2907) - The formula/boolean failed (general message), , Label was expected but was not found[13], Illegal character(s) encountered
            rem_depth = (prv_rem_depth - peck_depth),
            if rem_depth < peck_depth
              [                   <<PST LINE (2910) - The formula/boolean failed (general message), , Label was expected but was not found[13], Illegal character(s) encountered
              rem_depth = 0,
              ]
            ]
        ]
      else,
        [
        if metvals, pitch = n_tap_thds$  # Tap pitch (mm  per thread)
        else, pitch = 1/n_tap_thds$       # Tap pitch (inches per thread)
        pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
          prdrlout, [if peck1$, *peck1$], *pitch, !feed, strcantext, e$
        ]
      pcom_movea

But I still get essentially the same errors

Link to comment
Share on other sites

This is the output:

G98 G84 X.3337 Y1.9335 R.1 Z-.05 F10.
X.3337 Y1.9335 Z-.39
X10.9337 Y1.9335 Z-.44
X21.5337 Y1.9335
X29.9337 Y1.9335
G80
M9
M05

Its isn't generating the .05 incremental pecks between Z-.05 & Z-.39. And it doesn't reach the Z-.44 cacl_depth on the 1st hole.

Not to mention none of the logic is reaching the other holes. I think they are generated by ptap_2$.

I've been working on this for 3 days now. I think I'm getting a handle on it, but I can't figure out what I'm doing wrong that gets these errors.

I keep going back and forth to the MP documentation.

Link to comment
Share on other sites

Ok, I started over from scratch...again. This time I created a custom drill cycle. But I am still getting the same darn errors telling me that :

- The formula/boolean failed (general message), , Label was expected but was not found[9], Illegal character(s) encountered

- The formula/boolean does not terminate properly

These errors are at the postline that has nothing but the open bracket for my while loop!

What the heck am I doing wrong??? I've compared my syntax to other while loops in this and a couple other posts, I can't figure it out.:wallbash:

The other error I get is :

- Missing a matching open bracket

This one is on the postblock line of the pdrlcst9 that I created for the custom drill cycle. Why the heck would MP be expecting a bracket there?

Here's my postblocks, they aren't finished, but I just want to figure out the syntax first.

pdrlcst9        #Canned Peck tapping cycle
      pdrlcommonb
      trgt_depth = (depth$ - tosz$)               # The total caculated cutting depth
      peck_depth = peck1$                         # Incremental peck depth
      strt_depth = (tosz$ - peck_depth)            # The first peck depth
      rem_depth = (trgt_depth-cur_depth)
      cur_depth = strt_depth
      pcan1, pbld, n$, *sgdrlref, *sgdrill, pxout, pyout, strt_depth, prdrlout, feed, strcantext, e$
      while rem_depth <> 0
        [
        cur_depth = (prv_cur_depth - peck_depth),
        if cur_depth < peck1$, peck_depth = (trgt_depth -cur_depth)
        ]


pdrlcst9_2      #Canned Peck tapping cycle additional points
      pdrlcommonb
      pcan1, pbld, n$, pxout, pyout, strt_depth, strcantext, e$
      pcom_movea

Any clues or suggestions are greatly appreciated.

 

Zeke

Link to comment
Share on other sites

I removed the brackets and the errors went away. Now it looks like this:

pdrlcst9        #Canned Peck tapping cycle
      pdrlcommonb
      trgt_depth = (depth$ - tosz$)               # The total caculated cutting depth
      peck_depth = peck1$                         # Incremental peck depth
      strt_depth = (tosz$ - peck_depth)           # The first peck depth
      rem_depth = (trgt_depth-cur_depth)
      cur_depth = strt_depth
      pcan1, pbld, n$, *sgdrlref, *sgdrill, pxout, pyout, strt_depth, prdrlout, feed, strcantext, e$
      while rem_depth <> 0 & cur_depth < peck1$, cur_depth = (prv_cur_depth - peck_depth),
      n$, pfxout, cur_depth,e$,
      if cur_depth < peck1$, peck_depth = (trgt_depth -cur_depth),
      n$, pfxout, cur_depth,e$,

pdrlcst9_2      #Canned Peck tapping cycle additional points
      pdrlcommonb
      pcan1, pbld, n$, pxout, pyout, strt_depth, strcantext, e$
      pcom_movea

 

It's giving this output:

(GRID PLATE- 6-32 TAP)
T21 M6
G0 G90 G94 G54 X.3337 Y1.9335 S320 M3
G43 H21 Z1.
M8
G98 G84 Z-.05 R.1 F10.
X.3337 Z-.05
X.3337
X.3337 Z.34
X10.9337
X21.5337
X29.9337
G80
M9
M5
G91 G28 Z0.
G28 X0. Y0.
M30
%

 

Still not what I want, but moving in the right direction.

  • Like 1
Link to comment
Share on other sites

I think the place you've gotten confused is the purpose of the "While" loop. It isn't just to "calculate" some values for you. In this case, you should be using the 'While Loop' to output the "additional Peck values". The thing that is tripping you up (I think), is that you're trying to call the "while loop", in the middle of an output line, where what you really want, is just the "First Peck" depth value.

I took mercy on you (Just kidding, I was bored), and worked out some code over the weekend.

I've kept your variable names (for the most part), but added a couple more, that you'll need to initialize:

sav_force_dpts : 0
peck_tap_flag  : 0 #Flag to indicate that 'peck tapping' was active for ptap_2$

Next, replace your existing code inside 'ppecktap', and try this instead:

ppecktap        #Additional XYZ positions from Haas Peck Tap routine.
      while cur_depth > last_peck, #Loop until calc_depth = to last peck
        [
        cur_depth = cur_depth - peck_depth #Decrement depth
        if cur_depth <= last_peck, cur_depth = last_peck #Ensure last depth is output
        zabs = cur_depth #Assign Z for output
        pbld, n$, pdrlxy, pfzout, e$ #Output line for peck depths!
        ]

Next, replace your 'ptap$' Post Block (all of it), with the following:

ptap$            #Canned Tap Cycle
      pdrlcommonb
      if peck1$, #Peck tapping is enabled!
        [
        peck_tap_flag = yes$ #Set flag for pcanceldc$
        if tosz$ > 0 & depth$ >= 0, calc_depth = (tosz$ - depth$)
        if tosz$ > 0 & depth < 0, calc_depth = (abs(tosz$) + abs(depth$))
        if tosz$ = 0 & depth$ < 0, calc_depth = abs(depth$)
        if tosz$ < 0, calc_depth = tosz$ - depth$
        peck_depth = peck1$               #Set peck depth
        strt_depth = tosz$ - peck_depth   #Set strt_depth
        cur_depth = strt_depth            #Set variable for while loop
        last_peck = depth$
        zabs = strt_depth
        pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
          prdrlout, *feed, strcantext, e$
        sav_force_dpts = force_dpts
        force_dpts = yes$ # Set force out XY Drill Points before while loop
        ppecktap
        ]
      else,
        [
        #RH/LH based on spindle direction
        if rigid_tap, pbld, n$, *sm29, *speed, e$           #Rigid Tapping
        if use_pitch = 0,
          [
          pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
            prdrlout, [if peck1$, *peck1$], *feed, strcantext, e$
          ]
        else,
          [
          if metvals, pitch = n_tap_thds$  # Tap pitch (mm  per thread)
          else, pitch = 1/n_tap_thds$       # Tap pitch (inches per thread)
          pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
            prdrlout, [if peck1$, *peck1$], *pitch, !feed, strcantext, e$
          ]
        ]
      pcom_movea

We're not done!

In order to get your "Additional Tapped XY Points", you have to modify 'ptap_2$' as well:

ptap_2$          #Canned Tap Cycle
      pdrlcommonb
      if peck_tap_flag,
        [
        zabs = strt_depth
        cur_depth = strt_depth
        pbld, n$, pdrlxy, pfzout, pcout, pindexdrl, prdrlout, e$
        ppecktap #Call additional points.
        ]
      else, pcan1, pbld, n$, pdrlxy, pzout, pcout, pindexdrl, prdrlout, strcantext, e$
      pcom_movea

And finally, add the following line to the top of 'pcanceldc$':

pcanceldc$       #Cancel canned drill cycle
      if peck_tap_flag, peck_tap_flag = no$ #Reset flag value
      result = newfs (three, zinc)

 

Link to comment
Share on other sites

Ok, I also did the same thing, with some additional "comments" to help you try and make some sense of what is going on...

sav_force_dpts : 0
peck_tap_flag  : 0 #Flag to indicate that 'peck tapping' was active for ptap_2$

ppecktap        #Additional XYZ positions from Haas Peck Tap routine.
      #NOTE: This post block should be called AFTER you output the "strt_depth" Z value
      #  'ptap$' and 'ptap_2$' have been modified to output the 'strt_depth' only,
      #  then to 'call' this block. This block output all "pecks" including "final peck".
      while cur_depth > last_peck, #Loop until calc_depth = to last peck
        [
        cur_depth = cur_depth - peck_depth #Decrement depth
        if cur_depth <= last_peck, cur_depth = last_peck #Ensure last depth is output
        zabs = cur_depth #Assign Z for output 
        #Rember that XY points are already forced!
        pbld, n$, pdrlxy, pfzout, e$ #Output line for peck depths!
        ]


ptap$            #Canned Tap Cycle
      pdrlcommonb
      if peck1$, #Peck tapping is enabled!
        [
        peck_tap_flag = yes$ #Set flag for pcanceldc$
        #First, calculate the true "Cut depth"
        if tosz$ > 0 & depth$ >= 0, calc_depth = (tosz$ - depth$)
        if tosz$ > 0 & depth < 0, calc_depth = (abs(tosz$) + abs(depth$))
        if tosz$ = 0 & depth$ < 0, calc_depth = abs(depth$)
        if tosz$ < 0, calc_depth = tosz$ - depth$
        #Note: 'calc_depth' should now contain the "true" depth of the hole
        peck_depth = peck1$               #Set peck depth
        strt_depth = tosz$ - peck_depth   #Set strt_depth
        cur_depth = strt_depth            #Set variable for while loop, (remember, we will subtract the peck on 1st loop!)
        last_peck = depth$
        #Here, we are overwriting the value of "zabs", with our calculated value!
        # This makes sure we are still using the "output mechanism"; 'pfzout'.
        zabs = strt_depth
        #Start 1st output "G84" call line. (Single G84 Line of output code, with 1st peck depth)
        pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
          prdrlout, *feed, strcantext, e$
        #We know we need to force XY points out. So, save the current "force" value, and restore at drill cycle cancel.
        sav_force_dpts = force_dpts
        force_dpts = yes$ # Set force out XY Drill Points before while loop
        
        #Ok, we've got our 1st line out. We know the "current depth", and the final depth.
        #  Now, is the time for the 'While Loop'. The important thing to understand here
        #  is that 'ptap$' only outputs data (XYZ), for the FIRST Hole in the canned cycle.
        #  ALL OTHER HOLES ARE OUTPUT FROM 'ptap_2$'!!!!! This is super important to understand.
        #  Call to the "while loop"
        ppecktap
        ]
      else,
        [
        #RH/LH based on spindle direction
        if rigid_tap, pbld, n$, *sm29, *speed, e$           #Rigid Tapping
        if use_pitch = 0,
          [
          pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
            prdrlout, [if peck1$, *peck1$], *feed, strcantext, e$
          ]
        else,
          [
          if metvals, pitch = n_tap_thds$  # Tap pitch (mm  per thread)
          else, pitch = 1/n_tap_thds$       # Tap pitch (inches per thread)
          pcan1, pbld, n$, *sgdrlref, *sgdrill, pdrlxy, pfzout, pcout, pindexdrl,
            prdrlout, [if peck1$, *peck1$], *pitch, !feed, strcantext, e$
          ]
        ]
      pcom_movea

 

 


ptap_2$          #Canned Tap Cycle
      pdrlcommonb
      if peck_tap_flag,
        [
        zabs = strt_depth
        cur_depth = strt_depth
        #This line outputs the start depth for the "additional" holes.
        pbld, n$, pdrlxy, pfzout, pcout, pindexdrl, prdrlout, e$
        ppecktap #Call additional points.
        ]
      else, pcan1, pbld, n$, pdrlxy, pzout, pcout, pindexdrl, prdrlout, strcantext, e$
      pcom_movea

 

 

  • Like 1
Link to comment
Share on other sites
43 minutes ago, Colin Gilchrist said:

Ok, I also did the same thing, with some additional "comments" to help you try and make some sense of what is going on...

Thank you Colin, I'm going to study this awhile.

I have been making some progress. This is the most challenging post project I've tried so far and although I haven't been successful yet, I've learned a great deal.

  • Like 1
Link to comment
Share on other sites

I think there were a few things missing perhaps, in your knowledge of how Drill Cycles "work". There are some mechanisms that get called "automatically", based on the formatting of the NCI File.

In the NCI Data, each set of "Drill Points" is presented in "2-line" sets.

The 1st "Hole" of the set is NCI Gcode 81.

The Parameter line that "follows" the 81 code has all the Drill Parameters (for the Drill Cycle), but the first parameter is the "Drill Cycle number. Based on the value (0-7), MP automatically calls the Entry Post Block, that is associated with the Drill Cycle Number. For Drill Cycle #3, it will call 'ptap$'. For Drill Cycle #0, it will call 'pdrill$'. For Drill Cycle #1, it will call 'ppeck$', for #2 it calls 'pchpbrk$'.

#4 calls 'pbore1$', #5 calls 'pbore2$', #6 calls 'pmisc1$', and #7 calls 'pmisc2$'.

The important thing to note here, is that in the first cycle call line,   we only output the 1st drill point of the series.

If we only have a single hole, the 81 line (2-line set), is followed by a "80" NCI Gcode line. (The 80 code is output with a "blank" parameter line, in keeping with MP's "2-line set" rule.)

If we have additional holes, that are executed in the same "Operation", then all of the "additional drill points" (NCI Lines that "follow" the G81 line), are output as NCI Gcode "100".

These "100" lines are output with the same "parameter" line, and could include "changes" to the Drill Cycle parameters. For example, it is possible to "change depth" within the "same drill cycle", by selecting a series of Drill Points in Mastercam, with different Z Values.

For all of the "Additional Drill Points" of the same Drill Cycle, we call a different set of Entry Post Blocks. All Subsequent Points (NCI Gcode 100), are output from the "_2" series of blocks.

pdrill$ ---> pdrill_2$

ppeck$ --> ppeck_2$

.

ptap$ --> ptap_2$

.

.

pmisc2$ --> pmisc2_2$

So, we have to come up with a solution (for the while loop), that outputs "just the additional Z depths", and not the "additional XY points" as well. Those Additional Points, we handle with code in '_2' Post Blocks...

 

 

 

Link to comment
Share on other sites
3 minutes ago, Colin Gilchrist said:

The Parameter line that "follows" the 81 code has all the Drill Parameters (for the Drill Cycle), but the first parameter is the "Drill Cycle number. Based on the value (0-7)

I did get that figured out over the weekend, but I couldn't figure out how to get my output. That's why I had switched to trying to create a custom drill cycle, just for the peck tapping. That way I could create all of the postblocks I needed & have the predefined ones like pdrlcst point to my postblocks with

      if drillcyc$ = 9, pdrlcst9
      else,

I am still going to pursue this for the experience, even though I've got it working with a couple of edits, using your code from above.

Link to comment
Share on other sites
7 minutes ago, Colin Gilchrist said:

But it should be darn close

Yes, it most certainly was! I had to add a $ to depth here

if tosz$ > 0 & depth < 0, calc_depth = (abs(tosz$) + abs(depth$))

And initialize a label, I forgot which one. It amazes me that one character, the $, generated 125 errors and correcting it made them all go away.

Thank you again, I truly appreciate your patient assistance.

  • Like 1
Link to comment
Share on other sites
7 hours ago, Colin Gilchrist said:

You'll want to test the output and let me know if anything is wrong

If I select holes at varying heights, with incremental settings on the linking page, the "R" reference height updates correctly, but the depth and peck remain the same.

What is the best way to update the tosz$ & depth$ so that ptap_2 outputs correct values?

Link to comment
Share on other sites

It's not very elegant, but I got it to work buy adding a good deal of ptap$ to ptap_2$:

ptap_2$          #Canned Tap Cycle
      pdrlcommonb
      if peck_tap_flag,
        [
        if tosz$ > 0 & depth$ >= 0, calc_depth = (tosz$ - depth$)
        if tosz$ > 0 & depth$ < 0, calc_depth = (abs(tosz$) + abs(depth$))
        if tosz$ = 0 & depth$ < 0, calc_depth = abs(depth$)
        if tosz$ < 0, calc_depth = tosz$ - depth$
        #Note: 'calc_depth' should now contain the "true" depth of the hole
        peck_depth = peck1$               #Set peck depth
        strt_depth = tosz$ - peck_depth   #Set strt_depth
        cur_depth = strt_depth            #Set variable for while loop, (remember, we will subtract the peck on 1st loop!)
        last_peck = depth$
        #Here, we are overwriting the value of "zabs", with our calculated value!
        # This makes sure we are still using the "output mechanism"; 'pfzout'.
        zabs = strt_depth
        #Start 1st output "G84" call line. (Single G84 Line of output code, with 1st peck depth)
        pcan1, pbld, n$, pdrlxy, pfzout, pcout, pindexdrl,
          prdrlout, *feed, strcantext, e$
        #We know we need to force XY points out. So, save the current "force" value, and restore at drill cycle cancel.
        sav_force_dpts = force_dpts
        force_dpts = yes$ # Set force out XY Drill Points before while loop
        ppecktap #Call additional points.
        ]
      else, pcan1, pbld, n$, pdrlxy, pzout, pcout, pindexdrl, prdrlout, strcantext, e$
      pcom_movea

 

I'm still testing.

  • Like 1
Link to comment
Share on other sites

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...