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:

Logic checking "Next op" and "previous op"


Recommended Posts

Hi all,

I'm using the "Generic fanuc 5-axis" post as my base post for modification.

How do I check the values of future and past operations to use in my logic statements?

 

For example, Let's say I use "air blast" sometimes on one particular tool(maybe I blow out some pockets mid cycle). I would like to write a post logic that checks the "next op" for "air blast", and if it's used, turn off the coolant first.

 

What's the syntax?

 

 

Thanks,

Jay

Link to comment
Share on other sites
  • 2 weeks later...

It would probably be simpler to attach this to your scoolant string, just use it in place of your m7 assuming you are not already using it. Having it come on in mid cycle under specific conditions would be a real pain but this would do what you needed. I don't know there was a Generic 5 axis post.

Link to comment
Share on other sites

Hi Jay,

 

This isn't nearly as easy as you hope it will be. The MP Language is a scripting language. That means that when the post "runs", it processes the NCI file two lines at a time, and based on the calling line of the NCI, a certain entry post block is called, based on the NCI g-code value. Once all the logic (and jumps) have been made from the specific entry point into the script, MP simply moves on to the next two-line set of G-code.

 

Because of the fundamental way that MP processes NCI data, there is no ability to search forward or backwards in the NCI data. So there is no way to "look forward" or "look backwards" to "see what was, or will be, turned on/off".

 

To get around this limitation, the "Get Next" routine was built into the MP Language. The method that was chosen to overcome this limitation is to create two distinct processing loops. The "pre-read" routine in the MP language is used to scan through the NCI file, and gather data at the Tool Change events. The NCI file is read, but the Motion Data is skipped. The post only looks for Tool Changes. If the "write tool table" variables are turned on, then MP will build a "Tool List" and keep it in an internal string buffer.

 

During this "pre-read" routine, if the "Get Next" switch is turned on, then MP will build a list of "Next g-code" values. Variables like "nextdc$", and "next_tool$" get their values. (This "next" list is indexed "one tool change ahead").

 

Most of the time, when I am using multiple coolant options, I will setup a "flag" variable that I can use to keep track of the "coolant states". This is a separate "user defined" variable that you have to manipulate by writing custom logic.

 

Now, for Coolant specifically, I would just leverage the "X-Style" coolant options, and use these inside the Post. By using "X-Style" coolant, the coolant options (what is on, and what is off) is "auto-magically" tracked for you. The post tracks this using a "lookup" table. The "lookup table" is setup with a series of "binary" values based on which coolant options are on/off. The logic behind how this happens is straight-forward for a "computer programmer" to understand, but it can seem very complex to the average person learning how to make post edits.

 

Instead of worrying about doing any post edits to the logic. You can just setup the X-Style Coolant strings to give you the particular on/off strings you want for each Coolant option. The existing logic takes care of outputting the "on" codes, and cancelling the coolant with the appropriate "off" codes.

 

So, how do you turn on "Air Blast" in the middle of a program to clear chips? You would do this using the "Canned Text" options. This is an advantage, because you can use "Change at Point" in the Chain Manager to choose where the option is enabled. If you want to turn it off in a particular spot, you would use the same technique, just used "Canned Text" and set the option to "off".

 

Canned Text is really the way to get what you are after, and the functionality is already built directly into the post processor.

 

If you want to output Canned Text in the middle of a "path" (for example, when surface machining), then you can use the Toolpath Editor to insert the Canned Text option where you want it. (It does "lock" the operation, and the change is not associative, meaning if you have to regenerate the toolpath, you will have to make the Toolpath edit again.)

 

I could copy and paste all of the logic from the post into this response, but there would be a ton of code to wade through, and probably wouldn't teach you much.

 

What I would recommend instead is to search for every instance of the following variables:

 

coolant_bin

coolant_on

coolantx

local_int

 

The two post blocks that are used for on/off coolant code output are:

 

pcant_out

pretract

 

 

Actually, why not. Here are the post blocks in question:

pretract        #End of tool path, toolchange              
      pretract_mov
      sav_absinc = absinc$
      coolant$ = zero
      cc_pos$ = zero
      gcode$ = zero
      spdir2 = one
      

     ###### HERE IS THE COOLANT "OFF" CHECK  ######

#      if nextop$ = 1003, #Uncomment this line to leave coolant on until eof unless
        [                 #  explicitely turned off through a canned text edit
        if all_cool_off,
          [
          #all coolant off with a single off code here
          if coolant_on, pbld, n$, sall_cool_off, e$
          coolant_on = zero
          ]
        else,
          [
          local_int = zero
          coolantx = zero
          while local_int < 20 & coolant_on > 0,
            [
            coolantx = and(2^local_int, coolant_on)
            local_int = local_int + one
            if coolantx > zero,
              [
              coolantx = local_int
              pbld, n$, scoolantx, e$
              ]
            coolantx = zero
            ]
          coolant_on = zero
          ]
        ]

      ##### Custom changes allowed below #####

      pbld, n$, scoolant, e$
      pbld, n$, sccomp, spindle, e$
      pg69
      absinc$ = one
      prefreturn #xout, p_out not output here
      absinc$ = sav_absinc
      protretinc                          #01/26/04
      #pbld, n, *sg28, protretinc, e      #01/26/04      

And here is the 'pcant_out' section for turning the codes "on":

pcant_out       #Canned text - build the string for output
      #Assign string select type outputs
      if cant_pos < three, #cant_pos indicates canned text output
        [
        if cantext$ = three, bld = one
        if cantext$ = four, bld = zero
        #Build the cantext string
        if cantext$ = one, strcantext = strcantext + sm00
        if cantext$ = two, strcantext = strcantext + sm01
        if cantext$ > four,
          [
          strtextno = no2str(cantext$)
          strcantext = strcantext + strm + strtextno
          ]
        ]
      else, #cant_pos indicates coolant output
        [
        coolant_bin = flook (two, cantext$) #Create binary value for each coolant using lookup table
        if frac(cantext$/two),  # coolant off
          [
          if all_cool_off,
            [
            if coolant_on, pbld, n$, sall_cool_off, e$
            coolant_on = zero
            ]
          else,
            [
            if coolant_on > 0,
              [
              coolant_on = coolant_on - coolant_bin/2 #Odd = off command, subtract appropriate binary value.
              coolantx = cantext$ - 50                #Create a coolantx value for string select
              pbld, n$, *scoolantx, e$
              ]
            ]
          ]
        else,                                         #Even = on command
          [   #Determine if this coolant is already on
          local_int = zero
          coolantx = zero
          suppress = zero
          while local_int < 20 & coolant_on > 0,
            [
            result2 = and(2^local_int, coolant_on)
            local_int = local_int + one
            if result2 = coolant_bin, suppress = one
            ]
          if suppress <> 1, #Don't output an on code for a coolant that is already on
            [
            coolant_on = coolant_on + coolant_bin #Maintain binary sum of all coolants currently on
            coolantx = cantext$ - 50              #Create a coolantx value for string select
            if cant_pos = 4, *scoolantx           #Coolant "With"
            else, pbld, n$, *scoolantx, e$        #Coolant "Before" or "After"
            ]
          ]
        ]

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