584,854 active members*
4,347 visitors online*
Register for free
Login
Results 1 to 15 of 15
  1. #1
    Join Date
    Aug 2005
    Posts
    51

    Fanuc Serial Number Macro

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

  2. #2
    Join Date
    Mar 2003
    Posts
    2932
    Thanks for sharing.

  3. #3
    Join Date
    Jan 2009
    Posts
    19
    Thanks for the program should come in handy. Does anyone know of any similair macros for letters.

  4. #4
    Join Date
    Mar 2005
    Posts
    988
    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....

  5. #5
    Join Date
    Aug 2007
    Posts
    34

    Looking for OKUMA engraving macro

    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.

  6. #6
    Join Date
    Feb 2006
    Posts
    15

    Re: Looking for OKUMA engraving macro

    rats

  7. #7
    Join Date
    Feb 2006
    Posts
    15

    Re: Fanuc Serial Number Macro

    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

  8. #8
    Join Date
    Feb 2006
    Posts
    1792

    Re: Fanuc Serial Number Macro

    What does the second line do:
    T02 M06
    N01 T02

  9. #9
    Join Date
    Aug 2005
    Posts
    51

    Re: Fanuc Serial Number Macro

    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.

  10. #10
    Join Date
    Feb 2006
    Posts
    15

    Re: Fanuc Serial Number Macro

    Quote Originally Posted by sinha_nsit View Post
    What does the second line do:
    T02 M06
    N01 T02
    N01 TO2 positions the next tool on the carousel after a tool change. This program is a one tool test program. N01 T02 also has the effect of positioning the next tool for the program restart, in this case the same tool. N01 is the line number.

  11. #11
    Join Date
    Feb 2006
    Posts
    15

    Re: Fanuc Serial Number Macro

    Quote Originally Posted by TomL21 View Post
    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?

  12. #12
    Join Date
    Aug 2005
    Posts
    51

    Re: Fanuc Serial Number Macro

    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.

  13. #13
    Join Date
    Sep 2022
    Posts
    1

    Re: Fanuc Serial Number Macro

    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.

  14. #14
    Join Date
    Apr 2017
    Posts
    2

    Re: Fanuc Serial Number Macro

    Quote Originally Posted by nbogert View Post
    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.
    I found another bug when 999 is put in it doesn't do do that number it goes to the next number up 999 will do 1000, 1999 will do 2000, 19999 will do 20000 and so on
    I am trying to figure out what it is doing wrong

  15. #15
    Join Date
    Apr 2017
    Posts
    2

    Re: Fanuc Serial Number Macro

    figured it out , #149=.001 has to change to #149=.00001 or make it zero

Similar Threads

  1. Serial number in variable?
    By ghyman in forum Haas Mills
    Replies: 4
    Last Post: 08-30-2016, 11:42 PM
  2. serial number macro
    By Delw in forum Haas Mills
    Replies: 13
    Last Post: 04-25-2012, 12:01 AM
  3. Replies: 20
    Last Post: 03-21-2012, 11:47 PM
  4. Serial number
    By fergieman in forum Haas Mills
    Replies: 1
    Last Post: 03-21-2011, 03:16 PM
  5. Seq. serial number engraving
    By MSGMachine in forum G-Code Programing
    Replies: 2
    Last Post: 10-29-2010, 02:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •