HCL CAMWorks
Published

Converting Time and Date to a More Useful Format

FANUC and FANUC-compatible CNCs have multiple ways to monitor time. They are accessed by four system variables: milliseconds clock, hours clock, current date and current time. Here’s how to format information in a helpful way.

Share

Leaders-In background
  1. Milliseconds clock: (#3001). This variable always runs, can be reset using #3001=0 and will automatically reset after a few minutes (or when the power is turned off).
  2. Hours clock: (#3002). This variable includes the decimal portion of an hour. It always runs, can be reset using #3002=0, is retained after the power is turned off and will automatically reset after about 397 days.
  3. Current date: (#3011). This variable is shown in yyyymmdd format. It always runs and cannot be reset.
  4. Current time: (#3012). This variable is shown in hhmmss, 24-hour format. It always runs and cannot be reset.

The milliseconds clock reset interval is usually too short for any meaningful purpose. The hours clock is much better, but it does not consider “machine off” time. The date and time clocks are great, but their format is somewhat cumbersome. For example, at 3:45:10 p.m. May 3, 2019, we give these commands:

  • #101=#3011
  • #102=#3012

The values of common variables #101 and #102 will be:

  • #101: 20190503 (date)
  • #102: 154510 (time)

While this is great information, the format in its current state is not very helpful for timing purposes. They would not help much if, in a program, you need to determine the total amount of time a machine has been in use.

Our upcoming program uses date/time information to parse out the year value, determine the number of hours from the beginning of 2019 (midnight 12/31 of 2018), and the day-number of the current year (from 1 to 365 or 366 in a leap year). Here is the calling command, which could be placed in any program that requires timing an event:

  • G65 P9060 D#3011 T#3012 Y102.0 H103.0 F104.0

Where:

  • P9060: Program number for custom macro
  • D (#7): The date value to convert
  • T (#20):  The time value to convert
  • Y (#25): If included, the number of the variable that will contain the year value.
  • H (#11): If included, the number of the variable that will contain the hour value.
  • F (#9): If included, the number of the variable that will contain the day number.

If this command is given at 2:25 p.m. on February 4, 2019, the values of #102-#104 will be:

  • #102: 2019.0000 (year)
  • #103: 834.4146 (hours from the beginning of 2019)
  • #104: 35.0000 (days into the year)

Of primary importance is the hours value. It works much like the hours clock, but it is not affected by power on/off status, it considers leap years and it never resets. If the need arises, you could easily modify the program to have it output other time-related information such as month, day or hour.

Example: Need for Warmup

You need to determine elapsed time since finishing the last cycle. If it is over a given amount (say 10-minutes), the machine has cooled and needs to run a warm-up routine. The longer the elapsed time, the longer the required warmup.

Add this command at the end of your machining program:

  • G65 P9060 D#3011 T#3012 H500.0
  • M30

We only need the current hour, so only the H argument is specified. Now, modify the program’s beginning:

  • O0001
  • G65 P9060 D#3011 T#3012 H501.0

Next subtract #501 from #500. If the result is greater than 10 minutes (10/60 hours, or 0.1666) a warmup is required:

  • #1=#501=#500 (elapsed time)
  • IF[#1LE0.16666]GOTO10
  • IF[#1LE0.33332] THEN #2=300 (5-minutes)
  • IF[[#1GT0.33332] AND [#1LE0.5]] THEN #2=600
  • IF[#1GT0.5] THEN #2=900
  • S2000 M03 (Start spindle to warmup the headstock)
  • G04 X#2 (dwell)
  • N10 (Continue)

You may be thinking this easily could have been done with the hours timer (#3002). Keep in mind that the hours timer will ignore any elapsed time that occurs in the power-off state. If this program is run at the beginning of the day/shift, it is likely that the power will have just been turned on. A very long time may have elapsed since the last cycle was run. Since we are using permanent common variables in which to store hours data, elapsed time will be retained after the power is turned off.

HCL CAMWorks
ProShop
VERISURF
High Accuracy Linear Encoders
KraussMaffei
715 Series - 5-axis complete machining
MMS Made in the USA
Starrett W9400 Touch Screen Indicator
MWI
To any Measurement Question there is an Answer
DANOBAT
World Machine Tool Survey

Related Content

CNC Tech Talks

Obscure CNC Features That Can Help (or Hurt) You

You cannot begin to take advantage of an available feature if you do not know it exists. Conversely, you will not know how to avoid CNC features that may be detrimental to your process.

Read More
CNC Tech Talks

Troubleshooting Differences in Programming Methods, Machine Usage

Regardless of the level of consistency among machines owned by your company, you probably have experienced consistency-related issues. Here are some tips to help solve them.

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

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

Read Next

Workforce Development

Building Out a Foundation for Student Machinists

Autodesk and Haas have teamed up to produce an introductory course for students that covers the basics of CAD, CAM and CNC while providing them with a portfolio part.

Read More

5 Rules of Thumb for Buying CNC Machine Tools

Use these tips to carefully plan your machine tool purchases and to avoid regretting your decision later.

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
ProShop