CNC macro programming - Conditional statements

Practical Machinist
Practical Machinist
7 هزار بار بازدید - 4 سال پیش - Let's take a look at
Let's take a look at how to use conditional statements when CNC programming with G-code macros.

Conditional statements in CNC programming are used when we want to compare two values and act upon the results.
A typical program where we might use a conditional statement would look like this:

IF [#200 EQ 5] GOTO 310
GOTO 20

The statement above tells the CNC machine to go to line 310 (GOTO 310) that if the variable #200 is equal to 5 (our conditional statement) or go to line 20 if the conditional statement is not true.

In order to work, conditional expressions must be enclosed within square brackets, and compare two operands (such as a # variable or a number) through a comparison operator. The example above shows the comparison operator EQ (equal to). Other common comparison operators are:
NE = Not equal to
GT = Greater than
LT = Less than
GE = Greater or equal to
LE = Less than or equal to

To learn more about G-code programming, 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 (Facebook: PracticalMachinist)
Follow us on Instagram (Instagram: practicalmachinist)
Follow us on Twitter (Twitter: prac_machinist)
Connect with us on LinkedIn (LinkedIn: practical-machinist)

#Gcode #CNCprogramming #macroprogramming
4 سال پیش در تاریخ 1399/11/22 منتشر شده است.
7,089 بـار بازدید شده
... بیشتر