Thanks for sharing.
Wrote this for a customer today, thought it might be of use to others. I started with this macro from http://www.cncci.com/resources/tips/serial%20macro.htm written by Steve Wood. We had some different requirements, so all that is left of his original program are the programs for the numbers, those have been edited as well. The pdf is a full description of how to call the program, simple G65 call.
The macro allows scaling of the numbers as well as changing the spacing, the option of leading zeros or not, and can cut any integer number up to the maximum allowed length of the variables on your machine. 8 digits on the Oi that I tested the program on.
Anyways, use as you wish.
Similar Threads:
Thanks for the program should come in handy. Does anyone know of any similair macros for letters.
Here's one....
Letter engraving macro
I've never used it but I've heard it works well....
It's just a part..... cutter still goes round and round....
Does anyone have a g-code program that will run in an OKUMA U-10M control to create and increment scalable numeric characters for serial numbers.
Thank you.
rats
Last edited by naa73x; 02-03-2016 at 02:30 PM. Reason: wrong reply button
I am trying to make this XDigit Fanuc Serial Number macro work on my Fanuc Oi. The code runs like it does not know what the starting serial number is (Z goes down and right back up) and I can't figure out how to initialize the serial number. The code between the % signs is mine and below that is TomL21's macro:
%
O0998 (X DIGIT SERIAL NUMBER ENGRAVE)
( RPK )
( FANUC 0IMC WED. 02/03/2016 10:42AM)
(TOOL T2 S7 D.25 C0. A90. H2.5)
G90 G80 G40 G20 G17
G00 G91 G28 Z0.
(Machine Setup - 1 Engraving)
(FEATURE 2 AXIS)
(.25 V-TOOL)
T02 M06
N01 T02
G90 G54 X-.0613 Y.0593 S1191 M03
M08
G43 H02 Z5.
#500 = #500 + 1.
G65 P8100 S#500 C0. X-.0613 Y.0593 Z0. D.005 U.1 H.175 F33.
M09
M05
G91 G28 Z0. M6
G90 X0
G90 G53 Y0
M30
%
O8100 (X DIGIT SERIAL NUMBER INCREMENTAL)
(SET FEEDRATE FOR PROGRAM)
IF [#9 EQ #0] GOTO1
F#9
N1
(DEFAULT DEPTH TO .005 IF NOT SPECIFIED)
IF [#7 NE #0] GOTO 5
#7 = .005
N5
(DEFAULT SPACING TO .2 IF NOT SPECIFIED)
IF [#21 NE #0] GOTO 10
#21 = .2
N10
(SCALE FACTOR)
IF [#11 NE #0] GOTO 15
#11 = .25
N15
#140 = #11 / .25
(DEFAULT Z IS 0)
IF [#26 NE #0] GOTO 20
#26 = 0
N20
(ERROR COMPENSATION VARIABLE)
#149 = .001
(FIND NUMBER OF DIGITS)
IF [#19 EQ 0] GOTO 25
#120 = FIX[[LN[#19] / 2.3026] + 1]
N25
IF [#3 NE #0] THEN #120 = #3
IF [#120 NE #0] GOTO 30
IF [#19 EQ 0] THEN #120 = 1.
N30
#121 = 1
#122 = 1
WHILE [#121 LE [#120-1]] DO 1
#122 = FIX[[#122 * 10] + #149]
#121 = FIX[[#121 + 1] + #149]
END 1
(MOVE TO POSITION)
G0 G90
X#24 Y#25 (MOVE TO START X AND Y POSITION)
Z[#26+0.5] (MOVE TO SAFE Z POINT)
(START LOOP)
#102 = 0
N100
G0 G90 X[#24 + [#21*#102]] Y#25
G91
(COUNT DIGITS)
IF [#102 LE [#120-1]] GOTO 200
G0 G91 G28 Z0
M99
N200
#102 = FIX[[#102 + 1] + #149]
(ISOLATE DIGIT)
#101 = FIX[[#19 / #122] + #149]
#19 = #19 - FIX[[#101 * #122] + #149]
#122 = FIX[[#122 / 10] + #149]
(CUT DIGIT)
G0 G90 Z[#26 + .05]
IF[#101 EQ 0] GOTO 10
IF[#101 EQ 1] GOTO 11
IF[#101 EQ 2] GOTO 12
IF[#101 EQ 3] GOTO 13
IF[#101 EQ 4] GOTO 14
IF[#101 EQ 5] GOTO 15
IF[#101 EQ 6] GOTO 16
IF[#101 EQ 7] GOTO 17
IF[#101 EQ 8] GOTO 18
IF[#101 EQ 9] GOTO 19
N10 (ZERO)
G91 G0 X-[#140 * .0004] Y[#140 * .1076]
G90 G1 Z[#26 - #7]
G91 G1 X[#140 * .0176]
G2 X[#140 * .0374] Y-[#140 * .0194] I-[#140 * .0021] J-[#140 * .05]
X[#140 * .0164] Y-[#140 * .0417] I-[#140 * .0488] J-[#140 * .0432]
G1 X-[#140 * .0009] Y-[#140 * .1012]
G2 X-[#140 * .0157] Y-[#140 * .0372] I-[#140 * .0527] J[#140 * .0004]
X-[#140 * .0372] Y-[#140 * .0157] I-[#140 * .0375] J[#140 * .0371]
G1 X-[#140 * .0353]
G2 X-[#140 * .0372] Y[#140 * .0157] I[#140 * .0004] J[#140 * .0528]
X-[#140 * .0157] Y[#140 * .0372] I[#140 * .0371] J[#140 * .0376]
G1 Y[#140 * .1059]
G2 X[#140 * .0157] Y[#140 * .0389] I[#140 * .0585] J-[#140 * .001]
X[#140 * .0372] Y[#140 * .0175] I[#140 * .0382] J-[#140 * .033]
G1 X[#140 * .0177]
G90 G0 Z[#26 + .05]
GOTO 100
N11 (ONE)
G91 G0 X-[#140 * .0359] Y[#140 * .0719]
G90 G1 Z[#26 - #7]
G91 X[#140 * .0357] Y[#140 * .0361]
Y-[#140 * .2156]
X-[#140 * .0357]
X[#140 * .0718]
G90 G0 Z[#26 + .05]
GOTO 100
N12 (TWO)
G91 G0 X-[#140 * .071] Y[#140 * .0531]
G90 G1 Z[#26 - #7]
G91 G2 X[#140 * .0157] Y[#140 * .0375] I[#140 * .0535] J-[#140 * .0004]
X[#140 * .0377] Y[#140 * .0159] I[#140 * .0379] J-[#140 * .0371]
G1 X[#140 * .0352]
G2 X[#140 * .0375] Y-[#140 * .0159] I-[#140 * .0005] J-[#140 * .0531]
X[#140 * .0159] Y-[#140 * .0375] I-[#140 * .0373] J-[#140 * .038]
X-[#140 * .0164] Y-[#140 * .0383] I-[#140 * .0527] J-[#140 * .0001]
G1 X-[#140 * .1256] Y-[#140 * .1213]
X[#140 * .142]
G90 G0 Z[#26 + .05]
GOTO 100
N13 (THREE)
G91 G0 X-[#140 * .0605] Y[#140 * .0917]
G90 G1 Z[#26 - #7]
G91 G2 X[#140 * .0362] Y[#140 * .0159] I[#140 * .0366] J-[#140 * .0341]
G1 X[#140 * .034]
G2 X[#140 * .0357] Y-[#140 * .0159] I-[#140 * .0006] J-[#140 * .0494]
X[#140 * .0151] Y-[#140 * .0379] I-[#140 * .04] J-[#140 * .0379]
X-[#140 * .0151] Y-[#140 * .0379] I-[#140 * .0552]
X-[#140 * .0357] Y-[#140 * .0159] I-[#140 * .0363] J[#140 * .0335]
X[#140 * .0357] Y-[#140 * .0159] I-[#140 * .0006] J-[#140 * .0494]
X[#140 * .0151] Y-[#140 * .0379] I-[#140 * .04] J-[#140 * .0379]
X-[#140 * .0151] Y-[#140 * .0374] I-[#140 * .0546] J[#140 * .0002]
X-[#140 * .0357] Y-[#140 * .0159] I-[#140 * .0363] J[#140 * .0335]
G1 X-[#140 * .034]
G2 X-[#140 * .0362] Y[#140 * .0154] I[#140 * .0002] J[#140 * .0505]
G90 G0 Z[#26 + .05]
GOTO 100
N14 (FOUR)
G91 G0 X[#140 * .0353] Y-[#140 * .1059]
G90 G1 Z[#26 - #7]
G91 Y[#140 * .2117]
X-[#140 * .1059] Y-[#140 * .1411]
X[#140 * .1412]
G90 G0 Z[#26 + .05]
GOTO 100
N15 (FIVE)
G91 G0 X[#140 * .0714] Y[#140 * .1071]
G90 G1 Z[#26 - #7]
G91 X-[#140 * .1428]
Y-[#140 * .0714]
X[#140 * .0895]
G2 X[#140 * .0374] Y-[#140 * .0159] I-[#140 * .0005] J-[#140 * .0531]
X[#140 * .0159] Y-[#140 * .0374] I-[#140 * .0372] J-[#140 * .0379]
G1 Y-[#140 * .0358]
G2 X-[#140 * .0159] Y-[#140 * .0378] I-[#140 * .0537] J[#140 * .0003]
X-[#140 * .0374] Y-[#140 * .0159] I-[#140 * .0379] J[#140 * .0372]
G1 X-[#140 * .0357]
G2 X-[#140 * .0379] Y[#140 * .0159] I[#140 * .0002] J[#140 * .0536]
X-[#140 * .0159] Y[#140 * .0374] I[#140 * .0372] J[#140 * .0379]
G90 G0 Z[#26 + .05]
GOTO 100
N16 (SIX)
G91 G0 X[#140 * .0555] Y[#140 * .091]
G90 G1 Z[#26 - #7]
G91 G3 X-[#140 * .0379] Y[#140 * .0155] I-[#140 * .0376] J-[#140 * .038]
G1 X-[#140 * .0352]
G3 X-[#140 * .0377] Y-[#140 * .0159] I[#140 * .0002] J-[#140 * .053]
X-[#140 * .0157] Y-[#140 * .0375] I[#140 * .0378] J-[#140 * .0379]
G1 Y-[#140 * .1062]
G3 X[#140 * .0157] Y-[#140 * .0377] I[#140 * .0533] J[#140 * .0001]
X[#140 * .0377] Y-[#140 * .0157] I[#140 * .0378] J[#140 * .0376]
G1 X[#140 * .0352]
G3 X[#140 * .0375] Y[#140 * .0157] I-[#140 * .0004] J[#140 * .0535]
X[#140 * .0159] Y[#140 * .0377] I-[#140 * .0371] J[#140 * .0379]
G1 Y[#140 * .0352]
G3 X-[#140 * .0159] Y[#140 * .0375] I-[#140 * .0531] J-[#140 * .0005]
X-[#140 * .0375] Y[#140 * .0159] I-[#140 * .038] J-[#140 * .0372]
G1 X-[#140 * .0352]
G3 X-[#140 * .0377] Y-[#140 * .0159] I[#140 * .0002] J-[#140 * .053]
X-[#140 * .0157] Y-[#140 * .0375] I[#140 * .0378] J-[#140 * .0379]
G90 G0 Z[#26 + .05]
GOTO 100
N17 (SEVEN)
G91 G0 X-[#140 * .0714] Y[#140 * .1071]
G90 G1 Z[#26 - #7]
G91 X[#140 * .1428]
X-[#140 * .1071] Y-[#140 * .2142]
G90 G0 Z[#26 + .05]
GOTO 100
N18 (EIGHT)
G91 G0 X0. Y[#140 * .1061]
G90 G1 Z[#26 - #7]
G91 X[#140 * .0176]
G2 X[#140 * .0373] Y-[#140 * .016] I-[#140 * .0004] J-[#140 * .0525]
X[#140 * .0157] Y-[#140 * .0374] I-[#140 * .0378] J-[#140 * .0378]
X-[#140 * .0157] Y-[#140 * .0372] I-[#140 * .0528] J[#140 * .0004]
X-[#140 * .0373] Y-[#140 * .0157] I-[#140 * .0376] J[#140 * .0371]
G1 X-[#140 * .0352]
G3 X-[#140 * .0373] Y-[#140 * .0164] I[#140 * .0005] J-[#140 * .0519]
X-[#140 * .0157] Y-[#140 * .0383] I[#140 * .0398] J-[#140 * .0386]
X[#140 * .0159] Y-[#140 * .0361] I[#140 * .05] J[#140 * .0004]
X[#140 * .0375] Y-[#140 * .0151] I[#140 * .0377] J[#140 * .0395]
G1 X[#140 * .0348]
G3 X[#140 * .0373] Y[#140 * .0151] I-[#140 * .0001] J[#140 * .0539]
X[#140 * .0157] Y[#140 * .0361] I-[#140 * .0346] J[#140 * .0365]
X-[#140 * .016] Y[#140 * .0383] I-[#140 * .0551] J-[#140 * .0004]
X-[#140 * .037] Y[#140 * .0164] I-[#140 * .0378] J-[#140 * .0356]
G1 X-[#140 * .0352]
G2 X-[#140 * .0373] Y[#140 * .0157] I[#140 * .0003] J[#140 * .0528]
X-[#140 * .0157] Y[#140 * .0372] I[#140 * .0371] J[#140 * .0376]
X[#140 * .0157] Y[#140 * .0374] I[#140 * .0535] J-[#140 * .0004]
X[#140 * .0373] Y[#140 * .016] I[#140 * .0377] J-[#140 * .0365]
G1 X[#140 * .0176]
G90 G0 Z[#26 + .05]
GOTO 100
N19 (NINE)
G91 G0 X-[#140 * .0555] Y-[#140 * .091]
G90 G1 Z[#26 - #7]
G91 G3 X[#140 * .0379] Y-[#140 * .0155] I[#140 * .0376] J[#140 * .038]
G1 X[#140 * .0352]
G3 X[#140 * .0375] Y[#140 * .0157] I-[#140 * .0004] J[#140 * .0535]
X[#140 * .0159] Y[#140 * .0377] I-[#140 * .0371] J[#140 * .0379]
G1 Y[#140 * .1062]
G3 X-[#140 * .0159] Y[#140 * .0375] I-[#140 * .0532] J-[#140 * .0005]
X-[#140 * .0375] Y[#140 * .0159] I-[#140 * .038] J-[#140 * .0372]
G1 X-[#140 * .0352]
G3 X-[#140 * .0377] Y-[#140 * .0159] I[#140 * .0002] J-[#140 * .053]
X-[#140 * .0157] Y-[#140 * .0375] I[#140 * .0378] J-[#140 * .0379]
G1 Y-[#140 * .0352]
G3 X[#140 * .0157] Y-[#140 * .0377] I[#140 * .0533] J[#140 * .0001]
X[#140 * .0377] Y-[#140 * .0157] I[#140 * .0378] J[#140 * .0376]
G1 X[#140 * .0352]
G3 X[#140 * .0375] Y[#140 * .0157] I-[#140 * .0004] J[#140 * .0535]
X[#140 * .0159] Y[#140 * .0377] I-[#140 * .0371] J[#140 * .0379]
G90 G0 Z[#26 + .05]
GOTO 100
What does the second line do:
T02 M06
N01 T02
I think you found a bug. Looks like starting with a single digit with a value of 1 causes it to drop out before you start. If you plan on going into multiple digits you could add a C with the number of digits you want the serial number to be. It will add the leading zeros for place holders.
TomL21: that was the ticket, it works most excellently! Thank you so much for posting this thread and your quick reply to my question.
How can I know which number will engrave next, as when I start a new batch? How can I initialize or reset the next number to engrave to be the number I want?
The way you have it set up #500 stores the last number engraved. That can be reset or set to anything at any time by you. and nothing binds you to that one variable. For two different parts you could use #500 on one and #501 on the other and it would always pick up where it left off with that part. Which numbers get engraved are completely up to you.
You can set #500 in MDI or in the Macro settings page
Set #500 = 0 to go back and start at 1
Set #500 = 'your number' - 1 to start engraving at a specific number.
Remember in the format you have it #500 will be the last number engraved, because it increments immediately before the number is cut.
As of Sept 2022 the macro in the link in the 1st post still has a bug that prevents the digit "1" from being engraved when the numbers 10, 100, 1000 etc. are specified without a C value in the G65.
eg. the "9" will enrave ok but 10 will engrave as just "0" insteadd of "10" and 100 will engrave as just "00" insteadd of "100"
Thanks for posting this!
It is still very helpfull.
figured it out , #149=.001 has to change to #149=.00001 or make it zero
Last edited by chevyman1; 06-01-2023 at 02:25 PM.
Sorry to drag up a really old post but I'm trying to use this serial program on my older Fanuc control and when I read the program into the control (can't drip feed macro) it splits the program up and cuts the O8100 off before N200 and creates an additional O0200 program that includes everything below the N200 line.
I've tried all kinds of things (like M99P40 and then N40 M2, etc) with no luck. It just keeps creating the O0200 file.
Anyone have any tips on using this program with an older Fanuc?