588,166 active members*
4,715 visitors online*
Register for free
Login
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Posts
    6

    Help with Serial Number macro

    I need to engrave serial #'s on 100 parts, I'm using a macro I found here: CNC tip: A serial number engraving custom macro

    The problem I am having is that I am getting a 4 as my first digit (variable #524 at the bottom) no matter what I set #524 to. The other 2 numbers are working correctly, so I know that my "0" subprogram is correct. The little I know about macros says that this should be working, can anyone spot a problem?

    Here's my code:

    G0G90G54X-.8842Y.498 (<----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-.8842 Y.4197 (<----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-.8842 Y.3414 (<----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
    M5
    G91G28Z0
    G05.1Q0
    G90G0G54.1P48X0Y0
    M30
    %

  2. #2
    Join Date
    Apr 2007
    Posts
    6

    Re: Help with Serial Number macro

    Ah, nevermind, I figured it out. I didn't realize that I have a macro page in my cotroller and #524 was set to 4. Go figure. I'm finding new menus all the time.

  3. #3
    Join Date
    Feb 2015
    Posts
    14

    Re: Help with Serial Number macro

    I would suggest using one macro which contains all the characters you want instead of multiple subprograms each containing one character.
    Your main program code can then lose all of the IF/GOTO logic and will be a lot shorter.
    Using an example where #524 is your first character and #526 is your last:

    %
    O1111(ENGRAVING MACRO)
    GOTO#1 (GOTO WHATEVER A ARGUMENT WAS PASSED IN)

    N1 (NUMBER 1)
    INCREMENTAL MACHINE CODE FOR 1
    POSITION ENGRAVING TOOL AT BOTTOM LEFT OF NEXT LETTERBOX
    M99

    N2(NUMBER 2)
    INCREMENTAL MACHINE CODE FOR 1
    POSITION ENGRAVING TOOL AT BOTTOM LEFT OF NEXT LETTERBOX
    M99
    ...
    ... (SAME WITH REST OF CHARACTERS YOU NEED)
    M99
    %

    MAIN PROGRAM THEN LOOKS LIKE:

    G54X_Y_M3S_____(POSITION TO BOTTOM LEFT OF FIRST CHARACTER)
    G43H1Z__ (POSITION IN Z)
    G65P1111A#524
    G65P1111A#525
    G65P1111A#526
    G0G91G30Z0

    MUCH MUCH CLEANER!!!

Similar Threads

  1. Fanuc Serial Number Macro
    By TomL21 in forum Parametric Programing
    Replies: 17
    Last Post: 05-11-2024, 05:54 PM
  2. Serial number in variable?
    By ghyman in forum Haas Mills
    Replies: 4
    Last Post: 08-30-2016, 11:42 PM
  3. serial number macro
    By Delw in forum Haas Mills
    Replies: 13
    Last Post: 04-25-2012, 12:01 AM
  4. Lagun FTV-1 Serial Number?
    By icupeter in forum Knee Vertical Mills
    Replies: 1
    Last Post: 04-24-2011, 05:26 AM
  5. Serial number
    By fergieman in forum Haas Mills
    Replies: 1
    Last Post: 03-21-2011, 03:16 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
  •