91ÊÓƵÍøÕ¾ÎÛ

Published

Tracking Time with Custom Macro

System variables allow for time-based applications like tool-life monitoring, preventive maintenance, sampling inspections and machine warm-up.

Share

Leaders-In background

Custom Macro gives you the ability to monitor time from within a CNC program. System variables provide access to two timers (milliseconds and hours), a calendar (year, month, day) and a clock (hours, minutes, seconds):
 • #3001 millisecond timer
 • #3002 hour timer
 • #3011 date (yyyymmdd)
 • #3012 time (hhmmss)

The millisecond timer (#3001) will run for about 600 hours before it automatically resets. The hour timer (#3002) will run for about 9,500 hours before resetting. They are always running, but can be reset at any time. Consider these commands that use the milliseconds timer to cause a 10-second dwell:
#3001 = 0 (Reset millisecond timer)
N1 IF [#3001 GT 10000] GOTO 5
GOTO 1
N5 …

The date and clock functions work differently. If the present date and time is February 3, 2018, at 3:39:02 p.m., the current date and time system variable values will display as follows:
#3011: 20180203
#3012: 153902

The clock uses a 24-hour format: 15:39 is, of course, 3:39 p.m. Since these system variables run in sync with the CNC’s system clock, it is possible to track events over longer periods of time. 

These time-related system variables also allow unique time-based applications. Think of situations in which events must be timed:
 • How long a cutting tool is machining (part of a tool-life monitoring system).
 • Preventive maintenance tasks, like filter changes.
 • Time-based sampling inspections.
 • Machine warm-up after a period of non-use.

The following time-based spindle warm-up example was suggested by Ryan McKibbin of the Maryland Institute College of Art. A machine spindle’s thermal expansion during warm-up may cause size deviations that make it impossible to run acceptable workpieces until it warms up. The warm-up routine must be run whenever the spindle cools, such as after off-shifts and whenever the machine is idle for more than an hour.

As Mr. McKibbin’s program shows, tracking when the warm-up program is required can be programmed by including a few commands at the beginning and end of all programs:
%
O0001
IF [[[#509 + 010000] GT #3012] AND [#508 EQ #3011]] GOTO 5
#3006 = 1 (Cold spindle – press cycle start)
M03 S12000
G04 P120000
M03 S18000
G04 P120000
M03 S23000
G04 P60000
M05
#3006 = 2 (Warm-up over – press cycle start)
(Machining program begins here)
N5 . . .
(At the end of the program:)
#508 = #3011
#509 = #3012
M30
%

Permanent common variables #508 and #509 keep track of the last date and time when the machine finished running a program. The IF statement tests the last completion time plus one hour against the current time and the last completion date against the current date. If more than an hour has elapsed, or if the date changes, the operator is instructed (by the #3006 stop with message command) to press the cycle start button to run the warm-up routine. The warm-up routine could, of course, be run automatically by eliminating the stop with a message command.

The warm-up routine starts the spindle at varying speeds, and the CNC will dwell appropriately until the spindle warms up. After the spindle warms up, the operator is instructed to press the cycle start button again to run the program. This could also be an automatic action.

Permanent common variables #508 and #509 are updated at the end of the program, so new time and date values will be considered the next time the program is run.

Related Content

Turning Machines

4 Commonly Misapplied CNC Features

Misapplication of these important CNC features will result in wasted time, wasted or duplicated effort and/or wasted material.

Read More
CNC Tech Talks

CNC-Related Features of Custom Macro

CNC-related features of custom macro are separated into two topics: system variables and user-defined G and M codes. This column explores both.

Read More
CNC Tech Talks

The Best Point of Reference for Program Zero Assignment Entries

Correctly specified program zero assignment and coordinate position values enable the CNC to determine how far to move the cutting tool during each positioning motion.

Read More
CNC Tech Talks

Help Operators Understand Sizing Adjustments

Even when CNCs are equipped with automatic post-process gaging systems, there are always a few important adjustments that must be done manually. Don’t take operators understanding these adjustments for granted.

Read More

Read Next

View From My Shop

Shop Tour Video: You've Never Seen a Manufacturing Facility Like This

In the latest installment of our “View From My Shop” series, explore Marathon Precision’s multi-process approach to manufacturing, where blacksmiths and hand-forged dies meet state-of-the-art CNC machining. Discover how restoring classic muscle cars and building custom art projects creates a dynamic shop culture — and draws top talent to this unique and innovative metalworking facility. 

Read More

Registration Now Open for the Precision Machining Technology Show (PMTS) 2025

The precision machining industry’s premier event returns to Cleveland, OH, April 1-3.   

Read More
Automation

Why We Ask Machine Shop Leaders to Speak at TASC – The Automated Shop Conference

TASC is our industry’s premier peer-to-peer automation stage where America’s shop leaders refine the art of metalworking and CNC machining. For conference speakers, it's also an opportunity to showcase your skills and gain exposure for your business. Here are five why stepping into the spotlight at TASC could be your smartest move toward elevating your shop.

Read More