What exactly is a Gcode variable? In this video tutorial by @GCodeTutor, we are going to provide a simple explanation and show some examples of how to use them correctly.
When we are programming with Gcode, 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 Gcode, 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 Gcode. 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, visit Gcodetutor.com (https://rb.gy/7yzqfn).
Stay tuned for more machining videos!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Recommended CNC programming books:
Fanuc CNC Custom Macros https://amzn.to/370yX0P
CNC Programming Handbook https://amzn.to/2MPxT9g
CNC Programming Techniques https://amzn.to/3aTS4el
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Practical Machinist is the largest and most engaged metalworking community across the web. With more than 160,000 registered members and 300,000+ social media followers, Practical Machinist is the easiest way to learn new techniques, get answers quickly, and discuss common challenges with your peers. Visit Practical Machinist today to join the community and start connecting with your peers.
Become a Practical Machinist member (https://www.practicalmachinist.com/)
Like us on Facebook ( / practicalmachinist )
Follow us on Instagram ( / practicalmachinist )
Follow us on Twitter ( / prac_machinist )
Connect with us on LinkedIn ( / practicalmachinist )
#FANUC #Gcode #CNCprogramming