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:

Manual Entry Code Entered In Next Tool Operation


cncgotoguy
 Share

Recommended Posts

It seems like the manual entry code should come after the previous operation and before the next, but it is being entered after the next tool change. 

Is this how it normally goes? Seems like it should be placed between the operations as it is in the operations tree.

 

image.png.6e3db4cc9224e765632b8ffb817374ba.png

 

image.thumb.png.a0ecb11139e8b73b095b93ed941536e7.png

image.thumb.png.314ee5206db7724fe6946f8de1a58063.png

 

 

image.png

  • Like 1
Link to comment
Share on other sites
45 minutes ago, So not a Guru said:

Before you start, backup your post!!

Insert a # in front of ptoolcomment, like this:

#      ptoolcomment   

Then add ptoolcomment  like this:

ptlchg$          #Tool change
      ptoolcomment   
      pcuttype

Sorry Zeke I don't think ptoolcomment will give him what he wants. I think it needs to be comment$

ptlchg$          #Tool change
      comment$   
      pcuttype 

Colin what is the best method to handle this request sir?

Link to comment
Share on other sites

Use the following at your own risk!!!!!!

No your tool comment is still in the same place the operation comments are moved not the tool comments. I think you need to add logic for the output and lets explore how a new user would go about this.

If we review this section we see this for pcomment$

pcomment$       #Output Comments
      scomm$ = ucase (scomm$)
      if gcode$ = 1005, sopen_prn, scomm$, sclose_prn, e$  #Manual entry - as comment
      if gcode$ = 1006, scomm$, e$                         #Manual entry - as code
      if gcode$ = 1007, sopen_prn, scomm$, sclose_prn      #Manual entry - as comment with move NO e$
      if gcode$ = 1026, scomm$                             #Manual entry - as code with move NO e$
      if gcode$ = 1008, sopen_prn, scomm$, sclose_prn, e$  #Operation comment
      if gcode$ = 1051, sopen_prn, scomm$, sclose_prn, e$  #Machine name
      if gcode$ = 1052, sopen_prn, scomm$, sclose_prn, e$  #Group comment
      if gcode$ = 1053, sopen_prn, scomm$, sclose_prn, e$  #Group name
      if gcode$ = 1054, sopen_prn, scomm$, sclose_prn, e$  #File Descriptor

Now people who don't register at Mastercam.com and download the MP reference material cannot look up what does this mean in relation to comment$ and what we have in our post being output. I looked up comment$ in the documentation and found this section to help me decipher what is the post going to do when it see it and what will it output.

Quote

comment$

  • M
  •  
  • L
  •  
  • R
  •  
  • W
  •  
  • MT

Outputs the comments taken from the NCI and buffered at the tool change. This allows the post writer to position the location where comments are written in the tool change postblocks and end-of-file postblock.

By default, comments are output immediately before the toolchange. If you wish to output the comments after the toolchange, use the comment$ command to output them at the desired location.

The comment$ command affects comments output with the following NCI lines:

If MP sees the comment$ command in your post, when the above NCI lines are encountered, MP will save the comments to a special buffer instead of outputting them. When the comment$ command is encountered, the comments will be output, one string at a time. For each saved comment, MP copies the comment string to scomm$ and calls the pcomment$ postblock. This gives you an opportunity to format the comments before they are output to your NC file.

The comment$ command is typically used in the following postblocks:

  • psof$, lsof$, msof$
  • ptlchg$, ltlchg$, mtlchg$
  • ptlchg0$, ltlchg0$, mtlchg0$
  • peof$, leof$, meof$

You should never call the pcomment$ postblock directly from any of these postblocks. Always use the comment$ command instead.

Notes:

  • comment$ is only used as a command word, it has no value.
  • To control which comments are output, use the comm_filter$ to suppress unwanted comments.

Now the post writer did us a favor to understand what the NCI line mean and meant to do when we use certain functions in the software to get the output. We see in the pcomment$ section that gcode$ 1005, 1006, 1007 and 1026 have to do with manual entry. We also see from the MP reference what happens when comment sees anything related to comments in the Mastercam file. Everything related to getting all comments from the operations or other things will come out when that is used. In your case you only want the comment$ to output manual entry there and then you want operational comments output like they were. Problem is comment$ has no logic controlling the output. This is where understanding what conditional logic statements are and how to best use them to get your output. This is where sample file goes a long way to allow anyone willing to help a way to help easier, but I will take a stab at this.

I am thinking if we add the following logic statement to the first comment$ line:

if gcode$ = 1005, comment$ 

Then when manual entry with no code it will only be output where you want it at the tool change. Again I have no sample file and not making one to test this so I can be completely off my rocker, but how you learn is the willingness to try and fail and keep trying until you figure it out.

Then we have the other comment$ where it was, but add conditional logic to it also:

if gcode$ = 1008, comment$ #RDB only output Operational comment

Now the downside to this is I have limited the output to only these two conditions in the toolchange section. That may or may not be a problem. Again without a sample file to test go through 50 different scenarios to test then up to you to take this expand on it and see what you can work out to give you what you are after. Now another thing to consider is does the post have different logic for the start of a file and tool change? If it does then you have to think about how you want to handle situations for the first operation in a file.

Use at your own risk!!!!!!!!!!!!!

Link to comment
Share on other sites
3 hours ago, crazy^millman said:

Sorry Zeke I don't think ptoolcomment will give him what he wants. I think it needs to be comment$


ptlchg$          #Tool change
      comment$   
      pcuttype 

Colin what is the best method to handle this request sir?

Moving 'comment$' to the right place, will cause the comments to dump out.

He would need to add some logic to 'pcomment2', to capture the '1008' operation comment, and wait to output it until after the Tool Change (Txx M06) output.

We typically do this in 'pheader', where we want to set a flag that says "if we are inside pheader, then only output all comments except 1008, and save the 1008 comment string". Then, we add logic to test "the saved comment string", and output the string, if there is a value there...

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

Moving 'comment$' to the right place, will cause the comments to dump out.

He would need to add some logic to 'pcomment2', to capture the '1008' operation comment, and wait to output it until after the Tool Change (Txx M06) output.

We typically do this in 'pheader', where we want to set a flag that says "if we are inside pheader, then only output all comments except 1008, and save the 1008 comment string". Then, we add logic to test "the saved comment string", and output the string, if there is a value there...

Now don't go talking about buffers and I am good. You start mentioning buffers and I will have to step away from the computer before it gets thrown out of a window for good measure. :wallbash::wallbash::wallbash:

  • Like 3
  • Haha 1
Link to comment
Share on other sites
2 hours ago, crazy^millman said:

Use the following at your own risk!!!!!!

No your tool comment is still in the same place the operation comments are moved not the tool comments. I think you need to add logic for the output and lets explore how a new user would go about this.

If we review this section we see this for pcomment$


pcomment$       #Output Comments
      scomm$ = ucase (scomm$)
      if gcode$ = 1005, sopen_prn, scomm$, sclose_prn, e$  #Manual entry - as comment
      if gcode$ = 1006, scomm$, e$                         #Manual entry - as code
      if gcode$ = 1007, sopen_prn, scomm$, sclose_prn      #Manual entry - as comment with move NO e$
      if gcode$ = 1026, scomm$                             #Manual entry - as code with move NO e$
      if gcode$ = 1008, sopen_prn, scomm$, sclose_prn, e$  #Operation comment
      if gcode$ = 1051, sopen_prn, scomm$, sclose_prn, e$  #Machine name
      if gcode$ = 1052, sopen_prn, scomm$, sclose_prn, e$  #Group comment
      if gcode$ = 1053, sopen_prn, scomm$, sclose_prn, e$  #Group name
      if gcode$ = 1054, sopen_prn, scomm$, sclose_prn, e$  #File Descriptor

Now people who don't register at Mastercam.com and download the MP reference material cannot look up what does this mean in relation to comment$ and what we have in our post being output. I looked up comment$ in the documentation and found this section to help me decipher what is the post going to do when it see it and what will it output.

Now the post writer did us a favor to understand what the NCI line mean and meant to do when we use certain functions in the software to get the output. We see in the pcomment$ section that gcode$ 1005, 1006, 1007 and 1026 have to do with manual entry. We also see from the MP reference what happens when comment sees anything related to comments in the Mastercam file. Everything related to getting all comments from the operations or other things will come out when that is used. In your case you only want the comment$ to output manual entry there and then you want operational comments output like they were. Problem is comment$ has no logic controlling the output. This is where understanding what conditional logic statements are and how to best use them to get your output. This is where sample file goes a long way to allow anyone willing to help a way to help easier, but I will take a stab at this.

I am thinking if we add the following logic statement to the first comment$ line:


if gcode$ = 1005, comment$ 

Then when manual entry with no code it will only be output where you want it at the tool change. Again I have no sample file and not making one to test this so I can be completely off my rocker, but how you learn is the willingness to try and fail and keep trying until you figure it out.

Then we have the other comment$ where it was, but add conditional logic to it also:


if gcode$ = 1008, comment$ #RDB only output Operational comment

Now the downside to this is I have limited the output to only these two conditions in the toolchange section. That may or may not be a problem. Again without a sample file to test go through 50 different scenarios to test then up to you to take this expand on it and see what you can work out to give you what you are after. Now another thing to consider is does the post have different logic for the start of a file and tool change? If it does then you have to think about how you want to handle situations for the first operation in a file.

Use at your own risk!!!!!!!!!!!!!

"if gcode$ = 1005, scomm$"  < That says "if the comment line we are processing in the comment buffer is flagged as "1005", then output the value of 'scomm$'.

We only put 'comment$' as a command variable (no formula), during a normal Post Block call, like 'ptlchg$', or 'ptlchg0$', but would not have good results replacing 'scomm$' with 'comment$'.

This may fail with a Post Error, or it may just cause a recursive loop, which would break the Post. I'm not sure which, but 'pcomment2' is already being called by 'pcomment$', which in turn is triggered by the 'comment$' command variable.

We would normally add logic to 'if gcode$ = 1008' and add a user-defined Post Block here, so we can nest an additional "boolean if/else".

  • if we are "inside Tool Change", then save the comment to 'sav_opcomm' (I made up that var name)
  • else, we are "processing a comment outside the 'Tool Change' events, so just process them like normal". (in otherwords, output 'scomm$')

First, create 4 variables:

op_com_delay : yes$  #Variable to delay Operation Comment output
sav_op_comm  : ""    #String Var to capture operation comment string
op_comm_flag : 0     #Flag to record if a comment is saved
snull : ""           #Blank string variable

At the top of the 'ptlchg$' block, something like this would work:

ptlchg$          #Tool change
      op_com_delay = yes$
      comment$
      op_com_delay = no$

Then, we modify 'pcomment$', to output or capture the string:

pcomment$       #Output Comments
      scomm$ = ucase (scomm$)
      if gcode$ = 1005, sopen_prn, scomm$, sclose_prn, e$  #Manual entry - as comment
      if gcode$ = 1006, scomm$, e$                         #Manual entry - as code
      if gcode$ = 1007, sopen_prn, scomm$, sclose_prn      #Manual entry - as comment with move NO e$
      if gcode$ = 1026, scomm$                             #Manual entry - as code with move NO e$
      if gcode$ = 1008,
        [
        if op_com_delay = yes$,
          [
          sav_op_comm = scomm$ #Save comment, don't output
          op_comm_flag = yes$  #Set flag, for delayed comment output
          ]
        else, sopen_prn, scomm$, sclose_prn, e$  #Operation comment
        ]
      if gcode$ = 1051, sopen_prn, scomm$, sclose_prn, e$  #Machine name
      if gcode$ = 1052, sopen_prn, scomm$, sclose_prn, e$  #Group comment
      if gcode$ = 1053, sopen_prn, scomm$, sclose_prn, e$  #Group name
      if gcode$ = 1054, sopen_prn, scomm$, sclose_prn, e$  #File Descriptor

Finally, we modify 'ptlchg$' to output the saved comment, wherever you want it:

      pcheckaxis
      c_mmlt$ #Multiple tool subprogram call
      #ptoolcomment
      #comment$
      pcan
      result = newfs(15, feed)  #Reset the output format for 'feed'
      pbld, n$, *t$, sm06, e$
      ptoolcomment
      if op_comm_flag = yes$,
        [
        pbld, n$, sopen_prn, sav_op_comm, sclose_prn, e$
        sav_op_comm = snull
        op_comm_flag = no$
        ]
      pindex
      sav_absinc = absinc$
      if mi1$ > one, absinc$ = zero

 

Link to comment
Share on other sites

Colin you are correct I should have been more clear I was talking about adding that logic in the ptlchng section like so not in the pcomment$ section and agree doing there would be a disaster. Using a generic Mastercam 3 Axis post I was meaning like this to try.

ptlchg$          #Tool change
      if gcode$ = 1005, comment$ #RDB only output Manual Entry as Comment
      pxformtype  #Set flag to indicate if G51/G68 is active based on transform type
      toolchng = one
      if mi1$ = one, #Work coordinate system
        [
        pfbld, n$, *sg28ref, "X0.", "Y0.", e$
        pfbld, n$, sg92, *xh$, *yh$, *zh$, e$
        ]
      inhibit_probe$
      if prog_stop = 1, pbld, n$, *sm01, e$
      if prog_stop = 2, pbld, n$, *sm00, e$
      pcom_moveb
      pcheckaxis
      c_mmlt$ #Multiple tool subprogram call
      ptoolcomment
      if gcode$ = 1008, comment$ #RDB only output Operational comment
      pcan
      result = newfs(15, feed)  #Reset the output format for 'feed'
      pbld, n$, *t$, sm06, e$
      sav_absinc = absinc$
      if mi1$ > one, absinc$ = zero
      pcan1, pbld, n$, *sgcode, *sgabsinc, pwcs, pfxout, pfyout,
        [if nextdc$ <> 7, *speed, *spindle], pgear, strcantext, e$
      pbld, n$, sg43, *tlngno$, pfzout, pscool, pstagetool, e$
      absinc$ = sav_absinc
      pbld, n$, sgabsinc, e$
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call

Again where having a sample file to point to without having to try to piece meal stuff makes it easier to help point someone in the right direction, but as always you have come through with the best way to go about it. Thank you for taking the time to educate me along with him on the process to go about it. :respect:

No buffers either so my computer is safe and it thanks you for not being thrown out the window to survive to another day. :rofl::rofl::rofl:

 

  • Like 3
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...