To my surprise, CHATGPT appears to be able to write g-code specific to CNC12. Here is an example of where I wanted add the use of variables to the previous code:
Great! Below is a fully working example of a parameterized “Trim Top” routine for Centroid CNC12, using:
• A main G-code file that calls a macro (M101 Q7.85)
• A macro file (mfunc101.mac) that does the actual trimming using the Q value
________________________________________

1. Main G-code File (calls macro)
You can name this file something like trim_top.cnc:
gcode
CopyEdit
%
; TRIM TOP using macro with variable distance
M101 Q7.85 ; Call trim macro, passing 7.85 as trim distance
%
This sends Q7.85 (the trim distance) to macro M101.
________________________________________

2. Macro File: mfunc101.mac
Place this file in the CNC12 macro folder (usually c:\cncm\mill\mfunc or similar for milling machines).
Filename: mfunc101.mac
gcode
CopyEdit
; mfunc101.mac - Trim Top Edge using Q as trim distance
G91 ; Relative positioning
G1 X[-#1] F30 ; Move left by trim distance
G1 Z0.2 F20 ; Raise Z
G1 X[#1] F120 ; Move right by trim distance
G1 Z-0.2 F20 ; Lower Z
G90 ; Return to absolute positioning
#1 is the system variable that receives the Q value from the G-code call.
________________________________________
🛠 How to Use It
1. Save the macro as mfunc101.mac in your Centroid macro directory.
2. Call M101 Qxxx in any G-code file with the trim distance you want (e.g., Q7.85).
3. The macro handles all the relative motion based on the passed-in value.
________________________________________

Why This Works:
Centroid CNC12 doesn't allow math expressions like X[#100] in the G-code file, but it does support macros with passed parameters, so this setup is the clean, maintainable way to parameterize distances.
Inspiring!