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:

z_min$, z_max$


Recommended Posts

Hi,

 

In the ptooltable i've added z_min$ and z_max$ to capture the minimum and maximum values for Z.

 

the output is:


( T2 - VLAKFREES 125MM - H2 )
( T3 - HM BOOR 10.3MM INWENDIGE KOELADAP - H3 ) MINIMAAL - Z65. MAXIMAAL - Z170.
( T4 - HOEKFREES 32MM - H4 - D4 - CONTROL COMP - TOOL DIA. - 32. ) MINIMAAL - Z41. MAXIMAAL - Z165.
( T5 - AFSCHUINFREES 1SN SANVIK - H5 - D5 - CONTROL COMP - TOOL DIA. - 16. ) MINIMAAL - Z60.1
( T6 - GRAVEERFREES  - H6 ) MINIMAAL - Z64.1
( T7 - HM SN 12MM D COMP - H7 - D7 - CONTROL COMP - TOOL DIA. - 12. ) MINIMAAL - Z64.8 MAXIMAAL - Z115.
( T11 - VERZINKBOOR 30MM - H11 ) MINIMAAL - Z60. MAXIMAAL - Z165.
( T8 - TAP BLIND M12 - H8 ) MINIMAAL - Z58.85
 
as you can see, the first tool is empty. And the values for T3, are the values that should be for T2. I've also tried it with mpfan.pst. any idea's?
 
Thanks in advance, Roy Zomer
Link to comment
Share on other sites

Hi Roy,

 

I'm pretty sure those values don't get calculated until after the motion for the operation has been processed. So if you are trying to capture these in 'pwrtt$', you'll need to be sure that when you write them to the Tool Table output, you increment your read counter by 1. Also, you probably need to modify 'pwrtt$' to read the 1003 Gcode (EOF), and read the min/max Z there for the last operation (write the values to the buffer file).

 

Hope that helps,

 

Colin

Link to comment
Share on other sites

Thank you Colin!

 

PcRobotic,

I got it working after each operation. I'm trying to work on it some more....   What I've done is to take a look at the mill.set file. Try to figure out what's going on there with the buffer file Colin is talking about. .....   It got me this far!!!!   Good luck.

Link to comment
Share on other sites
  • 2 months later...

This may help ? These X8 routines store the min max of each tool into a buffer. Will work for older versions.

See the subroutine headers where to place the text below.

I hope I haven't forgoten anything. I don't check the forum often.

 

 

output_z : yes$  #Output Z Min and Z Max values (yes or no)


tool_info    : 3     #Output tooltable information?
                     #0 = Off - Do not output any tool comments or tooltable
                     #1 = Tool comments only
                     #2 = Tooltable in header - no tool comments at T/C
                     #3 = Tooltable in header - with tool comments at T/C




# --------------------------------------------------------------------------
# Buffer 1 Files for NEW Sequence Number routine
# --------------------------------------------------------------------------
#      "Nxxyy    xx = tool number   yy = repeat counter"
rc1          : 1
wc1          : 1
tlcount      : 0
fbuf 1 0 1 0 0
tlusage      : 0
fmt N 7 tlusage

# --------------------------------------------------------------------------
# Buffer 4 - Holds the variable 't' for each toolpath segment
# ------------------------------------------------------------------------
rc4 : 1                                                            #  
wc4 : 1                                                            #  
fbuf 4 0 1 0 0  # Buffer 4                                         #  
# ------------------------------------------------------------------------
# Buffer 5 - Min / Max                                             #  
# ------------------------------------------------------------------------
b5_gcode : 0                                                       #  
b5_zmin  : 0                                                       #  
b5_zmax  : 0                                                       #  
rc5      : 2                                                       #  
wc5      : 1                                                       #  
size5    : 0                                                       #  
fbuf 5 0 3 0 0          #Min / Max                                 #  


# ------------------------------------------------------------------------
fmt  "X" 2  x_tmin      #Total x_min                               #
fmt  "X" 2  x_tmax      #Total x_max                               #
fmt  "Y" 2  y_tmin      #Total y_min                               #
fmt  "Y" 2  y_tmax      #Total y_max                               #
fmt  "Z" 2  z_tmin      #Total z_min                               #
fmt  "Z" 2  z_tmax      #Total z_max                               #
fmt  "Z" 2  min_depth   #Tool z_min                                #
fmt  "Z" 2  max_depth   #Tool z_max                                #
#-------------------------------------------------------------------------

 

 

#Call this in pwrtt$
pinittlcount  #Initialize tool count
     if t$ > 0,
       [
       wc1 = t$
       tlcount = wbuf(1, wc1) #Write tool usage counter to buffer file. Initial counter is zero.
       ]

#Call in tool change post block and start of file post block if it is mill 4 axis post
ptoolcounter  #Buffer tool usage count
       rc1 = t$
       tlcount = rbuf(1, rc1)  #Read tool usage counter for current tool
       tlcount = tlcount + 1   #Tool usage counter
       wc1 = t$
       tlcount = wbuf(1, wc1)  #Save tool usage counter to buffer file

ptlusageout #Output tool usage
       tlusage = t$ * 100 + tlcount
       tlusage




# --------------------------------------------------------------------------
ptoolcomment    #Comment for tool
      tnote = t$, toffnote = tloffno$, tlngnote = tlngno$
      if tool_info = 1 | tool_info = 3,
           sopen_prn, ~t$, "= ",pstrtool,  sclose_prn, e$
# --------------------------------------------------------------------------




psof$            #Place this in psof . Start of file for non-zero tool number             
      ptoolcounter  #Calculate tool usage counter
#----------------------------------------------------------------------
      ptravel                                                   #  
      pwritbuf5                                                 #  
      if output_z = yes$ & tcnt > 0,                            #  
        [                                                       #  
        sav_spc = spaces$                                       #  
        spaces$ = 0                                             #  
        "(", "OVERALL MAX = ", *z_tmax, ")", e$                 #  
        "(", "OVERALL MIN = ", *z_tmin, ")", e$                 #  
        spaces$ = sav_spc                                       #          
        ]                                                       #  
#----------------------------------------------------------------------





psof$            #Place this in Psof and Tool Change
ptlchg$          #Tool change
#-----------------------------------------------------------------------      
      if output_z = yes$,                                        #  
        [                                                        #  
        preadbuf5                                                #  
        if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,          #  
          [                                                      #  
          #sav_spc = spaces$                                     #  
          spaces$ = 0                                            #  
          "(", "MAX = ", *max_depth, ")", e$                     #  
          "(", "MIN = ", *min_depth, ")", e$                     #  
          spaces$ = sav_spc                                      #  
          ]                                                      #  
        ]                                                        #  
#-----------------------------------------------------------------------




#-------------------------------------------------------------------------
ptravel    # Tool travel limit calculation                         #
           if x_min$ < x_tmin, x_tmin = x_min$                     #
           if x_max$ > x_tmax, x_tmax = x_max$                     #
           if y_min$ < y_tmin, y_tmin = y_min$                     #
           if y_max$ > y_tmax, y_tmax = y_max$                     #
           if z_min$ < z_tmin, z_tmin = z_min$                     #
           if z_max$ > z_tmax, z_tmax = z_max$                     #

# ------------------------------------------------------------------------
# Buffer 5  Read / Write Routines                               
# ------------------------------------------------------------------------
pwritbuf5   # Write Buffer 5                                       #
            b5_gcode = gcode$                                      #
            b5_zmin = z_min$                                       #
            b5_zmax = z_max$                                       #
            b5_gcode = wbuf(5, wc5)                                #
# ------------------------------------------------------------------------
preadbuf5   # Read Buffer 5                                        #
            size5 = rbuf(5,0)                                      #
            b5_gcode = 1000                                        #
            min_depth = 99999                                      #
            max_depth = -99999                                     #
            while rc5 <= size5 & b5_gcode = 1000,                  #
              [                                                    #
              if rc5 <= size5, b5_gcode = rbuf(5,rc5)              #
              if b5_zmin < min_depth, min_depth = b5_zmin          #
              if b5_zmax > max_depth, max_depth = b5_zmax          #
              ]                                                    #
# ------------------------------------------------------------------------
pwrtt$          #Pre-read NCI file
      if tool_info > 1 & t$ > 0 & gcode$ <> 1003, ptooltable
      pinittlcount                                            #Initialize tool usage counter
      if t$ > 0, tcnt=tcnt+1                                  #
      ptravel                                                 #
      pwritbuf5                                               #
      #if t$ <> prv_t$ & t$ > 0, pwritebuf7                    #Buffer 7
# ------------------------------------------------------------------------


 

  • Like 1
Link to comment
Share on other sites
  • 3 weeks later...

Hi,

i want to generate total maximum/minimum coordinates of whole program, so i added this into my post:

 

#buffer 2 min/max
b2_xmin : 0
b2_xmax : 0
b2_ymin : 0
b2_ymax : 0
b2_zmin : 0
b2_zmax : 0
size2 : 0
rc2 : 2
wc2 : 1
fbuf 2 0 3 0 0

 

 

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

 

# variable def
fmt "" 2 x_tmin     #min X
fmt "" 2 x_tmax     #max X
fmt "" 2 y_tmin     #minY
fmt "" 2 y_tmax     #max Y
fmt "" 2 z_tmin     #min Z
fmt "" 2 z_tmax     #max Z

 

 

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

# in psof section:

 

      ptravel
      pwritbuf2
      ";(","X-MIN= ",*x_tmin,")",e$
      ";(","X-MAX= ",*x_tmax,")",e$
      ";(","Y-MIN= ",*y_tmin,")",e$
      ";(","Y-MAX= ",*y_tmax,")",e$
      ";(","Z-MIN= ",*z_tmin,")",e$
      ";(","Z-MAX= ",*z_tmax,")",e$

 

ptravel
    if x_min$ < x_tmin, x_tmin = x_min$
    if x_max$ > x_tmax, x_tmax = x_max$
    if y_min$ < y_tmin, y_tmin = y_min$
    if y_max$ > y_tmax, y_tmax = y_max$
    if z_min$ < z_tmin, z_tmin = z_min$
    if z_max$ > z_tmax, z_tmax = z_max$

# buffer read write
pwritbuf2
     b2_xmin = x_min$
    b2_xmax = x_max$
    b2_ymin = y_min$
    b2_ymax = y_max$
    b2_zmin = z_min$
    b2_zmax = z_max$

 

 

 

 

 

and the result is this:

 

 

100 BEGIN PGM T MM
0 ; T
 ; DATE - 28-10-14
 ; TIME - 17:45
 ; MCX FILE -T
 ; NC FILE - C:\.............\T.H
 ; Created by: Kominik
110 BLK FORM  0.1 Z X+0.000 Y+0.000 Z+0.000
120 BLK FORM  0.2   X+0.000 Y+0.000 Z+0.000
; C. 20 R:5.00 Cor.rad.:0.50 overal:70 Code: 574.100.05
; C. 21 R:5.00 Cor.rad.:0.00 overal:50 Code: 80.6302
;( X-MIN= -109.356 )
;( X-MAX= +69.618 )
;( Y-MIN= -35.330 )
;( Y-MAX= +51.990 )
;( Z-MIN= +0.000 )
;( Z-MAX= +25.000 )
130 TOOL CALL 20 Z S22000
140 L X-72.967 Y+3.995 R0 FMAX M03
150 L Z+25.000 R0 FMAX M9
160 L Z+10.000 R0 FMAX
170 L Z+0.000 R0 F1500
180 L X-68.232 Y-4.814 R0 F6500
190 CC X-59.424 Y-0.079
200 C X-54.689 Y-8.887 DR+ R0
.....
....
...
..
.

 

 

It looks exactly what i want, but i would like to ask you, if this code is without any hidden bug.

Thanks

Link to comment
Share on other sites

Hello all, I all like this info in my post, I have modified an MP Master Post and that is one of the modifications but the standard posts in M\C don't have this in there, this should be a feature added in.

Does anyone know if Alfred S. modifications work and can they be used in an X7 post?

Link to comment
Share on other sites

Hello all, I all like this info in my post, I have modified an MP Master Post and that is one of the modifications but the standard posts in M\C don't have this in there, this should be a feature added in.

Does anyone know if Alfred S. modifications work and can they be used in an X7 post?

Speaking in generalities, any valid code an an MPMaster should be valid in a CNC Post

 

With that said there made be some logic that needs to be added or altered depending on exactly what you're doing but valid logic is valid logic

Link to comment
Share on other sites

Yea, I tried to get this running in the post I use for the Haas mill but I guess I couldn't get the logic in the proper places. (I have been told that I am not very logical) I still want to get that going but time is at a premium. You almost have to be in the right state of mind to do this stuff.

Link to comment
Share on other sites
  • 3 years later...
  • 5 months later...
On ‎10‎/‎7‎/‎2014 at 4:33 AM, Alfred Salzmann said:

This may help ? These X8 routines store the min max of each tool into a buffer. Will work for older versions.

See the subroutine headers where to place the text below.

I hope I haven't forgoten anything. I don't check the forum often.

 

 

output_z : yes$  #Output Z Min and Z Max values (yes or no)


tool_info    : 3     #Output tooltable information?
                     #0 = Off - Do not output any tool comments or tooltable
                     #1 = Tool comments only
                     #2 = Tooltable in header - no tool comments at T/C
                     #3 = Tooltable in header - with tool comments at T/C




# --------------------------------------------------------------------------
# Buffer 1 Files for NEW Sequence Number routine
# --------------------------------------------------------------------------
#      "Nxxyy    xx = tool number   yy = repeat counter"
rc1          : 1
wc1          : 1
tlcount      : 0
fbuf 1 0 1 0 0
tlusage      : 0
fmt N 7 tlusage

# --------------------------------------------------------------------------
# Buffer 4 - Holds the variable 't' for each toolpath segment
# ------------------------------------------------------------------------
rc4 : 1                                                            #  
wc4 : 1                                                            #  
fbuf 4 0 1 0 0  # Buffer 4                                         #  
# ------------------------------------------------------------------------
# Buffer 5 - Min / Max                                             #  
# ------------------------------------------------------------------------
b5_gcode : 0                                                       #  
b5_zmin  : 0                                                       #  
b5_zmax  : 0                                                       #  
rc5      : 2                                                       #  
wc5      : 1                                                       #  
size5    : 0                                                       #  
fbuf 5 0 3 0 0          #Min / Max                                 #  


# ------------------------------------------------------------------------
fmt  "X" 2  x_tmin      #Total x_min                               #
fmt  "X" 2  x_tmax      #Total x_max                               #
fmt  "Y" 2  y_tmin      #Total y_min                               #
fmt  "Y" 2  y_tmax      #Total y_max                               #
fmt  "Z" 2  z_tmin      #Total z_min                               #
fmt  "Z" 2  z_tmax      #Total z_max                               #
fmt  "Z" 2  min_depth   #Tool z_min                                #
fmt  "Z" 2  max_depth   #Tool z_max                                #
#-------------------------------------------------------------------------

 

 

#Call this in pwrtt$
pinittlcount  #Initialize tool count
     if t$ > 0,
       [
       wc1 = t$
       tlcount = wbuf(1, wc1) #Write tool usage counter to buffer file. Initial counter is zero.
       ]

#Call in tool change post block and start of file post block if it is mill 4 axis post
ptoolcounter  #Buffer tool usage count
       rc1 = t$
       tlcount = rbuf(1, rc1)  #Read tool usage counter for current tool
       tlcount = tlcount + 1   #Tool usage counter
       wc1 = t$
       tlcount = wbuf(1, wc1)  #Save tool usage counter to buffer file

ptlusageout #Output tool usage
       tlusage = t$ * 100 + tlcount
       tlusage




# --------------------------------------------------------------------------
ptoolcomment    #Comment for tool
      tnote = t$, toffnote = tloffno$, tlngnote = tlngno$
      if tool_info = 1 | tool_info = 3,
           sopen_prn, ~t$, "= ",pstrtool,  sclose_prn, e$
# --------------------------------------------------------------------------




psof$            #Place this in psof . Start of file for non-zero tool number             
      ptoolcounter  #Calculate tool usage counter
#----------------------------------------------------------------------
      ptravel                                                   #  
      pwritbuf5                                                 #  
      if output_z = yes$ & tcnt > 0,                            #  
        [                                                       #  
        sav_spc = spaces$                                       #  
        spaces$ = 0                                             #  
        "(", "OVERALL MAX = ", *z_tmax, ")", e$                 #  
        "(", "OVERALL MIN = ", *z_tmin, ")", e$                 #  
        spaces$ = sav_spc                                       #          
        ]                                                       #  
#----------------------------------------------------------------------





psof$            #Place this in Psof and Tool Change
ptlchg$          #Tool change
#-----------------------------------------------------------------------      
      if output_z = yes$,                                        #  
        [                                                        #  
        preadbuf5                                                #  
        if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,          #  
          [                                                      #  
          #sav_spc = spaces$                                     #  
          spaces$ = 0                                            #  
          "(", "MAX = ", *max_depth, ")", e$                     #  
          "(", "MIN = ", *min_depth, ")", e$                     #  
          spaces$ = sav_spc                                      #  
          ]                                                      #  
        ]                                                        #  
#-----------------------------------------------------------------------




#-------------------------------------------------------------------------
ptravel    # Tool travel limit calculation                         #
           if x_min$ < x_tmin, x_tmin = x_min$                     #
           if x_max$ > x_tmax, x_tmax = x_max$                     #
           if y_min$ < y_tmin, y_tmin = y_min$                     #
           if y_max$ > y_tmax, y_tmax = y_max$                     #
           if z_min$ < z_tmin, z_tmin = z_min$                     #
           if z_max$ > z_tmax, z_tmax = z_max$                     #

# ------------------------------------------------------------------------
# Buffer 5  Read / Write Routines                               
# ------------------------------------------------------------------------
pwritbuf5   # Write Buffer 5                                       #
            b5_gcode = gcode$                                      #
            b5_zmin = z_min$                                       #
            b5_zmax = z_max$                                       #
            b5_gcode = wbuf(5, wc5)                                #
# ------------------------------------------------------------------------
preadbuf5   # Read Buffer 5                                        #
            size5 = rbuf(5,0)                                      #
            b5_gcode = 1000                                        #
            min_depth = 99999                                      #
            max_depth = -99999                                     #
            while rc5 <= size5 & b5_gcode = 1000,                  #
              [                                                    #
              if rc5 <= size5, b5_gcode = rbuf(5,rc5)              #
              if b5_zmin < min_depth, min_depth = b5_zmin          #
              if b5_zmax > max_depth, max_depth = b5_zmax          #
              ]                                                    #
# ------------------------------------------------------------------------
pwrtt$          #Pre-read NCI file
      if tool_info > 1 & t$ > 0 & gcode$ <> 1003, ptooltable
      pinittlcount                                            #Initialize tool usage counter
      if t$ > 0, tcnt=tcnt+1                                  #
      ptravel                                                 #
      pwritbuf5                                               #
      #if t$ <> prv_t$ & t$ > 0, pwritebuf7                    #Buffer 7
# ------------------------------------------------------------------------


 

Good morning Alfred,
     I have seen Buffer 7 but not called out yet, may I see the BUFFER 7 how it was defined?

 

 

Thank you.

  • Like 1
  • Huh? 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...