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:

Control Your Comments


Recommended Posts

I am sure that I am not the only one that has struggled to get manual entries to post where they are needed.  Sometimes, they need to be before a tool change, so the operator can check the tool for wear or tie-up.  Sometimes, they need to be after the tool change to give instruction prior to the tool running.

 

The problem with the comment$ postblock is that it collects strings of data, then outputs all contained data contained each time it is called. A 'First In, First Out' buffer.

 

I have modified my post to allow the programmer to specify when the string data is to be output by teaching the post to check for the phrase 'BEFORE TOOL CHANGE'.  When that phrase is encountered, the subsequent string data is output before the tool change. Conversely, the phrase 'AFTER TOOL CHANGE' will cause the subsequent string data to be output after the tool change.  If neither phrase is encountered, all string data will output after the tool change.

 

The code required is relatively simple.  First, define the string variables to be used:

combefore    : 0
comafter     : 0
sopen_prn    : "("
sclos_prn    : ")"
scombefore   : "BEFORE TOOL CHANGE"
scomafter    : "AFTER TOOL CHANGE"
scom1        : ""
scom2        : ""
scom3        : ""
scom4        : ""
scom5        : ""
scom6        : ""
scom7        : ""
scom8        : ""
scom9        : ""
scom10       : ""
scom1b       : ""
scom2b       : ""
scom3b       : ""
scom4b       : ""
scom5b       : ""
scom6b       : ""
scom7b       : ""
scom8b       : ""
scom9b       : ""
scom10b      : ""

Next, and this is very important, change the name pcomment$ in your post to pcommentSAVE

Then, paste this code:

pcomment$        #Comment from manual entry
        scomm$ = ucase (scomm$)
        if combefore = 0, combefore = strstr (scombefore, scomm$)
        if comafter = 0, comafter = strstr (scomafter, scomm$)
        if scomm$ = scombefore, scomm$ = ""
        if scomm$ = scomafter, scomm$ = ""
        if combefore <= 0 | comafter > 0 | gcode$ = 1008,
         [
          if scom9 <> "" & scom10 = "",
           [
            if gcode$ = 1006, scom10 = scomm$
            else, scom10 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom8 <> "" & scom9 = "",
           [
            if gcode$ = 1006, scom9 = scomm$
            else, scom9 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom7 <> "" & scom8 = "",
           [
            if gcode$ = 1006, scom8 = scomm$
            else, scom8 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom6 <> "" & scom7 = "",
           [
            if gcode$ = 1006, scom7 = scomm$
            else, scom7 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom5 <> "" & scom6 = "",
           [
            if gcode$ = 1006, scom6 = scomm$
            else, scom6 = sopen_prn + scomm$ + sclose_prn
              ]
          if scom4 <> "" & scom5 = "",
           [
            if gcode$ = 1006, scom5 = scomm$
            else, scom5 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom3 <> "" & scom4 = "",
           [
            if gcode$ = 1006, scom4 = scomm$
            else, scom4 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom2 <> "" & scom3 = "",
           [
            if gcode$ = 1006, scom3 = scomm$
            else, scom3 = sopen_prn + scomm$ + sclose_prn
           ]
          if scom1 <> "" & scom2 = "",
           [
            if gcode$ = 1006, scom2 = scomm$
            else, scom2 = sopen_prn + scomm$ + sclose_prn
           ]
          if scomm$ <> "" & scom1 = "",
           [
            if gcode$ = 1006, scom1 = scomm$
            else, scom1 = sopen_prn + scomm$ + sclose_prn
           ]
         ]
        if combefore > 0 & comafter <= 0 & gcode$ <> 1008,
         [
          if scom9b <> "" & scom10b = "",
           [
            if gcode$ = 1006, scom10b = scomm$
            else, scom10b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom8b <> "" & scom9b = "",
           [
            if gcode$ = 1006, scom9b = scomm$
            else, scom9b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom7b <> "" & scom8b = "",
            [
            if gcode$ = 1006, scom8b = scomm$
            else, scom8b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom6b <> "" & scom7b = "",
           [
            if gcode$ = 1006, scom7b = scomm$
            else, scom7b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom5b <> "" & scom6b = "",
           [
            if gcode$ = 1006, scom6b = scomm$
            else, scom6b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom4b <> "" & scom5b = "",
           [
            if gcode$ = 1006, scom5b = scomm$
            else, scom5b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom3b <> "" & scom4b = "",
           [
            if gcode$ = 1006, scom4b = scomm$
            else, scom4b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom2b <> "" & scom3b = "",
           [
            if gcode$ = 1006, scom3b = scomm$
            else, scom3b = sopen_prn + scomm$ + sclose_prn
           ]
          if scom1b <> "" & scom2b = "",
           [
            if gcode$ = 1006, scom2b = scomm$
            else, scom2b = sopen_prn + scomm$ + sclose_prn
           ]
          if scomm$ <> "" & scom1b = "",
           [
            if gcode$ = 1006, scom1b = scomm$
            else, scom1b = sopen_prn + scomm$ + sclose_prn
           ]
         ]
        scomm$ = ""

pcombefore
      if combefore > 0 & gcode$ <> 1008,
       [
        if scomm$ = "",
         [
          scom1b, e$
          scom2b, e$
          scom3b, e$
          scom4b, e$
          scom5b, e$
          scom6b, e$
          scom7b, e$
          scom8b, e$
          scom9b, e$
          scom10b, e$
          scom1b = "", scom2b = "", scom3b = "", scom4b = "", scom5b = ""
          scom6b = "", scom7b = "", scom8b = "", scom9b = "", scom10b = ""
         ]
       ]

pcomafter
        if scomm$ = "",
         [
          scom1, e$
          scom2, e$
          scom3, e$
          scom4, e$
          scom5, e$
          scom6, e$
          scom7, e$
          scom8, e$
          scom9, e$
          scom10, e$
          scom1 = "", scom2 = "", scom3 = "", scom4 = "", scom5 = ""
          scom6 = "", scom7 = "", scom8 = "", scom9 = "", scom10 = ""
         ]


So now, in psof$, ptlchg$ and ptlchg0$ postblocks, place the comment$ command near the top of the postblock.  Then call pcombefore just before the tool change and pcomafter just after the tool change.  Also, put this line at the end of each of the postblocks:

        combefore = 0, comafter = 0

If, at any time in the future, you decide to go back to the original way you had it, just delete pcomment$ and rename pcommentSAVE back.

 

Hopefully, some of you will find this code useful.  Cheers!  :cheers:

  • Like 5
Link to comment
Share on other sites

Hi EX-wccprogrammer,

   I've been asking you for tons of questions and I had the same problems.  I got it like this, I hope with my little knowledge will help you.

 

 

Here is my NC code and I hope this is what I may help you.

 

%
O0258 (Test File-OP1.NC)
(GROUP COMMENT)
(SOURCE= TEST FILE.MCX-8)
(POSTED ON AUG.30.2014 AT 12*28AM)
(GENERIC FANUC 4X MILL)
(MATERIAL TYPE= ALUMINUM INCH - 2024)
(MATERIAL STK= X4.96 Y3.85 Z2.00)
(*)
(Work Offset Info:)
(xxxx IT, WHERE IS THE WORKOFFSET?)
(*)
(TOOLS LIST)
(T3  - 3/8 BALL ENDMILL     -  H3)
(T4  - NO. 1-64 TAPRH       -  H4)
N3(3/8 BALL ENDMILL )
G0 G17 G40 G49 G80 G90 Z0
T3 M6(ROUGH AND FINISH PROFILE, CUT#3)
G90 G55
X-.375 Y2.005 S7000 M3
G43 H3 Z1. M8(DOC= Z-.5)
Z.0625
G1 Z-.5 F40.
G41 D3 Y1.63
G3 X0. Y1.255 I.375 J0.
G1 X1.875
G2 X2.255 Y.875 I0. J-.38
G1 Y-.875
G2 X1.875 Y-1.255 I-.38 J0.
G1 X-1.875
G2 X-2.255 Y-.875 I0. J.38
G1 Y.875
G2 X-1.875 Y1.255 I.38 J0.
G1 X0.
G3 X.375 Y1.63 I0. J.375
G1 G40 Y2.005
X-.375 Y1.9425
G41 D3 Y1.5675
G3 X0. Y1.1925 I.375 J0.
G1 X1.875
G2 X2.1925 Y.875 I0. J-.3175
G1 Y-.875
G2 X1.875 Y-1.1925 I-.3175 J0.
G1 X-1.875
G2 X-2.1925 Y-.875 I0. J.3175
G1 Y.875
G2 X-1.875 Y1.1925 I.3175 J0.
G1 X0.
G3 X.375 Y1.5675 I0. J.375
G1 G40 Y1.9425
S7500 M3
X-.375 Y1.9375 F30.
G41 D3 Y1.5625
G3 X0. Y1.1875 I.375 J0.
G1 X1.875
G2 X2.1875 Y.875 I0. J-.3125
G1 Y-.875
G2 X1.875 Y-1.1875 I-.3125 J0.
G1 X-1.875
G2 X-2.1875 Y-.875 I0. J.3125
G1 Y.875
G2 X-1.875 Y1.1875 I.3125 J0.
G1 X0.
G3 X.375 Y1.5625 I0. J.375
G1 G40 Y1.9375
Z.0625 F6.33
G0 Z1. M9
G28 G91 Z0 M5
/ G28 Y0
M1
M0(RECLAMP THE PART WITH 15LBS TORQUE)
(*)
N4(NO. 1-64 TAPRH )
G0 G17 G40 G49 G80 G90 Z0
T4 M6(ROUGH AND FINISH PROFILE, CUT#5)
G90 G55
X-.8258 Y1.3177 S640 M3
G43 H4 Z2. M8(DOC= Z-1.)
G95
G98 G84 Z-1. R.125 F10.
X-2.9564 Y2.491
X-1.0011 Y2.8541
X.5405 Y2.4295
G94
G80 M9
G28 G91 Z0 M5
/ G28 Y0
M1
M30
%
 

 

--------------------

 

In....

 

pcomment2       #Comment from manual entry
      #1005 - As Comment
      #1006 - As Code
      #1007 - As Comment with output line, change at point
      #1026 - As Code with output line, change at point
      #1008 - Operation comment

      #1051 - Machine Name
      #1052 - Group Comment
      #1053 - Group Name
      #1054 - File Descriptor

      spaces$ = 0
      scomm$ = ucase (scomm$)
      if sof & gcode$ = 1052, scomm_str, scomm$, scomm_end, e$
      #if sof & gcode$ = 1053, scomm_str, "P/NAME= ", scomm$, scomm_end, e$
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1006, n$, pspc, scomm$, e$
      #if gcode$ = 1007, scomm_str, scomm$, scomm_end
      #if gcode$ = 1026, scomm$
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1008, scomm_sav = ucase(scomm$)
      spaces$ = sav_spc

 

In.....

psof$            #Start of file for non-zero tool number
      ptlchg_errorcheck #Check for common toolchange errors

      if ntools$ > 40, [if mprint(stooltotalmax, 2) = 2, exitpost$]
      #
      pwritbuf5_extra
      #
      #"(*)", e$
      #"( *** INDEX ANGLES AND WORK OFFSETS *** )", e$
      #pReadBufferTLPN
      #"( ******************** )", e$
      #
      #rc5 = 2
      #
      #"(*)", e$,
      comment$, e$
      #spaces$=0, scomm_str, *stpgrpname, scomm_end, spaces$=sav_spc, e$
      ptravel
      pcuttype

 

In.....

pheader$         #Call before start of file                        
      hour = int(time$)
      min = int((time$ - hour)* 100)
      if hour > 12, hour = hour - 12
      if hour = 0, hour = 12
      year$ = year$ + 2000

      "%", e$
      [spaces$=0, *progno$, " ", scomm_str, snamenc$, sextnc$, scomm_end, e$

        #pReadRevNumber
        #" REV.", *b9_RevNumber, scomm_end, e$, spaces$=sav_spc
      ]

      #scomm_str, spathnc$, scomm_end, e$
      comment$, e$

 

 In...

pncoutput       #Movement output
      pcom_moveb
      comment$
      if coolant$ <> 0 & coolant$ <> sav_coolant,

 

In....

pdwl_spd$        #Call from NCI gcode 4
      pspindle
      comment$

 

In.....

pdrlcommonb     #Canned Drill Cycle common call, before

      if sav_dgcode = 81,
        [

        if drillcyc$ = three, drlgsel = fsg1(-ss$) + drillcyc$ * two
        else, drlgsel = fsg2(dwell$) + drillcyc$ * two
        if clearflg = one & clearstrt = zero, drillref = zero
        else, drillref = one
        if absinc$, result = force(refht_i, refht_i)
        else, result = force(refht_a, refht_a)
        ]
      result = newfs (two, zinc)

      if drillcyc$ = 3,
        [
        if mi6$, use_pitch = 1
        else, use_pitch = sav_use_pitch
        ]

      pcom_moveb
      feed = fr_pos$
      comment$

 

 

In......

# --------------------------------------------------------------------------
# Parameter read postblocks:
# --------------------------------------------------------------------------

 

poperation
      if sof & scomm_sav <> snull,
      spaces$ = 0
      scomm_str, *scomm_sav, ", CUT#", *sOpSeqNo, scomm_end, e$
      spaces$ = sav_spc


 

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