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:

How to force WCS output?


Recommended Posts

Having a heck of a time keeping up with chip build-up on a ti job I'm running so I decided to give the "Tool inspection/change" thing a whirl. Well the code in the post was a joke, all it did was output M00's in the middle of the program with nothing else. After some fiddling I have it pretty well set up the way I'd like it - basically it looks like a fairly standard toolchange - except the post will not output the WCS. I'm assuming it won't because it knows it's the same WCS and thinks there's no need to repeat it, which makes perfect sense. However, I would really like it there so if the program is reset for any reason, we can restart here without the machine defaulting back to G54 and crashing into another op. 

 

prapidout       #Output to NC of linear movement - rapid               
      pcan1, pbld, n$, sgplane, `sgcode, sgabsinc, pccdia,
        pxout, pyout, pzout, strcantext, scoolant, e$
      #Modify following line to customize output for high-speed toolpath
      #tool inspection/change points
      if rpd_typ$ = 7, pbld, n$, sm09, e$,
      "G53 G90 G00 Z0.0", e$,
      sm05, e$, 
      ";", e$,
      ";", e$,
      "M00", "(CLEAR CHIPS)", e$, 
      ";", e$,
      ";", e$,
      *t$, sm06, e$,
      *speed, sm03, e$,
      *sgcode, *sgabsinc, pwcs, pfxout, pfyout, e$,
      sg43, *tlngno$, pfzout, e$,
      sm08, e$

 

Link to comment
Share on other sites

There are logic statements inside the 'pwcs' Post Block, which restricts output to certain conditions. You either need to modify the pwcs Post Block to force output, or you need to trick 'pwcs' into thinking that the conditions for output are being met.

I'll show you how I would set this up. I would add a condition to 'pwcs' to allow output when called from 'prapidout'.

Look for a condition like this:

      if workofs$ <> prv_workofs$ | (force_wcs & toolchng > zero),

Add the condition as an Or statement to allow output during tool inspection restart.

   if workofs$ <> prv_workofs$ | (force_wcs & toolchng > zero) | rpd_typ$ = 7,

Also, you should add an 'open square bracket' ([) after the 'if rpd_typ$ = 7', inside 'prapidout', and add a close square bracket (]) at the end of your multiple lines of output. This makes it a user-defined post block.

 

      if rpd_typ$ = 7,
      [
      pbld, n$, sm09, e$
      "G53 G90 G00 Z0.0", e$
      sm05, e$
      *e$
      *e$
      "M00", "(CLEAR CHIPS)", e$
      *e$
      *e$
      *t$, sm06, e$
      *speed, sm03, e$
      *sgcode, *sgabsinc, pwcs, pfxout, pfyout, e$
      sg43, *tlngno$, pfzout, e$
      sm08, e$
      ]

 

  • Thanks 1
  • Like 1
Link to comment
Share on other sites

An alternative you can use to get WCS output, without modifying 'pwcs':

      if rpd_typ$ = 7,
      [
      pbld, n$, sm09, e$
      "G53 G90 G00 Z0.0", e$
      sm05, e$
      *e$
      *e$
      "M00", "(CLEAR CHIPS)", e$
      *e$
      *e$
      *t$, sm06, e$
      *speed, sm03, e$
      prv_workofs$ = 9999
      *sgcode, *sgabsinc, pwcs, pfxout, pfyout, e$
      sg43, *tlngno$, pfzout, e$
      sm08, e$
      ]

By setting the previous Work Offset Variable Value to a 'non-used' value, we trigger the 'workofs$ <> prv_workofs$' boolean statement. 

  • Thanks 1
  • Like 1
Link to comment
Share on other sites
9 hours ago, Colin Gilchrist said:

There are logic statements inside the 'pwcs' Post Block, which restricts output to certain conditions. You either need to modify the pwcs Post Block to force output, or you need to trick 'pwcs' into thinking that the conditions for output are being met.

I'll show you how I would set this up. I would add a condition to 'pwcs' to allow output when called from 'prapidout'.

Look for a condition like this:


      if workofs$ <> prv_workofs$ | (force_wcs & toolchng > zero),

Add the condition as an Or statement to allow output during tool inspection restart.


   if workofs$ <> prv_workofs$ | (force_wcs & toolchng > zero) | rpd_typ$ = 7,

Also, you should add an 'open square bracket' ([) after the 'if rpd_typ$ = 7', inside 'prapidout', and add a close square bracket (]) at the end of your multiple lines of output. This makes it a user-defined post block.

 


      if rpd_typ$ = 7,
      [
      pbld, n$, sm09, e$
      "G53 G90 G00 Z0.0", e$
      sm05, e$
      *e$
      *e$
      "M00", "(CLEAR CHIPS)", e$
      *e$
      *e$
      *t$, sm06, e$
      *speed, sm03, e$
      *sgcode, *sgabsinc, pwcs, pfxout, pfyout, e$
      sg43, *tlngno$, pfzout, e$
      sm08, e$
      ]

 

 

Hi Colin,
   What if I always want it to show PWCS although the previous work offset is the same as the current?  How can I make it always show work offset with the same work offset number for the next following toolpath?



Thank you.

Link to comment
Share on other sites

Thank you, I added it to the condition, it seems cleaner that way. As for the brackets - what purpose do they serve? What does it change about the code? Also, I noticed you removed the commas at the end of each line - without those, this batch of code gets added every single place in the program where there's a rapid in Z - is that what the brackets eliminate? I found the only place I MUST NOT use a comma is after the very last line or else it repeats everything twice.

Link to comment
Share on other sites

My boss wanted me to state the wcs on every line that that starts a new cut for a 'safe' line to restart at. Essentially every 'null toolchange' needed a wcs, g90, and spindle commands. The only way I could get the code to output this way was to get rid of the pwcs command inside of all feed and rapid blocks. This is probably very wrong, but it works. Since the wcs is stated at every toolchange and null toolchange it doesn't need to be anywhere else for me.

Link to comment
Share on other sites
13 minutes ago, Cavi Mike said:

Thank you, I added it to the condition, it seems cleaner that way. As for the brackets - what purpose do they serve? What does it change about the code? Also, I noticed you removed the commas at the end of each line - without those, this batch of code gets added every single place in the program where there's a rapid in Z - is that what the brackets eliminate? I found the only place I MUST NOT use a comma is after the very last line or else it repeats everything twice.

The brackets keep all the individual lines "grouped together", to be executed only if the results of the 'if rpd_typ$ = 7', is true.

The brackets form what is known as an "User Defined Post Block", and makes sure the output of all those individual lines is tied to that single 'boolean test'.

It is simply the "proper way" to format a multi-line output statement. Yes, including a comma after the End of Line (e$) command works, but it makes the output more complicated than necessary.

The way the MP Language is built, MP will search for Boolean Statements as the start of a Post Line.

If the line starts with 'if', 'else', or 'while', then MP will execute all of the statements that follow the 'true condition', on the same output line. By default, MP will will consider any lines that have been ended with 'e$' as the "end of that 'Boolean statement'". By wrapping multiple lines of output, with Square Brackets ([ ]), we are saying - treat all the lines in-between the bracketsas being "tied" to the Boolean statement results.

Consider the following:

pset_mach       #Set post switches by reading machine def parameters
      rot_ax_cnt = 0
      rotaxerror = 0
      rot_on_x = 0  #Turn off rotary axis unless it is detected in machine read - supresses rotary output in 3 axis machines

      rd_cd$       #Read control definition parameters - calls pmachineinfo$
      #Output error message if Write NC operation information is not enabled in CD
      #if write_ops = 0, result = mprint(swriteopserror,2), exitpost$

      if sof = 1,
        [
        maxfeedpm = 999999       #Uncomment these variables to force use of machine def values as initial lowest max feedrate value
        maxfeedpm_m = 9999999    #Otherwise the default (post) initialization setting is used as initial value
        #minfeedpm = 999999
        #minfeedpm_m = 999999
        !maxfeedpm, !maxfeedpm_m  #, !minfeedpm, !minfeedpm_m
        rd_mch_ent_no$ = 0
        rd_md$       #Read machine definition parameters - calls pmachineinfo$
        ]

      rd_mch_ent_no$ = syncaxis$  #Retrieve machine parameters based on current axis combination - read from .nci G950 line
      rd_md$       #Read machine definition parameters - calls pmachineinfo$
      rd_tlpathgrp$  # Read toolpath group parameters - calls pmachineinfo$

      rd_prm_op_no$ = op_id$
      rd_params$       #Read operaitons parameters

      #We only need these set at toolchange (and start of file).  No need to set them each time a user may call rd_md
      if sav_rot_on_x = zero, rot_on_x = zero
      else, rot_on_x = rot_axis
      rot_cw_pos = rot_dir
      index = rot_index
      if rot_angle = zero, ctable = one #ctable zero will produce a divide by zero error, so force to one if zero in MD
      else, ctable = rot_angle

      if met_tool$ = 1,
        [
        maxfrinv = maxfrinv_m           #Set limit for feed inverse time
        minfrinv = minfrinv_m
        maxfeedpm = maxfeedpm_m         #Set limit for feed in mm/min
        minfeedpm = minfeedpm_m
        ]

      if use_md_rot_label, sav_srot_label = srot_label   #Backup the original rotary axis label

# --------------------------------------------------------------------------
# Machine definition and control definition parameter capture:
# --------------------------------------------------------------------------
pmachineinfo$   #Machine information parameters postblock

Note that this 'pset_mach' Post Block is present in many of the Generic Fanuc Posts and the MPMaster Post from In-House Solutions.

The block itself is called from only 2 places, when the Post is executing:

  • 'pset_mach' is called from 'ptlchg_1002$', but only when the value of 'op_id$' has changed. This means we only call 'pset_mach' from 'ptlchg_1002', when we are processing a "new operation" in the NCI file. Any individual Operation in Mastercam can output multiple "null-tool change events", based on if the Operation includes Depth Cuts or Multi-passes.
  • 'pset_mach' is also called from 'psynclath$'. This Post Block is called for every 'NCI 950 Line', which is the Axis Combination NCI G-code. So, whenever the NCI file includes a NCI 950 line, the Post will call 'psynclath$', which in-turn calls 'pset_mach'.

Now, look a little deeper at the Post Lines that make up 'pset_mach'.

  • The first 3 lines of 'pset_mach' are just setting Variable Values. (Variable Assignment = )
  • The 4th actual line of Post Code is 'rd_cd$'.
  • This single 'Command Variable' causes a bunch of actions to take place. This command "cycles through" all of the Control Definition Parameters, by making a repeated "loop call" to 'pmachineinfo$'. Basically, 'rd_cd$' makes MP cycle through all of the ''18,000-18,999" parameters. The Post will call 'pmachineinfo$' for every Parameter Number in-between 18,000 and 18,999, and if there is logic inside 'pmachineinfo$' to read an individual Parameter Number, then that code will be executed. Otherwise, we simply cycle through every parameter, and don't do anything if there is no code to capture a parameter value.
  • Now, continue to the Logic Condition 'if sof = 1'. This condition checks the value of the 'sof' variable, and if it is '1', then the Post will execute all of the logic in-between the Square Brackets. If 'sof' is any value, except 1, then the Post will skip past that entire 'bracketed' section of code.

Consider these 4 lines of code, inside the Post Block Body:

      if sav_rot_on_x = zero, rot_on_x = zero
      else, rot_on_x = rot_axis
      rot_cw_pos = rot_dir
      index = rot_index

Notice that we have an "if/else" statement.

The "If" condition (when true) follows the "comma" on that line. (rot_on_x = zero)

The "else" condition immediately follows the "if". You do not have to include an "else" statement, but if you do, it will always execute when the 'if' condition is false.

Note: The "results" of a "True Test", mean that we will execute anything to the right of the statement. The "condition" is not multi-line, unless you use the Square Brackets!

  • Like 1
Link to comment
Share on other sites
5 hours ago, PcRobotic said:

 

Hi Colin,
   What if I always want it to show PWCS although the previous work offset is the same as the current?  How can I make it always show work offset with the same work offset number for the next following toolpath?



Thank you.

There are many ways to accomplish this. I will show you the way that works with "the generic posts". I'm not sure if it will work with your customized post, because you have modified it so much.

In the generic posts, I would recommend something like this:

Create a new variable:

force_pwcs  : 1 #Force WCS output

Modify 'pwcs':

pwcs            #G54+ coordinate setting at toolchange
      if wcstype = two | wcstype > three,
        [
        sav_frc_wcs = force_wcs
        if sub_level$ > zero, force_wcs = zero
        if sav_mi9 = 1, workofs$ = sav_workofs
        if workofs$ < 0, workofs$ = 0
        if workofs$ <> prv_workofs$ | (force_wcs & toolchng) | sof | force_pwcs,
          [
          if workofs$ < 6,
            [
            g_wcs = workofs$ + 54
            *g_wcs
            ]
          else,
            [
            if haas,
              [
              p_wcs = workofs$ - five        #G154 P1 to P99
              "G154", *p_wcs
              #g_wcs = workofs$ + 104        #G110 to G129
              #*g_wcs
              ]
            else,
              [
              p_wcs = workofs$ - five
              "G54.1", *p_wcs
              ]
            ]
          ]
        force_wcs = sav_frc_wcs
        !workofs$
        ]

 

Now, when you call 'pwcs' you need to manipulate the value of 'force_pwcs' so you can make sure you aren't getting output, where you don't want it.

Example:


ptlchg_com      #Tool change common blocks
      if force_output | sof,
        [
        result = force(ipr_type,ipr_type)
        result = force(absinc$,absinc$)
        result = force(plane$,plane$)
        ]
      pcom_moveb
      pcheckaxis      #Check for valid rotary axis
      if sof, uninhibit_probe$
      c_mmlt$ #Multiple tool subprogram call
      #ptoolcomment
      if sof & scomm_sav <> snull,
        [
        spaces$ = 0
        n$, pspc, scomm_str, *scomm_sav, scomm_end, e$
        spaces$ = sav_spc
        ]
      if sof = 0, scomm_sav = snull
      comment$
      pcomment3
      pmisccheck
      pcan
      if stagetool >= zero,
        [
        if omitseq$ = 1 & tseqno > 0,
          [
          if tseqno = 2, n$ = t$
          pbld, *n$, *t$, "M06", ptoolcomm, e$
          ]
        else, pbld, n$, *t$, "M06", ptoolcomm, e$
        ]
      spaces$=0
      if output_z = yes$,
        [
        preadbuf5
        if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,
          [
          n$, pspc, scomm_str, "MAX - ", *max_depth, scomm_end, e$
          n$, pspc, scomm_str, "MIN - ", *min_depth, scomm_end, e$
          ]
        ]
      spaces$=sav_spc
      pstock_surf
      if plane$ < 0 | opcode$ = 3 | opcode$ = 16, plane$ = 0
      sav_absinc = absinc$
      if wcstype > one, absinc$ = zero
      pindex
      if safe_index,
        [
        if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
        pbld, n$, pgear, e$
        pcan1, pbld, n$, *sgcode, sgplane, [if not(index), sgabsinc, pwcs], pfcout, strcantext, e$
        if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
        if convert_rpd$ = one,
          [
          gcode$ = one
          feed = maxfeedpm
          ipr_type = zero
          ]
        pbld, n$, sgcode, [if gcode$ = 1, sgfeed], pfxout, pfyout, pfspindleout, [if gcode$ = 1, *feed], e$
        ]
      else,
        [
        if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
        pbld, n$, pgear, e$
        if convert_rpd$ = one,
          [
          gcode$ = one
          feed = maxfeedpm
          ipr_type = zero
          ]
        pcan1, pbld, n$, *sgcode, sgplane, [if not(index), sgabsinc, pwcs], [if gcode$ = 1, sgfeed], pfcout, pfxout, pfyout,
          pfspindleout, [if gcode$ = 1, *feed], strcantext, e$
        if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
        ]
      phsm1_on        #must remain before G43
      pbld, n$, "G43", *tlngno$, pfzout, scoolant, next_tool$, e$
      pcan2           #Added so M and G codes in canned text will output before phsm2_on
      phsm2_on        #must remain after G43

      #PWCS has already been output, so we need to manipulate the 'force_pwcs' variable:
      force_pwcs = one
      pbld, "(WORK OFFSET:", pwcs, no_spc$, ")", e$
      force_pwcs = zero #Disable, so we suppress redundant output
      sav_coolant = coolant$
      if coolant$ = 1, sm09 = sm09_0
      if coolant$ = 2, sm09 = sm09_1
      if coolant$ = 3, sm09 = sm09_2
      absinc$ = sav_absinc
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call
      plast

 

 

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

There are many ways to accomplish this. I will show you the way that works with "the generic posts". I'm not sure if it will work with your customized post, because you have modified it so much.

In the generic posts, I would recommend something like this:

Create a new variable:


force_pwcs  : 1 #Force WCS output

Modify 'pwcs':


pwcs            #G54+ coordinate setting at toolchange
      if wcstype = two | wcstype > three,
        [
        sav_frc_wcs = force_wcs
        if sub_level$ > zero, force_wcs = zero
        if sav_mi9 = 1, workofs$ = sav_workofs
        if workofs$ < 0, workofs$ = 0
        if workofs$ <> prv_workofs$ | (force_wcs & toolchng) | sof | force_pwcs,
          [
          if workofs$ < 6,
            [
            g_wcs = workofs$ + 54
            *g_wcs
            ]
          else,
            [
            if haas,
              [
              p_wcs = workofs$ - five        #G154 P1 to P99
              "G154", *p_wcs
              #g_wcs = workofs$ + 104        #G110 to G129
              #*g_wcs
              ]
            else,
              [
              p_wcs = workofs$ - five
              "G54.1", *p_wcs
              ]
            ]
          ]
        force_wcs = sav_frc_wcs
        !workofs$
        ]

 

Now, when you call 'pwcs' you need to manipulate the value of 'force_pwcs' so you can make sure you aren't getting output, where you don't want it.

Example:



ptlchg_com      #Tool change common blocks
      if force_output | sof,
        [
        result = force(ipr_type,ipr_type)
        result = force(absinc$,absinc$)
        result = force(plane$,plane$)
        ]
      pcom_moveb
      pcheckaxis      #Check for valid rotary axis
      if sof, uninhibit_probe$
      c_mmlt$ #Multiple tool subprogram call
      #ptoolcomment
      if sof & scomm_sav <> snull,
        [
        spaces$ = 0
        n$, pspc, scomm_str, *scomm_sav, scomm_end, e$
        spaces$ = sav_spc
        ]
      if sof = 0, scomm_sav = snull
      comment$
      pcomment3
      pmisccheck
      pcan
      if stagetool >= zero,
        [
        if omitseq$ = 1 & tseqno > 0,
          [
          if tseqno = 2, n$ = t$
          pbld, *n$, *t$, "M06", ptoolcomm, e$
          ]
        else, pbld, n$, *t$, "M06", ptoolcomm, e$
        ]
      spaces$=0
      if output_z = yes$,
        [
        preadbuf5
        if (opcode$ > 0 & opcode$ < 16) | opcode$ = 19,
          [
          n$, pspc, scomm_str, "MAX - ", *max_depth, scomm_end, e$
          n$, pspc, scomm_str, "MIN - ", *min_depth, scomm_end, e$
          ]
        ]
      spaces$=sav_spc
      pstock_surf
      if plane$ < 0 | opcode$ = 3 | opcode$ = 16, plane$ = 0
      sav_absinc = absinc$
      if wcstype > one, absinc$ = zero
      pindex
      if safe_index,
        [
        if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
        pbld, n$, pgear, e$
        pcan1, pbld, n$, *sgcode, sgplane, [if not(index), sgabsinc, pwcs], pfcout, strcantext, e$
        if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
        if convert_rpd$ = one,
          [
          gcode$ = one
          feed = maxfeedpm
          ipr_type = zero
          ]
        pbld, n$, sgcode, [if gcode$ = 1, sgfeed], pfxout, pfyout, pfspindleout, [if gcode$ = 1, *feed], e$
        ]
      else,
        [
        if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
        pbld, n$, pgear, e$
        if convert_rpd$ = one,
          [
          gcode$ = one
          feed = maxfeedpm
          ipr_type = zero
          ]
        pcan1, pbld, n$, *sgcode, sgplane, [if not(index), sgabsinc, pwcs], [if gcode$ = 1, sgfeed], pfcout, pfxout, pfyout,
          pfspindleout, [if gcode$ = 1, *feed], strcantext, e$
        if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
        ]
      phsm1_on        #must remain before G43
      pbld, n$, "G43", *tlngno$, pfzout, scoolant, next_tool$, e$
      pcan2           #Added so M and G codes in canned text will output before phsm2_on
      phsm2_on        #must remain after G43

      #PWCS has already been output, so we need to manipulate the 'force_pwcs' variable:
      force_pwcs = one
      pbld, "(WORK OFFSET:", pwcs, no_spc$, ")", e$
      force_pwcs = zero #Disable, so we suppress redundant output
      sav_coolant = coolant$
      if coolant$ = 1, sm09 = sm09_0
      if coolant$ = 2, sm09 = sm09_1
      if coolant$ = 3, sm09 = sm09_2
      absinc$ = sav_absinc
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call
      plast

 

 

Thank you Colin, this is very helpful information that i need.

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