CNC Macro Programming Tutorial: IF Statements

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ค. 2024
  • ​‪@GCodeTutor‬ talks about IF statements within G-code and how we can use them to shorten our code with CNC macro programming.
    IF statements within G-code are typically used to check if a condition is true. If it is the machine tool will run a part of the code, if not the machine will ignore it.
    In order to understand the function of the IF statements, it's important to understand the GOTO function works. GOTO commands are used to communicate the machine to jump to a specific line of code.
    When an IF statement is added before the GOTO command, it instructs the machine to jump to a specific line of code if a particular condition is met. Here's an example of a typical IF statement:
    IF [# 200 EQ # 300] GOTO 500
    GOTO 700
    In this case, if variable #200 is equal to variable #300, the machine tool will jump to line 500. If not, the machine will keep reading the rest of the program, and in this case, it will jump to line 700.
    IF statements can include different conditional options and often multiple conditions are added, using the AND or OR commands to either restrict or expand the conditions.
    CNC macro programming is really beneficial to speed up our programming, and there are many uses for it, but knowing IF statements is a big part of being able to program with Macros.
    To learn more about G-code and CNC macro programming, visit Gcodetutor.com (rb.gy/7yzqfn).
    Stay tuned for more machining videos!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Recommended CNC programming books:
    Fanuc CNC Custom Macros - amzn.to/370yX0P
    CNC Programming Handbook - amzn.to/2MPxT9g
    CNC Programming Techniques - 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 (www.practicalmachinist.com/)
    Like us on Facebook ( / practicalmachinist )
    Follow us on Instagram ( / practicalmachinist )
    Follow us on Twitter ( / prac_machinist )
    Connect with us on LinkedIn ( / practical-machinist )
    #Gcode #CNCprogramming #macroprogramming
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 9

  • @seankerslake8103
    @seankerslake8103 8 หลายเดือนก่อน

    Armed with a loop this simple method is excellent for repetition to depth
    N10 #20 =100 (number of repetitions)
    N20 (code to repeat - might have incremental moves)
    N30 #20=#20-1
    N40 IF [#20 LT 1] GOTO 60
    N50 GOTO 20
    N60 M05

  • @gredangeo
    @gredangeo 3 ปีที่แล้ว +3

    After the first G91 that is called up. G90 is not called up afterwards. This machine isn't moving from the tool change position. Also, should be putting a G91 on G28 Blocks, just because. Otherwise crashes can occur. lastly, it would be pretty nice to see the example play out line by line. Just to see it. :)

  • @cibinmathew7075
    @cibinmathew7075 2 ปีที่แล้ว +1

    Please tech as the use of sin cos in macro program

  • @giova2927
    @giova2927 ปีที่แล้ว

    Hi, I would monitoring an old fanuc sigma vc1000 using macro. I WOULD say if in your opinion is possible. Thanks for answer me.

  • @conversationwithgod272
    @conversationwithgod272 3 ปีที่แล้ว

    if the program is running and the condition is true....the condition statement will be excuted even if the program passed that if statement?

  • @FHove
    @FHove 2 ปีที่แล้ว

    Why would you need macro programs? Can't you just use a normal program to do what you want?

    • @ryanm19
      @ryanm19 ปีที่แล้ว +2

      You can. I just started learning and I’m starting to see some of its uses. Currently I am writing a macro because I have a bunch of similar parts with the same operations just different sizes. Macro is way quicker than writing 20 different programs. That’s just one use.

  • @ricardoreyes-rj4hm
    @ricardoreyes-rj4hm 3 ปีที่แล้ว +2

    First