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:

Macro program trouble


Recommended Posts

Having trouble with a macro program I am running, it looks as follows:

 

 
:O5000 (ZERO)
G00 Z[#26+0.6]
G00 X.0003 Y0.
G00 Z[#26+0.02]
G01 Z[#26-#7] F#121
X-.0132 Y-.0024
X-.0256 Y-.0072
X-.0374 Y-.0168
X-.0479 Y-.0288
X-.0574 Y-.0445
X-.065 Y-.0625
X-.0703 Y-.0817
X-.0738 Y-.1034
X-.075 Y-.125
X-.0738 Y-.1466
X-.0703 Y-.1683
X-.065 Y-.1875
X-.0574 Y-.2055
X-.0479 Y-.2212
X-.0374 Y-.2332
X-.0256 Y-.2428
X-.0132 Y-.2476
X.0003 Y-.25
X.0132 Y-.2476
X.0256 Y-.2428
X.0374 Y-.2332
X.0479 Y-.2212
X.0574 Y-.2055
X.065 Y-.1875
X.0703 Y-.1683
X.0738 Y-.1466
X.075 Y-.125
X.0738 Y-.1034
X.0703 Y-.0817
X.065 Y-.0625
X.0574 Y-.0445
X.0479 Y-.0288
X.0374 Y-.0168
X.0256 Y-.0072
X.0132 Y-.0024
X.0003 Y0.
G00 Z[#26+0.6]
M99
%
 
It is a program for engraving a zero as part of a serial number. Everything goes great until I hit the M99 where it comes up with Alarm # 115 : Illegal Variable Number. Any idea why this is happening. Im running on a Fanuc controller using G65 for the macro call to pull up this program. 
 
Thanks for the help,
-Adam
Link to comment
Share on other sites
 


 

O4999 (SERIAL NUMBERING CUSTOM MACRO)

#111 = #24 (FIND CURRENT X ABS)

#112 = #25 (FIND CURRENT Y ABS)

#113 = #26 (FIND CURRENT Z ABS)

#500 = #500+1 (STEP SERIAL NUMBER)

#110 = #19 (SPACING)

#121 = #9 (FEEDRATE)

(1 THROUGH 1O)

IF [#500 GT 9] GOTO 10

G52 X#111 Y#112

G65 P5000 Z#26 D#7 (FIRST ZERO)

G52 X#[111+110] Y#112

G65 P5000 Z#26 D#7 (SECOND ZERO)

G52 X#[111+110*2] Y#112

#105 = 5000 + #500 (GET THIRD)

G65 P#105 Z#26 D#7

G52 X0 Y0

GOTO 99

 

(10 THROUGH 99)

N10 IF [#500 GT 99] GOTO 20

G52 X#111 Y#112

G65 P5000 Z#26 D#7 (FIRST ZERO)

G52 X[#111+#110] Y#112

#100 = FIX[#500/10] (GET SECOND)

#105 = 5000 + #100

G65 P[#105]

G52 X[#111+#110*2] Y#112

#101 = #500 - #100*10 (GET THIRD)

G65 P[5000+ #101] Z#26 D#7

G52 X0 Y0

GOTO 99

 

(100 THROUGH 999)

N20 IF [#500 GT 999] GOTO 30

G52 X#111 Y#112

#100 = FIX[#500/100] (GET FIRST)

G65 P[5000 +#100] Z#26 D#7

G52 X[#111+#110] Y#112

#101 = #500 - #100*100

#102 = FIX [#101/10] (GET SECOND)

G65 P[5000+ #102] Z#26 D#7

G52 X[#111+#110*2] Y#112

#103 = #101 - #102*10 (GET THIRD)

#105 = 5000 +#103

G65 P#105 Z#26 D#7

G52 X0 Y0

 

GOTO 99

N30 #3000 = 100 (OUT OF RANGE)

N99

M99


 

Here is the program used to call it. Just for fun I changed the GOTO10 to a GOTO99 which takes it to the end and this M99 work just fine. No clue what the difference is.
Link to comment
Share on other sites

And this is the main program I am using to test it:

 

O2000(SERIAL ENGRAVING)
T18 M06 (ENGRAVING TOOL)
G54 G90 S12000 M03
G00 X0. Y0.
G43 H18 Z1.0 M08
G65 P4999 X-0.5450 Y1.3612 Z-0.5525 F10. S0.24 D0.003
G55 G00 Z.25
G00 X0. Y0.
G65 P4999 X-0.5450 Y1.3612 Z-0.5525 F10. S0.24 D0.003
G91 G28 Z0.
M09
M05 
M30
Link to comment
Share on other sites

I think it has to do with the controller not liking the nested programs, going to write a more complicated program with everything in one subprogram and see if that work later this week.

 

If anyone has any other ideas or answers they would be very much apprieciated

Link to comment
Share on other sites

 

 
 
O4999 (SERIAL NUMBERING CUSTOM MACRO)
#111 = #24 (FIND CURRENT X ABS)
#112 = #25 (FIND CURRENT Y ABS)
#113 = #26 (FIND CURRENT Z ABS)
#500 = #500+1 (STEP SERIAL NUMBER)
#110 = #19 (SPACING)
#121 = #9 (FEEDRATE)
(1 THROUGH 1O)
IF [#500 GT 9] GOTO 10
G52 X#111 Y#112
G65 P5000 Z#26 D#7 (FIRST ZERO)
G52 X[#111+#110] Y#112
G65 P5000 Z#26 D#7 (SECOND ZERO)
G52 X[#111+#110*2] Y#112
#105 = 5000 + #500 (GET THIRD)
G65 P#105 Z#26 D#7
G52 X0 Y0
GOTO 99
 
(10 THROUGH 99)
N10 IF [#500 GT 99] GOTO 20
G52 X#111 Y#112
G65 P5000 Z#26 D#7 (FIRST ZERO)
G52 X[#111+#110] Y#112
#100 = FIX[#500/10] (GET SECOND)
#105 = 5000 + #100
G65 P[#105]
G52 X[#111+#110*2] Y#112
#101 = #500 - #100*10 (GET THIRD)
G65 P[5000+ #101] Z#26 D#7
G52 X0 Y0
GOTO 99
 
(100 THROUGH 999)
N20 IF [#500 GT 999] GOTO 30
G52 X#111 Y#112
#100 = FIX[#500/100] (GET FIRST)
G65 P[5000 +#100] Z#26 D#7
G52 X[#111+#110] Y#112
#101 = #500 - #100*100
#102 = FIX [#101/10] (GET SECOND)
G65 P[5000+ #102] Z#26 D#7
G52 X[#111+#110*2] Y#112
#103 = #101 - #102*10 (GET THIRD)
#105 = 5000 +#103
G65 P#105 Z#26 D#7
G52 X0 Y0
 
GOTO 99
N30 #3000 = 100 (OUT OF RANGE)
N99
M99
 
Here is the program used to call it. Just for fun I changed the GOTO10 to a GOTO99 which takes it to the end and this M99 work just fine. No clue what the difference is.

 

 

Try making the changes marked in red.

  • Like 1
Link to comment
Share on other sites

 

 
 
O4999 (SERIAL NUMBERING CUSTOM MACRO)
#111 = #24 (FIND CURRENT X ABS)
#112 = #25 (FIND CURRENT Y ABS)
#113 = #26 (FIND CURRENT Z ABS)
#500 = #500+1 (STEP SERIAL NUMBER)
#110 = #19 (SPACING)
#121 = #9 (FEEDRATE)
(1 THROUGH 1O)
IF [#500 GT 9] GOTO 10
G52 X#111 Y#112
G65 P5000 Z#26 D#7 (FIRST ZERO)
G52 X#[111+110] Y#112
G65 P5000 Z#26 D#7 (SECOND ZERO)
G52 X#[111+110*2] Y#112
#105 = 5000 + #500 (GET THIRD)
G65 P#105 Z#26 D#7
G52 X0 Y0
GOTO 99
 
(10 THROUGH 99)
N10 IF [#500 GT 99] GOTO 20
G52 X#111 Y#112
G65 P5000 Z#26 D#7 (FIRST ZERO)
G52 X[#111+#110] Y#112
#100 = FIX[#500/10] (GET SECOND)
#105 = 5000 + #100
G65 P[#105]
G52 X[#111+#110*2] Y#112
#101 = #500 - #100*10 (GET THIRD)
G65 P[5000+ #101] Z#26 D#7
G52 X0 Y0
GOTO 99
 
(100 THROUGH 999)
N20 IF [#500 GT 999] GOTO 30
G52 X#111 Y#112
#100 = FIX[#500/100] (GET FIRST)
G65 P[5000 +#100] Z#26 D#7
G52 X[#111+#110] Y#112
#101 = #500 - #100*100
#102 = FIX [#101/10] (GET SECOND)
G65 P[5000+ #102] Z#26 D#7
G52 X[#111+#110*2] Y#112
#103 = #101 - #102*10 (GET THIRD)
#105 = 5000 +#103
G65 P#105 Z#26 D#7
G52 X0 Y0
 
GOTO 99
N30 #3000 = 100 (OUT OF RANGE)
N99
M99
 
Here is the program used to call it. Just for fun I changed the GOTO10 to a GOTO99 which takes it to the end and this M99 work just fine. No clue what the difference is.

 

I believe your actual problem is highlighted in red. I don't think you can use a variable to call a program. Also the line G52 X#[111+110] Y#112 could cause a major crash since your telling to move in X whatever value is in #221

Link to comment
Share on other sites

I don't know about his particular control but on the Fanuc 21iTB we have here on the Hardinge behind me, a variable works fine for calling macro programs. I use them all the time to run many different types of parts per pallet with our robotic arm.

Link to comment
Share on other sites

Sooooo finally got it working and it looks like it was either the # outside the [] or the fact that I was nesting my programs too many levels deep for the controller.

 

Either way I ended up putting everything into a single program and now it works flawlessly every time. 

 

Thanks for the help guys. Here is my final product in case anyone else is looking for something similar or just a base they can modify for what they need. If you have any questions about the program just send me a message at [email protected]. This was a pain to make but fun to learn some tricks along the way. 




O4999 (SERIAL NUMBERING CUSTOM MACRO)
#111 = -0.6647 (X START POSITION)
#112 = 1.3612 (Y START POSITION)
#26 = -0.5555 (Z CUT DEPTH)
#500 = #500+1 (STEP SERIAL NUMBER)
#110 = 0.22 (SPACING)
#121 = 10.0 (FEEDRATE)
(#113 IS USED TO RETURN TO THE PROPER PLACE)
(IN THE MAIN MACRO AFTER A NUMER IS ENGRAVED)
(#101 TO #104 USED FOR PROGRAM MATH)
(#105 USED TO STORE LINE NUMBER OF)
(NUMER TO BE ENGRAVED)

(1 THROUGH 1O)
IF [#500 GT 9] GOTO 10
G52 X#111 Y#112
#113 = 11
GOTO5000 (CUT FIRST ZERO)
N11
G52 X[#111+#110] Y#112
#113 = 12
GOTO5000 (CUT SECOND ZERO)
N12
G52 X[#111+#110+#110] Y#112
#105 = 5000 + #500 (GET THIRD)
#113 = 13
GOTO#105 (CUT THIRD)
N13
G52 X0 Y0
GOTO 99

(10 THROUGH 99)
N10 IF [#500 GT 99] GOTO 20
G52 X#111 Y#112
#113 = 21
GOTO5000 (CUT FIRST ZERO)
N21
G52 X[#111+#110] Y#112
#101 = FIX[#500/10] (GET SECOND)
#105 = 5000 + #101
#113 = 22
GOTO#105 (CUT SECOND)
N22
G52 X[#111+#110+#110] Y#112
#102 = #500 - #101*10 (GET THIRD)
#105 = 5000 + #102
#113 = 23
GOTO#105 (CUT THIRD)
N23
G52 X0 Y0
GOTO 99

(100 THROUGH 999)
N20 IF [#500 GT 999] GOTO 30
G52 X#111 Y#112
#101 = FIX[#500/100] (GET FIRST)
#105 = 5000 + #101
#113 = 31
GOTO#105 (CUT FIRST)
N31
G52 X[#111+#110] Y#112
#102 = #500 - #101*100
#103 = FIX [#102/10] (GET SECOND)
#105 = 5000 + #103
#113 = 32
GOTO#105 (CUT SECOND)
N32
G52 X[#111+#110+#110] Y#112
#104 = #102 - #103*10 (GET THIRD)
#105 = 5000 + #104
#113 = 33
GOTO#105 (CUT THIRD)
N33
G52 X0 Y0

GOTO 99

N5000 (ZERO)
G00 Z[#26+0.6]
G00 X.0003 Y0.
G00 Z[#26+0.02]
G01 Z[#26] F#121
X-.0132 Y-.0024
X-.0256 Y-.0072
X-.0374 Y-.0168
X-.0479 Y-.0288
X-.0574 Y-.0445
X-.065 Y-.0625
X-.0703 Y-.0817
X-.0738 Y-.1034
X-.075 Y-.125
X-.0738 Y-.1466
X-.0703 Y-.1683
X-.065 Y-.1875
X-.0574 Y-.2055
X-.0479 Y-.2212
X-.0374 Y-.2332
X-.0256 Y-.2428
X-.0132 Y-.2476
X.0003 Y-.25
X.0132 Y-.2476
X.0256 Y-.2428
X.0374 Y-.2332
X.0479 Y-.2212
X.0574 Y-.2055
X.065 Y-.1875
X.0703 Y-.1683
X.0738 Y-.1466
X.075 Y-.125
X.0738 Y-.1034
X.0703 Y-.0817
X.065 Y-.0625
X.0574 Y-.0445
X.0479 Y-.0288
X.0374 Y-.0168
X.0256 Y-.0072
X.0132 Y-.0024
X.0003 Y0.
G00 Z[#26+0.6] 
GOTO#113

N5001 (ONE)
G00 Z[#26+0.6]
G00 X-.0498 Y-.0481
G00 Z[#26+0.02]
G01 Z[#26] F#121
N200 X.0027 Y0.
Y-.25
X.0498
G00 Z[#26+0.6]
X.0027
G00 Z[#26+0.02]
G01 Z[#26]
X-.0435
G00 Z[#26+0.6]
GOTO#113

N5002 (TWO)
G00 Z[#26+0.6]
G00 X.0625 Y-.25
G00 Z[#26+0.02]
G01 Z[#26] F#121
X-.0625
X.0542 Y-.0733
X.0586 Y-.0649
X.0615 Y-.0577
X.0625 Y-.0481
X.0615 Y-.0397
X.0586 Y-.0325
X.0542 Y-.024
X.0478 Y-.0168
X.04 Y-.0108
X.0311 Y-.006
X.0213 Y-.0024
X.011 Y-.0012
X.0002 Y0.
X-.011 Y-.0012
X-.0213 Y-.0024
X-.0311 Y-.006
X-.04 Y-.0108
X-.0478 Y-.0168
X-.0542 Y-.024
X-.0586 Y-.0325
X-.0615 Y-.0397
X-.0625 Y-.0481
G00 Z[#26+0.6]
GOTO#113

N5003 (THREE)
G00 Z[#26+0.6]
G00 X-.0556 Y-.0481
G00 Z[#26+0.02]
G01 Z[#26-#7] F#121
X-.0547 Y-.0397
X-.0522 Y-.0325
X-.0483 Y-.024
X-.0424 Y-.0168
X-.0355 Y-.0108
X-.0277 Y-.006
X-.0189 Y-.0024
X-.0096 Y-.0012
X.0002 Y0.
X.0096 Y-.0012
X.0189 Y-.0024
X.0277 Y-.006
X.0355 Y-.0108
X.0424 Y-.0168
X.0483 Y-.024
X.0522 Y-.0325
X.0547 Y-.0397
X.0556 Y-.0481
X.0547 Y-.0577
X.0522 Y-.0649
X.0483 Y-.0733
X.0424 Y-.0805
X.0355 Y-.0865
X.0277 Y-.0913
X.0189 Y-.095
X.0096 Y-.0962
X.0002 Y-.0974
X.011 Y-.0986
X.0213 Y-.1022
X.0311 Y-.1082
X.04 Y-.1154
X.0478 Y-.125
X.0542 Y-.1358
X.0586 Y-.1478
X.0615 Y-.1599
X.0625 Y-.1731
X.0615 Y-.1875
X.0586 Y-.1995
X.0542 Y-.2115
X.0478 Y-.2224
X.04 Y-.232
X.0311 Y-.2392
X.0213 Y-.2452
X.011 Y-.2488
X.0002 Y-.25
X-.011 Y-.2488
X-.0213 Y-.2452
X-.0311 Y-.2392
X-.04 Y-.232
X-.0478 Y-.2224
X-.0542 Y-.2115
X-.0586 Y-.1995
X-.0615 Y-.1875
X-.0625 Y-.1731
G00 Z[#26+0.6]
GOTO#113

N5004 (FOUR)
G00 Z[#26+0.6]
G00 X.0625 Y-.1671
G00 Z[#26+0.02]
G01 Z[#26-#7] F#121
X-.0625
X.0419 Y0.
Y-.25
G00 Z[#26+0.6]
GOTO#113

N5005 (FIVE)
G00 Z[#26+0.6]
G00 X.0625 Y0.
G00 Z[#26+0.02] 
G01 Z[#26-#7] F#121
X-.061
Y-.1334
X-.0556 Y-.125
X-.0473 Y-.1154
X-.038 Y-.1082
X-.0272 Y-.1022
X-.0159 Y-.0986
X-.0047 Y-.0974
X.0071 Y-.0986
X.0184 Y-.1022
X.0292 Y-.1082
X.0385 Y-.1154
X.0468 Y-.125
X.0537 Y-.1358
X.0586 Y-.1478
X.0615 Y-.1599
X.0625 Y-.1731
X.0615 Y-.1875
X.0586 Y-.1995
X.0537 Y-.2115
X.0468 Y-.2224
X.0385 Y-.232
X.0292 Y-.2392
X.0184 Y-.2452
X.0071 Y-.2488
X-.0047 Y-.25
X-.0159 Y-.2488
X-.0272 Y-.2452
X-.038 Y-.2392
X-.0473 Y-.232
X-.0556 Y-.2224
X-.0625 Y-.2115
G00 Z[#26+0.6]
GOTO#113

N5006 (SIX)
G00 Z[#26+0.6]
G00 X.0625 Y0.
G00 Z[#26+0.02] 
G01 Z[#26-#7] F#121
X-.0478 Y-.1478
X-.0542 Y-.1563
X-.0586 Y-.1659
X-.0615 Y-.1767
X-.0625 Y-.1875
X-.0615 Y-.1983
X-.0586 Y-.2091
X-.0542 Y-.2188
X-.0478 Y-.2272
X-.04 Y-.2356
X-.0311 Y-.2416
X-.0213 Y-.2464
X-.011 Y-.2488
X.0002 Y-.25
X.011 Y-.2488
X.0213 Y-.2464
X.0311 Y-.2416
X.04 Y-.2356
X.0478 Y-.2272
X.0542 Y-.2188
X.0586 Y-.2091
X.0615 Y-.1983
X.0625 Y-.1875
X.0615 Y-.1767
X.0586 Y-.1659
X.0542 Y-.1563
X.0478 Y-.1478
X.04 Y-.1394
X.0311 Y-.1334
X.0213 Y-.1286
X.011 Y-.1262
X.0002 Y-.125
X-.011 Y-.1262
X-.0213 Y-.1286
X-.0311 Y-.1334
X-.04 Y-.1394
X-.0478 Y-.1478
G00 Z[#26+0.6]
GOTO#113

N5007 (SEVEN)
G00 Z[#26+0.6]
G00 X-.0625 Y0.
G00 Z[#26+0.02]
G01 Z[#26-#7] F#121
X.0625
X-.0625 Y-.25
G00 Z[#26+0.6]
GOTO#113

N5008 (EIGHT)
G00 Z[#26+0.6]
G00 X-.0047 Y-.0974 
G00 Z[#26+0.02]
G01 Z[#26-#7] F#121
X-.0096 Y-.0962
X-.0189 Y-.095
X-.0277 Y-.0913
X-.0355 Y-.0865
X-.0424 Y-.0805
X-.0483 Y-.0733
X-.0522 Y-.0649
X-.0547 Y-.0577
X-.0556 Y-.0481
X-.0547 Y-.0397
X-.0522 Y-.0325
X-.0483 Y-.024
X-.0424 Y-.0168
X-.0355 Y-.0108
X-.0277 Y-.006
X-.0189 Y-.0024
X-.0096 Y-.0012
X.0002 Y0.
X.0096 Y-.0012
X.0189 Y-.0024
X.0277 Y-.006
X.0355 Y-.0108
X.0424 Y-.0168
X.0483 Y-.024
X.0522 Y-.0325
X.0547 Y-.0397
X.0556 Y-.0481
X.0547 Y-.0577
X.0522 Y-.0649
X.0483 Y-.0733
X.0424 Y-.0805
X.0355 Y-.0865
X.0277 Y-.0913
X.0189 Y-.095
X.0096 Y-.0962
X.0051 Y-.0974
X-.0047
X-.011 Y-.0986
X-.0213 Y-.1022
X-.0311 Y-.1082
X-.04 Y-.1154
X-.0478 Y-.125
X-.0542 Y-.1358
X-.0586 Y-.1478
X-.0615 Y-.1599
X-.0625 Y-.1731
X-.0615 Y-.1875
X-.0586 Y-.1995
X-.0542 Y-.2115
X-.0478 Y-.2224
X-.04 Y-.232
X-.0311 Y-.2392
X-.0213 Y-.2452
X-.011 Y-.2488
X.0002 Y-.25
X.011 Y-.2488
X.0213 Y-.2452
X.0311 Y-.2392
X.04 Y-.232
X.0478 Y-.2224
X.0542 Y-.2115
X.0586 Y-.1995
X.0615 Y-.1875
X.0625 Y-.1731
X.0615 Y-.1599
X.0586 Y-.1478
X.0542 Y-.1358
X.0478 Y-.125
X.04 Y-.1154
X.0311 Y-.1082
X.0213 Y-.1022
X.011 Y-.0986
X.0051 Y-.0974
G00 Z[#26+0.6]
GOTO#113

N5009 (NINE)
G00 Z[#26+0.6]
G00 X.0054 Y-.2602
G00 Z[#26+0.02]
G01 Z[#26-#7] F#121
X.0585 Y-.0836
X.0616 Y-.0735
X.0624 Y-.0629
X.0615 Y-.0518
X.0587 Y-.0413
X.0541 Y-.0314
X.0476 Y-.0223
X.0402 Y-.0147
X.0313 Y-.009
X.0211 Y-.0038
X.0108 Y-.0012
X-.0001 Y0.
X-.0106 Y-.0013
X-.0211 Y-.0038
X-.0313 Y-.0088
X-.0402 Y-.0146
X-.0477 Y-.0225
X-.054 Y-.0311
X-.0585 Y-.0417
X-.0616 Y-.0518
X-.0624 Y-.0623
X-.0615 Y-.0735
X-.0587 Y-.084
X-.0541 Y-.0938
X-.0476 Y-.103
X-.0402 Y-.1105
X-.0313 Y-.1163
X-.0211 Y-.1215
X-.0108 Y-.1241
X.0001 Y-.1253
X.0106 Y-.124
X.0216 Y-.1213
X.0313 Y-.1165
X.0402 Y-.1107
X.0477 Y-.1028
X.054 Y-.0941
X.0585 Y-.0836
G00 Z[#26+0.6]
GOTO#113

N30 #3000 = 100 (OUT OF RANGE)
N99
M99
%

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