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:

Local Subroutines


Recommended Posts

Greetings all,

I'm working with the MPMASTER post and want to output subroutines as local subs for a Fanuc 31i. I'm working with the 2023 MPMASTER post. I thought I could just change  the sub_prg_no$ and the sub_prg_call to Q and N respectively but, that had no effect. I've search all throughout the post but, I can't see where it sets these labels.  Where should I be looking? I would think this would have been a little easier than this...

#Move comment (pound) to output colon with program numbers
fmt  "O" 7  progno$     #Program number
#fmt ":" 7   progno$     #Program number
fmt  "O" 7  main_prg_no$ #Program number
#fmt ":" 7   main_prg_no$ #Program number
fmt  "O" 7  sub_prg_no$ #Program number      changed here, no effect
#fmt ":" 7   sub_prg_no$  #Program number  
fmt  "P" 7  sub_prg_call #Program number     changed here, no effect
fmt  "X" 2  sub_trnsx$  #Rotation point
fmt  "Y" 2  sub_trnsy$  #Rotation point
fmt  "Z" 2  sub_trnsz$  #Rotation point

 

Thanks,

Doug

 

Link to comment
Share on other sites

Try this instead...in this section, 

 

psub_call_trans #Translate level calls from toolchange, user
      if mi1$ <= one, result = mprint(shomeserror)
      sav_absinc = absinc$
      pindex
      #Mirror or Rotate Coord's
      if sub_trnstyp$ = zero, mr_rt_actv = three  #Mirror
      if mr_rt_actv,
        [
        if sub_trnstyp$ = zero,
          [
          #The original pattern is not mirrored
          if sub_chn_no$ <> one,
            [
            absinc$ = zero
            psub_mirror
            ]
          ]
        else,
          [
          #The original pattern is not rotated, calculate the rotation incremental angle for G68
          rt_csav = atan2(sub_m2$, sub_m1$)
          if sub_sec_no$,
            [
            rt_cinc = prv_rt_csav - rt_csav
            while rt_cinc > 180, rt_cinc = rt_cinc - 360
            while rt_cinc < -180, rt_cinc = rt_cinc + 360
            if rot_ccw_pos = one, rt_cinc = -rt_cinc
            !rt_csav
            absinc$ = zero
            psub_rotate
            ]
          else,
            [
            !rt_csav
            ]
          ]
        #Set restore flag and sign mr_rt_actv to indicate active
        mr_rt_rst = one
        mr_rt_actv = -abs(mr_rt_actv)
        ]
      else, #Translate all, Rotate toolplane
        [
        if sub_mny_t$,
          [
          if mi1$ > one, absinc$ = zero
          if convert_rpd$, pconvert_rpd
          pbld, n$, [if gcode$, *sgfeed], *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfzout, pfcout, [if gcode$, *feed], e$
          pe_inc_calc
          ps_inc_calc
          ]
        ]
      absinc$ = sav_absinc
      #result = nwadrs(strp, main_prg_no$)<-----------------------------------------------------------------------------Alter here
      result = nwadrs(strh, main_prg_no$)    #altered to get H output, 02/10/2020, jmp  <--------------------------------Alter here
      main_prg_no$ = main_prg_no$ + 40000   #alter to push subprograms #'s into the 40000 range, 02/10/2020, jmp
      #if progno$ = main_prg_no$, result = mprint(sprgnerror)
      pbld, n$, "M98", *main_prg_no$, e$
      result = force(feed)  # Force output of feed next time it's called for output (in sub)

and here

psub_st_m$       #Header in main level
      #result = nwadrs(stro, main_prg_no$)<----------------------------------------------HERE
      result = nwadrs(strn, main_prg_no$)<-----------------------------------------------HERE
      if first_sub & subs_before, first_sub = zero #suppress blank line before first sub with subs before main
      else, " ", e$
      *main_prg_no$, e$
      #G51/G68 requires absolute position on first move
      if mr_rt_rst,
        [
        sav_absinc = absinc$
        if absinc$ = one,
          [
          absinc$ = zero
          prv_absinc$ = m_one
          prv_xabs = m_one
          prv_yabs = m_one
          ]
        ]
      else, pbld, n$, sgabsinc, e$

 

  • Thanks 1
  • Like 1
Link to comment
Share on other sites
19 hours ago, JParis said:

Try this instead...in this section, 

Ok, so I'm getting a post error on line 3126 which is the first line I altered. which is the line I modified which, is under the psub_call_trans section.  I'm assuming I need to assign "h" as a variable? In my case I want a "Q" in my macro call. I get the same error regardless if I have strh or strq. It posts all of the macro calls with an "N" except for the very first macro call. It's still posting that one as an "N". But, lets tackle one issue at a time.

3125    #result = nwadrs(strp, main_prg_no$)    #altered to get H output, 12/16/2022, dsp  <-Alter here
3126      result = nwadrs(strh, main_prg_no$) 
Link to comment
Share on other sites

yeah, looking further up in your post, if strh isn't defined, go ahead and define it

The others will guide you as to what it should look like

What that line is doing is setting the address for the main_prg_no$ variable to be different that it is assigned further up in the post.

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