G-Wizard Calculator:
Fast, Easy, Reliable Feeds and Speeds


Join 100,000+ CNC'ers!  Get our latest blog posts delivered straight to your email inbox once a week for free. Plus, we’ll give you access to some great CNC reference materials including:

  • Our Big List of over 200 CNC Tips and Techniques
  • Our Free GCode Programming Basics Course
  • And more!


GCode is Complicated
G-Wizard Makes it Easy

LinuxCNC Subroutines Question


I’m not sure how to add a subroutine or loops.

In the GWizard Editor, the “O” code shows it as a subroutine but when using “sub”, “endsub” ,”while”, etc. I just get a bunch of errors.

This code works fine in Axis:

o<circle> sub
  (getting the radius from the diameter value)
  (that was passed by dividing it in 1/2)
  (then storing it in a named parameter)
  #<radius> = [#3 / 2]
  G0 X[#1 - #<radius>] Y[#2]
  (debug, X = #1 Y = #2 radius = #<radius>)
  G2 X[#1 - #<radius>] Y[#2] I[#<radius>] J0
  (msg, some useful code here)
o<circle> endsub

(X center, Y center, Circle Diameter)
o<circle> call [1.5] [2.0] [3]
G0 X0 Y0
  • You must to post comments

Kerry, at the moment GWE only handles subroutine and control structure syntaxes that are very similar to Fanuc Macro B.  LinuxCNC is quite different and so there’s a fair amount of work involved to set up for it.  I have it on my ToDo list, but it’ll be a little while before I get to it as some other things are higher priority.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.


Do you want to be a better CNC'er?

Get Better Tool Life, Surface Finish, and Material Removal Rates.


Start Now, It's Free!



  GW Calculator

  GW Editor



  Deals and Steals

CNC Blog








     Feeds and Speeds

     G-Code Tutorial

     CNC Machining & Manufacturing

     DIY CNC Cookbook

     CNC Dictionary

CNC Projects


     Machinist's Search


     Online Groups


     Reference Data


     CNC Dictionary


     Tool Brands


     Hall of Fame

     Organization: Soon!





     Our History

     Privacy Policy

All material © 2016, CNCCookbook, Inc.