Decisions with IF / ENDIF

Branch on a seeded value with an IF / ELSE / ENDIF block.

An IF … ENDIF block lets a program decide. The condition uses plain symbols — >, <, >=, ==, <> — and an optional ELSE gives the other path. This is the moment a program stops being a list of moves and starts being software.

Read firstSinumerik Programming Basics (828D)Fanuc-to-Siemens translation guide for the Sinumerik 828D: program structure, tool calls, work offsets, frames (TRANS/ROT), cycles, and ShopMill vs G-code programs.

Your turn

A feed value arrives in R1. Clamp it to a ceiling of 100: if R1 is above 100, set R2 to 100; otherwise set R2 to R1 unchanged.

The machine gives you

150 requested — over the ceiling:R1 = 150
50 requested — under the ceiling:R1 = 50

Your program is run once for each set of conditions. It has to work for all of them.

Loading...

This is a learning simulation — always prove out a program on the actual control before you cut metal.