A macro for engraving sequential serial numbers

Intro

We recently had some challenges with a customer who wanted permanent serial numbers added to an assembly. That’s a great idea, but, wait: how the heck were we supposed to do that?!

On some controls, such as Haas, they have macros which support serialization built-in. That’s great. But if you are running a control without such a macro you probably feel a little frustrated. This is a common problem that hasn’t had a lot of a attention.

A few years ago I ran into this article on Modern Machine Shop called A Serial Numbering Custom MacroYou’ll see a lot of some version of that macro floating around the ‘net while researching this problem. Personally, I thought I could do better, and I did:

How to engrave serial numbers using this macro

Once you have the programs setup, it’s simple for an operator to implement them in a part program:

;(activate WCS, move to origin)
G90 G54 G0 X0. Y0.
;(scale text)
G51 X2.5 Y2.5 
;(orient text) 
G68 X0. Y0. R30.
;(engrave three digit serial number)
G65 P1000 S3

How does this macro work?

There are subprograms for each number, letter, and character, plus a program that will count and engrave a serial. Then there is a flow control program that takes the parameters from the G65 call and directs our code to the correct engraving program.

The magic is in the arithmetic functions of the control. You can reduce a number to a single digit using division and rounding.

FIX[[565 / 10] % 10] = 6

Where to get the code

You can find SerialEngrave.nc (https://github.com/themachinist/SerialEngrave) hosted on GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *