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:

How to engrave sequential serial numbers


Recommended Posts

Hi All – The cool macros thread was getting a little long.

 

This is something I see people asking for every once in a while. This macro is a little different from some of the others you've seen online or read about in Modern Machine Shop. 

 

 

It will engrave as many digits as the machine can hold in a macro variable, normal letters (A-Z) and numbers (0-9); plus dot, dash, and space. It has been tested on Haas and Fanuc based controls. It should run on most machines with little modification.

 

Here is the meat so you can guys can get an idea of how it works:

 

O1000 (SerialEngrave)
G69 G17 G90 
G91 G28 Z0. 
(REQUIRED PARAMETERS)
(retract height here)
#130=-0.1
(character spacing)
#132=0.085 
(set lot number)
#140=4.
(set tool and offset)
T11 H11
(rpm and feed rate)
S6000 F30.
(XYZ origin)
G90 G10 L2 P5 X-8.243 Y-7.355 Z-17.526
(XYZ adjustment)
G91 G10 L2 P5 X-.2 Y.73 Z-.0035
G90 

M06 (tool change)
G17 G90 G58 G00 X0. Y0. M03
G68 X0 Y0 R[#133]
G43 Z[ABS[#130]]
/M08
G65 P9100 D10.  
G65 P9100 D[#140]
G65 P9100 C2. 
G65 P9100 S3. 

G00 Z3. M09 
G91 G28 G00 Z0. Y0. 
M30
:O9400 (SERIES)
IF[#529NE0]GOTO1(If the counter is not set reset it to one)
#529=1
N1
#527=#529 (Transfer counter to temp. variable so we can perform operations on it without modifying the original value)
#141=[#19-1] (Calculate the number of zeros we need to engrave ahead of the serial number)
G91 G0 X[[#19]*[#132]] (Move to first digit start position)
WHILE[#19GT0]DO1
N2 #528=FIX[[#527]MOD10] (Find digit to engrave)
#527=FIX[#527/10] (NEXT)
G91 G0 X[-[ABS[#132]]] (Move to start position)
IF[#528EQ0]THEN#528=10 (If the digit is a zero run program 9110)
M98 P[ABS[#528]+9100] (Engrave Digit)
#19=#19-1 (Decrement number of letters to engrave)
END1
(Increment Counter)
#529=#529+1
M99

The latest version can be download from GitHub:

https://github.com/themachinist/SerialEngrave

 

I encourage you to create an issue if you'd like report or a bug or request an enhancement.

 

Regards,

Dave

  • Like 1
Link to comment
Share on other sites

Around the circumference of a cylinder, like a c-axis on a lathe or 4th-axis on a mill? If we broke the letters up into line sections we could use trigonometric functions to adjust the Z positions, but then it would be difficult to scale the letters. I could try changing everything to arc moves of known size (say 1 inch) and then use scaling to adjust the letter paths to the diameter of the cylinder. 

 

It was the first thing I thought of after I got it working and the #1 requested feature, however it is rather difficult to implement and there hasn't been a need at my shop. I might work on it in the future.

Link to comment
Share on other sites

Around the circumference of a cylinder, like a c-axis on a lathe or 4th-axis on a mill? 

 

No a 2D arc.

We do a recurring job where they have to be serialized on the face of a gear, but it has to be on a radius, just under the gear teeth minor diameter.

Currently I use a 3rd party program, but for 275 pcs it's too big for the older machine we run it on. 

If I could set up a macro that would make my life so much easier.

Link to comment
Share on other sites

That shouldn't be difficult. I would first set the origin to the center of the gear, then rotate the coordinate system (G68) in between each letter, then translate the system (G10) up to the baseline + .100" (the height of the letters). Then you can use scaling (G51) to correct the size of the characters. Does that make sense?

 

I could probably write a sample within the next week or so.

Link to comment
Share on other sites

That shouldn't be difficult. I would first set the origin to the center of the gear, then rotate the coordinate system (G68) in between each letter, then translate the system (G10) up to the baseline + .100" (the height of the letters). Then you can use scaling (G51) to correct the size of the characters. Does that make sense?

 

I could probably write a sample within the next week or so.

Yep, that makes sense.

Link to comment
Share on other sites

 

Nice!

What would it take to program those letters/numbers on an arc instead of a straight line?

 

Try this one.  You may need to adjust the formatting to your purpose.

%
O1234
(SERIAL NUMBER MACRO)
(MATT HAJICEK)
T1M6

(G65 Variable Useage:)
(#543 = 1st number set to engrave)
(#548 = 2nd number set to engrave)
(#538 = 3rd number set to engrave, will be incremented if not reset.)
(E = Number set to engrave: 1., 2., or 3.)
(D = # of digits to engrave)
(Example: "N123D5" results in "00123")
(I = 1. = Dash, 0. = No Dash)
(X = X position of center of arc)
(Y = Y position of center of arc)
(Z = Z depth to cut)
(B = Radius of arc)
(A = Angular position on arc)
(U = X position of center of cylinder)
(V = Y position of center of cylinder)
(W = Z position of center of cylinder)
(Q = Radius of cylinder)
(C = Orientation of cylinder)
(T = Text size)
(F = Feed rate <-- REMOVED)
(R = Rapid / Retract plane)
(S = Spindle Speed)
(H = Tool length offset number)

F10.

#543=12345 (FIVE DIGIT WORK ORDER NUMBER)
G65P8500E1.D5I1.X0Y0Z-.01A112.T.5R.1B6.S8000.H1.U2.V5.W-4.C0.Q4.

#548=0708  (FOUR DIGIT DATE NUMBER)
G65P8500E2.D4I1.X0Y0Z-.01A83.T.5R.1B6.S8000.H1.U2.V5.W-4.C0.Q4.

(COMMENT OUT NEXT LINE TO INCREMENT)
#538=1234  (FOUR DIGIT SERIAL NUMBER)
G65P8500E3.D4I0X0Y0Z-.01A60.T.5R.1B6.S8000.H1.U2.V5.W-4.C0.Q4.

G65P8500E1.D5I1.X-1.5Y0Z-.01A45.T1.R.1B0.S8000.H1.U0V0.W-4.C90.Q4.

M30

O8500(SERIAL# DEFINITION)
(11-18-08)(MDH)

(#140 MACHINE ARC TANGENT SUPPORT)
(0 = NO ARC TANGENT FUNCTION)
(1 = ATN)
(2 = ATAN)
#140=0

(NUMBER DEFINITION)
(NOTE: UP TO FIVE DIGITS SUPPORTED)
#114=#8

N1
IF[#114NE1.]GOTO2
(#543, FIVE DIGIT WORK ORDER NUMBER)
#121=#543  (NUMBER)
GOTO4

N2
IF[#114NE2.]GOTO3
(#548, FOUR DIGIT DATE NUMBER)
#121=#548  (NUMBER)
GOTO4

N3
(#538, FOUR DIGIT SERIAL NUMBER)
#121=#538  (NUMBER)

N4
#122=#7    (NUMBER OF DIGITS)
#123=#4    (1 = DASH, 0 = NO DASH)

(ARC DEFINITION)
#107=#24   (X POSITION)
#108=#25   (Y POSITION)
#109=#2    (RADIUS, OR 0 FOR STRAIGHT)
#110=#1*-1 (ANGLE)
#112=#20   (DIGIT SIZE Y IN INCHES)
#111=#112  (DIGIT SIZE X IN INCHES)
#113=#112*.1 (SPACE BETWEEN DIGITS)

(CUT PARAMETERS)
#115=#18   (RETRACT HEIGHT)
#116=#26   (CUT DEPTH)
#117=#9    (FEED RATE)
#118=#19   (SPINDLE SPEED)
#120=#11   (H NUMBER)

(CYLINDER PROJECTION PARAMETERS)
#129=#21   (X COORDINANT OF THROUGH POINT)
#130=#22   (Y COORDINANT OF THROUGH POINT)
#131=#23   (Z COORDINANT OF THROUGH POINT)
#132=#3    (XY PLANE ANGLE OF CYLINDER, 0 OR 90)(90 BROKE SO FAR)
#133=0     (RESERVED FOR ELEVATION ANGLE OF CYLINDER)
#134=#17   (RADIUS OF CYLINDER, OR 0 FOR FLAT)
(CONDITION CYLINDER VARIABLES)
WHILE[#132 LT 0] DO1
#132=#132+180
END1
WHILE[#132 GE 180] DO1
#132=#132-180
END1
WHILE[#133 LT 0] DO1
#133=#133+90
END1
WHILE[#133 GE 90] DO1
#133=#133-90
END1
IF[#134 GE 0] GOTO 10
#3000=99(CYLINDER RADIUS < 0)
N10

M98P8501

IF[#114NE2.]GOTO5
#538=#538+1

N5
M99

O8501(SERIAL# CUTTING)

(BREAK IT DOWN)
#101=FIX[#121/10000]
#102=FIX[#121/1000]-[#101*10]
#103=FIX[#121/100]-[#101*100]-[#102*10]
#104=FIX[#121/10]-[#101*1000]-[#102*100]-[#103*10]
#105=FIX[#121]-[#101*10000]-[#102*1000]-[#103*100]-[#104*10]

(FIND STRING LENGTH)

#106 = #111/-2

(REMOVE NEXT LINE TO CENTER TEXT)
GOTO 100

#106=[#111*[#122-1]]+[#113*[#122-1]]

IF[#123EQ0.]GOTO 100
#106=#106+#111+#113 (ADD ANOTHER CHARACTER AND SPACE FOR DASH)

N100
#126=#106*[-.5]

(ARC CALCULATIONS)
#127=#109*2*3.14159 (CIRCUMFERENCE = RADIUS * 2 * PI)

IF[#122EQ0]GOTO 106
IF[#122EQ1]GOTO 105
IF[#122EQ2]GOTO 104
IF[#122EQ3]GOTO 103
IF[#122EQ4]GOTO 102
IF[#122EQ5]GOTO 101
#3000=99(# OF DIGITS ERROR)

N101
(CUT 1ST DIGIT)
IF[#101EQ0]GOTO 10 
IF[#101EQ1.]GOTO 11 
IF[#101EQ2.]GOTO 12 
IF[#101EQ3.]GOTO 13 
IF[#101EQ4.]GOTO 14 
IF[#101EQ5.]GOTO 15 
IF[#101EQ6.]GOTO 16 
IF[#101EQ7.]GOTO 17 
IF[#101EQ8.]GOTO 18 
IF[#101EQ9.]GOTO 19 
#3000=99(1ST DIGIT ERROR)
M00 
N10M98P8510 
GOTO 102 
N11M98P8511 
GOTO 102 
N12M98P8512 
GOTO 102 
N13M98P8513 
GOTO 102 
N14M98P8514 
GOTO 102 
N15M98P8515 
GOTO 102 
N16M98P8516 
GOTO 102 
N17M98P8517 
GOTO 102 
N18M98P8518 
GOTO 102 
N19M98P8519 
GOTO 102

N102
(CUT 2ND DIGIT)
IF[#102EQ0]GOTO 20 
IF[#102EQ1.]GOTO 21 
IF[#102EQ2.]GOTO 22 
IF[#102EQ3.]GOTO 23 
IF[#102EQ4.]GOTO 24 
IF[#102EQ5.]GOTO 25 
IF[#102EQ6.]GOTO 26 
IF[#102EQ7.]GOTO 27 
IF[#102EQ8.]GOTO 28 
IF[#102EQ9.]GOTO 29 
#3000=99(2ND DIGIT ERROR)
M00 
N20M98P8510
GOTO 103
N21M98P8511 
GOTO 103 
N22M98P8512 
GOTO 103 
N23M98P8513 
GOTO 103 
N24M98P8514 
GOTO 103 
N25M98P8515 
GOTO 103 
N26M98P8516 
GOTO 103 
N27M98P8517 
GOTO 103 
N28M98P8518 
GOTO 103 
N29M98P8519 
GOTO 103 

N103
(CUT 3RD DIGIT)
IF[#103EQ0]GOTO 30 
IF[#103EQ1.]GOTO 31 
IF[#103EQ2.]GOTO 32 
IF[#103EQ3.]GOTO 33 
IF[#103EQ4.]GOTO 34 
IF[#103EQ5.]GOTO 35 
IF[#103EQ6.]GOTO 36 
IF[#103EQ7.]GOTO 37 
IF[#103EQ8.]GOTO 38 
IF[#103EQ9.]GOTO 39 
#3000=99(3RD DIGIT ERROR)
M00 
N30M98P8510
GOTO 104
N31M98P8511 
GOTO 104 
N32M98P8512 
GOTO 104 
N33M98P8513 
GOTO 104 
N34M98P8514 
GOTO 104 
N35M98P8515 
GOTO 104 
N36M98P8516 
GOTO 104 
N37M98P8517 
GOTO 104 
N38M98P8518 
GOTO 104 
N39M98P8519 
GOTO 104 

N104
(CUT 4TH DIGIT)
IF[#104EQ0]GOTO 40 
IF[#104EQ1.]GOTO 41 
IF[#104EQ2.]GOTO 42 
IF[#104EQ3.]GOTO 43 
IF[#104EQ4.]GOTO 44 
IF[#104EQ5.]GOTO 45 
IF[#104EQ6.]GOTO 46 
IF[#104EQ7.]GOTO 47 
IF[#104EQ8.]GOTO 48 
IF[#104EQ9.]GOTO 49 
#3000=99(4TH DIGIT ERROR)
M00 
N40M98P8510
GOTO 105
N41M98P8511 
GOTO 105 
N42M98P8512 
GOTO 105 
N43M98P8513 
GOTO 105 
N44M98P8514 
GOTO 105 
N45M98P8515 
GOTO 105 
N46M98P8516 
GOTO 105 
N47M98P8517 
GOTO 105 
N48M98P8518 
GOTO 105 
N49M98P8519 
GOTO 105 

N105
(CUT 5TH DIGIT)
IF[#105EQ0]GOTO 40 
IF[#105EQ1.]GOTO 41 
IF[#105EQ2.]GOTO 42 
IF[#105EQ3.]GOTO 43 
IF[#105EQ4.]GOTO 44 
IF[#105EQ5.]GOTO 45 
IF[#105EQ6.]GOTO 46 
IF[#105EQ7.]GOTO 47 
IF[#105EQ8.]GOTO 48 
IF[#105EQ9.]GOTO 49 
#3000=99(5TH DIGIT ERROR)
M00 
N40M98P8510
GOTO 106
N41M98P8511 
GOTO 106 
N42M98P8512 
GOTO 106 
N43M98P8513 
GOTO 106 
N44M98P8514 
GOTO 106 
N45M98P8515 
GOTO 106 
N46M98P8516 
GOTO 106 
N47M98P8517 
GOTO 106 
N48M98P8518 
GOTO 106 
N49M98P8519 
GOTO 106 

N106
(CUT DASH)
IF[#123EQ0]GOTO 107
N49M98P8520
GOTO 107 

N107
M99

O8510(NUMBER ZERO)
G90G0
G65P8521X.2335Y0.1631
G43H#120Z#115
G1Z#116S#118
G65P8521X.2779Y0.329
G65P8521X.2929Y0.5
G65P8521X.2779Y0.671
G65P8521X.2335Y0.8369
G65P8521X.1907Y0.9121
G65P8521X.1246Y0.9681
G65P8521X.0433Y0.9978
G65P8521X-.0433Y0.9978
G65P8521X-.1246Y0.9681
G65P8521X-.1907Y0.9121
G65P8521X-.2335Y0.8369
G65P8521X-.2779Y0.671
G65P8521X-.2929Y0.5
G65P8521X-.2779Y0.329
G65P8521X-.2335Y0.1631
G65P8521X-.1907Y0.0879
G65P8521X-.1246Y0.0319
G65P8521X-.0433Y0.0022
G65P8521X.0433Y0.0022
G65P8521X.1246Y0.0319
G65P8521X.1907Y0.0879
G65P8521X.2335Y0.1631
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8511(NUMBER ONE)
G90G0
#138=0
G65P8521X0.Y0.0
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X0.Y1.0
G65P8521X-.1429Y0.8571
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8512(NUMBER TWO)
G90G0
#138=0
G65P8521X-.2774Y0.8571
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.2774Y0.8571
G65P8521X-.232Y0.9163
G65P8521X-.1728Y0.9617
G65P8521X-.1039Y0.9902
G65P8521X-.03Y1.0
G65P8521X-.0078Y1.0
G65P8521X.078Y0.9868
G65P8521X.156Y0.9484
G65P8521X.2187Y0.8884
G65P8521X.2606Y0.8123
G65P8521X.2776Y0.7271
G65P8521X.2671Y0.6622
G65P8521X.242Y0.6014
G65P8521X.2037Y0.548
G65P8521X.0785Y0.4478
G65P8521X-.0531Y0.3563
G65P8521X-.1443Y0.2913
G65P8521X-.2182Y0.2072
G65P8521X-.2706Y0.1083
G65P8521X-.2989Y0.0
G65P8521X.299Y0.0
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8513(NUMBER THREE)
G90G0
#138=0
G65P8521X-.2857Y0.8571
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.2857Y0.8571
G65P8521X-.2398Y0.9163
G65P8521X-.1803Y0.9617
G65P8521X-.1111Y0.9902
G65P8521X-.0368Y1.0
G65P8521X0.Y1.0
G65P8521X.0748Y0.991
G65P8521X.1454Y0.9645
G65P8521X.2077Y0.922
G65P8521X.2499Y0.8729
G65P8521X.2766Y0.814
G65P8521X.2857Y0.75
G65P8521X.2757Y0.6797
G65P8521X.2465Y0.615
G65P8521X.2004Y0.561
G65P8521X.1411Y0.5219
G65P8521X.0733Y0.501
G65P8521X.0019Y0.5009
G65P8521X.0733Y0.5009
G65P8521X.1449Y0.4828
G65P8521X.2082Y0.4446
G65P8521X.2577Y0.3898
G65P8521X.2892Y0.3231
G65P8521X.3Y0.25
G65P8521X.2908Y0.186
G65P8521X.2641Y0.1271
G65P8521X.222Y0.078
G65P8521X.1597Y0.0355
G65P8521X.0892Y0.009
G65P8521X.0143Y0.0
G65P8521X-.0511Y0.0
G65P8521X-.1254Y0.0097
G65P8521X-.1946Y0.0383
G65P8521X-.2542Y0.0837
G65P8521X-.3Y0.1429
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8514(NUMBER FOUR)
G90G0
#138=0
G65P8521X.1857Y0.0
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X.1857Y0.0
G65P8521X.1857Y1.0
G65P8521X-.3321Y0.2357
G65P8521X.3322Y0.2357
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8515(NUMBER FIVE)
G90G0
#138=0
G65P8521X-.3126Y0.1424
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.3126Y0.1424
G65P8521X-.2867Y0.1084
G65P8521X-.2566Y0.0782
G65P8521X-.1938Y0.0353
G65P8521X-.1225Y0.0086
G65P8521X-.047Y-0.0005
G65P8521X-.0019Y-0.0005
G65P8521X.0797Y0.0103
G65P8521X.1556Y0.0419
G65P8521X.2208Y0.0922
G65P8521X.2706Y0.1577
G65P8521X.304Y0.2413
G65P8521X.3134Y0.3308
G65P8521X.2979Y0.4194
G65P8521X.2588Y0.5005
G65P8521X.2072Y0.5596
G65P8521X.1422Y0.6034
G65P8521X.06Y0.6332
G65P8521X-.0269Y0.6433
G65P8521X-.1277Y0.6361
G65P8521X-.2245Y0.6071
G65P8521X-.3126Y0.5576
G65P8521X-.3126Y1.0005
G65P8521X.292Y1.0005
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8516(NUMBER SIX)
G90G0
#138=0
G65P8521X-.2739Y0.2245
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.2739Y0.2245
G65P8521X-.281Y0.3235
G65P8521X-.2552Y0.4192
G65P8521X-.1992Y0.5012
G65P8521X-.1194Y0.5601
G65P8521X-.0246Y0.5895
G65P8521X.0745Y0.586
G65P8521X.167Y0.5501
G65P8521X.2425Y0.4857
G65P8521X.2926Y0.4001
G65P8521X.3117Y0.3027
G65P8521X.2977Y0.2045
G65P8521X.254Y0.1193
G65P8521X.1855Y0.0524
G65P8521X.0993Y0.0108
G65P8521X.0043Y-0.0013
G65P8521X-.0896Y0.0174
G65P8521X-.1727Y0.065
G65P8521X-.2363Y0.1365
G65P8521X-.274Y0.2245
G65P8521X-.3042Y0.3666
G65P8521X-.311Y0.5117
G65P8521X-.2941Y0.656
G65P8521X-.254Y0.7956
G65P8521X-.2089Y0.8826
G65P8521X-.138Y0.9502
G65P8521X-.0489Y0.9911
G65P8521X.0486Y1.0009
G65P8521X.144Y0.9784
G65P8521X.2269Y0.9261
G65P8521X.2883Y0.8497
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8517(NUMBER SEVEN)
G90G0
#138=0
G65P8521X-.3Y1.0
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.3Y1.0
G65P8521X.3Y1.0
G65P8521X.194Y0.8168
G65P8521X.11Y0.6225
G65P8521X.0492Y0.4198
G65P8521X.0123Y0.2113
G65P8521X0.Y0.
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8518(NUMBER EIGHT)
G90G0
#138=0
G65P8521X-.0324Y0.5357
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.0324Y0.5357
G65P8521X-.1185Y0.5523
G65P8521X-.1924Y0.5996
G65P8521X-.2434Y0.671
G65P8521X-.2643Y0.7562
G65P8521X-.2521Y0.8431
G65P8521X-.2085Y0.9192
G65P8521X-.1398Y0.9738
G65P8521X-.0877Y0.9934
G65P8521X-.0324Y1.0
G65P8521X.0319Y1.0
G65P8521X.1036Y0.9886
G65P8521X.1683Y0.9557
G65P8521X.2197Y0.9043
G65P8521X.2526Y0.8396
G65P8521X.264Y0.7679
G65P8521X.2526Y0.6962
G65P8521X.2197Y0.6315
G65P8521X.1683Y0.5801
G65P8521X.1036Y0.5472
G65P8521X.0319Y0.5358
G65P8521X-.0324Y0.5357
G65P8521X-.1143Y0.5229
G65P8521X-.1884Y0.4856
G65P8521X-.2475Y0.4274
G65P8521X-.286Y0.3539
G65P8521X-.3002Y0.2722
G65P8521X-.2886Y0.1901
G65P8521X-.2526Y0.1154
G65P8521X-.1931Y0.0536
G65P8521X-.1171Y0.0138
G65P8521X-.0324Y0.0
G65P8521X.0319Y0.0
G65P8521X.1147Y0.0131
G65P8521X.1894Y0.0512
G65P8521X.2486Y0.1104
G65P8521X.2867Y0.1851
G65P8521X.2998Y0.2679
G65P8521X.2867Y0.3507
G65P8521X.2486Y0.4254
G65P8521X.1894Y0.4846
G65P8521X.1147Y0.5227
G65P8521X.0319Y0.5358
G65P8521Y0.5357
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8519(NUMBER NINE)
G90G0
#138=0
G65P8521X-.2883Y0.1503
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.2883Y0.1503
G65P8521X-.2269Y0.0739
G65P8521X-.144Y0.0216
G65P8521X-.0486Y-0.0008
G65P8521X.0489Y0.0089
G65P8521X.138Y0.0498
G65P8521X.2089Y0.1175
G65P8521X.254Y0.2045
G65P8521X.2941Y0.3441
G65P8521X.311Y0.4884
G65P8521X.3042Y0.6335
G65P8521X.2739Y0.7756
G65P8521X.2362Y0.8636
G65P8521X.1726Y0.935
G65P8521X.0895Y0.9826
G65P8521X-.0044Y1.0012
G65P8521X-.0993Y0.9891
G65P8521X-.1855Y0.9475
G65P8521X-.2539Y0.8806
G65P8521X-.2976Y0.7955
G65P8521X-.3117Y0.6973
G65P8521X-.2926Y0.5999
G65P8521X-.2425Y0.5142
G65P8521X-.167Y0.4499
G65P8521X-.0745Y0.414
G65P8521X.0247Y0.4105
G65P8521X.1195Y0.4399
G65P8521X.1993Y0.4989
G65P8521X.2552Y0.5808
G65P8521X.2811Y0.6766
G65P8521X.2739Y0.7756
G0Z#115
#126=#126+#111+#113 (ADD SHIFT FOR NEXT DIGIT)
M99

O8520(DASH)
G90G0
#138=0
G65P8521X-.3321Y0.5
G43H#120Z#115
G1Z#116S#118
#138=1
G65P8521X-.3321Y0.5
G65P8521X.3321Y0.5
G0Z#115
M99

O8521(POSITION)
#124=#24 (PULL X POSITION FROM MACHINE)
#125=#25 (PULL Y POSITION FROM MACHINE)

#124=#124*#111 (SCALE X)
#125=#125*#112 (SCALE Y)

#124=#124+#126 (SHIFT X BY DIGIT SPACING)

IF[#109 EQ 0] GOTO 1001 (FLAT LINE)
(ARC CALCULATIONS)
#125=#125+#109 (SHIFT Y BY RADIUS)

#128=[[#124/#127]*[-360]]-#110 (ANGLE FROM ARC CENTER)

#124=COS[#128]*#125
#125=SIN[#128]*#125

GOTO 1011
N1001
(FLAT LINE TILT)

IF[#110 EQ 0] GOTO 1011 (NO TILT)

IF[#124 NE 0] GOTO 1013
IF[#125 NE 0] GOTO 1013

N1012
#128 = 0
GOTO 1014

N1013
(#140 MACHINE ARC TANGENT SUPPORT)
(0 = NO ARC TANGENT FUNCTION)
(1 = ATN)
(2 = ATAN)

IF[#140 EQ 0] GOTO 1016

IF[#140 EQ 1] GOTO 1017

(ELSE-)
(ARC TANGENT BY "ATAN")
#128=ATAN[#125]/[#124]
GOTO 1014

N1017
(ARC TANGENT BY "ATN")
#128=ATN[#125]/[#124]
GOTO 1014

N1016
(ARC-TANGENT THE HARD WAY,)
(FOR WHEN "ATAN" NOT AVAILABLE)
(SLIGHTLY LESS ACCURATE)
#139=[#125]/[#124](ANGLE FROM ARC CENTER)

(ATAN APPROXIMATION FORMULA ONLY ACCURATE FROM -45 TO +45 DEGREES)
(SO MIRROR ABOUT 45 DEGREE LINE, CALCULATE, AND MIRROR BACK)
(WHEN APPROPRIATE)

IF[ABS[#139] LE 1.] GOTO 1015
(FOR RANGE 45 TO 90 DEGREES)
#139=[#124]/[#125]
#128=[[#139] + [0.43157974*[#139]*[#139]*[#139]]]/[1 + [0.76443945*[#139]*[#139]] + [0.05831938*[#139]*[#139]*[#139]*[#139]]]
#128=#128*57.2957795(CONVERT RADIANS TO DEGREES)
#128=[[#128-45.]*-1.]+45.
GOTO 1014

N1015
(FOR RANGE TO 45 DEGREES)
#128=[[#139] + [0.43157974*[#139]*[#139]*[#139]]]/[1 + [0.76443945*[#139]*[#139]] + [0.05831938*[#139]*[#139]*[#139]*[#139]]]
#128=#128*57.2957795(CONVERT RADIANS TO DEGREES)

N1014
#128=#128-#110 (ROTATE)
#119=SQRT[[#124*#124]+[#125*#125]] (DISTANCE FROM ARC CENTER)
#124=[COS[#128]]*#119
#125=[SIN[#128]]*#119

N1011

#124=#124+#107 (SHIFT X BY ARC CENTER)
#125=#125+#108 (SHIFT Y BY ARC CENTER)

(ARC CALCULATIONS COMPLETE)

#137=#116
IF[#134EQ0] GOTO 1100 (NO PROJECTION)

(BEGIN PROJECTION ON CYLINDER)

IF[#132NE0] GOTO 1003
(SPECIAL CASE #1: XY PLANE ANGLE = 0)
#135=ABS[#130-#125] (DISTANCE IN Y TO CYL. AXIS)
IF[#135LT#134] GOTO 1002
#137=#131+#116 (BEYOND CYLINDER, CUT AT CENTER PLANE)
GOTO 1100

N1002
#136=SQRT[ABS[[#134*#134]-[#135*#135]]]+#131
#137=#136+#116
GOTO 1100

N1003
IF[#132NE90] GOTO 1005
(SPECIAL CASE #2: XY PLANE ANGLE = 90)
#135=ABS[#129-#124] (DISTANCE IN X TO CYL. AXIS)
IF[#135LT#134] GOTO 1004
#137=#131+#116 (BEYOND CYLINDER, CUT AT CENTER PLANE)
GOTO 1100

N1004
#136=SQRT[ABS[[#134*#134]-[#135*#135]]]+#131
#137=#136+#116
GOTO 1100

N1005
#3000=99(ANGLES OTHER THAN 0 AND 90 NOT YET SUPPORTED)

N1100
IF[#138EQ0] GOTO 1101
X[#124]Y[#125]Z[#137] (OUTPUT WITH Z)
GOTO 1102

N1101
X[#124]Y[#125] (OUTPUT WITHOUT Z)

N1102
(DONE WITH POINT)
M99

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

if you guys are running haas machine use g47 for the engraving. the machine will generate the code for you once you have the proper values into the program. 

here is the hand written program we use, for all our engraving on the haas we just change the values according to the size of the part.  IF THE PROGRAM IS CORRECT THE MACHINE WILL GENERATE THE CODE FOR EACH NUMBER, LETTER AND CHARACTER THAT YOU HAVE GIVEN IT IN THE BRACKETS.  (THIS PROGRAM WAS WRITTEN USING THE CENTER OF THE CHECK AS Z0.0)

THIS PROGRAM IS FOR ENGRAVING ON A 4TH AXIS, THE Q=D OF SURFACE YOU ARE ENGRAVING, I = DIRECTION OF LETTERING, J = SIZE OF LETTERING (HEIGHT AND WIDTH WILL BE AFFECTED.) 

TO CHANGE SERIAL # ALL YOU HAVE TO DO IS CHANGE THE LAST NUMBER. ONLY HAAS MACHINES CAN USE THE G47. WE DO ALL OUR ENGRAVING THIS WAY VERY EASY TO CHANGE ANYTHING WE NEED TO ENGRAVE ON THE PART, NO NEED TO WRITE LONG COMPLEX PROGRAMS)

 

T22 M06 (engraving tool)

G00 G90 G54 X8.0 Y0.0 A-155.0 S6000 M03

G107 A0.0 Y0.0 Q4.36

G43 H22 Z3.0 M08

Z2.75 

G47 P0 Y0 I90.0 Z2.168 J0.25 R2.225 F10.0 E5.0 (PN-50-16-605 REV B.0 PO#2354 W0#99028-01 PTS 72907)

G00 Z5.0 M09

G107 

M05 

G91 G28 Z0.0 Y0.0

M00 

(CHECK CIRCUMFERENCE OF PART)

G00 G90 A-155.0 

M00 

G90 A0.0 

M30

 

Link to comment
Share on other sites
On 1/9/2019 at 3:24 PM, myemail said:

 

The problem I have with auto-incrementation is that the operators stop paying attention to what is going on. If you force them to do it manually, you have a better chance of getting it right.

I would say it's the opposite, if you have them to do it manually, the chances of wrong numbers skyrocket.

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