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:

Manipulating post with operation comments


Recommended Posts

Hi All,

 

I was hoping some of the experienced post writers could steer me in the right direction.  

 

I have a twin turret / twin spindle lathe with a decent post. It will output waitcodes at every operation change.  I am interested in in modifying it so that it is a little easier to sync up operations.

 

I know that it is common to use the misc variables or canned text to manipulate wait codes. I have done a few tweaks and gotten this to work - but one of the things I don't like about this method is it is hidden from the user when they look at the operation manager.  I was thinking if I put a standard string in the operation comments, I could use that to tell the post when I want the two channels to run together and it would be a little easier to see, rather then digging though each operations miscellaneous values. I've attached a picture of what I was thinking.  post-47490-0-42982200-1426783559_thumb.jpg

 

I've seen in some previous postings that there are some string functions within MP - are they robust enough to do something like this?  Can you use regular expressions within MP?

 

I know there could be potential problems if the user doesn't match the string perfectly, but I think it would be easier to visualize when looking at the operations as a whole, and hopefully might make it a little easier to use.

 

Feel free to share your opinions regarding the feasibility and/or the use from a programmer's perspective.

 

Thanks in advance for your thoughts,

 

Dan 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Hi Dan,

 

You can't use regular expressions within MP, but you can use the string functions to search the string for a 'sub string', and break the string up using the index variables (that show you the start/end positions of where you found the string. The command is 'strstr' and it uses two parameters. The string being searched, and the string we want to find within that string.

 

In addition, the 'scan' function can look for a sub string within a string, and if found, it will capture the "number" immediately following the sub string, and it will convert that string value into a numeric value.

 

So for example with scan, here would be some test code:

real_result = scan(str_my_string, "sync_grp")

That code above (assuming you has set 'str_my_string' to equal the 'comment$' string), would search through the comment string. If it found 'sync_grp' present in the string, it would look for "numeric string values" that follow the sub string, and it would convert those string characters into an actual real variable number.

 

So after running it against the comment, 'real_result' might hold '3.0' or '4.0', depending on what numeric value actually follows the 'sync_grp' string.

Link to comment
Share on other sites

Thanks Colin!  

 

I just looking through the string functions when I saw your reply.   I was assuming it was going to take a lot more manipulation to get what i needed.  

 The parameters needed to be switched in the scan function and it worked perfectly.  The function works fine if I declare my variable with the string in it.

 

The problem is I thought I could simply search the comment$ string or set it equal to my variable:

real_result = scan("sync_grp",comment$)

or 

smy_string = comments$
real_result = scan("sync_grp",smy_string)

Neither one of these work and I'm getting a "The math calculation/formula has an error"

 

I guess  I'm missing something on what the comment$ variable is and what i can do with it.  Apparently it isn't a simple string :(

I have to quit - but thanks for putting me in the right direction.

 

I did see you mentioned the string functions in a previous post.  Thanks for answering the same question twice.

 

Dan

Link to comment
Share on other sites

Hi Dan,

 

No, unfortunately you can't just use 'comment$', because it is a Command Variable, and does not actually contain a string.

 

When MP runs, there are many different comment strings that are output to the NCI file, each with their own unique Gcode value that tells MP what type of data the string represents.

 

These strings are captured by MP and stored in an internal buffer file. The post writer can then control the output of the comments by placing the command variable 'comment$' on a line of code all by itself. This triggers MP to start processing all of the comments strings that are stored inside the internal buffer. For every comment stored in the buffer, a call is made to the 'pcomment$' post block.

pcomment$       #Comment from manual entry (must call pcomment2)
      pcomment2 #Required if doing boolean 'if' logic testing!

pcomment2       #Output Comment from manual entry
      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

You can see in the code above that 'pcomment$' calls 'pcomment2', and that post block has the logic to process and output comments, based on the Gcode value of the comment type.

 

You will need to modify the 'if gcode$ = 1008' comment line. That is where you will need add logic to parse the string variable 'scomm$', and run the 'scan' function on it.

pcomment$       #Comment from manual entry (must call pcomment2)
      pcomment2 #Required if doing boolean 'if' logic testing!

ssync : "SYNC_GRP"


pcomment2       #Output Comment from manual entry
      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,
        [
        real_result = scan(ssync, scomm$)
        if real_result <> -9999,
          [
          #You should put your code here to "do" something with the scan results.
          #You captured the number after 'sync_grp', so now what?
          sopen_prn, "SCAN WAS SUCCESSFUL", sclose_prn, e$
          ]
        else, sopen_prn, scomm$, sclose_prn, e$
        ]
      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

That should point you in the right direction.

 

Note that your search string should be in ALL CAPS, since the 'ucase' function at the top of the 'pcomment2' post block converts all alpha characters to upper case, before the logic tests the value of the Gcode...

 

 

Hope it helps,

 

Colin

Link to comment
Share on other sites

Hi Colin,

 

Sorry I didn't have a chance to respond earlier but I had found the scomm$ string when searching through the nci.  I was lucky since the post already had a string to capture it and using the scan function gave me just what I was looking for - I thought.....

 

It seems the call to the wait code function is happening before the next operation.  I see the correct string with the first operation, bet I'm guessing this is being set on a prescan.  After that the output is always from the preceding operation.  It appears the call to the wait code post block is at the tail end of the operation so i can't get what is coming next.

 

I'm guessing the comment buffer is reloaded for every operation?  So to make this work I would have to create a seperate buffer file and capture everything during the pre-read, or move my calls to the wait code function to within the next operation?

 

It seemed like it was going to be an easy tweak.....

 

Thank you for your guidance,

 

Dan

 

 

 

Link to comment
Share on other sites

 

Hi All,
 
I was hoping some of the experienced post writers could steer me in the right direction.  
 
I have a twin turret / twin spindle lathe with a decent post. It will output waitcodes at every operation change.  I am interested in in modifying it so that it is a little easier to sync up operations.
 
I know that it is common to use the misc variables or canned text to manipulate wait codes. I have done a few tweaks and gotten this to work - but one of the things I don't like about this method is it is hidden from the user when they look at the operation manager.  I was thinking if I put a standard string in the operation comments, I could use that to tell the post when I want the two channels to run together and it would be a little easier to see, rather then digging though each operations miscellaneous values. I've attached a picture of what I was thinking.  attachicon.gifwait codes.JPG
 
I've seen in some previous postings that there are some string functions within MP - are they robust enough to do something like this?  Can you use regular expressions within MP?
 
I know there could be potential problems if the user doesn't match the string perfectly, but I think it would be easier to visualize when looking at the operations as a whole, and hopefully might make it a little easier to use.
 
Feel free to share your opinions regarding the feasibility and/or the use from a programmer's perspective.
 
Thanks in advance for your thoughts,
 
Dan 

 

 

Dan what I have done is make my operations based on groups. LUT (Left Upper Turret) and RUT (Right Upper Turret) and then I have gone a step further and put M101 in the operations linked to M101 Wait Codes and the then use that down through the operations. Using the misc values does not show up on the operations pages and you have a good thought, but short of a very complex search function not really sure how well what you have put together will work. The MT product has abandoned using any mechanism inside of the main Mastercam Product and requires the programmer to port over to code expert to do the sync commands. It is a very nice an visual process inside of code expert, but again not part of the main product. That tells me if that was the course of action the people making it have taken then the process you are trying to accomplish is not going to be easy. You can do a search on sync codes and see I have a lot of topics about it over the years. I have worked a lot with Postability and he has come the closest to any company to give error free code for these machines as anyone. The MT product is a great product and once the machine environment is dialed in you are golden, but for all the other machines not in MT what you are trying to accomplish will be the course to get it done.

Link to comment
Share on other sites

Hi Dan,

 

No, unfortunately you can't just use 'comment$', because it is a Command Variable, and does not actually contain a string.

 

When MP runs, there are many different comment strings that are output to the NCI file, each with their own unique Gcode value that tells MP what type of data the string represents.

 

These strings are captured by MP and stored in an internal buffer file. The post writer can then control the output of the comments by placing the command variable 'comment$' on a line of code all by itself. This triggers MP to start processing all of the comments strings that are stored inside the internal buffer. For every comment stored in the buffer, a call is made to the 'pcomment$' post block.

pcomment$       #Comment from manual entry (must call pcomment2)
      pcomment2 #Required if doing boolean 'if' logic testing!

pcomment2       #Output Comment from manual entry
      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

You can see in the code above that 'pcomment$' calls 'pcomment2', and that post block has the logic to process and output comments, based on the Gcode value of the comment type.

 

You will need to modify the 'if gcode$ = 1008' comment line. That is where you will need add logic to parse the string variable 'scomm$', and run the 'scan' function on it.

pcomment$       #Comment from manual entry (must call pcomment2)
      pcomment2 #Required if doing boolean 'if' logic testing!

ssync : "SYNC_GRP"


pcomment2       #Output Comment from manual entry
      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,
        [
        real_result = scan(ssync, scomm$)
        if real_result <> -9999,
          [
          #You should put your code here to "do" something with the scan results.
          #You captured the number after 'sync_grp', so now what?
          sopen_prn, "SCAN WAS SUCCESSFUL", sclose_prn, e$
          ]
        else, sopen_prn, scomm$, sclose_prn, e$
        ]
      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

That should point you in the right direction.

 

Note that your search string should be in ALL CAPS, since the 'ucase' function at the top of the 'pcomment2' post block converts all alpha characters to upper case, before the logic tests the value of the Gcode...

 

 

Hope it helps,

 

Colin

 

Colin good insight and thanks for sharing that.

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