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:

Recommended Posts

I'm trying to get my post to change my sub number to the tool number times 100 and I can't get the sub number to change to at all.

 

What I I'm getting is this:

 

( ROUGH PROFILE )

T1 M6 ( .375 ROUGHER E.M. )

G0 G90 G54 X-.145 Y.3445 S12000 M3

G43 H1 Z.1 M8 T2

M97 P0001

( ROUGH PROFILE )

G90 G55 X-.145 Y.3445 Z.1

M97 P0001

M9

G91 G28 Z0. M5

M01

( FACE TOP )

T2 M6 ( .375 E.M. )

G0 G90 G54 X.7455 Y-1.385 S12000 M3

G43 H2 Z.1 M8 T3

M97 P0002

( FACE TOP )

G90 G55 X.7455 Y-1.385 Z.1

M97 P0002

M9

G91 G28 Z0. M5

M01

 

And what I want is this:

 

 

( ROUGH PROFILE )

T1 M6 ( .375 ROUGHER E.M. )

G0 G90 G54 X-.145 Y.3445 S12000 M3

G43 H1 Z.1 M8 T2

M97 P100

( ROUGH PROFILE )

G90 G55 X-.145 Y.3445 Z.1

M97 P100

M9

G91 G28 Z0. M5

M01

( FACE TOP )

T2 M6 ( .375 E.M. )

G0 G90 G54 X.7455 Y-1.385 S12000 M3

G43 H2 Z.1 M8 T3

M97 P200

( FACE TOP )

G90 G55 X.7455 Y-1.385 Z.1

M97 P200

M9

G91 G28 Z0. M5

M01

 

 

I've been trying to change stuff in the post here:

 

psub_call_s$ #Call to sub level

result = nwadrs(strp, sub_prg_no$)

sub_prg_no$ = sub_prg_no$ + 1000 #Add sub number offset <------------------- I tried several different ways of doing the "=" on this line but I can't get it to change at all.

if progno$ = sub_prg_no$, result = mprint(sprgnerror)

pbld, n$, "M97", *sub_prg_no$, e$

 

I'm not even sure if I'm trying in the right place or not.

 

I'd also like it to give me the program number + 1 for each sub for a different post. I'm guessing the change between the two would be pretty similar.

 

Thank you very much.

Link to comment
Share on other sites

TRY THIS

 

 

psub_call_s$ #Call to sub level

result = nwadrs(strp, sub_prg_no$)

sub_prg_no$ = sub_prg_no$ + sav_progno + 100 #Add sub number offset

if sav_progno = sub_prg_no$, result = mprint(sprgnerror)

pbld, n$, "M98", *sub_prg_no$, e$

 

psub_st_s$ #Header in sub level

result = nwadrs(stro, sub_prg_no$)

*e$

*sub_prg_no$, [if scomm_sav <> snull, "", spaces$=0, scomm_str, "SUB OF ", *progno$, scomm_end], spaces$=sav_spc, e$

n$, spaces$ = 0, scomm_str, [if opcode$ <> 3, *sub_t, "= ",else,"", spaces$=sav_spc],

[spaces$ = 0, ptoolcomm, spaces$=sav_spc],", CUT#", spaces$ = 0, sOpSeqNo, scomm_end, spaces$=sav_spc, e$

 

 

if last_op_id = op_id$,

scomm_str, spaces$=0, *pwcs, *pfcout, *scomm_sav, scomm_end, spaces$ = sav_spc, e$

pbld, n$, sgabsinc, e$

pcan

 

if output_z = yes$,

[

[

#n$, pspc, scomm_str, "MAX - ", *max_depth, scomm_end, e$

n$, spaces$ = 0, scomm_str, "DOC= ", *min_depth, scomm_end, spaces$ = sav_spc, e$

]

]

 

 

psub_end_s$ #End in sub level

n$, "M99", e$

prv_absinc$ = -1

Link to comment
Share on other sites

This will set the subprogram number, equal to the tool number, times one hundred.

 

sub_prg_no$ = t$ * 100

 

Depending on the calling order of the post blocks, you may also need to add that line of code in the 'psub_st_s$' post block as well.

 

To add to that might also think about a process to have it incremented. If you are calling the same tool through out the program in different places then you will get the same sub program call and not unique ones. I controlled this in the past with a mi or mr so I could detail it down to a very finite level.

Link to comment
Share on other sites

Colin G. - Eapprentice.net, on 03 July 2014 - 10:05 PM, said:

 

This will set the subprogram number, equal to the tool number, times one hundred.

 

 

sub_prg_no$ = t$ * 100

Depending on the calling order of the post blocks, you may also need to add that line of code in the 'psub_st_s$' post block as well.

 

I've tried putting this in the psub_call_s$ and psub_st_s$.

 

I still can't get it to work.

 

This is what I have in my post now:

 

psub_call_s$ #Call to sub level

result = nwadrs(strp, sub_prg_no$)

sub_prg_no$ = t$ * 100 #Add sub number offset

if progno$ = sub_prg_no$, result = mprint(sprgnerror)

pbld, n$, "M97", *sub_prg_no$, e$

 

psub_st_s$ #Header in sub leveln

result = nwadrs(strn, sub_prg_no$)

sub_prg_no$ = t$ * 100

if first_sub & subs_before, first_sub = zero #suppress blank line before first sub with subs before main

else, " ", e$

*sub_prg_no$, e$

pbld, n$, sgabsinc, e$

 

psub_end_s$ #End in sub level

n$, "M99", e$

prv_absinc$ = -1

Link to comment
Share on other sites

To add to that might also think about a process to have it incremented. If you are calling the same tool through out the program in different places then you will get the same sub program call and not unique ones. I controlled this in the past with a mi or mr so I could detail it down to a very finite level.

 

I haven't used a mi or mr at all. How could I use to get the subs to increment?

 

Thank you.

Link to comment
Share on other sites

sub_prg_no$ = mr1$ * 100 Then you just put your value in the operation where the sub is starting from. Might have to so a sav_mr1$ process, but without testing would be a guess.

 

sub_prg_n0$ = (t$ * 100) + mr1$ could be another way to do it where you get what you had plus an increment amount from the mi1$, but here it could be mr or mi to do this. I would have to test all of this before I could say 100% what is warkable or not. That is where you wade through the mud getting the keys to the castle putting in the effort to figure it out. :turned:

Link to comment
Share on other sites

I would make a cautionary statement here. All of the variables that end with $ are automatically populated by Mastercam and are called System Variables. Unless you know exactly what they are used for, it would be prudent to not modify them in any way. The preferred approach would be to create a user defined variable to hold any formatted and/or calculated values.

 

Some system variables are accessed at multiple places throughout the post, and their values should not be manipulated in most cases.

 

JM2C

Link to comment
Share on other sites

I've had to add some logic and a postblock to increment my tool N numbers when the same tool is used at different times. The way we number sequences here is pretty simple: the first time a tool is called up it is simply N and the tool number, ie N3. The second time it is used it is N302, the N303 and so on.

 

This same method could probably be used to increment your sub program numbers, without the need to use a misc int or real.

 

If you're interested in the code let me know and I'll post it. Right now I'm supposed to be working ;)

Link to comment
Share on other sites

I've had to add some logic and a postblock to increment my tool N numbers when the same tool is used at different times. The way we number sequences here is pretty simple: the first time a tool is called up it is simply N and the tool number, ie N3. The second time it is used it is N302, the N303 and so on.

 

This same method could probably be used to increment your sub program numbers, without the need to use a misc int or real.

 

If you're interested in the code let me know and I'll post it. Right now I'm supposed to be working ;)

I would be interested in looking at that code to see if it would help me with my post.

 

Thank you.

Link to comment
Share on other sites

n$ is the system variable that handles N number output.  It increments automatically every time it is output.  Create your own variable for supplemental N number output like this:

 

fmt  "N" 4 nt               #Supplemental sequence number
 

Then,

 

nt = n$ * 100 + 1

 

Then, every time that you output nt, you need a line like this:

 

nt = nt + 1

 

That is all that you need to do.  :cheers:

 

 

Link to comment
Share on other sites

 

n$ is the system variable that handles N number output.  It increments automatically every time it is output.  Create your own variable for supplemental N number output like this:

 

fmt  "N" 4 nt               #Supplemental sequence number

 

Then,

 

nt = n$ * 100 + 1

 

Then, every time that you output nt, you need a line like this:

 

nt = nt + 1

 

That is all that you need to do.  :cheers:

 

Which is fine for the N number, but dealing with tool tracking and subprogram numbering, it isn't relevant. I wasn't very clear in my post when I was talking about sequence numbering: We don't use N numbers at all ~except~ at a tool change, and that N number always corresponds to the number of the tool being used. For example, a simple program would look like this:

 

N3 (SPOT DRILL)

G0 G40 G80 G90 G54 S1000 M3

G43 H3 X0 Y0 Z1. T2 M8

...

...

M6

N2 (DRILL)

G0 G40 G80 G90 G54 S1000 M3

G43 H2 X0 Y0 Z1. T3 M8

...

...

M6

N302 (SPOT DRILL)

....

 

And on and on.

 

Notice how the N number is tied to the tool number. As the tool is used multiple times, the N number keeps track and increments itself accordingly. This can be tied to a subprogram number, so the first time tool three does it's own subprogram, it can be M98 P0030. Then the subprogram for the next tool can call M98 P0020. When it goes back to tool three, and calls a new subprogram, it will be M98 P0031.

 

Keep it mind I'm an amateur at post stuff, so there may be easier ways to do this.

 

For the tool tracking, the first thing I did was create a few variables and strings:

 

fmt "N" 4 tool_seq     #Tool sequence variable

 

nt1 : 0                       #Initialize tool track string

nt2 : 0

nt3 : 0

fmt   " "  2   seqmult  

I actuallly have a "nt" for each tool, so there are 30 lines. This is what makes me think there is an easier way to do this, but this works for now.

 

Then in the psof postblock and tool change postblocks, I added the following lines:

 

      ptoolnum                 #Call tool track postblock

      if seqmult > 1, tool_seq = t$ *100 + seqmult

      else,  tool_seq = t$

      *tool_seq, sopen_prn, pstrtool, sclose_prn, e$

 

If your post doesn't call up the first tool in the psof postblock, you'll have to find it.

 

 

Then I made a simple postblock that does the tracking logic and stores them in the variables:

 

ptoolnum       #Change N number for multiple calls of same tool

    

    if t$ = 1, nt1 = nt1 + 1, seqmult = nt1

    if t$ = 2, nt2 = nt2 + 1, seqmult = nt2

    if t$ = 3, nt3 = nt3 + 1, seqmult = nt3

   again, there is a line line this for every tool up to 30

 

 

So what happens is, as a tool change is called, the post already has the t$ number ready to use. It goes to the ptoolnum post block, finds what tool it is, and changes the "nt" string that I made up to keep track of the tool use. It then sets the seqmult string variable to the count that the string has.

 

When it finishes that postblock and goes back to the toolchange postblock, as long as seqmult is greater than one (as long as the tool has been used more than once) it adjusts the tool_seq variable I made to add the string count.

     

Hopefully this helps.

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