Content Preview
TB188 Rev 2 Automatic Sequential Part Numbering for Engraving _
Purpose
This document describes how to set up Automatic Sequential Part Numbering for
Engraving Each time the operator presses cycle start to machine the next part the
serial number being machined into the part will automatically increment numerically
Requirements
Operator's Manual
MillWrite Manual
Overview
Macro & sub program file names can be changed to match a family of parts so you can
have different family names to do serial numbers for different parts
The example program is written to machine numbers that are 125" high and spaced
125" apart We are using three macro programs and ten individual sub program G code
files The 10 individual sub programs define the shape to be machined for each number
0 1 2 3 4 5 6 7 8 9 The first macro program sets the variables calls the second
macro program to assign variable #151 with the next serial number to engrave and
then calls the third macro program which will set the spacing for the number and
which number to engrave The first macro program also increments the serial number
for each run by the amount you set and saves it to the second macro program after
running the third macro program The third macro program calls the sub program for
each of the numbers to be engraved
We created our sub programs G code files for each number 0 through 9 10 files We
used MillWrite software to create the sub programs for the individual numbers
Note MillWrite is an optional conversational engraving program which quickly
creates G code programs for letters numbers and symbols In this case the base
number G code program that is being used could be created by many different CAD/CAM
programs or even by hand MillWrite was chosen because of its ease of use and
simplicity
*For additional information on variables sub programs macros and parameter
settings see Chapter 11 CNC Program Codes Chapter 12 G codes Chapter 13 M
functions and Chapter 15 Configuration of the operator's manual Also see the
MillWrite manual for creating and editing MillWrite programs
Procedure
Program 1 The main program that will define all of the variables
Before you run example program #1 for the very first time you need to edit the
second macro program "Serial Num Record DAT" with the starting serial number After
that you will not have to do this unless you want a
different starting serial number
Once variable #151 is correct in "Serial Num Record DAT" look at example program #1
to see what the program should look like by graphing it
Example Program #1
; Program name SER Num SN CNC
; Macro program that calls engraving numbers
; Purpose Draw an integer value that will index automatically
; Parameters
; #A Number to draw
; #B Total character width of numeric field
; #C 0 = Pad with leading zeros 1 = pad with spaces
; #D X Spacing between numbers
; #E Y Spacing between numbers
; #145 = 59 ; ASCII ';'
; Notes This routine will always draw the full value
M25
T1 M6
S6000 M3
M8
G4 P2
G43 H1
G0 X0 Y0 Z 05
;
; Getting the next serial number to be used and assigning it to #151
M98 "Serial Num Record DAT"
;
; Calling next level down in the macro to engrave numbers G65 "SERIAL Num CNC" A#151 B5 C0 D 125 E0
; If graphing the program goes to N1999 and skips indexing the number and storing it in a file
IF [#4201 == 1] THEN GOTO 1999;
; Index Number Save to Parameter and adds this Serial # to the File for a history
#151 = #151 + 1 ; See chapter 11 for more info about other variable that can be used
M121"SER Num SN CNC"; See Chapter 13 M functions about saving to a file
M123 P[#151]
;
;This section is used to write the next serial number in file "Serial Num Record DAT" that is read
;at the beginning of this program to assign #151 with the next number to engrave
;
IF [#25018 == 10] then if #6001 ; CNC10 HOLD JOB PROCESSING UNTIL NOW
IF [#25018 != 10] then if #50001 ; CNC11 HOLD JOB PROCESSING UNTIL NOW
#145 = 59 ; Assigning #145 to ASCII ';'
M120"Serial Num Record DAT"; See Chapter 13 M functions about saving to a file
;See Chapter 13 M functions about writing to a file
M123 ;;File Name "Serial Num Record DAT"
M223 "#151 = % 0f %c Next Serial Number\n" #151 #145
; End of writing next serial number to the file
;
N1999 ; Line to GOTO if graphing
M5
M9
M25
;END OF PROGRAM
Note The G code line with the G65 in file Ser Num SN CNC could be added to an
Intercon file The G code lines from the IF statement to the N1999 line should be
added to the very end of the Intercon file This would be done so the numbering
could be combined with other operations
Program 2 The file that the next serial number is saved to and when the G98 reads
it it will set #151 with the next serial when the program is run
Example Program #2
;File Name "Serial Num Record DAT"
#151 = 1 ; Next Serial Number
Note This file needs to be created before running Example 1 program for the first
time with the starting serial number After that Example #1 program will update this
file automatically each time it is run with the next serial number
Program 3 The file that extracts the integer to be engraved
The following is a macro program to extract the integer from the number to engrave
The parameters that are used are explained in the program All of the parameters are
not used in this example but are there so that it can be used as a master program
and can be easily changed for other numbers
Example Program #3
; SERIAL Num CNC
; Purpose Draw an integer value using a G code file for each integer
; Parameters
; #A Number to draw
; #B Total character width of numeric field Maximum 9
; #C 0 = pad with leading zeros 1 = pad with spaces
; #D X Spacing between numbers
; #E 4TH Axis rotary Spacing between numbers
; #G Holds digit to write
; #I Loop index
; #J Position of number being cut
; #N Used to extract number
; #P Used to hold value if padded with zeros or spaces
; #T Holds transformed integer reversed order of number
; #X Machine position for "X" set from parameter #5041
; #Y Machine position for "Y" set from parameter #5042
; #Z Machine position for "Z" set from parameter #5043
; #W Machine position for "4th" axis Rotary set from parameter #5044
; Notes This routine will always draw the full value
#[N] = #A ; Used to extract digits
#[T] = 0 ; Holds transformed integer reversed digits
; setting to zero to start
#[P] = #C ; setting #P equal to parameter #C
#[I] = 0 ; Loop index setting to zero to start
; Transform the integer by reversing the order of its digits
N1
#[T] = [#T * 10] + [#N % 10] ;Shift transformed integer left
; and adds Least Significant Digit
; LSD
#[N] = [#N / 10] OR 0 ;Shift number right and truncate
#[I] = #I + 1 ;Add 1 to Loop index
IF [[#I < #B] || [#N != 0]] GOTO 1 ; Loops back to finish reversing
; the order of the number
; Write each digit
#[I] = 0 ; Setting Index loop to zero
N2
#[G] = #T % 10 ;Setting #G equal to LSD
; Make leading zero a space if requested
IF [#G != 0] || [#I + 1 >= #B] THEN #[P] = 0
IF [#P && [#G == 0] && #C] THEN #[G] = 32
#[X] = #5041 ; Saving machine position for X
#[Y] = #5042 ; Saving machine position for Y
#[Z] = #5043 ; Saving machine position for Z
#[W] = #5044 ; Saving machine position for 4th axis
M00 ;READY TO CALL NEXT NUMBER
Goes to the "N" block for each number integer X 10
GOTO [#G * 10]
N0 ; Number Zero 0
G65 "Ser Num 0 CNC" ; Calls file to engrave Zero 0
GOTO 100
N10 ; Number One 1
G65 "Ser Num 1 CNC" ; Calls file to engrave One 1
GOTO 100
N20 ; Number Two 2
G65 "Ser Num 2 CNC" ; Calls file to engrave Two 2
GOTO 100
N30 ; Number Three 3
G65 "Ser Num 3 CNC" ; Calls file to engrave Three 3
GOTO 100
N40 ; Number Four 4
G65 "Ser Num 4 CNC" ; Calls file to engrave Four 4
GOTO 100
N50 ; Number Five 5
G65 "Ser Num 5 CNC" ; Calls file to engrave Five 5
GOTO 100
N60 ; Number Six 6
G65 "Ser Num 6 CNC" ; Calls file to engrave Six 6
GOTO 100
N70 ; Number Seven 7
G65 "Ser Num 7 CNC" ; Calls file to engrave Seven 7
GOTO 100
N80 ; Number Eight 8
G65 "Ser Num 8 CNC" ; Calls file to engrave Eight 8
GOTO 100
N90 ; Number Nine 9
G65 "Ser Num 9 CNC" ; Calls file to engrave Nine 9
GOTO 100
N320 ; Used for padding with spaces
GOTO 100
N100 ; Shifts number to the right and deletes integer that was just cut
#[T] = [#T / 10] OR 0 ; Shift number right and truncate
#[I] = #I + 1 ; Add 1 to Index loop
IF [#I >= #B] GOTO 200 ; Goes to N200 if no more integers
; Moving X and Y to start of next number
G90 ; Changes back to absolute positioning
IF [[#I < #B] || [#T !=0]] THEN #[X] = #X + #D ;Sets #X to Start of next number
IF [[#I < #B] || [#T !=0]] THEN #[W] = #W + #E ;Sets #W "4TH AXIS" to Start of next number
G0 X[#X]A[#W] ; Moves to start of next number
GOTO 2 ; Returns to N2 if there are more integers to cut
N200 ; Used so machine does not position for another integer
M99 ; End of sub program
Setting up the programs to do each number
Use MillWrite to create the files for each number
1 Set up the numbers so the lower left corner is 0 0 and the G Code is incremental
The reason the lower left corner is set to zero is so that you can position the tool
at any X Y position
2 Change the G90 so that the lower left corner of the number starts with a G91 Now
the program will move to where it needs to start cutting each number
3 While in MillWrite once the G Code is created you need to delete lines 2 through
8 change G90 to G91 on line 13 and delete lines 10 through 13 At the end of the
program before the M25 add line G00 Z0 60 This may be different for your program Z
depth of cut plus clearance height Change the M25 to M99
4 For the example below the number zero is shown and the G Code file is "Ser Num
0 CNC" For each other number change the number before the decimal to the number that
will be cut You need to create 10 files for 0 through 9
Example program 4 before editing
N1 ; MillWrite program start
N2 M25 G49 DELETE THIS LINE
N3 ; 90 DEG ENGR DELETE THIS LINE
N4 G17 G40 DELETE THIS LINE
N5 G20 DELETE THIS LINE
N6 G80 DELETE THIS LINE
N7 G90 DELETE THIS LINE
N8 G49 H0 M25 DELETE THIS LINE
N9 G90 G00 X0 0135 Y0 0258 CHANGE G90 TO G91
N10 T30 M6 DELETE THIS LINE
N11 M03 S5000 F15 0 DELETE THIS LINE
N12 G43 G0 Z0 05 H30 DELETE THIS LINE
N13 G91 DELETE THIS LINE
N14 G01 Z 0 06 F10 5
N15 ; 0
N16 G03 X0 0122 Y 0 0122 I0 0123 J0 F15 0
N17 G01 X0 0343
N18 G03 X0 0122 Y0 0122 I0 J0 0122
N19 G01 Y0 0735
N20 G03 X 0 0122 Y0 0122 I 0 0122 J0
N21 G01 X 0 0343
N22 G03 X 0 0122 Y 0 0122 I0 J 0 0123
N23 G01 Y 0 0735
N24 M25 INSERT G00 Z0 060 AND CHANGE M25 TO M99
N25 ; MillWrite program finish
Example program 4 after editing
; MillWrite program start
G91 G00 X0 0135 Y0 0258
G01 Z 0 06 F10 5
; 0
G03 X0 0122 Y 0 0122 I0 0123 J0 F15 0
G01 X0 0343
G03 X0 0122 Y0 0122 I0 J0 0122
G01 Y0 0735
G03 X 0 0122 Y0 0122 I 0 0122 J0
G01 X 0 0343
G03 X 0 0122 Y 0 0122 I0 J 0 0123
G01 Y 0 0735
G00 Z0 060
M99 ;RETURNS TO SERIAL Num CNC
; MillWrite program finish
_____________________________________________________________________________________
Document History
Rev2 Created on 2014 06 06 by #146