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:

Tool length stickout in tool table?


Recommended Posts

Looking to add tool min stick out lengths to the tool table to speed up setups and lessen the chances of things crashing. I looked around to see if anyone had posted this before but the only I found was this post.  Maybe I am searching for the wrong terms.

The bit of code posted by K2csq7 didn't work for me and I'm not sure if its the best way to get what I'm wanting anyways. Is there a way to lowest  z min depth to post out for each tool in the tool table?

 

my ptooltable currently looks like this 

ptooltable # Write tool table, scans entire file, null tools are negative
           tnote = t$
           toffnote = tloffno$
           tlngnote = tlngno$
           spaces$=0
           if t$ >= zero,
             [
             if tcr$>0, scomm_str, *t$, ptspace, " - ", plistcomm, " - ", *tldia$, punit, pdiamspc, " - ", *tcr$,  punit, " - ", "STICKOUT - ", *min_depth, punit, scomm_end, e$
			 if tcr$=0, scomm_str, *t$, ptspace, " - ", plistcomm, " - ", *tldia$, punit, pdiamspc, " - ", "STICKOUT - ", *min_depth, punit, scomm_end, e$
			 ]
           spaces$=sav_spc

but what I get as an output is this:

(T1   - 1/2 FLAT ENDMILL     - D0.5000" - STICKOUT - Z0.")
(T3   - 1/4 SPOTDRILL        - D0.2500" - STICKOUT - Z0.")
(T4   - 5/64 DRILL           - D0.0781" - STICKOUT - Z0.")
(T5   - NO. 2-56 FORM TAPRH  - D0.0860" - STICKOUT - Z0.")

 

Obviously I'm missing something. Do I need a buffer to make this work?

Link to comment
Share on other sites

Colin I can't seem to find the list of parameter numbers in the "What's New in Mastercam 2017" but my reseller gave me the parameter reference for what looks to be X2. I am sure that they have changed or added some stuff to that list in the last decade. 20007,3 would be holder parameters overall length though. Tool projection probably won't work for me because we don't usually edit the tool in MC, we just use the default tool library for the most part. I know it would probably be better if we did edit the tools to reflect what will actually be set up but I work in a small job shop and I get the feeling the other guys won't do the extra steps in writing programs even if I set up the post to show the tool projection's over all length.

I know that MPmaster, which is the post I'm modifying, uses "min_depth" for the min z when posting tool comments.  Problem is when I add "min_depth" to ptooltable I just get 0 as an output. If I add "preadbuf5" before "min_depth" I actually get some numbers but they aren't the right ones. Feel like I'm making this more complicated then it needs to be. 

Link to comment
Share on other sites

Decided to just go with using the tool projection's overall length. The other guys will just have to deal with properly setting up their tools in MC when doing a program or with generic 3" stick outs in the tool list. I think what I wanted to do with "min_depth" would be possible but would require way more to do with buffers when I am capable of doing at the moment.

 

So in case anyone was wondering I'll share what I ended up going with in case someone down the line has a question similar to mine. This was all pretty much already included in the MPmaster post.

Using the variable "oa_len" to grab the overall length from the tool's geometry, this is what my tool table looks like.

ptooltable # Write tool table, scans entire file, null tools are negative
           tnote = t$
           toffnote = tloffno$
           tlngnote = tlngno$
           spaces$=0
           if t$ >= zero,
             [
             if tcr$>0, scomm_str, *t$, ptspace, " - ", plistcomm, " - ", *tldia$, punit, pdiamspc, " - ", *tcr$,  punit, " - OAL: ", oa_len, punit, scomm_end, e$ # modified by ck
			 if tcr$=0, scomm_str, *t$, ptspace, " - ", plistcomm, " - ", *tldia$, punit, pdiamspc, " - OAL: ", oa_len, punit, scomm_end, e$ # modified by ck
		   space$=sav_spc

 

in "pwrttparam$" you will need this line. This allows "oa_len" to grab its value from tool's geometry.

if prmcode$ = 20007, pilot_dia = rpar(sparameter$,11)

The end result looks like this.

(T1   - 1/2 FLAT ENDMILL     - D0.5000" - OAL: .6")
(T3   - 1/4 SPOTDRILL        - D0.2500" - OAL: .5")
(T4   - 5/64 DRILL           - D0.0781" - OAL: 1.1")
(T5   - NO. 2-56 FORM TAPRH  - D0.0860" - OAL: .8")

Thanks guys for help, if you have any advice or suggestions on this topic still I'd love to hear it.

Link to comment
Share on other sites

I have done this in the past

 

 
( TOOL - 1   40MM MITSUBISHI AJX FEEDMILL )
( HANGOUT = 2.000"  HOLDER =  32MM - 100MM BRINEY SHRINK FIT )
 
( TOOL - 15090530   1/2 X .03R 5FL GORILLA MILL GMHT12RS5 )
( HANGOUT = 1.480"  HOLDER =  1/2" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 11090500   1/2 ENDMILL 4FL GORILLA MILL GM12FH4 )
( HANGOUT = 1.250"  HOLDER =  1/2" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 59090358   9.1MM KENNAMETAL GO DRILL B051A09100CPG )
( HANGOUT = 1.929"  HOLDER =  10MM - 100MM BRINEY SHRINK FIT )
 
( TOOL - 15090220   1/4 X .02R 5FL GORILLA MILL - GMHT14RS5 )
( HANGOUT = 1.000"  HOLDER =  1/4 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 13090500   1/2" 4FL BALLMILL GORILLA MILL CEM12B4TIALN )
( HANGOUT = 1.500"  HOLDER =  1/2 - 3" TECHNIKS SHRINK FIT )
 
( TOOL - 15090320   3/8 X .02R 5FL GORILLA MILL GMHT38R5 )
( HANGOUT = 1.250"  HOLDER =  3/8 - 3_75" TECHNIKS SHRINK FIT )
 
( TOOL - 15090110   1/8 X .01R 4FL DESTINY DVH RAPTOR DVH40806RC   )
( HANGOUT = .650"  HOLDER =  1/8 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 15080530   1/2 X .03R 7FL GORILLA MILL - BABOON GMHT12R7  )
( HANGOUT = 1.350"  HOLDER =  1/2 - 3_75" TECHNIKS SHRINK FIT )
 
( TOOL - 11090375   3/8 5FL GORILLA MILL - PHENOM GMHT38F5 )
( HANGOUT = 1.250"  HOLDER =  3/8" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 11090187   3/16 6FL DESTINY RAPTOR 3/6 R61210C )
( HANGOUT = .850"  HOLDER =  3/16" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 15090945   3/32 X .005R 4FL DVH RAPTOR VARIABLE HELIX DVH406010RC )
( HANGOUT = .650"  HOLDER =  1/8 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 22090047   .25 X .047 6FL KEYSEAT CUTTER HARVEY 22347-C3 )
( HANGOUT = .750"  HOLDER =  1/4 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 13090312   5/16 4FL DVH BALL MILL BDVH42008C )
( HANGOUT = .850"  HOLDER =  5/16" - 4_00 BRINEY SHRINK FIT )
 
( TOOL - 15090215   1/4 x .015R 7FL GORILLA MILL - BABOON - GMHT14R7  )
( HANGOUT = 1.000"  HOLDER =  1/4" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 22090125   .25 DIA X .125 THK KEYSEAT CUTTER HARVEY TOOL 986195-C3  )
( HANGOUT = .900"  HOLDER =  1/4" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 97090001   TOOL 800-657-201 )
( HANGOUT = 2.500"  HOLDER =  1/2 - 3_75" TECHNIKS SHRINK FIT )
 
( TOOL - 97090002   800-657-200 CUSTOM TOOL )
( HANGOUT = 2.250"  HOLDER =  1/2" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 28090020   .058 TIP X .020 CORNER ROUND HARVEY TOOL 67620-C3 )
( HANGOUT = .750"  HOLDER =  1/8 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 28090100   .107 TIP X .100R ROUNDOVER TOOL HARVEY TOOL 68100-C3 )
( HANGOUT = .900"  HOLDER =  5/16" - 4_00 BRINEY SHRINK FIT )
 
( TOOL - 97090003   CUSTOM TOOL 8000-6657-102 )
( HANGOUT = 1.750"  HOLDER =  3/4" - 2_75" BRINKEY SHRINK FIT )
 
( TOOL - 26090015   15° TAPER MILL - .093 TIP  CONICAL TOOL P-101C TIALN )
( HANGOUT = .750"  HOLDER =  1/4 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 11090125   1/8 4FL DVH RAPTOR ENDMILL DVH40806C  )
( HANGOUT = .750"  HOLDER =  1/8 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 54090125   1/8 X 140° SPOT DRILL - HARVEY TOOL 41008-C3 )
( HANGOUT = 1.000"  HOLDER =  1/8" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 59090120   .1200 GORILLA DRILL GDC1200X5 )
( HANGOUT = 1.250"  HOLDER =  1/8" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 59090086   .0866 KENNAMETAL GO DRILL B053A02200CPG  )
( HANGOUT = 1.300"  HOLDER =  4MM X 3_397" TECHNIKS SHRINK FIT HOLDER )
 
( TOOL - 59090074   1.9MM KENNAMETAL GO DRILL B053A01900CPG )
( HANGOUT = 1.000"  HOLDER =  4MM X 3_397" TECHNIKS SHRINK FIT HOLDER )
 
( TOOL - 70090080   .0803 REAMER - WALTER-TITEX 5072246 )
( HANGOUT = 1.100"  HOLDER =  ER20 - 4" TECHNIKS COLLET CHECK )
 
( TOOL - 65090125   1/8 X 30 DEG C'SINK - MA FORD 60012508  )
( HANGOUT = 1.000"  HOLDER =  1/8" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 17090125   .125 X 40 DEGREE DOVETAIL CUTTER /HARVEY TOOL 977808-C3 )
( HANGOUT = .850"  HOLDER =  1/8" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 23090250   1/4 X 90 CHAMFER TOOL HARVEY #47645 )
( HANGOUT = .850"  HOLDER =  1/4 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 11090250   1/4 5FL GORIALLA MILL - PHENOM GMHT14F5 )
( HANGOUT = 1.100"  HOLDER =  1/4 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 12090110   1/8 X .01R 4FL HELICIAL SOLUTIONS ENDMILL )
( HANGOUT = .650"  HOLDER =  1/8 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 11080125   1/8 5FL GORILLA  MILL GM18F5 )
( HANGOUT = .750"  HOLDER =  1/8 - 3_50" TECHNIKS SHRINK FIT )
 
( TOOL - 22090093   .500 X .093 KEYSEAT CUTTER HARVEY TOOL 71250-C3 )
( HANGOUT = 1.000"  HOLDER =  1/2" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 97090004   CUSTOM TOOL 8000-6657-103 )
( HANGOUT = .850"  HOLDER =  1/4" - 4_00" BRINEY SHRINK FIT )
 
( TOOL - 24090187   3/16 X 60 DEG CHAMFER MILL HARVEY TOOL #72430-C3 )
( HANGOUT = .850"  HOLDER =  3/16" - 2_75" BRINEY SHRINK FIT )

 

Link to comment
Share on other sites

I thought I'd take a minute to explain why this method requires a buffer, if you want to try and use the "Z Max" value that is calculated by the Operations.

  • When you run the MPMaster Post, there is a block of code in 'pwrtt$' that captures (stores) the Min and Max Z values in a buffer. It actually stores 3 values:
  1. The first value stored is the "NCI Gcode Value". This is either 1000 (for a Null-Tool Change), 1001 for the 1st Tool Change, or 1002 (for an Actual Tool Change). This is done in case you are processing "Depth cuts", since each Depth Cut pass will be output with a Null-Tool Change block.
  2. The 2nd value stored is the "Z Min" value.
  3. The 3rd value stored is the "Z Max" value.

The 'pwrtt$' Post Block will continue to write a Record (row) of data for each Tool Change event that is in your NCI File.

The key to understand is that you don't just get a single Record for each Operation. You can get many (multiple) rows for each Operation. Say for example that you have an Operation that cuts from Z0.0 to Z-2.75 (Total depth of 2.75), and you are using a Max Depth Cut value of .250. That would give you 11 different Records of data (rows) in the Buffer File for that single Operation.

Let's use an example where our 11 (depth) pass Operation is Operation #1. We've also got Operation #2 which is a Dill Operation, and Operation #3 which is a Pocket Operation that is used to finish our Pocket. It takes 2 passes, one that stays .02 off the Floor (finishes the walls), then makes the final pass that finishes the Floor.

For our 3 Operations total, we have a Buffer File that looks like the following:

1001 2.0 -.25
1000 2.0 -.5
1000 2.0 -.75
1000 2.0 -1.0
1000 2.0 -1.25
1000 2.0 -1.5
1000 2.0 -1.75
1000 2.0 -2.0
1000 2.0 -2.25
1000 2.0 -2.5
1000 2.0 -2.75
1002 1.5 -1.85
1002 2.0 -2.72
1000 2.0 -2.78

As you can see, we've got 14 Records in our Buffer, for our 3 Operations.

Operation #1 goes from Line 1 to Line 11. (11 Records for this single Operation.)

Operation #2 goes from Line 12 to Line 12. (Only a single 1002 record for this Operation.)

Operation #3 goes from Line 13 to Line 14. (2 Records for this Operation.)

The only thing that indicates that we are still using the same Tool is the 1000 G-code. In fact, we can have 10 Operations in a row that use the same Tool in Mastercam, and the Buffer File does not make any distinction between Operations, only Actual Tool Changes. The Buffer Read Logic doesn't care, because we don't track the Operation number or anything like that. This does mean that we get a Min/Max Z value that is only for the current Tool, up until the next Tool Change event. If you "reuse" a Tool later in the program, in other words if you used Tool 1, then Tool 5, Tool 9, Tool 2, and then changed back to Tool 1, the Buffer Logic does not scan through the entire Buffer File for each Tool.

You cannot use the existing logic to output Z Depths into a Tool Table. Because there is nothing "tying" the Tool Change values to a Tool Number. If you used only Sequential Tool Numbers (T1, T2, T3, T4, ...) then it might work.

So, how does this logic work exactly? What is the process that MP goes through from start to finish, with the existing logic?

First, let's look at what it takes to define and use a Buffer File:

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

The Buffer itself is created with a single line of code, that starts with 'fbuf'. This creates the storage location in Memory, and tells MP how many Columns of Data to store in the buffer. In our case, this is Buffer #5, and it stores 3 variables (columns) on each Row.

We have created 3 user-defined variables that are used to Write Data into the buffer. These 3 variables start with 'b5'. This is just a naming convention used to indicate to you not to break up the 3 variables. (Keep the list ordered!)

In addition, we have 2 variables that are used to "read" data from the buffer. Technically, we actually read the 3 variables from the Record into the same 3 'b5' variables, then we set these 2 other "formatted" variables from these 3 variables. The 2 variables are:

fmt  "Z" 2 min_depth# Tool z_min
fmt  "Z" 2 max_depth# Tool z_max

What are the "other 3" variables used for?

  • 'rc5' is the READ counter. Our logic is inside 'ptlchg_com', which is technically the "2nd" Tool Change event. The first Operation is output from 'psof$', which is why we initialize the Read Counter Variable (rc5) to '2'
  • 'wc5' is the WRITE counter. Our write logic is inside 'pwrtt$', so we start with the First Tool Change. This means we can initialize the variable to '1' to start.
  • 'size5' is used when we READ the buffer. We must make sure that we don't ever read past the "end" of the buffer. If we have 101 Records (Rows) of data, that's cool. We can have 10 million lines if we want, we just can't read past the end. So if we have 101 Records, and we try to read '102' or higher, then we will get an error. This is overcome with a special Buffer Function. We "Read" Record Number Zero (0). MP always "dynamically" updates the Record Zero to hold the total number of Records (Rows) that are in the Buffer File. That is because MP will dynamically create your Buffer and store data into the Buffer "Dynamically", meaning that the number of Rows will change, based on the Operations in your Mastercam File.

 

So, how do we fill the Buffer with data?

Here is our 'pwrtt$' post block:

# --------------------------------------------------------------------------
# Tooltable Output
# --------------------------------------------------------------------------
pwrtt$      # Write tool table, scans entire file, null tools are negative
           if rotaxis$ > 0 | rotary_type$ > 0 | mill5$ <> 0,
             [
             sav_rot_on_x = rot_on_x
             output_z = no$
             ]
           if vmc = 0 & tlplnno$ <> 2, sav_rot_on_x = rot_on_x
           if vmc = 1 & tlplnno$ > 1, sav_rot_on_x = rot_on_x
           #sav_rot_on_x = rot_on_x    #Uncomment this line to output rotary axis value even when it's not used           
           t$ = wbuf(4,wc4)        #Buffers out tool number values
           if tool_table = 1, ptooltable
           if tool_table = 2, ppredtool
           if tool_table = 3, pmetatool
           if t$ >= zero, tcnt = tcnt + one
           ptravel
           pwritbuf5

The very last line of code in that block is where we write the data into Buffer 5. (pwrtt$ is called for each Tool Change event in your NCI File.)

Here is what happens in 'pwritbuf5':

pwritbuf5   # Write Buffer 1
            b5_gcode = gcode$
            b5_zmin = z_min$
            b5_zmax = z_max$
            b5_gcode = wbuf(5, wc5)

Looks pretty simple (hopefully), right?

What is going on in this Post Block?

  • The first 3 lines are Formula Statements. We are copying the 'gcode$' value, 'z_min$' value, and 'z_max$' value into our 3 buffer variables. It is very important to understand that we must "set" all of the variables we want to write into our Record, BEFORE we actually call the 'buffer write' function.
  • The line of code that actually writes to the buffer is a single line: b5_gcode = wbuf (5, wc5)
  • This line of code starts with the variable we are passing (b5_gcode) on the left side (this is the information we are passing to the function on the right), and on the right side of the equation we have the "Write Buffer" Function (wbuf), which has two Parameters that are used with the function. "(5, wc5)"
  • The two Parameters that follow the 'wbuf' function tell MP a couple things. 1) The first parameter is the Buffer Number we want to access, and 2) the second parameter is the "Write Counter" variable. This variable is "auto-incremented" by MP, every time we write to the Buffer!
  • The reason for this is due to the way MP works with Functions. Historically, we were limited passing a single parameter to a function call. This means that if you break down the 'buffer write' function, here is what we are telling MP:
  1. Take the implied array (ordered list) of variables, starting with 'b5_gcode', and write the number of columns of data indicated in the 'fbuf' function to the current Row, which is indicated by the current value of the "write counter" variable, which is 'wc5'. Since we can only pass a single variable, that variable is simply the start of the list of variables. If we created a Buffer File with 15 values (columns), we have to make sure we set all 15 variable values before we call the 'buffer write' function.
  2. If you look at the Right Side of the equation, the 1st parameter after the 'wbuf' call is the Buffer Number. In our case, this is Buffer #5.
  3. The 2nd Parameter is the Write Counter. We almost always initialize the Write Counter to a value of '1'. That means the first Tool Change will call 'pwritbuf5', and 'wc5' is set to '1', so we write to the first Record in the buffer. As soon as we finish writing the data to the Record, MP now Auto-Increments the value of 'wc5'. On the 2nd Tool Change Event (In our case, a Null-Tool Change), 'wc5' is now set to '2', so we fill out our 3 pieces of variable data, and we write the Record (row) to the Buffer. 'wc5' is now set to '3', so we are "prepared" to write the next row, and on, and on.

So running through the "Pre-Read Routine" (calls to 'pwrtt$'), we can "fill out the data", but we can't sort it or output it in this loop. Because we "don't know" what is coming next. We capture the data to the Buffer File, but we have to wait until the "NC Output Loop"

Ok, so we've written our Buffer Data.

The MPMaster Post now uses this Buffer data to write Min/Max values at each Actual Tool Change event. How does it do this?

      if output_z = yes$,
        [
        preadbuf5
        if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,
          [
          n$, pspc, scomm_str, "MAX - ", *max_depth, scomm_end, e$
          n$, pspc, scomm_str, "MIN - ", *min_depth, scomm_end, e$
          ]
        ]

Inside the 'ptlchg_com' (tool change common) Post Block, there is a section of code that checks 'output_z', and when set to True, the user-defined Post Block executes.

The first thing that happens is we call 'preadbuf5'. This is where the "magic" happens. We set the values of 'max_depth' and 'min_depth' inside this Post Block. In fact, the rest of our section of code just outputs the Min/Max values, after making sure the 'opcode$' value is in the correct range. (It won't calculate Min/Max Z values for most 5X Ops (opcode$ 16-18).

 

 

 

  • Like 5
Link to comment
Share on other sites

So here is what happens in 'preadbuf5':

preadbuf5   # Read Buffer 1
            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
              ]

This block of code is called for each time we have a Tool Change Event. What happens in this "magic" block of code to capture the true "min/max" values for our Operations?

Let's break down what happens, line by line:

  1. Line 1 - We start by using our special Buffer Function; reading Record Zero. This sets 'size5' to the total number of Rows (Records) that are contained in our Buffer. This is used in the 'While' Loop. This event occurs each time we run this chunk of code. So it happens for each Tool Change Event. 'size5' will always get set to the total number of Records for the current set of NCI data. It is used to "Cancel" the 'while loop' at the "last" tool change, so we don't "overrun" the Buffer.
  2. Line 2 - We set 'b5_gcode' to '1000'. This is a "trick" to allow us "entry" into the 'while loop'. By setting 'b5_gcode' to 1000, this allows both conditions to evaluate to 'True' at first to get "into" the block of code below. We'll get to that in a minute...
  3. Line 3 sets 'min_depth' to 99999. Why? What is the purpose of that? Down lower inside the 'while loop', we end up setting both 'min_depth' and 'max_depth'. By first setting them both to "5 nines", this will allow Modality to "do its thing". When we set 'min_depth' for example, inside the while loop', this means that the current value is equal to "real minimum" for the current use of the Tool, and the 'previous value' gets set to '99999'. That means when we encounter 'min_depth' on an output line, we evaluate the Modality of this variable, and we have basically "forced" the output with the trick we used here.
  4. Line 4 does the same thing, it sets the 'current value' of 'max_depth', in order to invoke Modality later on.
  5. Line 5 - This is where the "Magic" Starts!
  • The 'while loop' is used to execute "multiple actions". It typically uses some type of "counter" to break out of the loop. Using a 'while loop' has some rules associated with it.
  • The "loop" must start by evaluating to 'True' in order to execute the "actions" contained in the Body of the loop. In order to have more than "one action", you must use the While Loop with an "implied Post Block", which is a set of Square Brackets "[ ]".
  • When "True", the Loop will execute each and every line of code that is contained inside the Square Brackets. We typically want to "increment" some type of counter or variable that allows the "condition" to evaluate as "False".
  • In our case, we actually have 2 different conditions, separated with an "AND" Boolean Condition.
  1. Condition #1 is "rc5 <= size 5". This is read as "while the value of 'rc5' is less than or equal to 'size 5' (number of rows in our Buffer)". If that condition is "true", then we continue to execute the loop. This condition is to explicitly prevent "overrun" of the buffer. Even on the very "last" row of the Buffer File, rc5 would be "equal" to size5, so in this case, it would still be true. Since 'rc5' is "auto-incremented" every time the Buffer File is read, it will now be "one greater" than the value of 'size5', so we don't have to worry about overrunning the Buffer.
  2. Condition #2 is "b5_gcode = 1000". This will always be "True" when we first execute the code because we set it to '1000' on Line 2!.

So now, we've gotten "into the Loop", because we set 'size5' on Line #1, and we set 'b5_gcode' to '1000' on Line #2. This is what allows us into the Loop on the frist pass. On the first line of the Implied Post Block, we make sure we don't Overrun the buffer, and we read the 2nd Record.

Wait, why do we read the 2nd Record???

We read the 2nd Record, because that is how we initialized 'rc5'. We set it to '2', so we start by reading the 2nd Record.

But look, really look at the code in that line: b5_gcode = rbuf (5, rc5)

'b5_code' is used on the Left side of the 'rbuf' function. Remember how we can only have a single variable as the "return" value?  We are telling MP to "read all the Columns of Data" on the Row indicated by the current value of 'rc5', and Load them into the Implied Array, that starts with 'b5_gcode'.

So with that 1 line of code, we just set the value of 3 variables!

That's the whole secret. That, and we auto-incremented the value of 'rc5', for the next pass through the Loop. So we really just accomplished two distinct things. We loaded all the Buffer Values from the Columns into our Ordered List of Variables, and we incremented the counter.

Finally, on the last 2 lines of code, we check the value of 'b5_zmin' and 'b5_zmax', and set the 'min_depth' and 'max_depth' values, based on the current values we have read out of the Buffer.

So, what keeps us "Reading Ahead" in the Buffer?

It is the value of 'b5_gcode'!!!

We set it to '1000' to first enter the "while loop", but then we keep looping, until the value of 'b5_gcode' equals "1002". Why '1002'? Because that is the Actual Tool Change value. So we will "keep reading records" in the Buffer, until we've hit the "next Tool Change". That means we can use "Depth Cuts" or even "multiple Operations in a Row" that use the same Tool Number, and we get to "add up" all the Z Min/Max values for all those Null Tool Records.

If you look at our Buffer Data, we have 11 Records for Operation #1. We "Loop" and this causes us to "read up to line 12", and that is what finally "kicks us out of the loop". The 2nd condition evaluates to "False", and we don't continue processing the loop anymore.

 

  • Like 4
Link to comment
Share on other sites

Another quick question for you guys. How do you pad comment lines so that they line up in a certain way? Not sure what the term is to actually search for because I'm not getting any real hits for it when search on here.

I'm wanting my tool list to look like this:

(TOOL LIST:)
(T1 - 2"  FACE MILL          		D2.0000"  - OAL:2." )
(T2 - 3/4 UNDERCUT BULL ENDMILL		D0.7500"  - R.0300"  - OAL:3.825" )
(T3 - 3/16 BULL ENDMILL      		D0.1875"  - R.0100"  - OAL:1.2" )
(T4 - 1/4 SPOTDRILL          		D0.2500"  - OAL:1.125" )
(T5 - NO. 25 DRILL           		D0.1495"  - OAL:3." )
(T6 - NO. 6-32 STI CUT TAPRH 		D0.1800"  - OAL:1.35" )
(T7 - NO. 31 DRILL           		D0.1200"  - OAL:3." )
(T8 - NO. 4-40 STI CUT TAPRH 		D0.1450"  - OAL:1.2" )
(T9 - 1/4 BULL ENDMILL       		D0.2500"  - R.0300"  - OAL:1." )
(T10 - 1/8 BULL ENDMILL       		D0.1250"  - R.0100"  - OAL:.5" )
(T11 - 1/4 BALL ENDMILL       		D0.2500"  - R.1250"  - OAL:1." )
(T12 - 1/16 BALL .312 LOC ENDMILL	D0.0625"  - R.0313"  - OAL:.4" )
(T13 - 1/8 CORNER ROUNDER     		D0.0400"  - R.0100"  - OAL:.75" )

Instead of this:

(TOOL LIST:)
(T1 - 2"  FACE MILL          D2.0000"  - OAL:2." )
(T2 - 3/4 UNDERCUT BULL ENDMILLD0.7500"  - R.0300"  - OAL:3.825" )
(T3 - 3/16 BULL ENDMILL      D0.1875"  - R.0100"  - OAL:1.2" )
(T4 - 1/4 SPOTDRILL          D0.2500"  - OAL:1.125" )
(T5 - NO. 25 DRILL           D0.1495"  - OAL:3." )
(T6 - NO. 6-32 STI CUT TAPRH D0.1800"  - OAL:1.35" )
(T7 - NO. 31 DRILL           D0.1200"  - OAL:3." )
(T8 - NO. 4-40 STI CUT TAPRH D0.1450"  - OAL:1.2" )
(T9 - 1/4 BULL ENDMILL       D0.2500"  - R.0300"  - OAL:1." )
(T10 - 1/8 BULL ENDMILL       D0.1250"  - R.0100"  - OAL:.5" )
(T11 - 1/4 BALL ENDMILL       D0.2500"  - R.1250"  - OAL:1." )
(T12 - 1/16 BALL .312 LOC ENDMILLD0.0625"  - R.0313"  - OAL:.5" )
(T13 - 1/8 CORNER ROUNDER     D0.0400"  - R.0100"  - OAL:.75" )

And is there a way to get rid of the trailing zeros? Not sure why OAL doesn't have them but tool diameter and corner radius do.

Link to comment
Share on other sites

These are controlled by space makers and fmt statements in the post using MPLMASTER as the example here.

ptooltable # Write tool table, scans entire file, null tools are negative
           #if you want repetitive tool output, keep the abs( ) in ptooltable and remove the >= t$ from the pwrtt call to this block
           tnote = abs(t$)
           tldianote = abs(tldia$) #Oct-20-08 AEH
           if opcode$ = 3 | opcode$ = 16, toffnote = tlngno$
           else, toffnote = tloffno$
           stinsert2 = ucase(stinsert2)
           !spaces$
           spaces$ = zero
           if posttype$ = 2,    #lathe tools
             [
             scomm_str, *tnote, ptspace, " - ", plistcomm, " - ", *toffnote, pdspace, " - ", *stinsert, *stinsert2, " - ", *stholder, *stholder2, scomm_end, e$
             #scomm_str, *tnote, ptspace, " - ", *toffnote, pdspace, " - ", *stinsert, *stinsert2, " - ", *stholder, *stholder2, scomm_end, e$
             ]
           else,                  #mill tools
             [
             if opcode$ = 3 | opcode$ = 16,
               [
               if tcr$ = 0, scomm_str, *tnote, ptspace, " - ", plistcomm, " - ", *tldianote, punit, pdiamspc, scomm_end, e$
               ]
             else,
               [
               if tcr$ > 0, scomm_str, *tnote, ptspace, " - ", plistcomm, " - ", *toffnote, pdspace, " - ", *tldianote, punit, pdiamspc, " - ", *tcr$,  punit, scomm_end, e$
               if tcr$ = 0, scomm_str, *tnote, ptspace, " - ", plistcomm, " - ", *toffnote, pdspace, " - ", *tldianote, punit, pdiamspc,  scomm_end, e$
               ]
             ]
           spaces$ = prv_spaces$

plistcomm  # Comments from tool library
           strtool$=ucase(strtool$)
           if strtool$=snull, strtool$ = snocomm
           *strtool$

           nstrlen = strlen(strtool$)
           counter = 1
           while counter <= (20-nstrlen), pspace

pspace     # Creates spaces based on tool comment length
           " "
           counter = counter + 1

ptspace    # Creates spaces based on tool number
           if t$ < 10, "  "
           if t$ >= 10 & t$ < 100, " "

pdspace    # Creates spaces based on diameter offset number
           if tloffno$ < 10, "  "
           if tloffno$ >= 10 & tloffno$ < 100, " "

pdiamspc   # Creates spaces based on diameter offset number
           #if tldia$ < 10, "  "        

 

  • Like 1
Link to comment
Share on other sites

Ron showed a good example of how it is done in MPMaster, and other Posts. The key is to use the 'string length' function to read the number of characters in the string. Once you know how long the string is, you can add additional space characters to the end of the string, or use a "while loop" (like they did in Ron's sample), to "pad" the extra space characters.

The 'plistcomm' Post Block first outputs the Tool Name String, (*strtool$), then we use the 'strlen' function to capture the String Length, and setup a Counter variable that is used to test the logic condition in the While loop. The While loop uses the value of "20, minus the Tool Name String Length" to determine how many spaces to pad.

That means that given the way the logic is built, it uses a fixed column width of 20 characters. You can modify that single line of code to adjust the column width, or even use your own user-defined variable in place of the numeric literal.

column : 35

plistcomm  # Comments from tool library
           strtool$=ucase(strtool$)
           if strtool$=snull, strtool$ = snocomm
           *strtool$
           nstrlen = strlen(strtool$)
           counter = 1
           while counter <= (column-nstrlen), pspace

pspace     # Creates spaces based on tool comment length
           " "
           counter = counter + 1
  • Like 1
Link to comment
Share on other sites
  • 2 months later...

Hello guys, this site is awesome. I use to do CNC programming using other software. Now, being involve again in CNC using Mastercam is new learning experience.

I've been spending a lot of my time here and trying to apply most thing that I want. I am using 2018 version and only have MPFAN.pst, able to put MAX Z and MIN Z. But it would be great to have Number of Flute, Length of Cut and Stick Out in my tool table and tool comment. I love the padding but I need to make programs too. Anyway this is what I got so far.

 

(DATE - 16-07-17 TIME - 17:44)
(MATERIAL - 10.50L X 5.25W X 3.25H ALUM 6061-T6)
( T#322 | 2"  FACE MILL | SO:0. | H#322 )
( T#294 | 3/4 EM, 3FLT, 3LOC, .062 TIP RAD | SO:0. | H#294 | D#294 | WEAR COMP | DIA - .75 )
( T#1286 | 5/16 EM, 3FLT, .75LOC, 3SO | SO:0. | H#1286 | D#1286 | WEAR COMP | DIA - .3125 )
( T#23 | 3/8 SPOTDRILL, 3.25 STICK OUT | SO:0. | H#23 )
( T#124 | 1/4 DRILL, 3.25 STICK OUT | SO:0. | H#124 )
G20
G0 G17 G40 G49 G80 G90
#322 = 322 ( 2"  FACE MILL | SO:0. | DIA - 2. )
( G54 IS LEFT BACK TOP CORNER )
N1 ( FACING )
T#322 M6 ( 2"  FACE MILL | SO:0. | DIA - 2. )
( MAX -  Z2. )
( MIN -  Z0. )
G0 G90 G54 X-2.2 Y-.5001 A0. S6000 M3
G43 H#322 Z2. M8 T#294

 

I couldn't get the right tool length stick out right.

fmt  "SO:" 2 oa_len   # Tool Stick Out

if prmcode$ = 20007, oa_len = rpar(sparameter$,12)

 

 

Link to comment
Share on other sites
12 hours ago, niwrad said:

Hello guys, this site is awesome. I use to do CNC programming using other software. Now, being involve again in CNC using Mastercam is new learning experience.

I've been spending a lot of my time here and trying to apply most thing that I want. I am using 2018 version and only have MPFAN.pst, able to put MAX Z and MIN Z. But it would be great to have Number of Flute, Length of Cut and Stick Out in my tool table and tool comment. I love the padding but I need to make programs too. Anyway this is what I got so far.

 

(DATE - 16-07-17 TIME - 17:44)
(MATERIAL - 10.50L X 5.25W X 3.25H ALUM 6061-T6)
( T#322 | 2"  FACE MILL | SO:0. | H#322 )
( T#294 | 3/4 EM, 3FLT, 3LOC, .062 TIP RAD | SO:0. | H#294 | D#294 | WEAR COMP | DIA - .75 )
( T#1286 | 5/16 EM, 3FLT, .75LOC, 3SO | SO:0. | H#1286 | D#1286 | WEAR COMP | DIA - .3125 )
( T#23 | 3/8 SPOTDRILL, 3.25 STICK OUT | SO:0. | H#23 )
( T#124 | 1/4 DRILL, 3.25 STICK OUT | SO:0. | H#124 )
G20
G0 G17 G40 G49 G80 G90
#322 = 322 ( 2"  FACE MILL | SO:0. | DIA - 2. )
( G54 IS LEFT BACK TOP CORNER )
N1 ( FACING )
T#322 M6 ( 2"  FACE MILL | SO:0. | DIA - 2. )
( MAX -  Z2. )
( MIN -  Z0. )
G0 G90 G54 X-2.2 Y-.5001 A0. S6000 M3
G43 H#322 Z2. M8 T#294

 

I couldn't get the right tool length stick out right.

fmt  "SO:" 2 oa_len   # Tool Stick Out

if prmcode$ = 20007, oa_len = rpar(sparameter$,12)

 

 

Why not download MPMASTER that has all of this done for you and call it a day?

Mill.Set is has all of this logic in it also.

Link to comment
Share on other sites

A lot happened since I posted this. Our Mastercam vendor sent me NCI parameter list and able to get the Tool table the way we want it.

Now, our operators still want to see the Tool comment after M6 but I every tools getting the same Flute #, Stick Out and Length of cut of the first Tool.

I've downloaded the MPMaster but getting an error loading the machine or the post. 

Link to comment
Share on other sites
  • 2 weeks 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...