Understanding FANUC Macro B Variables

November 21, 2020 12:00 pm


What exactly is a G-code variable? In this video tutorial by @G-Code Tutor, we are going to provide a simple explanation and show some examples of how to use them correctly.

When we are programming with G-code, many FANUC controls these days come with macro B programs enabled, and that allows us to use variables in our programming. But what exactly is a variable? In a nutshell, a variable is a symbol for a number we don’t know yet. They are the backbone of all programming languages. In the world of G-code, variables are expressed in the program by a hash symbol followed by a number, like in the example below…

# 100 = 1

So we can give variables a number or a value, so if we state # 100 = 1, every variable # 100 in the program will equal 1. Variables can also be used to do math within G-code. Variables math is often used to count cycles by adding a simple code like this “# 100 = # 110 + 1” at the bottom of every block of the program so that it adds 1 to the variable # 100 every time it gets to that point of the program.

By giving a value to a variable, we define the variable, and there are multiple ways to do that. We can add it manually into the register of the machine controls or we can change the value of the variables inside our NC program.

To learn more about FANUC macro B variables, Gcodetutor.com. Stay tuned for more machining videos!

Recommended Videos

Leave a Reply