Arithmetic & Brackets

Control the order of operations with square brackets on the OSP.

Okuma does * / before + -, same as arithmetic class. Square brackets override that: [VC1 + 5] * 2 adds first, then doubles. Get the brackets wrong and the control happily computes the wrong number — there's no error, just a bad part.

Read firstWhat Is a CNC Macro? — Start HereA beginner's on-ramp to CNC macro programming for machinists who already write G-code: what macros are, why they matter, variables, math, loops, passing arguments with G65, and a complete first macro worked line by line.

Your turn

The machine hands you a value in VC1. Set VC2 to [VC1 + 5] * 2 — the five must be added before the doubling, so it needs brackets. Then set VC3 to a quarter of VC1.

The machine gives you

VC1 = 10:VC1 = 10
VC1 = 20:VC1 = 20

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.