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:

Insert M-code manually


connormac
 Share

Recommended Posts

I know that we have been threw this before so please don't YELL at me. I need to insert a M42 between 2 drill cycles. This will actuate our third-party 4th axis. I have seen before where Kathy said to switch from 1005 to 1006 or the other way around. But my M42 still comes out (M42). I can go in my post and change a few things aroud but then all my notes are posted without any brackets. The post I am running was written by MC for our company. Help !!!! confused.gif

Link to comment
Share on other sites
Guest CNC Apps Guy 1

Try This format;

 

pcomment2 #Comment from manual entry

spaces = 0

scomm = ucase (scomm)

#1005 - Comment option 1

#1006 - Comment option 2

#1007 - Define comment with output line

#1008 - Define NC parameter comment

#1026 - ?

if gcode = 1005, pbld, n, pspc, "(", scomm, ")"

if gcode = 1006, pbld, n, pspc, "(", scomm, ")" #Comments

#if gcode = 1006, pbld, n, pspc, scomm #Codes

if gcode = 1007, "(", scomm, ")"

if gcode = 1008, pbld, n, pspc, "(", scomm, ")"

if gcode = 1026, pbld, scomm

if gcode <> 1007 & gcode <> 1026, e

spaces = sav_spc

 

 

Stolen from MPMaster's comment section.

 

HTH

Link to comment
Share on other sites

James,

Our post was written for 4 diffrent machines

code:

pcomment   # Manual Entry - COMMENTS (on a block by itself) 1005 , 1006

if machtyp = 0, n, "(", scomm, ")"

if machtyp = 2, n, "(", scomm, ")"

if machtyp = 3, n, "(", scomm, ")"

if machtyp = 4, n, "(", scomm, ")"

How do I use an if /then statment within an if/then statment. What you told me is what I need . I just need a little more. Thanks

Link to comment
Share on other sites

For nested if statements like that, you use square brackets or call new postblocks.

 

Square brackets:

 

code:

pcomment

if machtyp = 0,

[

if gcode = 1005, ...

...

]

if machtyp = 1,

...

New postblocks:

 

code:

pcomment

if machtyp = 0, pcom_mtyp0

if machtyp = 1, pcom_mtyp1

...

 

pcom_mtyp0

if gcode = 1005, ...

...

Do you see what I mean? There are two ways to do it, which method you use is up to your personal preference.

Link to comment
Share on other sites

here is what I did.

code:

 pcomment   # Manual Entry - COMMENTS (on a block by itself) 

 

if machtyp = 0,

 

[spaces = 0

scomm = ucase (scomm)

#1005 - Comment option 1

#1006 - Comment option 2

#1007 - Define comment with output line

#1008 - Define NC parameter comment

#1026 - ?

if gcode = 1005, n, "(", scomm, ")"

if gcode = 1006, n, "(", scomm, ")" #Comments

#if gcode = 1006, n, scomm #Codes

if gcode = 1007, "(", scomm, ")"

if gcode = 1008, n,"(", scomm, ")"

if gcode = 1026, scomm

if gcode <> 1007 & gcode <> 1026, e

]

 

if machtyp = 2,

[spaces = 0

scomm = ucase (scomm)

#1005 - Comment option 1

#1006 - Comment option 2

#1007 - Define comment with output line

#1008 - Define NC parameter comment

#1026 - ?

if gcode = 1005, n, "(", scomm, ")"

if gcode = 1006, n, "(", scomm, ")" #Comments

#if gcode = 1006, n, scomm #Codes

if gcode = 1007, "(", scomm, ")"

if gcode = 1008, n, "(", scomm, ")"

if gcode = 1026, scomm

if gcode <> 1007 & gcode <> 1026, e

]

 

if machtyp = 3,

[spaces = 0

scomm = ucase (scomm)

#1005 - Comment option 1

#1006 - Comment option 2

#1007 - Define comment with output line

#1008 - Define NC parameter comment

#1026 - ?

if gcode = 1005, n, "(", scomm, ")"

if gcode = 1006, n, "(", scomm, ")" #Comments

#if gcode = 1006, n, scomm #Codes

if gcode = 1007, "(", scomm, ")"

if gcode = 1008, n, "(", scomm, ")"

if gcode = 1026, scomm

if gcode <> 1007 & gcode <> 1026, e

]

 

if machtyp = 4,

 

[spaces = 0

scomm = ucase (scomm)

#1005 - Comment option 1

#1006 - Comment option 2

#1007 - Define comment with output line

#1008 - Define NC parameter comment

#1026 - ?

if gcode = 1005, n, "(", scomm, ")"

if gcode = 1006, n, "(", scomm, ")" #Comments

#if gcode = 1006, n, scomm #Codes

if gcode = 1007, "(", scomm, ")"

if gcode = 1008, n, "(", scomm, ")"

if gcode = 1026, scomm

if gcode <> 1007 & gcode <> 1026, e

]

 


It still gave me (M42)

 

I think it is getting close

thanks for all the help so far

Link to comment
Share on other sites

Hey guys,

 

i did it i think. I have it now where it will output anything you put in without ()'s. hte only thing is there is 1 space before the M42 or what ever code you want put in. I don't think the machine will have any problem reading it but I'm at home and machine is at work.

code:

           if machtyp = 2, 

[spaces = 0

scomm = ucase (scomm)

#1005 - Comment option 1

#1006 - Comment option 2

#1007 - Define comment with output line

#1008 - Define NC parameter comment

#1026 - ?

if gcode = 1005, n, "(", scomm, ")"

if gcode = 1006, n, " " #Comments

#if gcode = 1006, n, scomm #Codes

if gcode = 1007, "(", scomm, ")"

if gcode = 1008, n, "(", scomm, ")"

if gcode = 1026, scomm

if gcode <> 1007 & gcode <> 1026, e

]

gives me this

code:

G40 G1 X-.2

G0 Z.25

M42

X-.8Y-.025

Z.1

G1Z-.245


can anyone see any problem with this. If not , thanks James & Christian. I couldn't have done this without ya'll

Link to comment
Share on other sites

I think your problem is in the lines

code:

        if gcode = 1006, n,  " " #Comments

#if gcode = 1006, n, scomm #Codes

You should write that as this one line

code:

	if gcode = 1006, n, scomm #Codes

Or if you want two lines, as this

code:

        #if gcode = 1006, n,  "(", scomm, ")" #Comments

if gcode = 1006, n, scomm #Codes

I hope that solves your problem.

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