Sign in to follow this  
BlaskoM

Z depth as macro variable

Recommended Posts

Hello, I am new to mastercam and the post processes but I am taking over some basic mastercam programming responsibilities  from a co worker. 

What I can't figure out is how to make the post create code with the Z depths as macro variables.

In my tool path parameters under linking parameters it has the feed plane at 6 so it puts Z6. in the post code.

What I want is Z[#502+7.00]

Is there a way I can do that? If I try to put [#502+7.00] directly in the box i linking parameters, it crashes mastercam because it does not know the # symbol

 

Thanks

  • Like 1

Share this post


Link to post
Share on other sites

You would have to create a logic process using mi and mr triggers to accomplish this task. Mastercam is not a macro output by nature software. It can be done, but heavy post work IMHO would need to be done to accomplish that task.

Welcome to the Mastercam forum.

Share this post


Link to post
Share on other sites
On 3/14/2020 at 8:45 AM, BlaskoM said:

Hello, I am new to mastercam and the post processes but I am taking over some basic mastercam programming responsibilities  from a co worker. 

What I can't figure out is how to make the post create code with the Z depths as macro variables.

In my tool path parameters under linking parameters it has the feed plane at 6 so it puts Z6. in the post code.

What I want is Z[#502+7.00]

Is there a way I can do that? If I try to put [#502+7.00] directly in the box i linking parameters, it crashes mastercam because it does not know the # symbol

 

Thanks

Part of the issue is: do you want "all Z Values" coming out of the Post to have that Variable output, or "just the Clearance Value at the Tool Change Event?

You can use the 'new address' function to assign different prefix and suffix values to the numerical output.

I made these edits to MPMaster, to get the output you are looking for. Warning: use this at your own risk! No warranty is expressed or implied, and Selway Machine Tool is not liable for and edits you make to your Post Processor. (Make sure you make a backup copy (at least 2 copies!!!) of your Post before you start!)

First, create some variables:

sav_zabs    : 0     #Saved Z Abs Value
str_z_pvar   : "Z[#502+"
str_z_svar   : "]"
str_z_pstd   : "Z"
str_z_sstd   : ""

 

Inside "ptlchg_com", change this:

      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

To This:

      phsm1_on        #must remain before G43
      ### CMG START CHANGES- We must manipulate the formatting for 'zabs' (output in pfzout), but then we must restore it afterwards!
      sav_zabs = zabs # Store current for restore
      result = nwadrs(str_z_pvar, zabs) #Assign new prefix string to zabs
      result = nwsufx(str_z_svar, zabs) #Assign new suffix string to zabs
      zabs = sav_zabs, prv_zabs = c9k #set current to output, force output by setting previous to c9k
      pbld, n$, "G43", *tlngno$, pfzout, scoolant, next_tool$, e$
      #Set Z back to normal output
      result = nwadrs(str_z_pstd, zabs) #Assign original prefix string to zabs
      result = nwsufx(str_z_sstd, zabs) #Assign original suffix string to zabs
      zabs = sav_zabs, !zabs #set current to output, update variable to maintain proper modality
      #CMG END CHANGES
      pcan2           #Added so M and G codes in canned text will output before phsm2_on

 

 

Here is the output I got from a simple rectangle:

%
O0123 (T)
(MCX FILE  - T)
(PROGRAM   - T.NC)
(DATE      - MAR-16-2020)
(TIME      - 9:32 AM)
(T3   - 5/8 FLAT ENDMILL     - H3   - D3   - D0.6250")
G00 G17 G20 G40 G80 G90
G91 G28 Z0.
(COMPENSATION TYPE - COMPUTER)
M08
T3 M06 (5/8 FLAT ENDMILL)
(MAX - Z5.1234)
(MIN - Z0.)
G00 G17 G90 G54 X-2.8265 Y-.7537 S11111 M03
G49
G94
G05.1 Q1
G43 H3 Z[#502+5.1234]
Z.2
G95 G01 Z0. F.0079
X-2.2015 F.02
G03 X-1.5765 Y-.1287 I0. J.625
G01 Y.6999
G02 X-1.264 Y1.0124 I.3125 J0.
G01 X1.2453
G02 X1.5578 Y.6999 I0. J-.3125
G01 Y-.9574
G02 X1.2453 Y-1.2699 I-.3125 J0.

 

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • 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