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:

Posting subrograms with .nc or .sub extension


Recommended Posts

1 minute ago, balnh said:

Good morning, I messed around with a post to post subs as individual programs. I followed the instructions in this link:

https://forum.mastercam.com/Topic24759.aspx

Posting works as planned except it posts with a .sub file extension. What do I need to do to post out subs with a .nc file extension. 
 

Thanks 

I would look in the Control Definition.

Link to comment
Share on other sites

Try the following:

Look at the sextaux$  and sextsub$ line

pheader$
   result = setncstr(two, spathnc$ + snamenc$ + sextnc$)

psub_st_s$
      result = fclose(spathaux$ + snameaux$ + sextaux$)
      snameaux$ = drs_str(two, sub_prg_no$)
      sextaux$ = ".nc"
      result = setncstr(two, spathaux$ + snameaux$ + sextaux$)
 
psub_st_m$
      result = fclose(spathsub$ + snamesub$ + sextsub$)
      snamesub$ = drs_str(two, main_prg_no$)
      sextsub$ = ".nc"
      result = setncstr(two, spathsub$ + snamesub$ + sextsub$)
  • Like 3
Link to comment
Share on other sites
47 minutes ago, Werktuigbouwer said:

Try the following:

Look at the sextaux$  and sextsub$ line


pheader$
   result = setncstr(two, spathnc$ + snamenc$ + sextnc$)

psub_st_s$
      result = fclose(spathaux$ + snameaux$ + sextaux$)
      snameaux$ = drs_str(two, sub_prg_no$)
      sextaux$ = ".nc"
      result = setncstr(two, spathaux$ + snameaux$ + sextaux$)
 
psub_st_m$
      result = fclose(spathsub$ + snamesub$ + sextsub$)
      snamesub$ = drs_str(two, main_prg_no$)
      sextsub$ = ".nc"
      result = setncstr(two, spathsub$ + snamesub$ + sextsub$)

Thanks. That did it. I appreciate the help. 

  • Like 1
Link to comment
Share on other sites
  • 2 years later...

I was hoping the link in the OP was still good but it's not.

I'm working with a slightly modified MPFAN post, looking to have subprograms output as individual files. A while back I saw a post explaining how to do this but I can't seem to find it again. Any chance someone can point me in the right direction here? I honestly don't know where to even start.

MC2023 TIA

Link to comment
Share on other sites
Just now, JParis said:

I am curious as to why you would want them as separate files as opposed to in the same file?

In my own head it seems they would be easier to manage all in a single file..

Thanks for the response. If they're all in a single file, when we load them into the machine it splits them into separate files. Then when we go to save the programs they save as separate files. So we either have to mush them all back together, or save each file individually. I imagine it would be less work to start with them split up.

If there's a better way around this issue I'm all ears. We don't do a ton with sub programs so I'd guess our "sub program best practices" may be lacking.

Link to comment
Share on other sites

I remember back in the day on some older Fanucs...I would have them all after the M30....

I would make sure there was no % as that signals the end of the program, after the M30. I would edit the M30 to M99 for loading, then change it back after loading it..

The larger answer to separate subs is using the subout command....though I would have to mess with it to figure it out, perhaps someone has a concise answer

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

I remember back in the day on some older Fanucs...I would have them all after the M30....

I would make sure there was no % as that signals the end of the program, after the M30. I would edit the M30 to M99 for loading, then change it back after loading it..

 

Here's the current code:

%

O1314
G90 G80 G40 G0 G49 G17
 
N138 M6 T138 ( 1/2 EM )
M22
G90 G0 G54.1 P1 B0.
M21
G5.1 Q1
G0 G90 G54.1 P1 X-3.1165 Y-2.3 S7640 M3
G43 H138 Z1. M8 T104
M50
M98 P0001


G90 G54.1 P8 X-3.1165 Y-2.3
Z1.
M98 P0001
G5.1 Q0
M09
M22
M5
G49 G53 Z0.
M00 (changed from M30)

 

O0001

(code)

M99

%

We just tried loading this into the machine and it split the programs into two programs O1234 and O0001.

I was excited about the changing the M30 suggestion but it seems like the machine may break up the program each time it sees an O.

Link to comment
Share on other sites
Just now, JParis said:

What control?

I know for our Mazaks the internal calls work as such

M98H40001

that calls 

N40001

at the bottom..

You might look through the controls book and see if it calls internal subs using different headers

 

Fanuc G-Tech 16i

I'll take a look thru the book because I've only ever seen M98 Pxxxx to call Oxxxx. I've never seen M98 Hxxxx to call Nxxxx.

I'll follow up

Link to comment
Share on other sites

Here's the response from @cncappsjames:

Set #3201.6(NPE) = 1 Program registration not completed on M02, M30, or M99

Set #3201.5(N99) = 1 Program registration not completed on M99

Set #6005.0 (SBC) = 1 This will allow you to use Q as a line number jump.

I have not tested this yet but it looks promising. I'll return with results after testing.

  • Like 2
Link to comment
Share on other sites
16 hours ago, JParis said:

That'll make file management a WHOLE lot easier!

You ain't kidding. We've got a job with 110 tools and each has its own separate sub program, really makes a mess.

After changing the parameters James suggested this is the code I end up with:

%
O1314(MAIN PROGRAM)

(T1 SUB CALL)
M98 P0001 Q1234

(T2 SUB CALL)
M98 P0001 Q1235

M30
%

%
O0001(SUBPROGRAMS)

(T1 SUB)
N1234
(CODE)
M99

(T2 SUB)
N1235
(CODE)
M99
%


So I have a main program and I have a second program with all my sub programs in it. The Pxxxx is still a regular subprogram call, but the Qxxxx tells the machine to start on line Nxxxx within the subprogram.

My next question is what you use for a naming convention, here's what I'm thinking:

N101033

10 (op#10) 1 (1st call) 033 (tool #33)

N253112

25 (op#25) 3 (3rd call)  112 (tool #112)

Because we will have multiple ops, and possibly multiple tool callouts, this seems like a good solution. But I'm interested to hear others thoughts on this.

 

Link to comment
Share on other sites

I keep mine very simple...

Every single program I post the subs start numbering at 40001 and just continue. Because everything is in the one file, I can use those numbers in each and every program. It makes no difference what OP....

MInd you, this is Tool #1 that works on 4 parts on 3 sides of a tombstone and has controls built in to control to choose how the program will run...that's the macro options

G20
G0G17G40G49G80G90
G0G28G91Z0.
M00
()
IF[#925EQ3]GOTO88001
()
(1/2 3FL ENDMILL TOOL - 11010500 DIA. OFF. - 51999 LEN. - 51999 TOOL DIA. - .5)
(1/2 ENDMILL / R-F-MILL SIDE STEPS MILL .650 WIDE  / Z-.080)
(MAX Z DEPTH - Z1.)
(MIN Z DEPTH - Z-.862)
(OPERATION #1)
N1000
T11010500M6
IF[#925NE0]GOTO80001
T11010188
N80001
G90G10L10P#51999R0
G90G10L12P#51999R0
S18000M3
M8
()
IF[#925EQ1]GOTO10101
IF[#925EQ2]GOTO10108
IF[#925EQ4]GOTO10117
IF[#900EQ1]GOTO10101
IF[#900EQ0]GOTO30101
N10101
()
G0G90B0.
G0G90G54.1P101X-2.315Y1.2448
G43H#51999Z1.
M98H40001
(1/2 ENDMILL / R-F-MILL SIDE STEPS MILL .650 WIDE  / Z-.080)
G0G90Z12.
()
IF[#925EQ1]GOTO30100
()
N30101
IF[#901EQ1]GOTO10102
IF[#901EQ0]GOTO30102
N10102
()
G0G90B0.
G54.1P102X-2.315Y1.2448
G43H#51999Z1.
M98H40001
(1/2 ENDMILL / R-F-MILL SIDE STEPS MILL .650 WIDE  / Z-.080)
G0G90Z12.
()
N30102
IF[#902EQ1]GOTO10103
IF[#902EQ0]GOTO30103
N10103
()
G0G90B0.
G54.1P103X-2.315Y1.2448
G43H#51999Z1.
M98H40001
(1/2 ENDMILL / R-F-MILL SIDE STEPS MILL .650 WIDE  / Z-.080)
G0G90Z12.
()
N30103
IF[#903EQ1]GOTO10104
IF[#903EQ0]GOTO30104
N10104
()
G0G90B0.
G54.1P104X-2.315Y1.2448
G43H#51999Z1.
M98H40001
(1/2 R-MILL / R-MILL OUTSIDE PROFILE / Z-.74)
(OPERATION #3)
N1001
G0G90Z12.
()
N30104
IF[#903EQ1]GOTO10105
IF[#903EQ0]GOTO30105
N10105
()
G0G90B90.
G54.1P10X-1.5185Y-2.2413
Z1.
M98H40002
(1/2 R-MILL / R-MILL OUTSIDE PROFILE / Z-.74)
(OPERATION #3)
N1016
G0G90Z12.
()
N30105
IF[#902EQ1]GOTO10106
IF[#902EQ0]GOTO30106
N10106
()
G0G90B90.
G54.1P7X-1.5185Y-2.2413
Z1.
M98H40002
(1/2 R-MILL / R-MILL OUTSIDE PROFILE / Z-.74)
(OPERATION #3)
N1031
G0G90Z12.
()
N30106
IF[#901EQ1]GOTO10107
IF[#901EQ0]GOTO30107
N10107
()
G0G90B90.
G54.1P4X-1.5185Y-2.2413
Z1.
M98H40002
(1/2 R-MILL / R-MILL OUTSIDE PROFILE / Z-.74)
(OPERATION #3)
N1046
G0G90Z12.
()
N30107
IF[#900EQ1]GOTO10108
IF[#900EQ0]GOTO30108
N10108
()
G0G90B90.
G54.1P1X-1.5185Y-2.2413
G43H#51999Z1.
M98H40002
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.390)
(OPERATION #19)
N1061
G0G90Z12.
()
IF[#925EQ2]GOTO10109
()
N30108
IF[#900EQ1]GOTO10109
IF[#900EQ0]GOTO30109
N10109
()
G0G90B0.
G54.1P2X.3978Y.7071
Z1.
M98H40003
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.390)
(OPERATION #19)
N1063
G0G90Z12.
()
IF[#925EQ2]GOTO10116
()
N30109
IF[#901EQ1]GOTO10110
IF[#901EQ0]GOTO30110
N10110
()
G0G90B0.
G54.1P5X.3978Y.7071
Z1.
M98H40003
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.390)
(OPERATION #19)
N1065
G0G90Z12.
()
N30110
IF[#902EQ1]GOTO10111
IF[#902EQ0]GOTO30111
N10111
()
G0G90B0.
G54.1P8X.3978Y.7071
Z1.
M98H40003
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.390)
(OPERATION #19)
N1067
G0G90Z12.
()
N30111
IF[#903EQ1]GOTO10112
IF[#903EQ0]GOTO30112
N10112
()
G0G90B0.
G54.1P11X.3978Y.7071
Z1.
M98H40003
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.280)
(OPERATION #22)
N1069
G0G90Z12.
()
N30112
IF[#903EQ1]GOTO10113
IF[#903EQ0]GOTO30113
N10113
()
G0G90B180.
G54.1P12X-.0328Y-1.3437
Z1.
M98H40004
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.280)
G0G90Z12.
()
N30113
IF[#902EQ1]GOTO10114
IF[#902EQ0]GOTO30114
N10114
()
G0G90B180.
G54.1P9X-.0328Y-1.3437
Z1.
M98H40004
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.280)
G0G90Z12.
()
N30114
IF[#901EQ1]GOTO10115
IF[#901EQ0]GOTO30115
N10115
()
G0G90B180.
G54.1P6X-.0328Y-1.3437
Z1.
M98H40004
(1/2 R-MILL / R-MILL SIDE RECESS / Z-.280)
G0G90Z12.
()
N30115
IF[#900EQ1]GOTO10116
IF[#900EQ0]GOTO30116
N10116
()
G0G90B180.
G54.1P3X-.0328Y-1.3437
Z1.
M98H40004
(1/2 R-MILL / R-MILL EXCESS STOCK / Z+.010)
(OPERATION #24)
N1070
G0G90Z12.
()
IF[#925EQ2]GOTO30100
()
N30116
IF[#900EQ1]GOTO10117
IF[#900EQ0]GOTO30117
N10117
()
G0G90B270.
G54.1P17X-1.3827Y-2.1882
G43H#51999Z1.
M98H40005
(1/2 R-MILL / R-MILL EXCESS STOCK / Z+.010)
G0G90Z12.
()
IF[#925EQ4]GOTO30100
()
N30117
IF[#901EQ1]GOTO10118
IF[#901EQ0]GOTO30118
N10118
()
G0G90B270.
G54.1P18X-1.3827Y-2.1882
Z1.
M98H40005
(1/2 R-MILL / R-MILL EXCESS STOCK / Z+.010)
G0G90Z12.
()
N30118
IF[#902EQ1]GOTO10119
IF[#902EQ0]GOTO30119
N10119
()
G0G90B270.
G54.1P19X-1.3827Y-2.1882
Z1.
M98H40005
(1/2 R-MILL / R-MILL EXCESS STOCK / Z+.010)
G0G90Z12.
()
N30119
IF[#903EQ1]GOTO10120
IF[#903EQ0]GOTO30100
N10120
()
G0G90B270.
G54.1P20X-1.3827Y-2.1882
Z1.
M98H40005
()
N30100
()
M9
M5
G0G28G91Z0.
G90G10L10P#51999R0
G90G10L12P#51999R0
M01

 

  • Thanks 1
  • Like 3
Link to comment
Share on other sites
8 minutes ago, Tim Johnson said:

What kind of fixtures are you using?

We use custom fixtures. 

Matsuura H.Plus-630 4-axis HMC. We have a custom tombstone on the machine pallet and custom fixtures on the tombstone.

 Tombstone City Link This is similar to the custom tombstones we use.

The fixtures are all 4140 steel with mitee bites to hold the parts. 

Link to comment
Share on other sites
2 hours ago, Jake L said:

After changing the parameters James suggested this is the code I end up with:

%
O1314(MAIN PROGRAM)

(T1 SUB CALL)
M98 P0001 Q1234

(T2 SUB CALL)
M98 P0001 Q1235

M30
%

%
O0001(SUBPROGRAMS)

(T1 SUB)
N1234
(CODE)
M99

(T2 SUB)
N1235
(CODE)
M99
%


So I have a main program and I have a second program with all my sub programs in it. The Pxxxx is still a regular subprogram call, but the Qxxxx tells the machine to start on line Nxxxx within the subprogram.

 

New discovery. My machine provider just got back to me. I can omit the Pxxxx from the M98 call line and it will search the current program for Nxxxx based on Qxxxx.

%
O1314(MAIN PROGRAM)

(T1 SUB CALL)
M98 Q1234

(T2 SUB CALL)
M98 Q1235

M30


(T1 SUB)
N1234
(CODE)
M99

(T2 SUB)
N1235
(CODE)
M99
%

 

Link to comment
Share on other sites
17 minutes ago, Jake L said:

New discovery. My machine provider just got back to me. I can omit the Pxxxx from the M98 call line and it will search the current program for Nxxxx based on Qxxxx.

That was one of my suggestions further up  :)

That will allow single program now

 

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