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 Problems


Recommended Posts

 

I've been working on getting my generic fanuc 2x lathe post to output a min overhang for boring bars and have hit a bit of a brick wall.

Started by making a buffer to capture op_id, z_min and z_max, defined and formatted the variables, modified the pwrtt and tooltable post blocks and hit the G1 button.

The result was wrong as the read values ended up staggered. To figure out why, I added t$ to the buffer and found that op_id 1001 was already writing tool 1 into the buffer. I tried to force all 0. if gcode$=1001, and it just repeated the next row with tool 1. 

I think I'm pretty close, but definitely need some help from more experienced people. IHS said they'd look at it for a charge and that the MP documentation is no longer distributed, so I'm hoping someone here can point me to what I'm missing. Snippets below.

 

Buffer results

1001. 0. 0. 0.
1001. 0. 0. 1.
1000. 0.206 0.055 1.
1002. 0.211 0.05 4.
1000. 14.85931503 0.03004284 4.
1000. 14.85931503 12.00595716 4.
1000. 12.47595716 0.03004284 4.
1002. 12.48095716 0.00004284 6.
1002. 7.05867671 0.1 6.
1002. 7.05867671 0.1 10.
1002. 5.5 0.5 6.
1002. 14.7522132 0.03004284 6.
1002. 14.7522132 0.03004284 8.
1000. 7.07 0.03 8.
1000. 7.16667541 6.78875 8.

 

 

Buffer definition
#Buffer 4, z_max values
# --------------------------------------------------------------------------
b4_op_id     : 0
b4_zmin      : 0
b4_zmax      : 0
b4_tool      : 0  #added to see where the values came from
rc4          : 2
wc4          : 1
size4        : 0

sbufname4$ : "C:\desktop\buffer4_data.txt"
fbuf 4 1 4 0 0     #Buffer 4

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


modified postblock and buffer read/write functions

pwrtt$           #Buffer toolchange information, tooltable = 3 calls on 1003
      
      if gcode$ = 1001, psetup
      pcut_cctyp
      if opcode$=104 | opcode$=105 | opcode$=three | opcode$=16, cc_pos$ = zero
      if gcode$ <> 1001, plast_recd
      pcur_recd
      if gcode$ <> 1003, cc_pos$ = zero
      !opcode$, !tool_op$
      if gcode$ = 1003,
        [
        size1 = rbuf (one, zero)
        rc1 = one
        if rc1 < size1, preadcur_nxt
        if cc_1013$ = zero, cc_pos$ = zero
        
        ]
        
        if gcode$ <> 1003, pwritbuf4   #added write buffer
        if t$ > 0 & gcode$ <> 1003, ptooltable
        
        
pwritbuf4 #Write zmin/max
      if gcode$ = 1001,
      [
        b4_op_id = gcode$ 
        b4_tool = 0
        b4_zmin = 0 
        b4_zmax = 0 
        b4_op_id = wbuf(4, wc4)
      ]
      else,
            
        b4_op_id = gcode$ 
        b4_tool = abs(t$) 
        b4_zmin = abs(z_min$) 
        b4_zmax = abs(z_max$) 
        b4_op_id = wbuf(4, wc4)

preadbuf4 #read zmin/max
                
        min_depth = b4_zmin 
        max_depth = b4_zmax

 

Thanks for the help, I wouldn't have made it this far without this forum.

 

Link to comment
Share on other sites

You've got a couple things going on here.

  1. When you read or write to a Buffer File, the "input" to the Read or Write Command, is a "single variable", which represents the start of an ordered list of variables.
  2. You don't have any 'read buffer' calls. You are attempting to "read the values directly from the 'read storage variables', but you don't have any logic to 'recall the data', or 'loop through the values, to find the largest one'.

When you create a buffer, I think it is a 'best practice' to create two separate lists of variables. One list for 'reading from' the buffer, and one list for 'writing to' the buffer. Technically, you can use a single list of variables, for writing/reading, depending on how you write your logic.

Also, please use the 'Code' button, when entering code from the Post File. It makes it much easier if the spacing/indents are correct, as MP is a 'column dependent language'.

 

Buffer definition
#Buffer 4, z_max values
# --------------------------------------------------------------------------
#Write Variable List
#  'b4w_op_id' is the 'list index'
b4w_op_id     : 0
b4w_zmin      : 0
b4w_zmax      : 0
b4w_tool      : 0  #added to see where the values came from

#Read Variable List
#    'b4r_op_id' is the 'list index'
b4r_op_id     : 0
b4r_zmin      : 0
b4r_zmax      : 0
b4r_tool      : 0  #added to see where the values came from


rc4          : 2
wc4          : 1
size4        : 0

sbufname4$ : "C:\desktop\buffer4_data.txt"
fbuf 4 1 4 0 0     #Buffer 4

fmt "" 2 b4_min_depth #z_min
fmt "" 2 b4_max_depth #z_max

 

Note:

The only thing I really did in that Buffer Initialization, is to 'rename' the b4 'write' variables, (added 'w' to the name), and created a 2nd set of variables (another list), with a similar name. The only thing I changed was the 'r' designation, to indicate that it is a 'read' variable. This is purely personal preference, and wasn't technically necessary.

The last change I made was to add 'b4_' to the 'min and max' variable names. Just to help keep them separate.

We already know you are "loading data" into the buffer. But you aren't reading that data back into the Post correctly.

You will need to write some "buffer read logic" that can 'loop through the buffer data, for each tool number", and have the logic "compare the Z Min / Z Max values to something", and update the "max depth" if there is a deeper depth in the list.

Here is some 'pseudo-code' to help get you going:

 

preadbuf4 #read zmin/max
      #Get buffer size
      size4 = rbuf (4, 0)
      rc4 = one #Start with first line

      while rc4 <= size4,
        [
        #Loop through whole list. Only read min/max if Tool in Buffer list = Current Tool being processed.
        b4r_op_id = rbuf(4, rc4) #Read all 4 lines from buffer. Load into variable list.
        #You may have to work on positioning, depending on where you call 'preadbuf4'
        if b4r_tool = abs(t$),
          [
          if b4r_zmin < b4_min_depth, b4_min_depth = b4r_zmin
          if b4r_zmax > b4_max_depth, b4_max_depth = b4r_zmax
          ]
        ]
        
        
        

 

NOTE: The 'loop counter' variable [rc4], will be Auto-Incremented, by '1', just by using the 'rbuf' command, unless the 'buf_no_index$' Command Variable has been enabled!

  • Thanks 1
  • Like 2
Link to comment
Share on other sites
  • 3 months later...

Well, I finally gave up on the buffer route for this problem. I just couldn't get to the record I needed in the proper order with the way the post accesses the min/max values during processing. 

So, I ended up going the easier route and adding this into the pwrtt$ postblock.

if t$ > 0 | gcode$ <> 1001,
		[
		b4_min_depth = abs (z_min$)
		b4_min_depth = (round(b4_min_depth) + 0.5)
		"(", *b4_min_depth, no_spc$, 34, "MIN OVER HANG)", e$ 
		" ", e$ 
        ]

Takes the min depth, rounds it and adds a 1/2" clearance. It adds it after the ptooltable output for each tool. Not exactly in the location I wanted it, but it'll do until I revisit it some day.

Link to comment
Share on other sites
  • 2 weeks later...
11 minutes ago, Sushant Singh said:

Does anyone has a Buffer file ?   pdf in detail 

I can promise you your reseller does....if they don't for some reason, they(your reseller) can contact me directly to verify that you're a legitimate user and I'd be happy to share what I have...

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