Free simulator
Fanuc Macro B Simulator — Run G65, WHILE, IF and System Variables
Macros are the most powerful part of a Fanuc control and the least taught. This simulator runs them block by block and shows every variable, the real NC blocks the macro creates and the path. Make the mistakes here and not on the machine.
Variables #500–#999 stay in your browser like on a real control after power off.
feed rapid drilled hole
Variables
| Variable | Value | Kind |
|---|
How it works
Order of operations: functions and [ ] first, then * / AND MOD, then + − OR XOR, then comparisons. Vacant #0 is not zero: #0 + 0 = 0, but [#0 EQ 0] is false and an address with a vacant variable is left out of the block. G65 arguments: A=#1, B=#2, C=#3, I=#4, J=#5, K=#6, D=#7, E=#8, F=#9, H=#11, M=#13, Q=#17, R=#18, S=#19, T=#20, U=#21 … Z=#26.
Variables that matter
- #1–#33 local: new in every G65 call, gone after M99.
- #100–#199 common: shared by all programs, cleared at reset or power off on most controls.
- #500–#999 permanent: kept after power off. Here they stay in your browser.
- #3000 = n stops with alarm 3000+n and your message. #3006 stops with a message.
- #4001–#4130 modal state of the last block (G group, H, D, F, S, T). #5001–#5003 end point of the last block, #5021–#5023 machine position.
- #5221–#5223 G54 X, Y, Z. Writing to them changes the offset like G10 L2 P1.
Typical mistakes the simulator shows
- WHILE without matching END, or END 2 inside DO 1 (PS0124/PS0126 class)
- GOTO to a sequence number that does not exist
- SQRT of a negative value or division by zero
- A G65 call to a program that is not loaded
- Endless loops (stopped after 200,000 blocks)
Put your main program first and subprograms after it, each starting with O and a number. Then try the generated path in the 3D milling simulator. Exact alarm numbers and limits differ between controls and options; always test a new macro in single block with the feed override low.
Embed this calculator on your site
Free for workshops, schools and forums — copy this snippet:
<iframe src="https://cnccode.com/embed/macro-b-simulator/" width="100%" height="720" style="border:0" loading="lazy" title="Fanuc Macro B Simulator"></iframe>More free CNC tools
- G-Code Viewer & Simulator
- 3D CNC Simulator & Challenges
- CNC Lathe Simulator
- 5-Axis Simulator (A/C Trunnion)
- Live Milling Simulation
- STL Viewer & Part Weight
- Virtual CNC Machine
- Canned Cycle Simulator
- G41/G42 Cutter Compensation Simulator
- Chatter & Stability Lobe Simulator
- Trochoidal Milling Simulator
- Feeds & Speeds Calculator
- Drilling Speed & Feed Calculator
- Surface Finish Calculator
- All tools