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:

SUB PROGRAMS


specv
 Share

Recommended Posts

How much work would it be to change my post to output subprograms like this? as of right now the main looks almost like i want it but the subs still come out as seperate programs.

 

Main body:

 

N8T[#701]M6

N9T[#703]/M26

(4.0 DIA 5 FL FACE MILL)

N10G65P9222A4.981

N11G4P1M26

N12G0G55X-2.1438Y-22.1612S5000M3

N13G43H1Z1.

N14#656=1701

N15M98P1191

N16G54X2.156Y4.1773

N17G43H1Z1.

N18#656=2701

 

Then the sub would look like this:

O1191(0188.P01/PAL1/TOOLSUB)

(4.0 DIA 5 FL FACE MILL)

GOTO#656

N1701

N1X-2.1438Y-22.1612

N2Z.1

N3G1Z.01F100.

N6Y2.1612

N7Z.1

N8G0Z10.

N9M99

(4.0 DIA 5 FL FACE MILL)

N2701

N1X2.156Y4.1773

N2Z.1

N3G1Z.01F100.

N6Y-20.1773

N7Z.1

N8G0Z15.

N9M99

N19M98P1191

Link to comment
Share on other sites

What post are you using? I‘ve used a lot of custom macro in some of my post for changing subprograms to local subprograms and adding other things. Maybe I can help.

 

Sample

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

N83T83(100332 SLOT MILL)

M6

G65P4828B180.(COORDINATE ROTATION)

M11

G0G90G54B180.M88

M10

G0G90G54X-47.616Y-2.0

S2420M3T84

G43H83Z67.25

#21=2012

GOTO1007

N2012

G0G90G55X-47.616Y-2.0

Z67.25

#21=2013

GOTO1007

N2013

M5

G0G91G30Z0.M89

G0G91G30X0.Y0.

M01

 

N1007(SUB 100332 S1)

Z19.75

G1Z17.22F550.

G41D83X-34.601

Y16.07

G40X-47.616

G0Y87.93

G1G41D83X-34.661

Y104.

G40X-47.616

G0Z67.25

X19.106

Z70.25

Z22.75

G1Z20.25

G41D83X6.091

Y88.583

G40X19.106

G0Y15.807

G1G41D83X6.091

Y0.

G40X19.106

G0Z70.25

GOTO#[21]

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

Link to comment
Share on other sites

basicly i want to have one main and one sub, so instead of having a seperate sub for each operation/fixture offset i use goto statements to go to a certain line in the same sub. the line number is the sequential tool/operation number so tool 701 would be 1701 for the first operation and then 2701 for the second.

pete

Link to comment
Share on other sites

Try this in the sub program areas of your post.

 

 

#Subprogram variables

mr_rt_actv : 0 #Flag to indicate if G51/G68 is active

#0=Off, 1=Toolchange, 2=Subprogram call/start, G68

#3=Absolute start, both

rt_csav : 0 #C saved value

end_sub_mny : 0 #Many tool setting captured at transform sub end

skip : 0 #skip sub program name

 

 

psub_st_m #Header in main level

result = nwadrs(stro, main_prg_no)

" ", e

if skip = 0,[

*main_prg_no, e

]

else,

[

#no name

]

#G51/G68 requires absolute position on first move

if mr_rt_actv & absinc = one,

[

sav_absinc = absinc

absinc = zero

prv_absinc = m_one

prv_xabs = m_one

prv_yabs = m_one

]

else, pbld, n, sgabsinc, e

skip = 1 #Skip all sub names

Link to comment
Share on other sites

that helped a little, but there are no comments by the subprogram, so its hard to tell which code is for which tool, also the line numbering is messed up now for the main and the subs.

the line numbers need to be output like the example in the first post

not like this:

main

 

N10

N20

N30

N40M98P0001

 

then the sub looks like this

N50

N60

N70

 

[ 08-11-2003, 08:58 AM: Message edited by: specv ]

Link to comment
Share on other sites

try adding a (comment) statment befor the (if skip = 0,[) statment.

 

psub_st_m #Header in main level

result = nwadrs(stro, main_prg_no)

" ", e

n,comment, e

if skip = 0,[

*main_prg_no, e

]

else,

[

#no name

]

#G51/G68 requires absolute position on first move

if mr_rt_actv & absinc = one,

[

sav_absinc = absinc

absinc = zero

prv_absinc = m_one

prv_xabs = m_one

prv_yabs = m_one

]

else, pbld, n, sgabsinc, e

skip = 1 #Skip all sub names

Link to comment
Share on other sites

this is what the code looks like now

 

4.0 DIA 5 FL FACE MILL

N10G65P9222A4.981

N11G4P1M26

N12G0G55X-2.1438Y-22.1612S5000M3

N13G43H1Z1.

N14#656=1701

N15M98P0001<-------------the sub callout needs to be the same all the time

 

N16G54X2.156Y4.1773

N17G43H1Z1.

N18#656=1701<------this number should be 2701, as it is the second operation for that tool, if it was the third it would have to be 3701

 

N19M98P0002

 

Then the sub would look like this:

O11910188.P01/PAL1/TOOLSUB

4.0 DIA 5 FL FACE MILL

GOTO#656

N1701

N1X-2.1438Y-22.1612

N2Z.1

N3G1Z.01F100.

N6Y2.1612

N7Z.1

N8G0Z10.

N9M99

4.0 DIA 5 FL FACE MILL

N1701<------this line number needs to match the main number, second op therefore it should be 2701

N1X2.156Y4.1773

N2Z.1

N3G1Z.01F100.

N6Y-20.1773

N7Z.1

N8G0Z15.

N9M99

 

 

the thing i cant figure out is the sequencing, how do i "count" the operations, so to speak, so that i can have the right line number attached to it?

 

[ 08-11-2003, 02:01 PM: Message edited by: specv ]

Link to comment
Share on other sites

That’s going to be very tricky but you can try to insert another (#Subprogram variables) called (sav_n) and then set (n to 0) before the sub and after the (M99) set the (n) back to (sav_n). Or try to change the (psub_call_s #Call to sub level ) by removing the (if skip = 0) statement and let the sub name be the program name + 1000.So that (M98P1001) will equal to (N1001) or something of that nature for my self, I just change the (M98P1001) to a GOTO statement, and just jump back and forth with line numbers all in one program.

 

(Example)

 

O8608 (8608HH13.CNC)

G0G17G20G40G49G80G90

N2T2(100610 ENDMILL)

M6

G65P8708B0.(COORDINATE ROTATION)

M11

G0G90G54B0.M88

M10

G0G90G54X-.0196Y6.0795S7422M3T3

G43H2Z4.59

#21=2000

GOTO1001 (same as M98P1001)

N2000

G0G90G55X-.0196Y6.0795

Z4.59

#21=2001

GOTO1001 (same as M98P1001)

N2001

M5

G0G91G30Z0.M89

G0G91G30X0.Y0.

M01

 

N3T3(100612 ENDMILL)

M6

G65P8708B0.(COORDINATE ROTATION)

M11

G0G90G54B0.M8

M10

G0G90G54X0.Y4.431S12000M3T2

G43H3Z3.336

#21=2002

GOTO1002 (same as M98P1002)

N2002

G0G90G55X0.Y4.431

Z3.336

#21=2003

GOTO1002 (same as M98P1002)

N2003

M5

G0G91G30Z0.M9

G0G91G30X0.Y0.

M30

 

N1001(SUB FOR 100540) (same as O1001)

Z2.69

G99G81Z1.336R2.69F89.06

X.126

X-.128Y5.2974

Y3.6455

G80

GOTO#[21]

 

N1002(SUB FOR 100542) (same as O1002)

Z1.436

G1Z1.2287F36.

G41D3X.031Y4.4336F72.01

Y4.615

G3X-.031I-.031J0.F25.

G1Y4.247F72.01

G3X.031I.031J0.F25.

G1Y4.4336F72.01

Y4.4836

G40X0.Y4.431

G0Z3.2287

GOTO#[21] (same as M99)

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