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 Change Cutter Comp. position in Lathe


Recommended Posts

1 hour ago, @Mastercam said:

Hello Everyone,

Is it possible to change cutter compensation position in linear block in lathe. Because we are facing issue when using cutter compensation - control mode.

is there any switch inside the post ? 

 

Cutter Compensation.jpg

Looks like someone messed with your post. I have never seen G41 come out like that. Reload the Generic post and see what it does. If that is correct then do a file compare to correct the mistake someone made with the post.

Link to comment
Share on other sites
6 hours ago, nickbe10 said:

This will require some fairly straight forward post modification.

Will need to know your base post and what you want it to look like.

i'm using Default MPLFAN for MC2021

5 hours ago, crazy^millman said:

Looks like someone messed with your post. I have never seen G41 come out like that. Reload the Generic post and see what it does. If that is correct then do a file compare to correct the mistake someone made with the post.

No one has modify the post . Only our requirement is G41/G42 should be come in Linear blocks only .  
if possible could you please help me to fix this. 

Link to comment
Share on other sites
29 minutes ago, @Mastercam said:

No one has modify the post . Only our requirement is G41/G42 should be come in Linear blocks only .  
if possible could you please help me to fix this. 

Okay post a Z2G and then we can see what you're seeing. I have never seen the default Lathe post put the G41 there so that is new and not sure why you're seeing it. Only way to know is to have a copy of everything to then see why.

Link to comment
Share on other sites
1 hour ago, crazy^millman said:

Okay post a Z2G and then we can see what you're seeing. I have never seen the default Lathe post put the G41 there so that is new and not sure why you're seeing it. Only way to know is to have a copy of everything to then see why.

i've attached post & project .  Default output for G41/G42 is in rapid block , But we need in linear block.....

Cutter Compensation Test.mcam

MPLFAN.mcam-content

Link to comment
Share on other sites
12 hours ago, @Mastercam said:

i've attached post & project .  Default output for G41/G42 is in rapid block , But we need in linear block.....

Cutter Compensation Test.mcam

MPLFAN.mcam-content

I stand corrected the post has not been modified I apologize for making that assumption.

Okay since you shared your file I will try to help you get it.

We are looking in the Post for psccomp as the output variable.

We first see it called in the ltlchg$ section of the post. This the first block called when changing tools or making a program. We see it in this section.

ltlchg$          #Toolchange, lathe
      toolchng = one
      gcode$ = zero
      copy_x = vequ(x$)
      pcc_capture   #Capture LCC ends, stop output RLCC
      c_rcc_setup$  #Setup LCC on first 60000
      plcc_lead_begin  #Save original in sav_xa and shift copy_x for LCC comp.
      pcom_moveb    #Get machine position, set inc. from c1_xh
      c_mmlt$       #Position multi-tool sub, sets inc. current if G54...
      ptoolcomment
      comment$
      if home_type < two, #Toolchange G50/home/reference position
        [
        sav_xh = vequ(copy_x)
        sav_absinc = absinc$
        absinc$ = zero
        pmap_home   #Get home position, xabs
        ps_inc_calc #Set start position, not incremental
        #Toolchange home position
        if home_type = one,
          pbld, n$, *sgcode, pfxout, pfyout, pfzout, e$
        else,
          [
          #Toolchange g50 position
          pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], "W0.", e$
          toolno = t$ * 100 + zero
          if home_type = m_one, pbld, n$, *sgcode, *toolno, e$
          else, pbld, n$, *sg50, pfxout, pfyout, pfzout, e$
          ]
        pe_inc_calc #Update previous
        absinc$ = sav_absinc
        copy_x = vequ(sav_xh)
        ]
      toolno = t$ * 100 + tloffno$
      pbld, n$, *sgcode, *toolno, e$
      pbld, n$, pfsgplane, e$
      pcaxis_off_l  #Postblock for lathe transition
      pcom_moveb    #Reset machine position, set inc. from last position
      pcan
      pspindle
      if opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$),  #Do not enable spindle for point toolpath
        [
        if css_actv$,
          [
          if css_start_rpm, prpm  #Direct RPM startup for programmed CSS
          else, pcssg50, pcss  #NO RPM start - just output the CSS
          ]
        else, prpm  #Direct RPM was programmed
        ]
      sav_absinc = absinc$
      if home_type > one, absinc$ = zero
      pcan1, pbld, n$, psccomp, *sgcode, pwcs, pfxout, pyout, pfzout,
        pscool, strcantext, e$
      plcc_lead_end #Use sav_xa to position with comp. LCC
      pcom_movea    #Update previous, pcan2
      ps_inc_calc   #Reset current
      absinc$ = sav_absinc
      if (opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$)) & css_start_rpm,  #Do not enable spindle for point toolpath
        pcssg50, pcss  #CSS output AFTER a G97S???? RPM spindle startup
      c_msng$        #Position single-tool sub, sets inc. current if G54...
      toolchng = zero
      !op_id$, !lturret$, !tool_op$, prv_millcc = zero
      prev_spindle = spindle_no$  #Save spindle used in this operation

I like to copy the line or lines of code and then paste them into my post keeping the original post blocks like they were for reference.

#      pcan1, pbld, n$, psccomp, *sgcode, pwcs, pfxout, pyout, pfzout,
#        pscool, strcantext, e$

      pcan1, pbld, n$, *sgcode, pwcs, pfxout, pyout, pfzout,
        pscool, strcantext, e$ #RDB 2-11-21 Removed psccomp

I then test the post and see where the G41/G42 get output to see if that moves it to where I want. Now we have created a big mess and don't get good output. We have different options, but none of them are what I would consider acceptable and worth spending anymore time on.

%
O0000
(PROGRAM NAME - T)
(DATE=DD-MM-YY - 11-02-21 TIME=HH:MM - 07:29)
(MCAM FILE - C:\USERS\RON\DOCUMENTS\MY MASTERCAM 2021\MASTERCAM\PARTS\CUTTER COMPENSATION TEST.MCAM)
(NC FILE - C:\USERS\RON\DOCUMENTS\MY MASTERCAM 2021\MASTERCAM\LATHE\NC\T.NC)
(MATERIAL - ALUMINUM MM - 2024)
G21
(TOOL - 12 OFFSET - 12)
(OD RIGHT 55 DEG  INSERT - DNMG 15 06 08)
G0 T1212
G18
G97 S2136 M03
G0 G54 X43.951 Z5.3 M8
G50 S3600
G96 S295
G99 G1 Z3.3 F.2
Z-59.864
X46.447
G18 G3 X46.847 Z-60.064 K-.2
G1 Z-97.155
G40 X49.676 Z-95.741
G0 G42 Z5.3
X41.055
G1 Z3.3 F.2
Z-59.864
X43.951
G40 X46.78 Z-58.45
G0 G42 Z5.3
X38.159
G1 Z3.3 F.2
Z0.
Z-59.864
X41.055
G40 X43.884 Z-58.45
G0 X46.247
G28 U0. V0. W0. M05
T1200
M01
(TOOL - 21 OFFSET - 21)
(OD FINISH RIGHT - 35 DEG.  INSERT - VNMG 16 04 08)
G0 T2121
G18
G97 S2487 M03
G0 G54 X37.759 Z2.
G50 S3600
G96 S295
G1 Z0. F.2
Z-60.064
X46.447
Z-97.155
G40 X49.276 Z-95.741
G28 U0. V0. W0. M05
T2100
M30
%

I have what I call the Vanilla, Chocolate, Strawberry things people want. End of the day if it makes a good parts and get the job done then be happy you can do so and this will be one of those instances where sorry you get what you are getting. Want something super custom then reach out to your dealer and get a custom post because because of the way you want to see it. I tested this with about 5 different free lathe posts and they all do the same thing. Only my custom posts do what your asking for.

Sorry I couldn't be of more assistance, but thank you for showing your a legitimate user of Mastercam.

Link to comment
Share on other sites
4 minutes ago, crazy^millman said:

I stand corrected the post has not been modified I apologize for making that assumption.

Okay since you shared your file I will try to help you get it.

We are looking in the Post for psccomp as the output variable.

We first see it called in the ltlchg$ section of the post. This the first block called when changing tools or making a program. We see it in this section.


ltlchg$          #Toolchange, lathe
      toolchng = one
      gcode$ = zero
      copy_x = vequ(x$)
      pcc_capture   #Capture LCC ends, stop output RLCC
      c_rcc_setup$  #Setup LCC on first 60000
      plcc_lead_begin  #Save original in sav_xa and shift copy_x for LCC comp.
      pcom_moveb    #Get machine position, set inc. from c1_xh
      c_mmlt$       #Position multi-tool sub, sets inc. current if G54...
      ptoolcomment
      comment$
      if home_type < two, #Toolchange G50/home/reference position
        [
        sav_xh = vequ(copy_x)
        sav_absinc = absinc$
        absinc$ = zero
        pmap_home   #Get home position, xabs
        ps_inc_calc #Set start position, not incremental
        #Toolchange home position
        if home_type = one,
          pbld, n$, *sgcode, pfxout, pfyout, pfzout, e$
        else,
          [
          #Toolchange g50 position
          pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], "W0.", e$
          toolno = t$ * 100 + zero
          if home_type = m_one, pbld, n$, *sgcode, *toolno, e$
          else, pbld, n$, *sg50, pfxout, pfyout, pfzout, e$
          ]
        pe_inc_calc #Update previous
        absinc$ = sav_absinc
        copy_x = vequ(sav_xh)
        ]
      toolno = t$ * 100 + tloffno$
      pbld, n$, *sgcode, *toolno, e$
      pbld, n$, pfsgplane, e$
      pcaxis_off_l  #Postblock for lathe transition
      pcom_moveb    #Reset machine position, set inc. from last position
      pcan
      pspindle
      if opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$),  #Do not enable spindle for point toolpath
        [
        if css_actv$,
          [
          if css_start_rpm, prpm  #Direct RPM startup for programmed CSS
          else, pcssg50, pcss  #NO RPM start - just output the CSS
          ]
        else, prpm  #Direct RPM was programmed
        ]
      sav_absinc = absinc$
      if home_type > one, absinc$ = zero
      pcan1, pbld, n$, psccomp, *sgcode, pwcs, pfxout, pyout, pfzout,
        pscool, strcantext, e$
      plcc_lead_end #Use sav_xa to position with comp. LCC
      pcom_movea    #Update previous, pcan2
      ps_inc_calc   #Reset current
      absinc$ = sav_absinc
      if (opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$)) & css_start_rpm,  #Do not enable spindle for point toolpath
        pcssg50, pcss  #CSS output AFTER a G97S???? RPM spindle startup
      c_msng$        #Position single-tool sub, sets inc. current if G54...
      toolchng = zero
      !op_id$, !lturret$, !tool_op$, prv_millcc = zero
      prev_spindle = spindle_no$  #Save spindle used in this operation

I like to copy the line or lines of code and then paste them into my post keeping the original post blocks like they were for reference.


#      pcan1, pbld, n$, psccomp, *sgcode, pwcs, pfxout, pyout, pfzout,
#        pscool, strcantext, e$

      pcan1, pbld, n$, *sgcode, pwcs, pfxout, pyout, pfzout,
        pscool, strcantext, e$ #RDB 2-11-21 Removed psccomp

I then test the post and see where the G41/G42 get output to see if that moves it to where I want. Now we have created a big mess and don't get good output. We have different options, but none of them are what I would consider acceptable and worth spending anymore time on.


%
O0000
(PROGRAM NAME - T)
(DATE=DD-MM-YY - 11-02-21 TIME=HH:MM - 07:29)
(MCAM FILE - C:\USERS\RON\DOCUMENTS\MY MASTERCAM 2021\MASTERCAM\PARTS\CUTTER COMPENSATION TEST.MCAM)
(NC FILE - C:\USERS\RON\DOCUMENTS\MY MASTERCAM 2021\MASTERCAM\LATHE\NC\T.NC)
(MATERIAL - ALUMINUM MM - 2024)
G21
(TOOL - 12 OFFSET - 12)
(OD RIGHT 55 DEG  INSERT - DNMG 15 06 08)
G0 T1212
G18
G97 S2136 M03
G0 G54 X43.951 Z5.3 M8
G50 S3600
G96 S295
G99 G1 Z3.3 F.2
Z-59.864
X46.447
G18 G3 X46.847 Z-60.064 K-.2
G1 Z-97.155
G40 X49.676 Z-95.741
G0 G42 Z5.3
X41.055
G1 Z3.3 F.2
Z-59.864
X43.951
G40 X46.78 Z-58.45
G0 G42 Z5.3
X38.159
G1 Z3.3 F.2
Z0.
Z-59.864
X41.055
G40 X43.884 Z-58.45
G0 X46.247
G28 U0. V0. W0. M05
T1200
M01
(TOOL - 21 OFFSET - 21)
(OD FINISH RIGHT - 35 DEG.  INSERT - VNMG 16 04 08)
G0 T2121
G18
G97 S2487 M03
G0 G54 X37.759 Z2.
G50 S3600
G96 S295
G1 Z0. F.2
Z-60.064
X46.447
Z-97.155
G40 X49.276 Z-95.741
G28 U0. V0. W0. M05
T2100
M30
%

I have what I call the Vanilla, Chocolate, Strawberry things people want. End of the day if it makes a good parts and get the job done then be happy you can do so and this will be one of those instances where sorry you get what you are getting. Want something super custom then reach out to your dealer and get a custom post because because of the way you want to see it. I tested this with about 5 different free lathe posts and they all do the same thing. Only my custom posts do what your asking for.

Sorry I couldn't be of more assistance, but thank you for showing your a legitimate user of Mastercam.

Thank you for quick response 😊

Link to comment
Share on other sites

Hello,

I had the same question, but did not had the time yet (until yesterday and today).

I came up with the following changes to the standerd post:

# --------------------------------------------------------------------------
# Custom variables
# --------------------------------------------------------------------------
op1_G41      : 0
cc_pos_pre   : -1       # add variable       JHM 2021-02-12
#




# add variable to lsof$
lsof$            #Start of file for non-zero tool number, lathe
      sav_cc_1013 = cc_1013$
	  op1_G41 = 0                  # 2021-02-12 initialize variable for first op G41
      ltlchg$




# Added logic to ltlch$
ltlchg$          #Toolchange, lathe
      toolchng = one
      gcode$ = zero
      copy_x = vequ(x$)
      pcc_capture   #Capture LCC ends, stop output RLCC
      c_rcc_setup$  #Setup LCC on first 60000
      plcc_lead_begin  #Save original in sav_xa and shift copy_x for LCC comp.
      pcom_moveb    #Get machine position, set inc. from c1_xh
      c_mmlt$       #Position multi-tool sub, sets inc. current if G54...
      ptoolcomment
      comment$
      if home_type < two, #Toolchange G50/home/reference position
        [
        sav_xh = vequ(copy_x)
        sav_absinc = absinc$
        absinc$ = zero
        pmap_home   #Get home position, xabs
        ps_inc_calc #Set start position, not incremental
        #Toolchange home position
        if home_type = one,
          pbld, n$, *sgcode, pfxout, pfyout, pfzout, e$
        else,
          [
          #Toolchange g50 position
          pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], "W0.", e$
          toolno = t$ * 100 + zero
          if home_type = m_one, pbld, n$, *sgcode, *toolno, e$
          else, pbld, n$, *sg50, pfxout, pfyout, pfzout, e$
          ]
        pe_inc_calc #Update previous
        absinc$ = sav_absinc
        copy_x = vequ(sav_xh)
        ]
      toolno = t$ * 100 + tloffno$
      pbld, n$, *sgcode, *toolno, e$
      pbld, n$, pfsgplane, e$
      pcaxis_off_l  #Postblock for lathe transition
      pcom_moveb    #Reset machine position, set inc. from last position
      pcan
      pspindle
      if opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$),  #Do not enable spindle for point toolpath
        [
        if css_actv$,
          [
          if css_start_rpm, prpm  #Direct RPM startup for programmed CSS
          else, pcssg50, pcss  #NO RPM start - just output the CSS
          ]
        else, prpm  #Direct RPM was programmed
        ]
      sav_absinc = absinc$
      if home_type > one, absinc$ = zero
      # *************************************  New location of psccomp       *********************************************************	JHM 2021-02-12 for location of G41
	  pcan1, pbld, n$, #psccomp,                            #commented psccomp out to get correct location G41
	    *sgcode, pwcs, pfxout, pyout, pfzout,
        pscool, strcantext, e$
	
	  # *************************************  Changed location of rpm start *********************************************************	JHM 2021-02-12 for location of G41
	  if (opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$)) & css_start_rpm,  #Do not enable spindle for point toolpath
        pcssg50, pcss  #CSS output AFTER a G97S???? RPM spindle startup
	  
	  # *************************************  New location of psccomp       *********************************************************	JHM 2021-02-12 for location of G41
	  pbld, psccomp
	  if op1_G41=0, cc_pos_pre = cc_pos$     # Set previous variable for psccomp
	  op1_G41 = 1
	
      plcc_lead_end #Use sav_xa to position with comp. LCC
      pcom_movea    #Update previous, pcan2
	  
      ps_inc_calc   #Reset current
      absinc$ = sav_absinc
	   # *************************************  Changed location of rpm start *********************************************************	JHM 2021-02-12 for location of G41
      #if (opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$)) & css_start_rpm,  #Do not enable spindle for point toolpath
      #  pcssg50, pcss  #CSS output AFTER a G97S???? RPM spindle startup
      c_msng$        #Position single-tool sub, sets inc. current if G54...
      toolchng = zero
      !op_id$, !lturret$, !tool_op$, prv_millcc = zero
      prev_spindle = spindle_no$  #Save spindle used in this operation
#end ltlchg$




# Edit prapidout to comment out psccomp in G0 movements
prapidout       #Output to NC, linear movement - rapid
      if lathecc = zero,
        [
        if millcc_flag & (abs(cuttype) = four | abs(cuttype) = two) & cutpos2$ = zero,  #Polar interpolation is active & Y-axis subs or Right face or Left face & before start point of operation geometry
          [
          if abs(cuttype) = four,  #Y-axis substitution, output C first on separate line
            [
            pcan1, pbld, n$, pexct, psgcode, pcout, e$
            pbld, n$, pexct, pxout, pyout, pzout, pscool, strcantext, e$
            ]
          else,  #Right or Left face cut, output Z last on separate line
            [
            pcan1, pbld, n$, pexct, psgcode, pxout, pyout, pcout, pscool, strcantext, e$
            pbld, n$, pexct, psgcode, pzout, e$
            ]
          ]
        else,
          [
          pcan1, pbld, n$, psgplane, pexct, psgcode, #psccomp,              # commented psccomp out for correct location output of G41
		    pwcs, pxout, pyout,
          pzout, pcout, pscool, strcantext, e$
          ]
        ]
      else,  #Lathe canned turning cycle
        [
        pcan1, pbld, n$, pexct, psgcode, #psccomp,                          # commented psccomp out for correct location output of G41
		  pxout, pyout, pzout, pcout, pscool, strcantext, e$
        ]
      if force_feed, result = force(feed)  # Force output of feed next time it's called for output
      if rpd_typ$ = 7, ptool_insp      #Tool inspection point
#end prapidout



# psccomp, added logic to forse G41/G42/G40 output to plane$=2 and prevent double output 
psccomp         #Output the cutter compensation based on the current plane
      if compok | lcc_compok >= two,
        [
        if plane$ = zero, sccomp
        if plane$ = one, sccomp1
        if plane$ = two,             #added logic, instead of sccomp2
		  [
		  if cc_pos_pre <> cc_pos$,    
		    [
		  	*sccomp2
		  	cc_pos_pre = cc_pos$
		  	]
		  ]
        ]
# end psccomp

which gives as a result:

G0 T1212
G18
G97 S2136 M03
G0 G54 X43.951 Z5.3 M8
G50 S3600
G96 S295
G42 G99 G1 Z3.3 F.2
Z-59.864
X46.447
G18 G3 X46.847 Z-60.064 K-.2
G1 Z-97.155
G40 X49.676 Z-95.741
G0 Z5.3
X41.055
G1 G42 Z3.3 F.2
Z-59.864
X43.951
G40 X46.78 Z-58.45
G0 Z5.3
X38.159
G1 G42 Z3.3 F.2
Z0.
Z-59.864
X41.055
G40 X43.884 Z-58.45
G0 X46.247
G28 U0. V0. W0. M05
T1200

I have not tested it yet, so test carefully 😀

Greetz,

Jan

  • Like 1
Link to comment
Share on other sites
1 hour ago, Werktuigbouwer said:

Hello,

I had the same question, but did not had the time yet (until yesterday and today).

I came up with the following changes to the standerd post:


# --------------------------------------------------------------------------
# Custom variables
# --------------------------------------------------------------------------
op1_G41      : 0
cc_pos_pre   : -1       # add variable       JHM 2021-02-12
#




# add variable to lsof$
lsof$            #Start of file for non-zero tool number, lathe
      sav_cc_1013 = cc_1013$
	  op1_G41 = 0                  # 2021-02-12 initialize variable for first op G41
      ltlchg$




# Added logic to ltlch$
ltlchg$          #Toolchange, lathe
      toolchng = one
      gcode$ = zero
      copy_x = vequ(x$)
      pcc_capture   #Capture LCC ends, stop output RLCC
      c_rcc_setup$  #Setup LCC on first 60000
      plcc_lead_begin  #Save original in sav_xa and shift copy_x for LCC comp.
      pcom_moveb    #Get machine position, set inc. from c1_xh
      c_mmlt$       #Position multi-tool sub, sets inc. current if G54...
      ptoolcomment
      comment$
      if home_type < two, #Toolchange G50/home/reference position
        [
        sav_xh = vequ(copy_x)
        sav_absinc = absinc$
        absinc$ = zero
        pmap_home   #Get home position, xabs
        ps_inc_calc #Set start position, not incremental
        #Toolchange home position
        if home_type = one,
          pbld, n$, *sgcode, pfxout, pfyout, pfzout, e$
        else,
          [
          #Toolchange g50 position
          pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], "W0.", e$
          toolno = t$ * 100 + zero
          if home_type = m_one, pbld, n$, *sgcode, *toolno, e$
          else, pbld, n$, *sg50, pfxout, pfyout, pfzout, e$
          ]
        pe_inc_calc #Update previous
        absinc$ = sav_absinc
        copy_x = vequ(sav_xh)
        ]
      toolno = t$ * 100 + tloffno$
      pbld, n$, *sgcode, *toolno, e$
      pbld, n$, pfsgplane, e$
      pcaxis_off_l  #Postblock for lathe transition
      pcom_moveb    #Reset machine position, set inc. from last position
      pcan
      pspindle
      if opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$),  #Do not enable spindle for point toolpath
        [
        if css_actv$,
          [
          if css_start_rpm, prpm  #Direct RPM startup for programmed CSS
          else, pcssg50, pcss  #NO RPM start - just output the CSS
          ]
        else, prpm  #Direct RPM was programmed
        ]
      sav_absinc = absinc$
      if home_type > one, absinc$ = zero
      # *************************************  New location of psccomp       *********************************************************	JHM 2021-02-12 for location of G41
	  pcan1, pbld, n$, #psccomp,                            #commented psccomp out to get correct location G41
	    *sgcode, pwcs, pfxout, pyout, pfzout,
        pscool, strcantext, e$
	
	  # *************************************  Changed location of rpm start *********************************************************	JHM 2021-02-12 for location of G41
	  if (opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$)) & css_start_rpm,  #Do not enable spindle for point toolpath
        pcssg50, pcss  #CSS output AFTER a G97S???? RPM spindle startup
	  
	  # *************************************  New location of psccomp       *********************************************************	JHM 2021-02-12 for location of G41
	  pbld, psccomp
	  if op1_G41=0, cc_pos_pre = cc_pos$     # Set previous variable for psccomp
	  op1_G41 = 1
	
      plcc_lead_end #Use sav_xa to position with comp. LCC
      pcom_movea    #Update previous, pcan2
	  
      ps_inc_calc   #Reset current
      absinc$ = sav_absinc
	   # *************************************  Changed location of rpm start *********************************************************	JHM 2021-02-12 for location of G41
      #if (opcode$ <> 106 | (opcode$ = 106 & suppress_point_spindle = no$)) & css_start_rpm,  #Do not enable spindle for point toolpath
      #  pcssg50, pcss  #CSS output AFTER a G97S???? RPM spindle startup
      c_msng$        #Position single-tool sub, sets inc. current if G54...
      toolchng = zero
      !op_id$, !lturret$, !tool_op$, prv_millcc = zero
      prev_spindle = spindle_no$  #Save spindle used in this operation
#end ltlchg$




# Edit prapidout to comment out psccomp in G0 movements
prapidout       #Output to NC, linear movement - rapid
      if lathecc = zero,
        [
        if millcc_flag & (abs(cuttype) = four | abs(cuttype) = two) & cutpos2$ = zero,  #Polar interpolation is active & Y-axis subs or Right face or Left face & before start point of operation geometry
          [
          if abs(cuttype) = four,  #Y-axis substitution, output C first on separate line
            [
            pcan1, pbld, n$, pexct, psgcode, pcout, e$
            pbld, n$, pexct, pxout, pyout, pzout, pscool, strcantext, e$
            ]
          else,  #Right or Left face cut, output Z last on separate line
            [
            pcan1, pbld, n$, pexct, psgcode, pxout, pyout, pcout, pscool, strcantext, e$
            pbld, n$, pexct, psgcode, pzout, e$
            ]
          ]
        else,
          [
          pcan1, pbld, n$, psgplane, pexct, psgcode, #psccomp,              # commented psccomp out for correct location output of G41
		    pwcs, pxout, pyout,
          pzout, pcout, pscool, strcantext, e$
          ]
        ]
      else,  #Lathe canned turning cycle
        [
        pcan1, pbld, n$, pexct, psgcode, #psccomp,                          # commented psccomp out for correct location output of G41
		  pxout, pyout, pzout, pcout, pscool, strcantext, e$
        ]
      if force_feed, result = force(feed)  # Force output of feed next time it's called for output
      if rpd_typ$ = 7, ptool_insp      #Tool inspection point
#end prapidout



# psccomp, added logic to forse G41/G42/G40 output to plane$=2 and prevent double output 
psccomp         #Output the cutter compensation based on the current plane
      if compok | lcc_compok >= two,
        [
        if plane$ = zero, sccomp
        if plane$ = one, sccomp1
        if plane$ = two,             #added logic, instead of sccomp2
		  [
		  if cc_pos_pre <> cc_pos$,    
		    [
		  	*sccomp2
		  	cc_pos_pre = cc_pos$
		  	]
		  ]
        ]
# end psccomp

which gives as a result:


G0 T1212
G18
G97 S2136 M03
G0 G54 X43.951 Z5.3 M8
G50 S3600
G96 S295
G42 G99 G1 Z3.3 F.2
Z-59.864
X46.447
G18 G3 X46.847 Z-60.064 K-.2
G1 Z-97.155
G40 X49.676 Z-95.741
G0 Z5.3
X41.055
G1 G42 Z3.3 F.2
Z-59.864
X43.951
G40 X46.78 Z-58.45
G0 Z5.3
X38.159
G1 G42 Z3.3 F.2
Z0.
Z-59.864
X41.055
G40 X43.884 Z-58.45
G0 X46.247
G28 U0. V0. W0. M05
T1200

I have not tested it yet, so test carefully 😀

Greetz,

Jan

Nice work and was alogn the lines I was thinking it would need to be done. Thank you for sharing, but like you said anyone should test and use at their own risk. I added two finish operations to the sample file with the same tool and different tool to allow me to check null tool changes and tool changes.

  • Thanks 1
Link to comment
Share on other sites
  • 1 month later...

Anyone have any insight into why psccomp doesn't return an output when you just remove it from prapidout? It's in plinout, but doesn't seem to do anything as far as outputting comp.

Milling ops and end of lathe ops force psccomp somehow as well.

I found a dirty solution, just wondered what's actually driving in the background.  

Link to comment
Share on other sites
13 hours ago, Kalibre said:

Anyone have any insight into why psccomp doesn't return an output when you just remove it from prapidout? It's in plinout, but doesn't seem to do anything as far as outputting comp.

Milling ops and end of lathe ops force psccomp somehow as well.

I found a dirty solution, just wondered what's actually driving in the background.  

There are flags in the NCI Data which tell MP to output a Comp On or Off command.

The reason why you don't see the output from all the places 'psccomp' is called, is due to a feature of the Post Language, called Modality.

Modality tells the software to 'only output a new value, when the old value has changed. But do not continue to output redundant tokens to the NC File. Only output values if the value has changed.

You shouldn't remove the extra calls to 'psccomp', unless you really know what you are doing. It is easy to inadvertently break the existing mechanisms inside the Post.

There are many calls to 'psccomp', because Canned Text can be used to turn Comp on/off at any point within the path itself.

 

Link to comment
Share on other sites
2 hours ago, Colin Gilchrist said:

There are flags in the NCI Data which tell MP to output a Comp On or Off command.

The reason why you don't see the output from all the places 'psccomp' is called, is due to a feature of the Post Language, called Modality.

Modality tells the software to 'only output a new value, when the old value has changed. But do not continue to output redundant tokens to the NC File. Only output values if the value has changed.

You shouldn't remove the extra calls to 'psccomp', unless you really know what you are doing. It is easy to inadvertently break the existing mechanisms inside the Post.

There are many calls to 'psccomp', because Canned Text can be used to turn Comp on/off at any point within the path itself.

 

Thanks for the response Colin.

I don't quite understand the Canned Text comment. Are you saying there's no reason for a solution like  Werktuigbouwer's or the absolute clusterf*ck I've mashed together because there's already built in ability to control the output position? Or a person would still have to build the logic in to exploit that from NCI 1025 or similar?

Link to comment
Share on other sites
22 minutes ago, Kalibre said:

Thanks for the response Colin.

I don't quite understand the Canned Text comment. Are you saying there's no reason for a solution like  Werktuigbouwer's or the absolute clusterf*ck I've mashed together because there's already built in ability to control the output position? Or a person would still have to build the logic in to exploit that from NCI 1025 or similar?

I don't want to say that, as I haven't been keeping up with either of these threads specifically. But there is the "built in ability" to trigger M-Code and/or G-Code Text Strings. It is called Canned Text, and has existed inside Mastercam for many years. Since back in the V9 days, and possibly a bit before that.

Canned Text can is actually the mechanism used to "expand V9 Coolant", from a single variable, to the option of 10 on/off pairs of m-codes, which is referred to as "X-Style Coolant".

Some Toolpaths support the "Change at Point" function, which allows you to output Canned Text at a specific position along the chain. The issue is "what happens if you output multiple passes or depth cuts"? This is where Change at Point is limited. I don't know what Lathe or Mill paths support it specifically. I commonly use this function with Contour Toolpaths. The benefits of Change at Point is that these changes 'stick' as part of the geometry input to the path itself. 

Then, for changes on a deper level, there is always the Toolpath Editor. Here, you can make changes at any point along the path. But be careful, these changes can sometimes corrupt a path. Also be careful about Modality when it comes to Feed and/or Rapid changes, and especially if you are changing Depths. Here, you can output Canned Text at most points. 

When this occurs, you simply get a 1025 Line, in the midst of your NCI Data stream.

 

Now, is this the right way to fix your issue? Likely not. I'd really have to dig into your Post, and look at the issue you are having in-depth. I honestly have quite a few different people seeking out my help with Post issues. So I hopefully didn't stir up trouble for you, but I'm always of the opinion that we should learn as much as possible about how the system functions, so we can have meaningful control over the output of every Toolpath. I would be willing to dive into this at some point on my YouTube channel, but there are a couple of requests which I've arranged to cover first.

Link to comment
Share on other sites
8 minutes ago, Colin Gilchrist said:

I don't want to say that, as I haven't been keeping up with either of these threads specifically. But there is the "built in ability" to trigger M-Code and/or G-Code Text Strings. It is called Canned Text, and has existed inside Mastercam for many years. Since back in the V9 days, and possibly a bit before that.

Canned Text can is actually the mechanism used to "expand V9 Coolant", from a single variable, to the option of 10 on/off pairs of m-codes, which is referred to as "X-Style Coolant".

Some Toolpaths support the "Change at Point" function, which allows you to output Canned Text at a specific position along the chain. The issue is "what happens if you output multiple passes or depth cuts"? This is where Change at Point is limited. I don't know what Lathe or Mill paths support it specifically. I commonly use this function with Contour Toolpaths. The benefits of Change at Point is that these changes 'stick' as part of the geometry input to the path itself. 

Then, for changes on a deper level, there is always the Toolpath Editor. Here, you can make changes at any point along the path. But be careful, these changes can sometimes corrupt a path. Also be careful about Modality when it comes to Feed and/or Rapid changes, and especially if you are changing Depths. Here, you can output Canned Text at most points. 

When this occurs, you simply get a 1025 Line, in the midst of your NCI Data stream.

 

Now, is this the right way to fix your issue? Likely not. I'd really have to dig into your Post, and look at the issue you are having in-depth. I honestly have quite a few different people seeking out my help with Post issues. So I hopefully didn't stir up trouble for you, but I'm always of the opinion that we should learn as much as possible about how the system functions, so we can have meaningful control over the output of every Toolpath. I would be willing to dive into this at some point on my YouTube channel, but there are a couple of requests which I've arranged to cover first.

I've used canned text for drilling output and a few M codes/macro calls before, but I was ready to light my desk on fire if I missed a simple fix for psccomp behavior in this instance.  Oddly, it only comes up in the lathe side of the post. Remove psccomp from ltlchg$ and comp doesn't output until it's cancelled.

Yet psccomp isn't even part of mtlchg$ and it still reads it and outputs comp in plinout/prapidout just fine.

Overall, it's an interesting quirk and was fun in a "throw your keyboard" kind of way to find a work around for.

My post may be ugly as sin and would make anybody else cry, but the code comes out pretty and error free at least. 🤣

I appreciate the insight Colin, thank you. I'll be sure to check out your channel, you're a wealth of good info on here.

Link to comment
Share on other sites
48 minutes ago, Kalibre said:

I've used canned text for drilling output and a few M codes/macro calls before, but I was ready to light my desk on fire if I missed a simple fix for psccomp behavior in this instance.  Oddly, it only comes up in the lathe side of the post. Remove psccomp from ltlchg$ and comp doesn't output until it's cancelled.

Yet psccomp isn't even part of mtlchg$ and it still reads it and outputs comp in plinout/prapidout just fine.

Overall, it's an interesting quirk and was fun in a "throw your keyboard" kind of way to find a work around for.

My post may be ugly as sin and would make anybody else cry, but the code comes out pretty and error free at least. 🤣

I appreciate the insight Colin, thank you. I'll be sure to check out your channel, you're a wealth of good info on here.

Making the NC code run without edits is the best part. I'm sure some of my first code edits weren't the prettiest, but they got the job done. The code I can write today is much nicer looking, but I owe that to all the work that came before. Glad to hear that you've got something working, pretty or not.

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