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:

Buffer question


Recommended Posts

Hello everyone,
   I am trying to recall memory to do a BUFFER for the TOOL LIST depths call out and somehow I don't get the right number.  I got trained by some professional post writer and it was great lesion to learn from him, I just didn't do much on buffer on my own and now I forgot some.  I now I miss something but I cannot know pacifically what I have missed.

 

 

Thank you guys.
   S.Luong

 

*************************************************** DEFINED  POST ================================================


#Region pwritbuf1 TOOLS LIST ISSUE
# --------------------------------------------------------------------------
pwritbuf1     # Write Buffer 1, first one here
           b1_gcode = gcode$
           b1_zmin = z_min$
           b1_zmax = z_max$
           b1_gcode = wbuf(4, wc4)
rc1             : 1
wc1             : 1
size1           : 0
fbuf 1 0 255 0 1
sbufname1$ = "D:\Tool Depths.txt"

s_ToolPlaneComm     : ""    # Tool Plane Comment
s_ToolPlaneComm_n   : ""    # Tool Plane Comment
#Endregion pwritbuf1

#Region preadbuf1
preadbuf1     # Read Buffer 1
           size4 = rbuf(1,0)
           b1_gcode = 1000
           min_depth = 10.
           max_depth = 0
           while rc4 <= size4 & b1_gcode = 1000,
              [
               if rc4 <= size4, b1_gcode = rbuf(4,rc4)
               if b1_zmin < min_depth, min_depth = b1_zmin
               if b1_zmax > max_depth, max_depth = b1_zmax
               ]
#EndRegion preadbuf1

 

#Region Buffer 4
# --------------------------------------------------------------------------
# Buffer 4 
# --------------------------------------------------------------------------
rc4 : 1
wc4 : 1
size4: 1
fbuf 4 0 1 0 0  # Buffer 4
#EndRegion Buffer 4

 

psetup        # Output of toolchange information
           if output_z = yes$, preadbuf1
           *min_depth

 

 

Region ptooltable
ptooltable # Write tool table, scans entire file, null tools are negative
           tnote = t$
           toffnote = tloffno$
           tlngnote = tlngno$
           spaces$=0
           if t$ >= zero,
             [
             scomm_str, *t$, "=", *tldia$, pstrtool, ", DOC= ", psetup, scomm_end, e$
             ]

 

===================== G-CODE===================
%
O3456(10488456 RevB.NC)
(SOURCE = 10488456 REVB.MCAM)
(VERTICAL INDEX)
(PART NAME= DEFLECSION CAP)
(UNOROMEN  )
(*)
(POSTED ON JAN.18.2019 AT 12*13PM)
(POSTED BY= PCROBOTIC\ADMIN)
(BAR STOCK= X3.13 Y1.85 Z1.85)
(VERTICAL INDEX)
(*)
(TOTAL TOOLS FOR OP2 ARE= 5 TOOLS)
(******************)
(T13=.5000 1/2 FLAT ENDMILL, DOC= Z10.)  ==============> DOC is wrong, it should be Z0. (Deepest point)
(******************)
(T14=.2500 1/4 SPOTDRILL, DOC= Z0.) ==============> DOC is wrong, it should be Z-.055 (Deepest point)
(******************)
(T15=.0995 #39 DRILL, DOC= Z10.) ==============> DOC is wrong, it should be Z-.550 (Deepest point)
(******************)
(T16=.1180M3 X .5 , DOC= Z10.) ==============> DOC is wrong, it should be Z-.150 (Deepest point)
(******************)
(T17=.1000.25CHAMFER EM 90, DOC= Z10.) ==============> DOC is wrong, it should be Z-.060 (Deepest point)
(******************)
(*)
(WORK OFFSET LIST)
(G54)
(X CENTER,Y BACK)
(Z AT TOP)
(*)
N13(.5000,  1/2 FLAT ENDMILL, HSS,USED TOOL)
(4FLTS 2.000LOC, 2.500RLF, 3.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19(XY= -.02, Z STK= .005)
(34X, ROUGH MULTI-PASSES, .05 EACH)
/G28 Y0.(TOOLPATH ZCLEARANCE= .34 MIN.)
T13 M6(ROUGH OUT TOP SURFACE, CUT#25)
G90 G54 S1200 M3
X1.9665 Y-1.88 T14(NEXT TOOL)
G43 H13 Z2.(DOC= Z.005, .35DP)
M8 G17(XY PLANE) G90 Z.7
G1 Z.005 F200.
X1.4665 F15.
(CUTTING...)
G1 Z.005 F200.
X1.4665 F15.
X-1.4665
X-1.9665
G0 Z2.
M9(PROGRAM JUMPS HERE)
(*)
N1302(FINISH TOP SURFACE, CUT#26)
G0 G17(XY PLANE) G90 G54 S1200 M3(PROGRAM JUMPS HERE)
X1.9665 Y-1.48(XY STK= -.02)
G43 H13 Z2.(DOC= Z0., .35DP)
(6X, ROUGH MULTI-PASSES, .25 EACH)
M8 Z.1
G1 Z0. F12.
X1.4665
(CUTTING...)
Z.1
G1 Z0. F12.
X1.4665
X-1.4665
X-1.9665
G0 Z2.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N14(.2500,  1/4 SPOTDRILL, HSS, 90.DEGS,)
(2FLTS 2.000LOC, 2.500RLF, 3.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.
T14 M6(SPOT 6X .260, CUT#27)
G90 G54 S600 M3
X-.6299 Y-.8268 T15(NEXT TOOL)
G43 H14 Z2.(DOC= Z-.055, .35DP)
M8(6X SPOTS, .11'CSINK SIZE)
G98 G81 Z-.055 R.03 F1.5
X-.315 Y-1.3723
Y-.2812
X.315 Y-1.3723
Y-.2812
X.6299 Y-.8268
G80 M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N15(.0995,  #39 DRILL, HSS, 118.DEGS,)
(2FLTS 2.000LOC, 2.500RLF, 3.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.
T15 M6(DRILL 6X .260, CUT#28)
G90 G54 S3000 M3
X-.6299 Y-.8268 T16(NEXT TOOL)
G43 H15 Z2.(DOC= Z-.55, .35DP)
M8(6X DRILL HOLES)
(55 PECKS, -.5799 PIN DEPTH)
G98 G83 Z-.55 R.08 Q.01 F2.
X-.315 Y-1.3723
Y-.2812
X.315 Y-1.3723
Y-.2812
X.6299 Y-.8268
G80 M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N16(.1180, M3 X .5 , PLUG,HSS,)
(1FLT 2.000LOC, 2.500RLF, 3.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.
T16 M6(TAP 6X, CUT#29)
G90 G54 S56 M3
X-.6299 Y-.8268 T17(NEXT TOOL)
G43 H16 Z2.(DOC= Z-.15, .35DP)
M8 (6X AKIRA SEIKI TAP HOLES)
G98 G84 Z-.15 R.08 E56.,R1
X-.315 Y-1.3723
Y-.2812
X.315 Y-1.3723
Y-.2812
X.6299 Y-.8268
G80 M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N17(.1000, .25CHAMFER EM 90, HSS, 45.DEGS, .1000TIP,)
(4FLTS 1.000LOC, 1.200RLF, 2.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.(TOOLPATH ZCLEARANCE= .04 MIN.)
T17 M6(DEBURR, CUT#30)
G90 G54 S5000 M3
X-1.5665 Y.05 T13(NEXT TOOL)
G43 H17 Z2.(DOC= Z-.06, .35DP)
M8 G17(XY PLANE) G90 Z.1
G1 Z-.06 F45.
X-1.4665
X1.4665
G2 X1.5165 Y0. J-.05
G1 Y-1.6535
G2 X1.4665 Y-1.7035 I-.05
G1 X-1.4665
G2 X-1.5165 Y-1.6535 J.05
G1 Y0.
G2 X-1.4665 Y.05 I.05
G1 X-1.3665
G0 Z2.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
T13 M6(FIRST PROGRAMMED TOOL)
M30
%(6,256 CHARACTERS = 6.28KB)

Link to comment
Share on other sites

You have a post block called pwritbuf1 that writes to buffer 4.  It's not part of you're problem, but it is confusing.

Buffer 4 appears to be sized incorrectly.  Also, if you're reading and writing to a buffer multiple times and you're not using strings, consider using a stack.

You should contact your Mastercam reseller about this issue; there's a simpler way to do this.

 

Link to comment
Share on other sites
4 hours ago, jeff.D said:

You have a post block called pwritbuf1 that writes to buffer 4.  It's not part of you're problem, but it is confusing.

Buffer 4 appears to be sized incorrectly.  Also, if you're reading and writing to a buffer multiple times and you're not using strings, consider using a stack.

You should contact your Mastercam reseller about this issue; there's a simpler way to do this.

 

 

Hi Jeff,
   Thank you for your suggestions, I have contacted the deal and they said they would BLOCK the codes after they are done.  I would like to learn what they did honestly.  I also contacted the person who trained me but he is SUPPER BUSY.  Therefore, I would like to get help from this forum.

 

 

Thanks.

Link to comment
Share on other sites

Steven,

I think part of the issue you are having is "when" you are trying to collect the data during the NCI Processing.

  • "pwrtt$" is the Post Block that creates the Tool List, but it does it "during the NCI Pre-Read Process".
  • You defined a "String Buffer" file type. This should probably be "numeric", and I would recommend saving "two 'reals' per record", with the 'z_min$' and 'op_number' values.
  • Because 'pwrtt$' gets called during the Pre-Read routine, I don't think the "z_min$" and "z_max$" variables get filled with the appropriate values, until we are actually processing the NCI Data, during the "output loop".
  • I think you see this, since the Z output is not correct.
  • To make this work is probably more complex than you think, but should still be possible.

 

I am guessing you'll having to do something like this:

  1. Write the Tool Table Comment Strings as normal, but output a "dummy" String at the end of the Comment String. I would probably do something like put the "op_id$" value, with a "flag label string", so we can use that as a search string later on.
  2. Add "start_tool_table" and "end_tool_table" tags of some sort, so you can easily flag where the Tool Table Comments start and stop in the NC File.
  3. Process the NCI data as normal, but at each 'ptoolend$', you would save the 'z_min$' value and 'op_id$' values to the buffer file.
  4. Inside 'ppost$', make sure the NC File is closed.
  5. Initialize a new String Buffer from the NC File Data, so the Buffer gets loaded with the NC File that was just generated by the Post Processor.
  6. Read each new line from the NC File Header (as buffered records), and scan through the line for the 'flag label string', and replace the string with retrieved data from the Z depth buffer.
  7. Once the new string is 'parsed and manipulated', write the modified string back to one of the "External File Types" (alternate output streams).
  8. After the string manipulation is finished, loop through the remaining lines of code in the String Buffer, writing each remaining line to the alternate output stream.
  9. Save the Alternate file, with a temp file name.
  10. Use the File Functions to delete the original NC File.
  11. Rename the Alternate File to match the original NC File.

 

This is quite honestly a lot of work to go through to get what you are after.

I believe Jeff has mentioned that there is an alternate method available, using the new Tool Table functionality that has been added to MP, but I think that requires that you rewrite all of the existing logic to remove the 'pparameter$' functions, and only use the new functions. That is also quite a lot of work.

 

 

 

 

 

Link to comment
Share on other sites
On ‎1‎/‎23‎/‎2019 at 9:19 AM, Colin Gilchrist said:

Steven,

I think part of the issue you are having is "when" you are trying to collect the data during the NCI Processing.

  • "pwrtt$" is the Post Block that creates the Tool List, but it does it "during the NCI Pre-Read Process".
  • You defined a "String Buffer" file type. This should probably be "numeric", and I would recommend saving "two 'reals' per record", with the 'z_min$' and 'op_number' values.
  • Because 'pwrtt$' gets called during the Pre-Read routine, I don't think the "z_min$" and "z_max$" variables get filled with the appropriate values, until we are actually processing the NCI Data, during the "output loop".
  • I think you see this, since the Z output is not correct.
  • To make this work is probably more complex than you think, but should still be possible.

 

I am guessing you'll having to do something like this:

  1. Write the Tool Table Comment Strings as normal, but output a "dummy" String at the end of the Comment String. I would probably do something like put the "op_id$" value, with a "flag label string", so we can use that as a search string later on.
  2. Add "start_tool_table" and "end_tool_table" tags of some sort, so you can easily flag where the Tool Table Comments start and stop in the NC File.
  3. Process the NCI data as normal, but at each 'ptoolend$', you would save the 'z_min$' value and 'op_id$' values to the buffer file.
  4. Inside 'ppost$', make sure the NC File is closed.
  5. Initialize a new String Buffer from the NC File Data, so the Buffer gets loaded with the NC File that was just generated by the Post Processor.
  6. Read each new line from the NC File Header (as buffered records), and scan through the line for the 'flag label string', and replace the string with retrieved data from the Z depth buffer.
  7. Once the new string is 'parsed and manipulated', write the modified string back to one of the "External File Types" (alternate output streams).
  8. After the string manipulation is finished, loop through the remaining lines of code in the String Buffer, writing each remaining line to the alternate output stream.
  9. Save the Alternate file, with a temp file name.
  10. Use the File Functions to delete the original NC File.
  11. Rename the Alternate File to match the original NC File.

 

This is quite honestly a lot of work to go through to get what you are after.

I believe Jeff has mentioned that there is an alternate method available, using the new Tool Table functionality that has been added to MP, but I think that requires that you rewrite all of the existing logic to remove the 'pparameter$' functions, and only use the new functions. That is also quite a lot of work.

 

 

 

 

 

Hello Colin,
    Thank you for your golden time because I know you are super busy.  These guidelines are very helpful and I will do it, also will feedback ASAP.

 

 

Thanks,
   S.Luong

Link to comment
Share on other sites
On ‎1‎/‎23‎/‎2019 at 9:19 AM, Colin Gilchrist said:

Steven,

I think part of the issue you are having is "when" you are trying to collect the data during the NCI Processing.

  • "pwrtt$" is the Post Block that creates the Tool List, but it does it "during the NCI Pre-Read Process".
  • You defined a "String Buffer" file type. This should probably be "numeric", and I would recommend saving "two 'reals' per record", with the 'z_min$' and 'op_number' values.
  • Because 'pwrtt$' gets called during the Pre-Read routine, I don't think the "z_min$" and "z_max$" variables get filled with the appropriate values, until we are actually processing the NCI Data, during the "output loop".
  • I think you see this, since the Z output is not correct.
  • To make this work is probably more complex than you think, but should still be possible.

 

I am guessing you'll having to do something like this:

  1. Write the Tool Table Comment Strings as normal, but output a "dummy" String at the end of the Comment String. I would probably do something like put the "op_id$" value, with a "flag label string", so we can use that as a search string later on.
  2. Add "start_tool_table" and "end_tool_table" tags of some sort, so you can easily flag where the Tool Table Comments start and stop in the NC File.
  3. Process the NCI data as normal, but at each 'ptoolend$', you would save the 'z_min$' value and 'op_id$' values to the buffer file.
  4. Inside 'ppost$', make sure the NC File is closed.
  5. Initialize a new String Buffer from the NC File Data, so the Buffer gets loaded with the NC File that was just generated by the Post Processor.
  6. Read each new line from the NC File Header (as buffered records), and scan through the line for the 'flag label string', and replace the string with retrieved data from the Z depth buffer.
  7. Once the new string is 'parsed and manipulated', write the modified string back to one of the "External File Types" (alternate output streams).
  8. After the string manipulation is finished, loop through the remaining lines of code in the String Buffer, writing each remaining line to the alternate output stream.
  9. Save the Alternate file, with a temp file name.
  10. Use the File Functions to delete the original NC File.
  11. Rename the Alternate File to match the original NC File.

 

This is quite honestly a lot of work to go through to get what you are after.

I believe Jeff has mentioned that there is an alternate method available, using the new Tool Table functionality that has been added to MP, but I think that requires that you rewrite all of the existing logic to remove the 'pparameter$' functions, and only use the new functions. That is also quite a lot of work.

 

 

 

 

 

 

Good morning Colin,
   I was lucky that someone has very similar post of which I am begging for and after I looked into the post with some modifications I am surely that you are right.  This post have modified entirely with the PTOOLTABLE with a replacement one.  One of the question is, it has DUPLICATION of tooling if inside the program has repeat tools.  Would you please point out what should I fix to make it better?  




Thank you for your time,
   S.Luong

 

 

============================== G-CODE  ============================

%
O3001(21973001 REVA - OP1.NC)
(KOVAR, BAR STOCK= L6. W.75 H.025)
(NOTE= WE NEED 200PCS!!!)
(21973001 REVA - OP1)
(POSTED ON = JAN.29.2019 AT 08:35)
(*)
(G54 = OP1)
(XY0= CENTER;  Z0 = TOP OF STOCK)
(*)
(TOOLS LIST, OP1 = 6 TOOLS)
(T1= .0313,#00 CNT DRILL | DOC= -.015)     =====================> GOOD DEEPEST DEPTH INFO
(T2= .0625,1/16 STUB DRILL | DOC= -.015)  =====================> GOOD DEEPEST DEPTH INFO
(T6= .081,#46 STUB DRILL | DOC= -.0588)   =====================> GOOD DEEPEST DEPTH INFO
(T3= .1875,3/16 BULL EM | DOC= -.0643)    =====================> GOOD DEEPEST DEPTH INFO
(T4= .1875,3/16 EM | DOC= -.004)                =====================> GOOD DEEPEST DEPTH INFO
(T5= .0612,1/16 EM | DOC= -.004)               =====================> GOOD DEEPEST DEPTH INFO


                                                                               ======TOOLS DUPLICATE BELOW, WRONG DEEPEST DEPTH INFO, NOT NEEDED========
(T1= .0313,#00 CNT DRILL | DOC= -.004)   =====================> WRONG DEEPEST DEPTH INFO
(T2= .0625,1/16 STUB DRILL | DOC= -.004) =====================> WRONG DEEPEST DEPTH INFO
(T6= .081,#46 STUB DRILL | DOC= -.009)    =====================> WRONG DEEPEST DEPTH INFO
(T3= .1875,3/16 BULL EM | DOC= -.009)     =====================> WRONG DEEPEST DEPTH INFO
(T4= .1875,3/16 EM | DOC= -.009)               =====================> WRONG DEEPEST DEPTH INFO
(T5= .0612,1/16 EM | DOC= -.009)               =====================> WRONG DEEPEST DEPTH INFO
(T2= .0625,1/16 STUB DRILL | DOC= -.009) =====================> WRONG DEEPEST DEPTH INFO
(T5= .0612,1/16 EM | DOC= -.009)                =====================> WRONG DEEPEST DEPTH INFO
(*)
N1(SPOT 28X .070 HOLES, CUT#1)
G0 G17 G40 G49 G80 G90
G91 G28 Z0.(DOC= -.015)  =============================> ZDEPTH
T1 M6(.0313,#00 CNT DRILL)
G0 G17 G90 G54 X-2.896 Y.039 S1000 M3
G43 H1 Z1. T2(NEXT TOOL)M8
G98 G81 Z-.015 R.0625 F5.
Y-.235
X-2.245
(CUTTING...)
Y.039
G80
N102(SPOT 4X .090 THRU HOLES, CUT#2)
G43 H1 Z1.(PROGRAM JUMPS HERE)
G0 G90 G54 S1000 M3
X-2.571 Y0.
G98 G81 Z-.015 R.0625 F5.
(CUTTING...)
G80 M9
G91 G28 Z0.
/G28 Y0. M5
M30
%

 

 

============================== DEFINED ============================

# --------------------------------------------------------------------------
# General Output Settings
# --------------------------------------------------------------------------
toolable_XYZ : yes$    # Output Axis limit comments in tooltable?
toolchange_XYZ : yes$  # Output Axis limit comments at toolchanges?
overall_XYZ : yes$     # Output Axis limit values for the 'entire program'
X_limits : no$        # Output the X axis limits
Y_limits : no$        # Output the Y axis limits
Z_limits : yes$        # Output the Z axis limits

 

#Region Buffer 4
# --------------------------------------------------------------------------
# Buffer 4 - Holds the variable 't' for each toolpath segment
# --------------------------------------------------------------------------
rc4 : 1
wc4 : 1
fbuf 4 0 1 0 0  # Buffer 4
#EndRegion Buffer 4


#Region Buffer 5
# --------------------------------------------------------------------------
# Buffer definition (for Max/Min X,Y,Z storage)
# --------------------------------------------------------------------------
rc5     : 2  #Buffer 5 READ pointer (YES, '2' is correct for this case!)
wc5     : 1  #Buffer 5 WRITE pointer
size5   : 0  #To hold 'size' of Buffer 5

b5_gcode : 0 #Stored in Buffer #5
b5_tcode : 0 #        "
b5_xmax  : 0 #        "
b5_xmin  : 0 #        "
b5_ymax  : 0 #        "
b5_ymin  : 0 #        "
b5_zmax  : 0 #        "
b5_zmin  : 0 #        "

fbuf 5 0 8 0 0 #Declare Buffer1 to hold Min/Max X,Y,Z axis info.
#EndRegion Buffer 5


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

           pwritbuf5 # Save X,Y,Z axis limit data
           if tool_table = 1, ptooltable, e$

           if (gcode$ <> 1003),  # *ADDED*
           [
               if tool_table = 2, ppredtool,e$
               if tool_table = 3, pmetatool,e$
           ]
           if t$ >= zero, tcnt = tcnt + one

punit      # Tool unit
           if met_tool$, " MM"
           else, 34

 

sdlm : " - "
sopn : "("
scls : ")"

stoollib : ""
scurop : ""
sunit  : ""

pgettooltable # Write tool table, scans entire file, null tools are negative
           if opcode$ = 3, !nextdc$, !sdrnote, scurop = sdrnote
           else, !opcode$, !sopnote, scurop = sopnote

           if met_tool$, sunit = " MM"
           else, sunit = no2asc(34)

           if tcr$ > 0,
              #stoollib = sopn + "T" + no2str(t$) + "= " + no2str(tldia$) + "," + strtool$ + " |" + "H" + no2str(tlngno$) + "|" + "D" + no2str(tloffno$) + " | " + sunit + sdlm + "R" + no2str(tcr$)
              stoollib = sopn + "T" + no2str(t$) + "= " + no2str(tldia$) + "," + strtool$ + " | "
           else,
              #stoollib = sopn + "T" + no2str(t$) + "= " + no2str(tldia$) + "," + strtool$ + " |" + "H" + no2str(tlngno$) + "|" + "D" + no2str(tloffno$)
              stoollib = sopn + "T" + no2str(t$) + "= " + no2str(tldia$) + "," + strtool$ + " | "

      


# --------------------------------------------------------------------------
# Buffer 5  Read / Write Routines
# --------------------------------------------------------------------------
pinit    #Initialize the limit checking variables
          max_Xpos = m_c9k #Initialize
          min_Xpos = c9k   #     "
          max_Ypos = m_c9k #     "
          min_Ypos = c9k   #     "
          max_Zpos = m_c9k #     "
          min_Zpos = c9k   #     "

plimits  # Check for NEW X,Y,Z limits
          if b5_xmax > max_Xpos, max_Xpos = b5_xmax
          if b5_xmin < min_Xpos, min_Xpos = b5_xmin
          if b5_ymax > max_Ypos, max_Ypos = b5_ymax
          if b5_ymin < min_Ypos, min_Ypos = b5_ymin
          if b5_zmax > max_Zpos, max_Zpos = b5_zmax
          if b5_zmin < min_Zpos, min_Zpos = b5_zmin

old_t : 0

pwritbuf5   # Write Buffer 5
          b5_gcode = gcode$
          if abs(t$) <> abs(old_t), t$ = abs (t$)
          if gcode$ = 1002 & t$ < zero, b5_gcode = 1000           #Added (6/24/03)
          if gcode$ = 1002 & op_id$ = prv_op_id$, b5_gcode = 1000 #Added (4/22/03)
          !op_id$                                                 #Added (4/22/03)
          b5_tcode = t$
          b5_xmax  = x_max$
          b5_xmin  = x_min$
          b5_ymax  = y_max$
          b5_ymin  = y_min$
          b5_zmax  = z_max$
          b5_zmin  = z_min$
          b5_gcode = wbuf(5, wc5) # Write the record
          if wc5 = 2,
          [
             wc5 = 1
             b5_gcode = wbuf(5, wc5)
          ]
          old_t = t$

preadbuf5t # Read Buffer 5 (at the toolchanges for X,Y,Z limits)
          pinit                      #Initialize the limit checking variables
          b5_gcode = rbuf(5, rc5)    #Read a record from the Buffer
          plimits                    #Check for NEW limits
          # Need this loop to scan thru possible NULL tlchgs
          while (b5_gcode = 1000),   #Find the next NON-NULL toolchange
            [
            b5_gcode = rbuf(5, rc5)  #Read the next record from the Buffer
            plimits                  #Check for NEW limits
            ]

preadbuf5e # Read Buffer 5 (for Program X,Y,Z limits)
          pinit                     #Initialize the limit checking variables
          size5 = rbuf(5, 0)        #Get the size of the Buffer
          rc5 = two                 #Reset read pointer (SKIP 1st record!)
          while rc5 <= size5,       #Loop thru entire program
            [
            b5_gcode = rbuf(5, rc5) #Read a record from the Buffer
            plimits                 #Check for NEW limits
            ]
         rc5 = two          
       #Reset read pointer (SKIP 1st record!)


pMaxMin # Output Max/Min X,Y, Z coordinates

          if X_limits = yes$, # Output MAX/MIN positions in the X axis
            "(", "Max_X = ", *max_Xpos, "  Min_X = ", *min_Xpos, ")", e$
          if Y_limits = yes$, # Output MAX/MIN positions in the Y axis
            "(", "Max_Y = ", *max_Ypos, "  Min_Y = ", *min_Ypos, ")", e$
          if Z_limits = yes$, # Output MAX/MIN positions in the Z axis
             [
              "(", "OVERALL MAX Z = ", *max_Zpos, ")", e$
              "(", "OVERALL MIN Z  = ", *min_Zpos, ")", e$
             ]

      
pMaxMin_str # Output Max/Min X,Y, Z coordinates
      stoollib, [if Z_limits = yes$, "DOC= ", *min_Zpos], scls, e$

 

       


ptooltable # Write tool table, scans entire file, null tools are negative
           tnote = t$
           toffnote = tloffno$
           tlngnote = tlngno$
           spaces$=0
           if t$ >= zero | gcode$ = 1003,
           [
              # *ADDED* for XYZ limit output "in the ToolTable"
              if (toolable_XYZ = yes$) & (gcode$ <> 1001),
              [
                  preadbuf5t #Read the data from the Buffer 5
 #                pMaxMin    #Output Max/Min X,Y,Z coords during this tool operation
                  pMaxMin_str
              ]
              if gcode$ <> 1003, # '1003' = end of program
                  pgettooltable

           ]
           spaces$=sav_spc


 

Link to comment
Share on other sites
  • 3 weeks later...
On ‎1‎/‎31‎/‎2019 at 12:21 AM, jeff.D said:

Some of the comments put portions of that code as being added '03.  I'm guessing the rest of logic is older than that.

Code ages, and I really think you should investage some of the new methods MP has to offer.

 

 

 

 

Good morning Jeff.D,
   Thank you for your valuable time to help me with this BUFFER.  After 3 weeks, 2 hours a day and I have came up with this result (please see below).  I think I am 90% completion and I am having 1 more issue. It is the tools list truncated the last tool, I guess my knowledge of writing post is very limited and I hope that guys can point out that I have been blinding.

 

 

Best regards,
   S.Luong

 

 

======================= G-Codes ========================
%
O2531(000-561-6253-002 - OP1.NC)
(SOURCE = 000-561-6253-002.MCAM)
(VERTICAL INDEX)
(PART NAME= SQUARE BLOCK)
(UNPROVEN SOURCE FILE)
(*)
(POSTED ON FEB.15.2019 AT 10*26AM)
(POSTED BY= PCROBOTIC\ADMIN)
(ALUM 6061-T6, BAR STOCK= X.63 Y2.00 Z3.30)
(VERTICAL INDEX)
(*)
(TOOLS LIST, OP1 = 6 TOOLS)
(T1= 2.0000, 2" SHM 90DEG * STO= .015) ======================> This is correct
(T2= .5000, 1/2 EM * STO= -.515)======================> This is correct
(T3= .5000, 1/2 SPOTTER * STO= -.2056)======================> This is correct
(T4= .2810, LTR. K STUB DRILL * STO= -.7044)======================> This is correct
(T5= .4063, 13/32 STUB DRILL * STO= -.742)======================> This is correct
(T6 = .5000, 1/2 BULL EM * STO= ......) =======> MISSING THIS TOOL (DEPTH IS NOW SHOWN.....)
(*)
(WORK OFFSET LIST)
(G54)
(XY0= CENTER)
(Z0 = TOP OF STOCK)
( Z-.015 MINIMAL CLEAN UP)
(*)
N1(2.0000,2" SHM 90DEG, FIN, CB,)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19(Z STK= .015)
/G28 Y0.(TOOLPATH ZCLEARANCE= .05 MIN.)
T1 M6(2D TOOLPATHS - FACING, CUT#1)
G90 G54 S4500 M3(1.5 MAX., 75PERC STPOVR)
X-3.85 Y.4999 T2(NEXT TOOL)
G43 H1 Z1.(DOC1= Z.015, .015DP) ======================> This is correct
M8 G17(XY PLANE) G90 Z.0775
G1 Z.015 F100.
X2.85
Y-.4999
X-3.85
G0 Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N2(.5000,1/2 EM, U, CB, 1.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19(XY STK= .015)
/G28 Y0.(DYNAMIC MILL)
T2 M6(ROUGH OUT PROFILE, CUT#2)
G90 G54 S7500 M3(.075 STOVR, 15.PERC TDIA.)
X-1.7969 Y-1.2651 T3(NEXT TOOL)
G43 H2 Z1.(DOC1= Z-.515, .015DP, .015 THRU) ======================> This is correct
M8 G17(XY PLANE) G90 Z.0625
G1 Z-.505 F200.
X-1.8121 Y-1.2262 Z-.5097
G3 X-1.8374 Y-1.1874 Z-.515 I-.1049 J-.0408
(CUTTING....)
G3 X1.7629 Y-1.0412 Z-.5097 I.1109 J-.0191
G1 X1.773 Y-1.0818 Z-.505
G0 Z1.
M9(PROGRAM JUMPS HERE)
(*)
N202(.5000,1/2 EM, U, CB, 1.00STO)
(ROUGH OUT .150 CHAMFER, CUT#3)
G0 G17(XY PLANE) G90 G54 S7500 M3
X-2. Y-1.205(3D XYZ STK= .025)
G43 H2 Z1.(DOC2= Z-.1196, .015DP)======================> This is correct
M8 Z.0931
G1 Z.015 F200.
(CUTTING...)
X-1.5
X1.5
X2.
G0 Z-.0571
Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N3(.5000, 1/2 SPOTTER, HSS, 1.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.
T3 M6(SPOT 2X, CUT#4)
G90 G54 S3500 M3
X-.9 Y.65 T4(NEXT TOOL)
G43 H3 Z1.(DOC1= Z-.1425, .015DP)======================> This is correct
M8 G17(XY PLANE) G90 Z.125
(2X SPOTS, .285'CSINK SIZE)
G99 G81 Z-.1425 R.125 F5.
X.9
G80
Z1.
M9(PROGRAM JUMPS HERE)
(*)
N302(.5000, 1/2 SPOTTER, HSS, 1.00STO)
(SPOT 2X, CUT#5)
G0 G17(XY PLANE) G90 G54 S3500 M3
X-.979 Y-.414
G43 H3 Z1.(DOC2= Z-.2056, .015DP)======================> This is correct
M8 Z.125
(2X SPOTS, .4112'CSINK SIZE)
G99 G81 Z-.2056 R.125 F5.
X.987 Y-.352
G80
Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N4(.2810, LTR. K STUB DRILL, HSS, 1.75STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.
T4 M6(DRILL 2X .281 +.006 - .001, CUT#6)
G90 G54 S6600 M3
X-.9 Y.65 T5(NEXT TOOL)
G43 H4 Z1.(DOC1= Z-.7044, .015DP)======================> This is correct
M8 G17(XY PLANE) G90 Z.125
(2X DRILL HOLES)
(8 PECKS, W.0944 THRU, -.7044 PIN DEPTH)
G99 G83 Z-.7044 R.125 Q.0937 F25.
X.9
G80
Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N5(.4063, 13/32 STUB DRILL, HSS, 2.25STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.
T5 M6(DRILL .407  +.006 - .001, CUT#7)
G90 G54 S4568 M3
X-.979 Y-.414 T1(NEXT TOOL)
G43 H5 Z1.(DOC1= Z-.742, .015DP)======================> This is correct
M8 G17(XY PLANE) G90 Z.125
(2X DRILL HOLES)
(6 PECKS, W.1321 THRU, -.7421 PIN DEPTH)
G99 G83 Z-.742 R.125 Q.1357 F25.
X.987 Y-.352
G80
Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N102(2.0000,2" SHM 90DEG, FIN, CB,)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19
/G28 Y0.(TOOLPATH ZCLEARANCE= .06 MIN.)
T1 M6(FINISH TOP SURFACE, CUT#8)
G90 G54 S4500 M3(1.5 MAX., 75PERC STPOVR)
X-3.85 Y.4999 T2(NEXT TOOL)
G43 H1 Z1.(DOC1= Z0., .015DP, .015 THRU)======================> This is correct
M8 G17(XY PLANE) G90 Z.0775
G1 Z0. F100.
X2.85
Y-.4999
X-3.85
G0 Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N203(.5000,1/2 EM, U, CB, 1.00STO)
G0 G17 G40 G49 G80 G90
G91 G28 Z0 M19(1X, RMULTI-PASS, .015)
(1X, FINISH MULTI-PASS, .005)
/G28 Y0.
T2 M6(FINISH PROFILE, CUT#9)
G90 G54 S7500 M3
X2.005 Y.0025 T6(NEXT TOOL)
G43(D2)H2 Z1.(DOC1= Z-.515, .015DP, .015 THRU)======================> This is correct
M8 G17(XY PLANE) G90 Z.0625
G1 Z-.515 F50.
G41 D2 X1.8282 Y.1793
(CUTTING...)
G1 G40 X2. Y-.1225 F25.
G0 Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
(*)
N6(.5000,1/2 BULL EM, .030RAD, RG, CB, 1.25STO)
G0 G17 G40 G49 G80 G90(.001 3D MAX STOVR)
(3D MAX STOVR)
G91 G28 Z0 M19
/G28 Y0.(TOOLPATH ZCLEARANCE= .06 MIN.)
T6 M6(FINISH 3D CHAMFER, CUT#10)
G90 G54 S7500 M3
X-2. Y-1.1904 M8 T1(NEXT TOOL)
G43 H6 Z1.(DOC1= Z-.515, .015DP) ==================  Depth of Cut is also wrong, it should be Z-.157
G17(XY PLANE) G90 Z-.0955
G1 Z-.158 F100.
X-1.5
X1.5
X2.
X2.0007 Y-1.1898 Z-.1573
X-1.5 Y-1.1894 Z-.157
(CUTTING...)
X-1.5 Y-1.0424 Z-.01
X-2.
X-2.0006 Y-1.0422 Z-.0097
X-2. Y-1.0414 Z-.009
X2.
G0 Z.0535
Z1.
M9
G91 G28 Z0.
/G28 Y0. M5
G0 G90 G54 X0.
M1
T1 M6(FIRST PROGRAMMED TOOL)
M30
%(19,561 CHARACTERS = 19.62KB)

 

=================================== Defined========================================

# --------------------------------------------------------------------------
# General Output Settings
# --------------------------------------------------------------------------
X_limits : no$        # Output the X axis limits
Y_limits : no$        # Output the Y axis limits
Z_limits : yes$        # Output the Z axis limits

toolable_XYZ : yes$    # Output Axis limit comments in tooltable?
toolchange_XYZ : yes$  # Output Axis limit comments at toolchanges?
overall_XYZ : yes$     # Output Axis limit values for the 'entire program'


#Region  Define Number Constants

#Define Number Constants
m_one       :  -1   #Define constant
zero        : 0     #Define constant
one         : 1     #Define constant
two         : 2     #Define constant
three       : 3     #Define constant
four        : 4     #Define constant
five        : 5     #Define constant
six         : 6     #Define constant
seven       : 7     #Define constant
eight       : 8     #Define constant
nine        : 9     #Define constant

c9k         : 9999  #Define constantbug4$        : -1    #Debug output with the tilde '~'.
                     #A value greater the zero applies the variable formatting with
                     #debug output (default is typically FS 1 but not a guarantee).
                     #A value of zero gets the value directly with NO formatting.

m_c9k       : -99999  #Define constant

#Region Customed Misc Strings
# --------------------------------------------------------------------------
# Customed Misc strings
# --------------------------------------------------------------------------
sdlm : " - "
sopn : "("
scls : ")"

stoollib : ""
scurop : ""
sunit  : ""


#Region Buffer 4
# --------------------------------------------------------------------------
# Buffer definition (for Max/Min X,Y,Z storage)
# --------------------------------------------------------------------------
rc4     : 2  #Buffer 4 READ pointer (YES, '2' is correct for this case!)
wc4     : 1  #Buffer 4 WRITE pointer
size4   : 0  #To hold 'size' of Buffer 4

b4_gcode : 0 #Stored in Buffer #4
b4_tcode : 0 #        "
b4_xmax  : 0 #        "
b4_xmin  : 0 #        "
b4_ymax  : 0 #        "
b4_ymin  : 0 #        "
b4_zmax  : 0 #        "
b4_zmin  : 0 #        "

fbuf 4 0 8 0 0 #Declare Buffer1 to hold Min/Max X,Y,Z axis info.
#EndRegion Buffer 4
#EndRegion Buffer 4


#Region Common user-defined variable initializations (not switches!)
# --------------------------------------------------------------------------
# Common User-defined Variable Initializations (not switches!)
# --------------------------------------------------------------------------
sav_rc4         : 0

# --------------------------------------------------------------------------
# Toolchange / NC output Variable Formats
# --------------------------------------------------------------------------
fmt 2  max_Xpos
fmt 2  min_Xpos
fmt 2  max_Ypos
fmt 2  min_Ypos
fmt 2  max_Zpos
fmt 2  min_Zpos

#Region Start of file
# --------------------------------------------------------------------------
# Start of File and Toolchange Setup
# --------------------------------------------------------------------------
psof0$           #Start of file for tool zero
      psof$

psof$            #Start of file for non-zero tool number
      pwritbuf4
      pwritbuf5
#Region Tool change common blocks
ptlchg_com      #Tool change common blocks
      if output_z = yes$,
        preadbuf5
        if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,
           scomm_str, no_spc$, "DOC1=", *min_depth, no_spc$, [if acd <> 0, *acd], # First DOC


#Region Null tool change
ptlchg0$         #Call from NCI null tool change (tool number repeats)
           if retractflg = 0,
           
           spaces$ = 0, no_spc$, scomm_str, "DOC2= ", *min_depth, # Second DOC
           
#Region pwrtt$
# --------------------------------------------------------------------------
# Tooltable Output
# --------------------------------------------------------------------------
pwrtt$      # Write tool table, scans entire file, null tools are negative
           pwritbuf4 # Save X,Y,Z axis limit data

pgettooltable # Write tool table, scans entire file, null tools are negative
           if opcode$ = 3, !nextdc$, !sdrnote, scurop = sdrnote
           else, !opcode$, !sopnote, scurop = sopnote

           if met_tool$, sunit = " MM"
           else, sunit = no2asc(34)

           if tcr$ > 0,
              stoollib = sopn + "T" + no2str(t$) + "= " + no2str(tldia$) + ", " + strtool$ + sdlm + "R" + no2str(tcr$)
           else,
              stoollib = sopn + "T" + no2str(t$) + "= " + no2str(tldia$) + ", " + strtool$ # + "H" + no2str(tloffno$)


# --------------------------------------------------------------------------
# Buffer 4  Read / Write Routines
# --------------------------------------------------------------------------
pinit    #Initialize the limit checking variables
          max_Xpos = m_c9k #Initialize
          min_Xpos = c9k   #     "
          max_Ypos = m_c9k #     "
          min_Ypos = c9k   #     "
          max_Zpos = m_c9k #     "
          min_Zpos = c9k   #     "

plimits  # Check for NEW X,Y,Z limits
          if b4_xmax > max_Xpos, max_Xpos = b4_xmax
          if b4_xmin < min_Xpos, min_Xpos = b4_xmin
          if b4_ymax > max_Ypos, max_Ypos = b4_ymax
          if b4_ymin < min_Ypos, min_Ypos = b4_ymin
          if b4_zmax > max_Zpos, max_Zpos = b4_zmax
          if b4_zmin < min_Zpos, min_Zpos = b4_zmin


preadbuf4t # Read Buffer 5 (at the toolchanges for X,Y,Z limits)
          pinit                      #Initialize the limit checking variables
          b4_gcode = rbuf(4, rc4)    #Read a record from the Buffer
          plimits                    #Check for NEW limits
          # Need this loop to scan thru possible NULL tlchgs
          while (b4_gcode = 1000),   #Find the next NON-NULL toolchange
            [
            b4_gcode = rbuf(4, rc4)  #Read the next record from the Buffer
            plimits                  #Check for NEW limits
            ]

preadbuf4e # Read Buffer 5 (for Program X,Y,Z limits)
          pinit                     #Initialize the limit checking variables
          size4 = rbuf(4, 0)        #Get the size of the Buffer
          rc5 = two                 #Reset read pointer (SKIP 1st record!)
          while rc4 <= size4,       #Loop thru entire program
            [
            b4_gcode = rbuf(4, rc4) #Read a record from the Buffer
            plimits                 #Check for NEW limits
            ]
         rc4 = two                  #Reset read pointer (SKIP 1st record!)


pMaxMin # Output Max/Min X,Y, Z coordinates

          if X_limits = yes$, # Output MAX/MIN positions in the X axis
            "(", "Max_X = ", *max_Xpos, "  Min_X = ", *min_Xpos, ")", e$
          if Y_limits = yes$, # Output MAX/MIN positions in the Y axis
            "(", "Max_Y = ", *max_Ypos, "  Min_Y = ", *min_Ypos, ")", e$
          if Z_limits = yes$, # Output MAX/MIN positions in the Z axis
             [
              "(", "OVERALL MAX Z = ", *max_Zpos, ")", e$
              "(", "OVERALL MIN Z  = ", *min_Zpos, ")", e$
             ]

pMaxMin_str # Output Max/Min X,Y, Z coordinates
      stoollib, [if Z_limits = yes$, " * ", "STO= ", *min_Zpos], scls, e$


#Region ptooltable
ptooltable # Write tool table, scans entire file, null tools are negative
           tnote = t$
           toffnote = tloffno$
           tlngnote = tlngno$
           spaces$=0
           if t$ >= zero | gcode$ = 1003,
           [
              # *ADDED* for XYZ limit output "in the ToolTable"
              if (toolable_XYZ = yes$) & (gcode$ <> 1001),
              [
                  preadbuf4t #Read the data from the Buffer 4
 #                pMaxMin    #Output Max/Min X,Y,Z coords during this tool operation
                  pMaxMin_str
              ]
              if gcode$ <> 1003, # '1003' = end of program
                  pgettooltable
           ]
           spaces$=sav_spc
           
#Region pwritbuf4
# --------------------------------------------------------------------------
# Buffer 4  Read / Write Routines
# --------------------------------------------------------------------------
pwritbuf4   # Write Buffer 4
          b4_gcode = gcode$
          if gcode$ = 1002 & op_id$ = prv_op_id$, b4_gcode = 1003 #Added (4/22/03)
          !op_id$                                                 #Added (4/22/03)
          b4_xmax  = x_max$
          b4_xmin  = x_min$
          b4_ymax  = y_max$
          b4_ymin  = y_min$
          b4_zmax  = z_max$
          b4_zmin  = z_min$
          b4_gcode = wbuf(4, wc4) # Write the record
          if wc4 = 2,
          [
             wc4 = 1
             b4_gcode = wbuf(4, wc4)
          ]
#EndRegion pwritbuf4

#Region preadbuf5
preadbuf5   # Read Buffer 5
            size5 = rbuf(5,0)
            b5_gcode = 1001
            min_depth = 99999
            max_depth = -99999
            while rc5 <= size5 & b5_gcode = 1001,
              [
              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
              ]
#EndRegion preadbuf5

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