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:

Linking sgfeed to feed rate output


dmaier
 Share

Recommended Posts

I am trying to create a post for a machine that requires a G94 or G95 before every feed rate change.  I am a little stuck on how to go about this.  Currently if I have a feed rate change and G94 or G95 is still active it will only post the feed rate change without posting the sgfeed string. I can force the string sgfeed to post with the feed but if there is no feed rate change the sgfeed string will still post. Is there away to link the two together so that if a feed rate is posted the sgfeed is force out only with the feed rate change?

Link to comment
Share on other sites

I had thought about doing it that way but I need to be able to use G95 as well for boring and tapping cycles. I have sgfeed working awesome with the feed rate with my canned cycles. It is just my linear and circular moves that are not posting G94 before the feed rate change. Right now I am using single quotations to force a G94 only before a feed rate post on linear and circular moves but that limits me to G94 only. We are currently not using G95 for these type of moves so I guess this will work for now. I am still getting the hang all the functions within Mastercam and was curious if there was a better way of doing this without using a dependent string literal.

Link to comment
Share on other sites

I think this would be the best way to go about it. Please try it, and let me know if this is what you are after.

First, add the following line of code, at the top of 'pncoutput':

pncoutput       #Movement output
      if fr_pos$ <> prv_fr_pos$, result = force(sgfeed, sgfeed)   #<<< ADD THIS LINE HERE
      pcom_moveb

Then, you need to "update" the 'fr_pos$' variable, at the end of each "tool change" event.

Add the following line, to the End of each of these Post Blocks:

'psof$'

'ptlchg$'

'ptlchg0$'

#HERE IS A MPMASTER SAMPLE, FROM PSOF:

psof$            #Start of file for non-zero tool number
      probe_head$
      ptravel
      pwritbuf5
      pcuttype
      toolchng = one
      if ntools$ = one,
        [
        #skip single tool outputs, stagetool must be on
        #stagetool = m_one
        !next_tool$
        ]
      tooltotal = rbuf(4,0)  #Reads total tool and null tool changes
      if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)
      else, nexttool = first_tool$

      if tool_table = 2, ppredstck
      if tool_table = 3, pmetastck

      spaces$=0
      if output_z = yes$ & tcnt > 1,
        [
        scomm_str, "OVERALL MAX - ", *z_tmax, scomm_end, e$
        scomm_str, "OVERALL MIN - ", *z_tmin, scomm_end, e$
        ]
      spaces$=sav_spc

      if plane$ < 0 | opcode$ = 3 | opcode$ = 16, plane$ = 0
      pbld, n$, *sgcode, *sgplane, *smetric, "G40", "G80", *sgabsinc, e$
      inhibit_probe$
      sav_absinc = absinc$
      absinc$ = one
      if wcstype <= one, #Work coordinate system
        [
        pfbld, n$, sgabsinc, *sg28, "Z0.", e$
        pfbld, n$, *sg28, "X0.", "Y0.", e$
        pfbld, n$, "G92", *xh$, *yh$, *zh$, e$
        ]
      else,
        [
        pbld, n$, sgabsinc, *sg28, "Z0.", e$
        ]
      absinc$ = sav_absinc
      sav_mi9 = mi9$
      sav_workofs = workofs$
      if sav_workofs < 0, sav_workofs = 0
      ptlchg_com
      sof = 0
      !fr_pos$  #ADD THIS AS THE LAST LINE IN PSOF, PTLCHG, PTLCHG0!

Using the "update" command at the end of the Tool Change, tells MP to "store the current Feed rate value in the PREVIOUS variable".

Here is ptlchg0$ from MPMASTER:

ptlchg0$         #Call from NCI null tool change (tool number repeats)
      toolchng0 = one
      if op_id$ <> last_op_id,
        [
        rd_params$  # Read parameters - pparameter
        pmisccheck
        ]
      pcuttype
      toolcount = toolcount + 1
      if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)
      else, nexttool = first_tool$
      retractflg = 0
      if (mi10$ & (op_id$ <> last_op_id | (op_id$ = last_op_id & xform_op_id$ <> op_id$)))
        | ((tlplnno$ <> last_tlplnno | rotary_type$ <> last_rotary_type) & ret_on_indx)
        | (mr1$ = 2 & op_id$ <> last_op_id & mr2$ <> last_mr2),
        [
        phsm_off
        if mi10$,
          [
          pretract
          n$, *sm00, e$
          result = force(spdir2,spdir2)       #Force spindle output after M00
          result = force(speed,speed)         #Force speed output after M00          
          ]
        else, pretract0
        retractflg = 1
        ]
      else,
        [
        if mr1$ <> last_mr1 | mr2$ <> last_mr2, phsm_off
        ]
      pcom_moveb
      pcheckaxis      #Check for valid rotary axis
      !op_id$
      inhibit_probe$
      c_mmlt$ #Multiple tool subprogram call
      comment$
      pcomment3
      pcan
      if plane$ < 0 | opcode$ = 3 | opcode$ = 16, plane$ = 0
      if op_id$ <> last_op_id, pbld, n$, sgplane, e$
      pspindchng
      if coolant$ <> 0 & coolant$ <> sav_coolant & sav_coolant, pbld, n$, sm09, e$
      pbld, n$, scoolant, e$
      sav_coolant = coolant$
      if coolant$ = 1, sm09 = sm09_0
      if coolant$ = 2, sm09 = sm09_1
      if coolant$ = 3, sm09 = sm09_2
      if sav_mi9 = 1, workofs$ = sav_workofs
      if (wcstype > one & workofs$ <> prv_workofs$) | (tlplnno$ <> last_tlplnno) | retractflg,
        [
        if convert_rpd$ = one,
          [
          gcode$ = one
          feed = maxfeedpm
          ipr_type = zero
          ]
        sav_absinc = absinc$
        absinc$ = zero
        pindex
        if retractflg,
          [
          if safe_index,
            [
            if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
            pbld, n$, pgear, e$
            pbld, n$, *sgcode, [if not(index), sgabsinc, pwcs], pfcout, pspindleout, e$
            if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
            pbld, n$, pfxout, pfyout, e$
            ]
          else,
            [
            if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
            pbld, n$, pgear, e$
            pbld, n$, *sgcode, [if not(index), sgabsinc, pwcs], pfcout, pfxout, pfyout, pspindleout, 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, e$
          phsm2_on        #must remain after G43
          ]
        else,
          [
          if fmtrnd(prv_cabs) <> fmtrnd(cabs),
            [
            if safe_index,
              [
              if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
              pbld, n$, [if not(index), sgabsinc, pwcs], pfcout, e$
              if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
              pbld, n$, pfxout, pfyout, e$
              ]
            else,
              [
              if lock_codes = one & not(index) & rot_on_x, pbld, n$, *sunlock, sunlockcomm, e$
              pbld, n$, [if not(index), sgabsinc, pwcs], pfcout, pfxout, pfyout, e$
              if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$
              ]
            pbld, n$, pfzout, e$
            ]
          else,
            [
            pbld, n$, sgabsinc, [if not(index), pwcs], pfxout, pfyout, pfzout, pcout, e$
            ]
          ]
        pe_inc_calc
        ps_inc_calc
        absinc$ = sav_absinc
        ]
      if lock_codes = one & cuttype <> last_cuttype & cuttype > 0, pbld, n$, *sunlock, sunlockcomm, e$
      if cuttype = zero, ppos_cax_lin
      if lock_codes = one & cuttype <> last_cuttype & cuttype = 0 & fmtrnd(prv_cabs) = fmtrnd(cabs), pbld, n$, *slock, slockcomm, e$
      if gcode$ = one, plinout
      else, prapidout
      pcom_movea
      if retractflg = 0 & op_id$ <> last_op_id,  #output if not forced output above with the G43
        [
        if mr1$ <> 2 | (mr1$ = 2 & mr2$ <> last_mr2), phsm1_on
        phsm2_on
        ]
      c_msng$ #Single tool subprogram call
      plast
      toolchng0 = zero
      !fr_pos$

And here is 'ptlchg$':

ptlchg$          #Tool change
      pcuttype
      toolchng = one
      toolcount = toolcount + 1
      if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)
      else, nexttool = first_tool$
      if wcstype = one, #Work coordinate system
        [
        pfbld, n$, *sg28, "X0.", "Y0.", e$
        pfbld, n$, "G92", *xh$, *yh$, *zh$, e$
        ]
      if mi10$=one, n$, *sm00, e$
      else, pbld, n$, *sm01, e$
      inhibit_probe$
      ptlchg_com
      !fr_pos$

 

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

pncoutput #Movement output

if fr_pos$ <> prv_fr_pos$, result = force(sgfeed, sgfeed) #<<< ADD THIS LINE HERE

pcom_moveb

28 Feb 2018 12:30:51 PM - PST LINE (2977) - The arguments for this operator/function are not the same type (var/string)[43]

I am getting an error from the pncoutput block. If I am understanding the error correctly the force command does not work on a string? If this is the correct,  should I capture the string value (in this case 0 or 1 based on mi6$) and convert it into variable that would work with the force command and add this newly created  variable to my motion post blocks. Or is there something more simplistic  to this problem?

Link to comment
Share on other sites

if fr_pos$ <> prv_fr_pos$, result = force(ipr_type, ipr_type)

The line above was spitting out a G94 at the beginning of every motion line.

 

I changed fr_pos$ to feed and got exactly what I was looking for.

if feed <> feed, result = force(ipr_type, ipr_type)

 

Thank you Colin. I always learn a lot from the knowledge and advice you give on this forum.

 

  • Thanks 1
Link to comment
Share on other sites

Agreed. I have customized a few of  the post at my work place now  (with help from you and others on this forum).  It is nice being able to have custom M codes inserted where you want or address the proper code formats to a specific machine and have it automatically generated an edit free program.

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