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:

Serialization macro


Recommended Posts

Ok, I have done a serial number macro in the past on a few different controls. I always used something based on what this website outlines....

 

https://www.cncci.com/resources/tips/serial%20macro.htm

 

It works great, except the spacing between numbers is not always a constant. With the font I am going to be using (or any font for that matter), 11111 takes up a lot less space then say 22222. Or when you have a number like 35122 using the above macro it would engrave and it would almost look like there is a space between the 1 and 2.

 

Just curious as to what others have done to deal with the letter/number spacing issue when it comes to serializing parts. Appearance is important on these parts, so no getting away with funny spacing.

 

 

Link to comment
Share on other sites

Douglas.

I think Leigh is on the right track.  My thoughts on this.

 

In the link you provide, He has programmed an absolute position for the start of each number.  I think if you switch and work in all incremental it can be done.

 

1. Think of each digit as a box with the left and right edges of the box being the edges of the digit (no leading or trailing space on the number).  The bottom of the box is the bottom line you will be writing the number on.

2. Start the code for each digit with the tool at the lower left of the box

3. End the code for each digit with the tool at the lower right of the box

 

Now in the program,

1. Start your Serial in an absolute location at the lower left of the first digit.

2. Cut the first digit in incremental mode from that location.  The tool will finish in the lower right corner.

3. Leave your machine in incremental mode in your main program and move your tool the correct distance to form the spacing you want

4. Cut the second digit

etc.... for each digit in your serial.

 

I hope this isn't too long or confusing.   I have it in my head, just not sure I am getting it explained out correctly.

 

-Brian

Link to comment
Share on other sites

A simple way to do it would be to add an incremental coordinate shift at the end of the digit macro.

 

Have the main macro that calls up and evaluates the number to etched;

etch the numbers through sub-macro,

have sub-macro keep track of how much shift is applied,

cancel all shift at the end of the main macro.

 

You'd have to evaluate each digit to find out how much shift each on needs to keep an aesthetically pleasing distance.

 

So, something like this:

 

M98 P5000 (CALL ETCH PROGRAM)

 

:5000 (ETCH PROGRAM)

[logic to determine what number to call]

M98 P0001 (ETCH NUMBER ONE)

         

:0001

[etch number one]

G50 W-.05

#500=#500+.05

M99 

 

(and so on)

 

G50 W#500 (CANCEL ALL SHIFT AND RETURN TO MAIN PROGRAM)

M99

 

 

 

Link to comment
Share on other sites

Hello, I've posted about this before. You should be able to run this macro out of the box on any Fanuc-compatible control. It uses a fixed width font with adjustable character spacing.

How to engrave sequential serial numbers

 

I looked at this. Much more elegant than what I am envisioning. Unfortunately I am stuck with using a specific font.

Link to comment
Share on other sites

I looked at this. Much more elegant than what I am envisioning. Unfortunately I am stuck with using a specific font.

 

You can swap the letters into the macro I posted. The toolpaths need to be incremental and start and end at the same point. If you need to convert absolute coordinates to incremental I think I have a python script for that, but someone around here might be able to use NCPlot or some other tool to do the conversion.

Link to comment
Share on other sites

You can swap out the character sections.  On my version just put in your own X's and Y's on the G65P8521 lines in the programs O8510(NUMBER ZERO) through O8520(DASH).  My version will scale, rotate, map on an arc, and project on a cylinder (along X or Y axis).

%
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

%
Link to comment
Share on other sites

 

You can swap out the character sections.  On my version just put in your own X's and Y's on the G65P8521 lines in the programs O8510(NUMBER ZERO) through O8520(DASH).  My version will scale, rotate, map on an arc, and project on a cylinder (along X or Y axis).

 

Interesting design pattern. Do you have a Github account? We could branch the repository and integrate these two programs. You have some useful features.

Link to comment
Share on other sites
  • 5 years later...
On 12/17/2015 at 3:50 PM, Matthew Hajicek - Conventus said:

You can swap out the character sections.  On my version just put in your own X's and Y's on the G65P8521 lines in the programs O8510(NUMBER ZERO) through O8520(DASH).  My version will scale, rotate, map on an arc, and project on a cylinder (along X or Y axis).


%
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

%

HI MATT

I AM  LOOKING FOR USE ABOVE MACRO FOR  MORISEIKI LATHE WITH LIVE TOOLING. WOULD YOU LIKE TO TELL ME THAT IT INCREMENT SR NO  OR NOT ?

THANKS

Link to comment
Share on other sites
16 hours ago, Rigo952 said:

HI MATT

I AM  LOOKING FOR USE ABOVE MACRO FOR  MORISEIKI LATHE WITH LIVE TOOLING. WOULD YOU LIKE TO TELL ME THAT IT INCREMENT SR NO  OR NOT ?

THANKS

It can increment, that's the easy part.  I haven't been into it for a couple years, and there's a lot to wrap your head around.  I recommend using NCPlot to backplot, practice using it, and make your edits to suit your purpose.

  • Thanks 1
Link to comment
Share on other sites
37 minutes ago, Matthew Hajicek - Conventus said:

It can increment, that's the easy part.  I haven't been into it for a couple years, and there's a lot to wrap your head around.  I recommend using NCPlot to backplot, practice using it, and make your edits to suit your purpose.

  1. "a lot to wrap your head around" < This is an understatement!
  2. Nice work. That code is very well written, and an extremely useful Macro B Example. That really shows the power of local variable passing, IF/GOTO Branching, and WHILE DO1/END1 Loops.
  • Thanks 2
  • Like 2
Link to comment
Share on other sites
5 hours ago, Matthew Hajicek - Conventus said:

It can increment, that's the easy part.  I haven't been into it for a couple years, and there's a lot to wrap your head around.  I recommend using NCPlot to backplot, practice using it, and make your edits to suit your purpose.

THANKS ,

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