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 apologize for the error, but would that help u out?

It might if I understood how macros work with variables. lol. I was envisioning a program I run from memory which I assume the above does once stored there but have it so I can set an known X,Y.Z zero in g55 and when I hit cycle start and run the program it knows the tool in the spindle without me telling it and also to tell said tool number to go to my x.y.z zeros without having to type this out all long hand in mdi. basically set the XYZ as needed per set up in the program that's in memory and once done I can go through my tools that need blended off. also a way to start with say tool 1 and work incrementally upwards but the ability to skip tool numbers if needed due to not being used in toolpaths posted to run. If this is to far demanding of a macro I don't know but if possible would definitely be helpful and I most grateful.  I don't know how to tell what variables are used or not other than the variables that are stored permanently for use with my probe. 500 to 520 I think cant recall since not by my machine.  thanks so much in advance for all help and ideas on my procedure im trying to simplify.

Link to comment
Share on other sites

MACRO 101;

 

There are 3 (4 if you count Null - #0) types of variables. Common (2 types - non-permanent -meaning they will revert to null when the machine is shut down and will remain what they are until changed or until the machine is shut off (#100-#199) and permanent (#500-#999)) only changed when when changed and never revert unless commanded to, and Local (#1-#30).

 

When a G65 is commanded this tells the control to start storing stuff. The P calls the program number. Now, the arguments(letters) on the line G65 P9950 A1.B2.C3, etc...are A, B and C. Their values get stored for a short time in the following variables;

 

A = #1

B = #2

C = #3

D = #7

E = #8

F = #9

H = #11

I = #4

J = #5

K = #6

M = #13

Q = #17

R = #18

S = #19

T = #20

U = #21

V = #22

W = #23

X = #24

Y = #25

Z = #26

 

So inside the MACRO, the arguments are then stored either in permanent or non permanent variables.

 

Hope that helps.

Link to comment
Share on other sites
  • 3 weeks later...
  • 4 weeks later...
  • 4 weeks later...

Does anyone out there have any more ideas for macros? I would really like to continue to help people with this stuff.

Hi Everyone! The question is how to create a rough pocket . I saw it on the machines "Hardinge/Fanuc System II - VMC Series II"  but it is used as a cycle G72

post-58015-0-43426300-1431808872_thumb.jpg

Maybe at somebody have this cycle,please share

Link to comment
Share on other sites

Hi Everyone! The question is how to create a rough pocket . I saw it on the machines "Hardinge/Fanuc System II - VMC Series II"  but it is used as a cycle G72

attachicon.gif1.jpg

Maybe at somebody have this cycle,please share

Do you want this routine to also step down in Z or do u want to adjust it every time?

Link to comment
Share on other sites

Hello Cncchipmaker! I Interested in how to do this with step by Z(step down) and use modal call (used as a cycle)

Yes, I already have the Z step down figured out, but not sure how to calcutlate the pocket yet. I will need some time to figure that out. This will be used as a G65 macro call. Ex: G65P0001T.5Q.2X5.Y6. where T is tool diameter, Q is stepover, X&Y are the dimensions of the pocket, and so on.

Link to comment
Share on other sites

I think we can remove the ( in front of that line :

 

(IF[[#24*#25*#17*#19*#20*#18*#26*#8*#9]EQ0]GOTO1000

 

:thumbup:  Nice macro cncchipmaker.

Yes, please remove it. I hope that is the only thing wrong. Can someone please let me know if it works out, I do not get a chance to prove out everything I write.

Link to comment
Share on other sites

Use FIX[ ] it's division that throws away the remainder - basically rounds down to a whole number..

 

like follows .. this will disregard any numbers after the decimal.. if you need that you need to take it a bit further.. but this is basically it.. haven't tested this but I don't think I made any logic errors..

 

BTW - IMPORTANT NOTE - THIS IS ONLY AN EXAMPLE !!!! don't just go messing with #500 series variables if you haven't checked that they aren't in use for probing / tool touch off's etc.. you can severely screwup your probe setups or possibly cause a costly and dangerous crash... YOU HAVE BEEN WARNED!!

 

 

#500 = 12345

 

#501=FIX[#500/10000] (#501 WILL EQ 1 IN THIS EXAMPLE)

#500 = #500 - [#501 * 10000] (#500 WILL NOW EQ 2345)

 

#502=FIX[#500/1000] (#502 WILL EQ 2 IN THIS EXAMPLE)

#500 = #500 - [#502 * 1000]

 

#503=FIX[#500/100] (#503 WILL EQ 3 IN THIS EXAMPLE)

#500 = #500 - [#503 * 100]

 

#504=FIX[#500/10] (#504 WILL EQ 4 IN THIS EXAMPLE)

#500 = #500 - [#504 * 10]

 

#505=FIX[#500/1] (#505 WILL EQ 5 IN THIS EXAMPLE)

Link to comment
Share on other sites

OK, I did find out that the original program would not work. Please use this revised program:

 

O3334(ROUGH POCKET)

(ABSOLUTE MACRO)

(MUST HAVE START HOLE IN CENTER)

(UNPROVEN)

(FORMAT G65/G66 XYQSTRZEF)

(X = #24 - X DIMENSION)

(Y = #25 - Y DIMENSION)

(Q = #17 - STEPOVER IN Z/ DOC)

(S = #19 - STEPOVER IN XY/ PERCENTAGE)

(T = #20 - TOOL DIAMETER)

(R = #18 - R PLANE)

(Z = #26 - Z START/ TOP OF STOCK)

(E = #8 - END OF POCKET IN Z)

(F = #9 - FEEDRATE)

(*********************************)

IF[[#24*#25*#17*#19*#20*#18*#26*#8*#9]EQ0]GOTO1000

(CALCULATE DOC IN Z)

#100=ABS[#26]-ABS[#8]

#100=ABS[#100]

IF[[#26*#8]GE0]GOTO1

#100=ABS[#26]+ABS[#8]

N1#101=ROUND[#100/#17]

#102=#100/#101

IF[#102GT[#100/2.]]THEN#102=#100

(CALCULATE DOC IN X)

#103=[#19*.01]*#20

#104=[#24/2.]-[#20/2.]

#105=ROUND[#104/#103]

#106=#104/#105

IF[#106GT[#104/2.]]THEN#106=#104

(CALCULATE DOC IN Y)

#107=[#19*.01]*#20

#108=[#25/2.]-[#20/2.]

#109=ROUND[#108/#107]

#110=#108/#109

IF[#110GT[#108/2.]]THEN#110=#108

(STORE POSTION AND GO TO Z START)

#111=#5001

#112=#5002

#114=#112

#115=#111

#116=#112

#117=#111

G0G90X#111Y#112

Z[#26+.1]

G1Z#26F#9

#113=#5003-#102

#120=#106

#IF[#120LT#110]THEN#120=#110

WHILE[#101GT0]DO1

IF[#101EQ0]GOTO10

#101=#101-1.

G90G1Z#113F#9

WHILE[#120GT0]DO2

IF[#120LT0]GOTO100

#120=#120-1.

(CALCULATE TOOL PATH)

IF[#109EQ0]GOTO20

#114=#114+#110

N20

IF[#105EQ0]GOTO30

#115=#115-#106

N30

IF[#109EQ0]GOTO40

#116=#116-#110

N40

IF[#105EQ0]TOTO50

#117=#117+#106

(CUT POCKET)

G1G90Y#114F#9

X#115

Y#116

X#117

X#111

(DOWN COUNT)

#105=#105-1.

#109=#109-1.

END2

N100

X#111Y#112

#113=#113-#102

END1

N10

X#111Y#112

Z#18

M99

N1000=(DATA LACKING)

Thank you Cncchipmaker! Error in line and there is no number 50

IF[#105EQ0]TOTO50

Link to comment
Share on other sites

Use FIX[ ] it's division that throws away the remainder - basically rounds down to a whole number..

 

like follows .. this will disregard any numbers after the decimal.. if you need that you need to take it a bit further.. but this is basically it.. haven't tested this but I don't think I made any logic errors..

 

BTW - IMPORTANT NOTE - THIS IS ONLY AN EXAMPLE !!!! don't just go messing with #500 series variables if you haven't checked that they aren't in use for probing / tool touch off's etc.. you can severely screwup your probe setups or possibly cause a costly and dangerous crash... YOU HAVE BEEN WARNED!!

 

 

#500 = 12345

 

#501=FIX[#500/10000] (#501 WILL EQ 1 IN THIS EXAMPLE)

#500 = #500 - [#501 * 10000] (#500 WILL NOW EQ 2345)

 

#502=FIX[#500/1000] (#502 WILL EQ 2 IN THIS EXAMPLE)

#500 = #500 - [#502 * 1000]

 

#503=FIX[#500/100] (#503 WILL EQ 3 IN THIS EXAMPLE)

#500 = #500 - [#503 * 100]

 

#504=FIX[#500/10] (#504 WILL EQ 4 IN THIS EXAMPLE)

#500 = #500 - [#504 * 10]

 

#505=FIX[#500/1] (#505 WILL EQ 5 IN THIS EXAMPLE)

This works until I have a zero in my sting of numbers. 

 

EDIT: Nevermind, I had a typo. This method works great.

Link to comment
Share on other sites

OK fixed it, thank you!

 

O3334(ROUGH POCKET)

(ABSOLUTE MACRO)

(MUST HAVE START HOLE IN CENTER)

(UNPROVEN)

(FORMAT G65/G66 XYQSTRZEF)

(X = #24 - X DIMENSION)

(Y = #25 - Y DIMENSION)

(Q = #17 - STEPOVER IN Z/ DOC)

(S = #19 - STEPOVER IN XY/ PERCENTAGE)

(T = #20 - TOOL DIAMETER)

(R = #18 - R PLANE)

(Z = #26 - Z START/ TOP OF STOCK)

(E = #8 - END OF POCKET IN Z)

(F = #9 - FEEDRATE)

(*********************************)

IF[[#24*#25*#17*#19*#20*#18*#26*#8*#9]EQ0]GOTO1000

(CALCULATE DOC IN Z)

#100=ABS[#26]-ABS[#8]

#100=ABS[#100]

IF[[#26*#8]GE0]GOTO1

#100=ABS[#26]+ABS[#8]

N1#101=ROUND[#100/#17]

#102=#100/#101

IF[#102GT[#100/2.]]THEN#102=#100

(CALCULATE DOC IN X)

#103=[#19*.01]*#20

#104=[#24/2.]-[#20/2.]

#105=ROUND[#104/#103]

#106=#104/#105

IF[#106GT[#104/2.]]THEN#106=#104

(CALCULATE DOC IN Y)

#107=[#19*.01]*#20

#108=[#25/2.]-[#20/2.]

#109=ROUND[#108/#107]

#110=#108/#109

IF[#110GT[#108/2.]]THEN#110=#108

(STORE POSTIONS AND GO TO Z START)

#111=#5001

#112=#5002

#114=#112

#115=#111

#116=#112

#117=#111

G0G90X#111Y#112

Z[#26+.1]

G1Z#26F#9

#113=#5003-#102

#120=#106

#IF[#120LT#110]THEN#120=#110

WHILE[#101GT0]DO1

IF[#101EQ0]GOTO10

#101=#101-1.

G90G1Z#113F#9

WHILE[#120GT0]DO2

IF[#120LT0]GOTO100

#120=#120-1.

(CALCULATE TOOL PATH)

IF[#109EQ0]GOTO20

#114=#114+#110

N20

IF[#105EQ0]GOTO30

#115=#115-#106

N30

IF[#109EQ0]GOTO40

#116=#116-#110

N40

IF[#105EQ0]GOTO50

#117=#117+#106

N50

(CUT POCKET)

G1G90Y#114F#9

X#115

Y#116

X#117

X#111

(DOWN COUNT)

#105=#105-1.

#109=#109-1.

END2

N100

X#111Y#112

#113=#113-#102

END1

N10

X#111Y#112

Z#18

M99

N1000=(DATA LACKING)

Thank you Cncchipmaker! Error in line and there is no number 50

IF[#105EQ0]TOTO50

Link to comment
Share on other sites

I need to take a string of digits (say 12345 for example) and then break that number down so that each digit goes into a different common varriable. Anybody have any ideas on how to acomplish this?

Here is an example of how you can pull the digits:

 

 

O8116( SIX DIGIT S/N MACRO)

( USE OFFSET 98 FOR SERIAL # )

( 00.0001 WILL ENGRAVE 1 )

( 1ST NUMBER )

#138=[#2098*.1]

#140=FIX[#138]

#141=#140+8100.

( 2ND NUMBER )

#138=[#140*10]

#139=FIX[#2098]

#140=#139-#138

#142=#140+8100.

( 3RD NUMBER )

#138=[#139*10]

#139=FIX[#2098*10]

#140=#139-#138

#143=#140+8100.

( 4TH NUMBER )

#138=[#139*10]

#139=FIX[#2098*100]

#140=#139-#138

#144=#140+8100.

( 5TH NUMBER )

#138=[#139*10]

#139=FIX[#2098*1000]

#140=#139-#138

#145=#140+8100.

( 6TH NUMBER )

#138=[#139*10]

#139=FIX[#2098*10000]

#140=#139-#138

#146=#140+8100.

( ARGUMENT )

IF[#141GT8100.]GOTO1

IF[#142GT8100.]GOTO2

IF[#143GT8100.]GOTO3

IF[#144GT8100.]GOTO4

IF[#145GT8100.]GOTO5

IF[#146GT8100.]GOTO6

GOTO100

N1M198P#141

N2M198P#142

N3M198P#143

N4M198P#144

N5M198P#145

N6M198P#146

N100M99

Link to comment
Share on other sites

I tend to over complicating things. This will parse a variable with a user defined number of integers to the left and right of the decimal. This is somewhat volatile because depending on the size of the number (ex 123.1 versus 12345.15125) the variable range will grow or shrink... which even though the max range is hard-coded and i fixed the ones place of the range to a known value, seems dangerous. Just out of curiosity, what is the usefulness of parsing a number in macro B?

(A = NUMBER YOU WOULD LIKE TO PARSE
(I = HOW TO HANDLE NUMBERS WITH TOO MANY DECIMALS: 1=ROUND, DEFAULT=FIX/TRUNCATE
(E = COMMON VARIABLE TO USE AS THE ONES PLACE. DEFUALT IS 190

G65 P255 A123.456
M30

O255
(#1, A = NUMBER YOU WOULD LIKE TO PARSE
(#4, I = HOW TO HANDLE NUMBERS WITH TOO MANY DECIMALS
(#4, I: 1=ROUND, DEFAULT=FIX/TRUNCATE
(#8, E = COMMON VARIABLE TO USE AS THE ONES PLACE. DEFUALT IS 190

IF[#1EQ#0]THEN #3000=3	(ARGUMENT MISSING (A), NOTHING TO PARSE)
IF[#4EQ#0]THEN #4=0
IF[#4EQ0]THEN #1=FIX[#1*100000]/100000
IF[#4NE0]THEN #1=ROUND[#1*100000]/100000
IF[#8EQ#0] THEN #8=190

(HARDCODE TO YOUR PREFERENCE
#2=5	(MAX # DIGITS TO THE LEFT OF THE DECIMAL
#3=4	(MAX # DIGITS TO THE RIGHT OF THE DECIMAL
	(ANY DIGITS PAST THIS WILL BE TRUNCATED OR ROUNDED
	(DEPENDING ON THE VALUE OF #4(I). DEFAULT IS TRUNCATE (FIX)

(COUNT THE NUMBER OF DIGITS TO THE LEFT OF THE DECIMAL
#10=#1
#11=0	(NUMBER OF DIGITS TO THE LEFT
#12=1

WHILE[#10GT1]DO1
#10=#1/#12
#11=#11+1
#12=#12*10
END1
#12=#12/10
#11=#11-1
IF[#11GT#2] THEN #3000=1	(TOO MANY DIGITS LEFT OF DECIMAL

(COUNT THE NUMBER OF DIGITS TO THE RIGHT OF THE DECIMAL
#19=FIX[#1]
#20=#1-#19
#21=0	(NUMBER OF DIGITS TO THE RIGHT
#22=1

WHILE[#20GT0.00000]DO1
#21=#21+1
#22=#22*10
#23=#1*#22
#24=FIX[#23]
#20=#23-#24
END1
#30=#1
IF[#21NE0]THEN #30=#1*#22

#15=#8-#11+1
WHILE[#15LE[#8+#21]]DO1
#[#15]=#0
#15=#15+1
END1

#31=1
#32=#8	(VARIABLE FOR THE ONES PLACE
#33=0.1

IF[#1EQ0] THEN #[#8]=0.
IF[#1LT1] THEN #[#8]=0.

(PASS THE PARSED VALUES TO THE COMMON # VARIABLES
WHILE[#31LE#11+#21+1]DO1
#25=FIX[#30/[#22*#12/#33/10]]
#26=#25-FIX[#30/[#22*#12/#33]]*10
#[#32-#11]=#26
#32=#32+1
#31=#31+1
#33=#33*10
END1

M99

Link to comment
Share on other sites

The most common use I can think of is when engraving serial numbers on parts..

 

You pass in the number, determine what each value is.. then add them to a known base value so you call the proper sub program to engrave the number you desire.

 

By doing this you can create 10 incremental sub programs 0-9 which allow you to engrave any number you need without having to create multiple programs in a cam system.

Link to comment
Share on other sites
Guest MTB Technical Services

The most common use I can think of is when engraving serial numbers on parts..

 

You pass in the number, determine what each value is.. then add them to a known base value so you call the proper sub program to engrave the number you desire.

 

By doing this you can create 10 incremental sub programs 0-9 which allow you to engrave any number you need without having to create multiple programs in a cam system.

 

http://www.mtbtech.net/blog/2013/02/27/Engraving-on-your-FANUC-Controlled-Mill.aspx

 

0_0_0_0_250_303_csupload_59506196_large.

Link to comment
Share on other sites

That system looks pretty slick Tim.. , where I currently work we always seem to get into weirder situations, I frequently use this method to do engraving of serial numbers on outside or inside diameters using fourth axis movement to reach 120 degrees or more of the diameter while keeping the tool normal to the surface of the part.

 

It requires me to create a new set of subs based on the diameter I am working at, however, I have gotten it tuned to where it creates the entire NC file including subs and Macro out of Mastercam with no need for any hand editing which is a huge improvement over anything that they were able to do here prior to my arrival.

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