A serial number engraving custom macro

A serial number engraving custom macro

Custom macro submitted by Steve Wood, Laconia, N.H.
This custom macro engraves three-digit serial numbers which increment by one. The character set is 1/4 high numerals from zero through nine. To get started store the left most number in variable #524. the second number in variable #525 and the right most number in variable #526 to start. To start with serial number 147, for example, set #524 to 1, #525 to 4, and #525 to 7. The engraving tool must first be positioned 0.1 inch over the center of the each numeral. The pitch is .200".
Editor's note: Thanks to Steve Wood for this excellent application. I've been asked about this kind of macro several times. A few notes: First, this macro is to be include in your main (cutting) program. You could easily separate it, making it a macro program by itself by passing a few variables - like X, Y, and Z position for the numerals, and maybe the depth of the engraving tool. Second, Steve points out that you could easily make another character set by rewriting programs O4000 through O4009. And third, this macro does a three-digit serial number, if you have a larger number, and if you understand the unique logic of Steve's macro, you can easily make a four or five digit serial number.
  • G0G90G54X.5Y.75S6500M3 (<----POSITION HERE FOR 1ST NUMBER
  • (FIND FIRST DIGIT)
  • IF[#524EQ0]GOTO 10
  • IF[#524EQ1.]GOTO 11
  • IF[#524EQ2.]GOTO 12
  • IF[#524EQ3.]GOTO 13
  • IF[#524EQ4.]GOTO 14
  • IF[#524EQ5.]GOTO 15
  • IF[#524EQ6.]GOTO 16
  • IF[#524EQ7.]GOTO 17
  • IF[#524EQ8.]GOTO 18
  • IF[#524EQ9.]GOTO 19
  • #3000=99(SETTING ERROR)
  • M00
  • N10M98P4000
  • GOTO 925
  • N11M98P4001
  • GOTO 925
  • N12M98P4002
  • GOTO 925
  • N13M98P4003
  • GOTO 925
  • N14M98P4004
  • GOTO 925
  • N15M98P4005
  • GOTO 925
  • N16M98P4006
  • GOTO 925
  • N17M98P4007
  • GOTO 925
  • N18M98P4008
  • GOTO 925
  • N19M98P4009
  • GOTO 925
  • (FIND 2ND DIGIT)
  • N925 G0G90G54X.7 Y.75 (<----POSITION HERE FOR 2ND NUMBER)
  • IF[#525EQ0]GOTO 20
  • IF[#525EQ1.]GOTO 21
  • IF[#525EQ2.]GOTO 22
  • IF[#525EQ3.]GOTO 23
  • IF[#525EQ4.]GOTO 24
  • IF[#525EQ5.]GOTO 25
  • IF[#525EQ6.]GOTO 26
  • IF[#525EQ7.]GOTO 27
  • IF[#525EQ8.]GOTO 28
  • IF[#525EQ9.]GOTO 29
  • #3000=99(SETTING ERROR)
  • M00
  • N20M98P4000
  • GOTO 950
  • N21M98P4001
  • GOTO 950
  • N22M98P4002
  • GOTO 950
  • N23M98P4003
  • GOTO 950
  • N24M98P4004
  • GOTO 950
  • N25M98P4005
  • GOTO 950
  • N26M98P4006
  • GOTO 950
  • N27M98P4007
  • GOTO 950
  • N28M98P4008
  • GOTO 950
  • N29M98P4009
  • GOTO 950
  • (FIND 3RD DIGIT)
  • N950 G0G90G54X.9 Y.75 (<----POSITION HERE FOR 3RD NUMBER)
  • IF[#526EQ0]GOTO 30
  • IF[#526EQ1.]GOTO 31
  • IF[#526EQ2.]GOTO 32
  • IF[#526EQ3.]GOTO 33
  • IF[#526EQ4.]GOTO 34
  • IF[#526EQ5.]GOTO 35
  • IF[#526EQ6.]GOTO 36
  • IF[#526EQ7.]GOTO 37
  • IF[#526EQ8.]GOTO 38
  • IF[#526EQ9.]GOTO 39
  • #3000=99(SETTING ERROR)
  • M00 N30M98P4000
  • GOTO 975
  • N31M98P4001
  • GOTO 975
  • N32M98P4002
  • GOTO 975
  • N33M98P4003
  • GOTO 975
  • N34M98P4004
  • GOTO 975
  • N35M98P4005
  • GOTO 975
  • N36M98P4006
  • GOTO 975
  • N37M98P4007
  • GOTO 975
  • N38M98P4008
  • GOTO 975
  • N39M98P4009
  • (UPDATE AND TEST COUNTERS)
  • N975 #526=#526+1
  • IF [#526 LT 10.] GOTO 980
  • #526=0
  • #525=#525+1
  • IF [#525 LT 10.]GOTO 980
  • #525=0
  • #524=#524+1
  • IF [#524 LT 10.] GOTO 980
  • #524=0
  • N980M9 G91G28Z0M19
  • M30
  • O4000 (ZERO)
  • G91G0X-.0004Y.1076
  • G90 G1Z-.005F20.
  • G91 G1X.0176
  • G2X.0374Y-.0194I-.0021J-.05
  • X.0164Y-.0417I-.0488J-.0432
  • G1X-.0009Y-.1012
  • G2X-.0157Y-.0372I-.0527J.0004
  • X-.0372Y-.0157I-.0375J.0371
  • G1X-.0353
  • G2X-.0372Y.0157I.0004J.0528
  • X-.0157Y.0372I.0371J.0376
  • G1Y.1059
  • G2X.0157Y.0389I.0585J-.001
  • X.0372Y.0175I.0382J-.033
  • G1X.0177 G90Z.05
  • M99
  • O4001 (ONE)
  • G91G0X-.0359Y.0719
  • G90 G1Z-.005F20.
  • G91 X.0357Y.0361
  • Y-.2156
  • X-.0357
  • X.0718
  • G90 G0Z.05
  • M99
  • O4002 (TWO)
  • G91G0X-.071Y.0531
  • G90 G1Z-.005F20.
  • G91 G2X.0157Y.0375I.0535J-.0004
  • X.0377Y.0159I.0379J-.0371
  • G1X.0352
  • G2X.0375Y-.0159I-.0005J-.0531
  • X.0159Y-.0375I-.0373J-.038
  • X-.0164Y-.0383I-.0527J-.0001
  • G1X-.1256Y-.1213
  • X.142
  • G90 G0Z.05
  • M99
  • O4003 (THREE)
  • G91G0X-.0605Y.0917
  • G90 G1Z-.005F20.
  • G91 G2X.0362Y.0159I.0366J-.0341
  • G1X.034
  • G2X.0357Y-.0159I-.0006J-.0494
  • X.0151Y-.0379I-.04J-.0379
  • X-.0151Y-.0379I-.0552
  • X-.0357Y-.0159I-.0363J.0335
  • X.0357Y-.0159I-.0006J-.0494
  • X.0151Y-.0379I-.04J-.0379
  • X-.0151Y-.0374I-.0546J.0002
  • X-.0357Y-.0159I-.0363J.0335
  • G1X-.034
  • G2X-.0362Y.0154I.0002J.0505
  • G90 G0Z.05
  • M99
  • O4004 (FOUR)
  • G91G0X.0353Y-.1059
  • G90 G1Z-.005F20.
  • G91 Y.2117
  • X-.1059Y-.1411
  • X.1412
  • G90 G0Z.05
  • M99
  • O4005 (FIVE)
  • G91G0X.0714Y.1071
  • G90 G1Z-.005F20.
  • G91 X-.1428 Y-.0714
  • X.0895
  • G2X.0374Y-.0159I-.0005J-.0531
  • X.0159Y-.0374I-.0372J-.0379
  • G1Y-.0358
  • G2X-.0159Y-.0378I-.0537J.0003
  • X-.0374Y-.0159I-.0379J.0372
  • G1X-.0357
  • G2X-.0379Y.0159I.0002J.0536
  • X-.0159Y.0374I.0372J.0379
  • G90 G0Z.05
  • M99
  • O4006 (SIX)
  • G91G0X.0555Y.091
  • G90 G1Z-.005F20.
  • G91 G3X-.0379Y.0155I-.0376J-.038
  • G1X-.0352
  • G3X-.0377Y-.0159I.0002J-.053
  • X-.0157Y-.0375I.0378J-.0379
  • G1Y-.1062
  • G3X.0157Y-.0377I.0533J.0001
  • X.0377Y-.0157I.0378J.0376
  • G1X.0352
  • 3X.0375Y.0157I-.0004J.0535
  • X.0159Y.0377I-.0371J.0379
  • G1Y.0352
  • G3X-.0159Y.0375I-.0531J-.0005
  • X-.0375Y.0159I-.038J-.0372
  • G1X-.0352
  • G3X-.0377Y-.0159I.0002J-.053
  • X-.0157Y-.0375I.0378J-.0379
  • G90 G0Z.05
  • M99
  • O4007 (SEVEN)
  • G91G0X-.0714Y.1071
  • G90 G1Z-.005F20.
  • G91 X.1428
  • X-.1071Y-.2142
  • G90 G0Z.05
  • M99
  • O4008 (EIGHT)
  • G91G0X0.Y.1061
  • G90 G1Z-.005F20.
  • G91 X.0176
  • G2X.0373Y-.016I-.0004J-.0525
  • X.0157Y-.0374I-.0378J-.0378
  • X-.0157Y-.0372I-.0528J.0004
  • X-.0373Y-.0157I-.0376J.0371
  • G1X-.0352
  • G3X-.0373Y-.0164I.0005J-.0519
  • X-.0157Y-.0383I.0398J-.0386
  • X.0159Y-.0361I.05J.0004
  • X.0375Y-.0151I.0377J.0395
  • G1X.0348
  • G3X.0373Y.0151I-.0001J.0539
  • X.0157Y.0361I-.0346J.0365
  • X-.016Y.0383I-.0551J-.0004
  • X-.037Y.0164I-.0378J-.0356
  • G1X-.0352 G2X-.0373Y.0157I.0003J.0528
  • X-.0157Y.0372I.0371J.0376
  • X.0157Y.0374I.0535J-.0004
  • X.0373Y.016I.0377J-.0365
  • G1X.0176
  • G90 G0Z.05
  • M99
  • O4009 (NINE)
  • G91G0X-.0555Y-.091
  • G90 G1Z-.005F20.
  • G91 G3X.0379Y-.0155I.0376J.038
  • G1X.0352
  • G3X.0375Y.0157I-.0004J.0535
  • X.0159Y.0377I-.0371J.0379
  • G1Y.1062
  • G3X-.0159Y.0375I-.0532J-.0005
  • X-.0375Y.0159I-.038J-.0372
  • G1X-.0352
  • G3X-.0377Y-.0159I.0002J-.053
  • X-.0157Y-.0375I.0378J-.0379
  • G1Y-.0352
  • G3X.0157Y-.0377I.0533J.0001
  • X.0377Y-.0157I.0378J.0376
  • G1X.0352
  • G3X.0375Y.0157I-.0004J.0535
  • X.0159Y.0377I-.0371J.0379
  • G90 G0Z.05
  • M99