Disclaimer: CNC Concepts, Inc.
accepts no responsibility for the use or misuse of
techniques shown in this web page. We simply publish
information we feel will be of interest to CNC users. In
all cases, the reader is totally responsible for
considering the implications, good and bad, of
implementing one or more of the techniques we show.
Date engraving custom macro
By Brian Glick
of Vermeer Corporation
Here is a custom macro I developed for
machining centers. It allows you to automatically
engrave the current date on a part as it is being
machined. The date is engraved along the X-axis in
numbers 3/16â� high with .0375â� spacing and in the
yyddd format (which we required). In this format,
December 31, 2007, would read 07365 for the 365th day of
2007; however, it would not be a problem to modify the
macro to arrange the date in any format.
The key to making this work is system
variable #3011, which maintains the current date in the
format of yyyymmdd allowing the program to update daily
without relying on anyone to change the date. In fact,
the operator only has to adjust the feed rate and the
depth of the engraving.
This macro checks the date to see if it is
a leap year or not, and during leap years the number of
the day is increased by one for days after February
28th. Another feature incorporated into the macro is
equal spacing between all the different numbers. Since
the number one is a different width than the number
eight, the spacing has to change with each number. I am
controlling this with variable #105 and it is set after
the code for each number is processed. The value is the
width of the number plus .0375.
This custom macro was set up for a Mori
Seiki Dura Vertical with a Fanuc 0i controller, but
should work on any machining center that supports Fanuc
Custom Macro B. One issue I did run into was a slight
hesitation between numbers caused by the program
constantly branching back and forth with the GOTO
statements. I enabled the high-speed macro and branching
parameters (Parameter #6000 bits 2 and 4 on this
machine) and that eliminated the problem.
On faster controllers it is not an
issue.
Main program
G65=Macro call
P9103= Macro program number
Z.005=Engraving depth (can be
positive or negative)
F30.0= Feed rate
The main program positions the engraving
tool in the upper left corner of the window in which you
want the date to appear and 1.00 above the surface. The
surface in this case is Z0. Since all the Z-axis
movements within the macro are in incremental mode it is
essential that the tool be 1.00 inch above the surface
when the macro is called and I have a built-in alarm to
check this.
O8297
N1T15M6 (Loads tool)
G0G90G54X1.Y-.5M3S8000 (Positions tool on X and Y)
G43H15Z1.M8 (Positions tool on Z)
G65P9103Z.005F30. (Calls macro)
M5
M9
G0G91G28X0Y0Z0
M30
Custom macro
O9103 (DATE MACRO)
#30=#4001 (Stores Current G-Code)
#31=#4003 (Stores Current G-Code)
#120=#5001 (Stores Current X Abs. Pos.)
#121=#5002 (Stores Current Y Abs. Pos.)
#122=#5003 (Stores Current Z Abs. Pos.)
#108=#9 (Stores feed rate in common variable)
#109=ABS[#26] (Stores the absolute depth in common
variable)
#110=#109+.1 (Feed-in and the retract on Z axis)
IF[#4006EQ21]GOTO500 (Check for metric mode)
IF[#122NE1.]GOTO501 (Check for correct Z position)
IF[#26EQ#0]GOTO502 (Check for missing depth)
IF[#9EQ#0]GOTO503 (Check for missing feed rate)
IF[#109GE.025]GOTO504 (Check for excessive depth)
#100=#3011 (Stores date)
#101=#100 (Keeps date correct in #100 for checking)
#1=FIX[#101/10000] (Separate Year)
#101=#101-[#1*10000]
#2=FIX[#101/100] (Separate Month)
#101=#101-[#2*100]
#3=FIX[#101] (Separate Day)
(DATE FORMAT #2/#3/#1 MM/DD/YYYY)
(The following alarms are included to help during
development and are not necessary after the program is
proven)
N10 (2ND NUMBER)
G90
#120=#120+#105 (Spacing added to X position)
G0X#120Y#121 (Positions for next number)
G91
IF[#6EQ0] GOTO100
IF[#6EQ1] GOTO110
IF[#6EQ2] GOTO120
IF[#6EQ3] GOTO130
IF[#6EQ4] GOTO140
IF[#6EQ5] GOTO150
IF[#6EQ6] GOTO160
IF[#6EQ7] GOTO170
IF[#6EQ8] GOTO180
IF[#6EQ9] GOTO190
N20 (3RD NUMBER)
G90
#120=#120+#105 (Spacing added to X position)
G0X#120Y#121 (Positions for next number)
G91
IF[#10EQ0] GOTO100
IF[#10EQ1] GOTO110
IF[#10EQ2] GOTO120
IF[#10EQ3] GOTO130
N30 (4TH NUMBER)
G90
#120=#120+#105 (Spacing added to X position)
G0X#120Y#121 (Positions for next number)
G91
IF[#11EQ0] GOTO100
IF[#11EQ1] GOTO110
IF[#11EQ2] GOTO120
IF[#11EQ3] GOTO130
IF[#11EQ4] GOTO140
IF[#11EQ5] GOTO150
IF[#11EQ6] GOTO160
IF[#11EQ7] GOTO170
IF[#11EQ8] GOTO180
IF[#11EQ9] GOTO190
N40 (5TH NUMBER)
G90
#120=#120+#105 (Spacing added to X position)
G0X#120Y#121 (Positions for next number)
G91
IF[#12EQ0] GOTO100
IF[#12EQ1] GOTO110
IF[#12EQ2] GOTO120
IF[#12EQ3] GOTO130
IF[#12EQ4] GOTO140
IF[#12EQ5] GOTO150
IF[#12EQ6] GOTO160
IF[#12EQ7] GOTO170
IF[#12EQ8] GOTO180
IF[#12EQ9] GOTO190
N50
GOTO999
(The following blocks are the NC Code for numbers 0-9.
When it makes a number the counter variable increases by
one and the spacing variable is the width of the number
plus .0375. It then checks the counter to go back to do
the next number in line.)
N100 (CODE FOR 0)
#33=#33+1
G91
X.0111Y-.0306
G1Z-#110F#108 (Feed to depth from clearance position)
G3Y-.1263I.1737J-.0631
X.0876I.0438J.0156
Y.1263I-.1737J.0632
X-.0876I-.0438J-.0156
G0Z#110 (Retract to clearance position)
#105=.1473
IF[#33EQ1] GOTO10 (Checks counter to see what number is
next)
IF[#33EQ2] GOTO20
IF[#33EQ3] GOTO30
IF[#33EQ4] GOTO40
IF[#33EQ5] GOTO50