Can GRBL run this code with variables?

Here is the grid program I use on my old Mazak laser at work. I would love to have something like this for my XXL. Is this doable?
The first two programs are the macros that do all of the calculating to run the grid. One is for an X first grid and one is for a Y first grid.
The last two programs are the programs that are edited with the parameters for the part that you want to grid. Only the macro subprogram call is changed, depending if you want an X or Y first grid.

O8500
(MACRO SHEET NEST X DIR)
(A #1 # OF X PARTS)
(B #2 # OF Y PARTS)
(I #4 X PART SPACING)
(J #5 Y PART SPACING)
(X #24 X START POSITION)
(Y #25 Y START POSITION)
(S #19 SUBPROGRAM # OF PART)
(K #6 # OF PARTS TO SKIP)
N10IF[#1LE0]GOTO390
N20IF[#2LE0]GOTO390
N30IF[#6GE[#1*#2]]GOTO390
N40IF[#24LT0]GOTO380
N50IF[#25LT0]GOTO380
N60#8=1
N70#9=1
N75#10=1
N80IF[#6EQ0]GOTO140
N90IF[#6LT[#1]]GOTO130
N100#6=#6-#1
N110#9=#9-1
N115#10=#10+1
N120GOTO90
N130#8=#6+1
N140G90G00X[#24+[[#8-1]#4]]Y[#25+[[#9-1]#5]]
N160G90G92X0Y0
N170GOTO250
N180G90G00X[#4]Y0
N200G90G92X0Y0
N210GOTO250
N220G90G00X[-#4*[#1-1]]Y-[#5]
N240G90G92X0Y0
N250M98P#19
N260IF[#1EQ1]GOTO320
N270IF[#8EQ[#1]]GOTO300
N280#8=#8+1
N290GOTO180
N300M31
N310G91G28Z0
N320IF[#10EQ[#2]]GOTO400
N330#8=1
N340#9=#9+1
N345#10=#10+1
N350GOTO220
N380#999=900(X Y POSITION MUST BE POSITIVE)
N390#999=900(CHECK G65 LINE VALUES)
N400M99

O8600
(MACRO SHEET NEST Y DIR)
(A #1 # OF X PARTS)
(B #2 # OF Y PARTS)
(I #4 X PART SPACING)
(J #5 Y PART SPACING)
(X #24 X START POSITION)
(Y #25 Y START POSITION)
(S #19 SUBPROGRAM # OF PART)
(K #6 # OF PARTS TO SKIP)
N10IF[#1LE0]GOTO390
N20IF[#2LE0]GOTO390
N30IF[#6GE[#1*#2]]GOTO390
N40IF[#24LT0]GOTO380
N50IF[#25LT0]GOTO380
N60#8=1
N70#9=1
N75#10=1
N80IF[#6EQ0]GOTO140
N90IF[#6LT[#2]]GOTO130
N100#6=#6-#2
N110#9=#9+1
N115#10=#10-1
#8=#8+1
N120GOTO90
N130#9=#6+1
N140G90G00X[#24+[[#8-1]#4]]Y[#25+[[#9-1]#5]]
N160G90G92X0Y0
N170GOTO250
N180G90G00X0Y[#5]
N200G90G92X0Y0
N210GOTO250
N220G90G00Y[-#5*[#2-1]]X[#4]
N240G90G92X0Y0
N250M98P#19
N260IF[#2EQ1]GOTO320
N270IF[#9EQ[#2]]GOTO300
N280#9=#9+1
N290GOTO180
N300M31
N310G91G28Z0
N320IF[#8EQ[#1]]GOTO400
N330#9=1
N340#8=#8+1
N345#10=#10+1
N350GOTO220
N380#999=900(X Y POSITION MUST BE POSITIVE)
N390#999=900(CHECK G65 LINE VALUES)
N400M99

o1
G91G28Z0
G90G54X0Y0
G65P8600I35.800J35.800A001B001X9.8000Y10.450S4321K0000
G91G28Z0
G28X0Y0
M30

o11
G91G28Z0
G90G54X0Y0
G65P8500I35.800J35.800A001B001X9.8000Y10.450S4321K0000
G91G28Z0
G28X0Y0
M30

Not directly. Grbl is intensely memory-constrained (see: http://bengler.no/grbl ) — the code may work with a pre-processor, see:

(I believe that’s integrated with some opensource communication/control programs, maybe bCNC?)

Usually folks use more robust tools for programming, see the list at: https://wiki.shapeoko.com/index.php/Programming

1 Like

So, Any of you software guys have this running on your system to try it out? :pleading_face::grinning:

Actually, the github repo that @WillAdams referenced contains a precompiled Windows executable that you may be able to use (assuming you are using Windows). Just download the repo as a zip, and head to the “win/Release_x64” directory and you have this GSharp2GCode.exe program.

I just tried out of curiosity, and it gave me this error where it complains about the O-codes:

image
I commented them out and then got this other error:

image
Sooo, you may need to look into it further yourself, playing with this executable :slight_smile:
I’m not even sure if your code is actually this “G sharp” language, but it looks like it.

Anyway there is definitely ways to preprocess that input to spit out plain GRBL compatible G-code. If not with some open source existing solution, I’m sure @ClayJar would do it for fun in the blink of an eye :slight_smile:

2 Likes

Cool! I saw C++ and stopped. :grinning:
The “O” code is nothing more than the program number for DNC, so it’s not needed anyway. I’ll have to play with this when I get a spare moment, since there is exe.

Thanks for looking at it!!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.