ThingConnect

CNC programs & data

CNC macro variables

CNC macro variables are numbered memory slots — #100, #500 and so on — that a part program can read and write, turning a fixed program into one that counts, decides and remembers.

Updated November 20263 min read

← All glossary terms

Plain G-code runs the same moves every time. Macro variables give a program memory: it can count parts, compare a measured size against a limit, or pick a different path — and leave the result somewhere other software can read.

The variable ranges

On many controls the numbers are grouped like this. Exact ranges vary between control makers, so treat this as a typical layout, not a rule.

  • #1–#33

    Type
    Local — arguments passed into one macro call
    Kept after power-off?
    No
  • #100–#199

    Type
    Common — shared by all programs
    Kept after power-off?
    No
  • #500–#999

    Type
    Common, retained — battery-backed
    Kept after power-off?
    Yes
  • #1000 and up

    Type
    System — set by the control (offsets, tool, alarms)
    Kept after power-off?
    Control-managed

What shops use them for

  • Part counting — #777=#777+1 before the program end
  • Tool life — a target and an actual count per tool, updated each part
  • Probing and gauging — writing a measured value straight into an offset
  • Family-of-parts programs — one program, with sizes held in variables

Reading macro variables from outside

Many controls let networked software read macro variables while a program runs. ThingConnect reads the variables you choose for each machine about once a second. If a machine counts parts in a macro variable instead of its standard counter, that variable can be set as the machine’s part count, so cycle time and output reports work the same as on every other machine. Per-tool counters in macro variables feed tool life monitoring.

On the floor

The built-in part counter can be reset from the operator panel — zero it and the history is gone. We’ve seen shops stop relying on it and drive the part count from a macro variable the program increments itself, so the count can’t be quietly reset. Same idea for tools: a tool number tells you which pocket, not which physical tool, so tracking target and actual counts per tool in dedicated variables keeps tool life tied to the real tool.

Frequently asked questions

Keep one shop-wide list of which variable numbers each program and probing cycle uses, and reserve a block of numbers for counters that monitoring software reads. Two jobs sharing a variable is a common reason a count or offset changes for no visible reason.

Often, yes. On many controls custom macro programming is an option that has to be enabled, and some basic packages don’t include it. Check the control’s option list or ask the machine builder before planning a program that depends on variables.

Related terms

Filed under

CNC programs & data

Live demo

See ThingConnect on a real shop floor

A one-on-one walkthrough with our team.

Book a demo
Talk to our team

Read the macro variables your programs already write, from every machine on the floor