Gcode flavors and what to know/modify so it runs on mpcnc

Hello,
My mpcnc is finally alive and drawing beautiful crowns. Pretty thrilling to see it actually work after lots of time and effort putting it all together. Next up I want to carve from a photo. There are programs that help turn a photo into gcode that basically use the darkness in the photo to set the depth. PhotoVCarve is probably known to many, but I was looking for a free one and found rastercarve. Saw there was a forum post on rastercarve a year ago but it never got to my question about post processing and gcode that is supported by mpcnc. But it actually brings up this more generaklquestion about generating, or obtaining, gcode and knowing if it will run on mpcnc (more specially latest marlin that runs on the latest rambo board). What are some red flags to look for and what mods are typically required to get it to work.
I am going to include the output gcode from rastercarve and ask is anyone spots anything that may be problematic and how it might be fixed. I will not include the very large file, but just what is at the beginning and end; the rest of the file is very much like what is happening in the samples below. All it is doing is drawing these diagonal lines and varying the depth as it goes along. Ive read through lots of other posts and see stuff that makes me think I need to do some post processing on this because of gcode commands not supported on marlin/mpcnc. I would be grateful for any advice on if this gcode looks ā€˜goodā€™ or what will likely need to be changed.
Kindest regards,
Mike

Beginning of gcode:

( Generated by rastercarve: github.com/built1n/rastercarve )
( Image name: /app/output/c4affb517726a8c707861a26db6835b1 )
N1 G00 G20
N2 M03
N3 G0 X0.000000 Y0.000000 Z0.100000
N4 G1 F30 Z0.100000
N5 G0 X0.000000 Y-0.000000
N6 G1 F30 X0.000000 Y-0.000000 Z-0.038281
N7 G1 F100 X0.000000 Y-0.000000 Z-0.038281
N8 G1 F30 Z0.100000
N9 G0 X0.070018 Y-0.000000
N10 G1 F30 X0.070018 Y-0.000000 Z-0.037891
N11 G1 F100 X0.060780 Y-0.003827 Z-0.036914
N12 G1 F100 X0.051541 Y-0.007654 Z-0.035156
N13 G1 F100 X0.042302 Y-0.011481 Z-0.037500
N14 G1 F100 X0.033063 Y-0.015307 Z-0.037500
N15 G1 F100 X0.023825 Y-0.019134 Z-0.039062
N16 G1 F100 X0.014586 Y-0.022961 Z-0.037891
N17 G1 F100 X0.005347 Y-0.026788 Z-0.037109
N18 G1 F100 X0.000000 Y-0.029003 Z-0.036133
N19 G1 F30 Z0.100000
N20 G0 X0.000000 Y-0.058005
N21 G1 F30 X0.000000 Y-0.058005 Z-0.038086
N22 G1 F100 X0.009239 Y-0.054178 Z-0.038086
N23 G1 F100 X0.018478 Y-0.050352 Z-0.039062
N24 G1 F100 X0.027716 Y-0.046525 Z-0.040039
N25 G1 F100 X0.036955 Y-0.042698 Z-0.039453
N26 G1 F100 X0.046194 Y-0.038871 Z-0.033398
N27 G1 F100 X0.055433 Y-0.035044 Z-0.035156
N28 G1 F100 X0.064672 Y-0.031217 Z-0.034961
N29 G1 F100 X0.073910 Y-0.027391 Z-0.035547
N30 G1 F100 X0.083149 Y-0.023564 Z-0.038281
N31 G1 F100 X0.092388 Y-0.019737 Z-0.037695
N32 G1 F100 X0.101627 Y-0.015910 Z-0.036719
N33 G1 F100 X0.110866 Y-0.012083 Z-0.036328
N34 G1 F100 X0.120104 Y-0.008256 Z-0.034961
N35 G1 F100 X0.129343 Y-0.004430 Z-0.037305
N36 G1 F100 X0.138582 Y-0.000603 Z-0.035156
N37 G1 F100 X0.140037 Y-0.000000 Z-0.035156
N38 G1 F30 Z0.100000
N39 G0 X0.210055 Y-0.000000
N40 G1 F30 X0.210055 Y-0.000000 Z-0.035938
N41 G1 F100 X0.200817 Y-0.003827 Z-0.036133
ā€¦

End of gcode:

ā€¦
N180209 G1 F100 X7.861418 Y-5.995527 Z-0.025000
N180210 G1 F100 X7.852179 Y-5.999354 Z-0.029102
N180211 G1 F100 X7.850620 Y-6.000000 Z-0.029102
N180212 G1 F30 Z0.100000
N180213 G0 X7.920638 Y-6.000000
N180214 G1 F30 X7.920638 Y-6.000000 Z-0.033008
N180215 G1 F100 X7.929877 Y-5.996173 Z-0.034180
N180216 G1 F100 X7.939116 Y-5.992346 Z-0.040039
N180217 G1 F100 X7.948354 Y-5.988519 Z-0.040430
N180218 G1 F100 X7.957593 Y-5.984693 Z-0.039648
N180219 G1 F100 X7.966832 Y-5.980866 Z-0.038477
N180220 G1 F100 X7.976071 Y-5.977039 Z-0.036914
N180221 G1 F100 X7.985310 Y-5.973212 Z-0.036328
N180222 G1 F100 X7.994548 Y-5.969385 Z-0.032031
N180223 G1 F100 X8.000000 Y-5.967127 Z-0.031250
N180224 G1 F30 Z0.100000
N180225 G0 X8.000000 Y-5.996130
N180226 G1 F30 X8.000000 Y-5.996130 Z-0.036523
N180227 G1 F100 X7.990761 Y-5.999957 Z-0.037109
N180228 G1 F100 X7.990657 Y-6.000000 Z-0.037109
N180229 G1 F30 X7.990657 Y-6.000000 Z2.000000
N180230 G0 X0.000000 Y0.000000 Z2.000000
N180231 M05

1 Like

oh, one thing I wanted to add is when I open the gcode in repetier host, it seems like it is confused about either origin or the direction of the y axis since the toolpaths are all on what appear to be the negative y axis.

I cannot comment on your more general question, but I just see a couple of things that jump out at me in this g-code. The first is this line:

N1 G00 G20

I donā€™t know what a G00 represents. It likely will be interpreted by Marlin as a G0 but will choke or ignore the G20 as a parameter. In addition Iā€™m guessing that the G20 is a separate g-code command. Marlin wants each command on its own line.

Next issue is units. Iā€™m guessing the G20 sets the units to inches. That is what it does in Marlin g-code as well as in some other g-code versions. In your g-code snippets, the coordinates in all the G0 and G1 commands are obviously in inches. Unfortunately the V1 maintained versions of the firmware do not support inches. If you are comfortable compiling and flashing firmware, you can enable inches by uncommenting the define in configuration.h:

//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT

In summary, get rid of the G00, put the G20 on its own line, enable inch support in Marlin, and it is likely this file will run.

Thereā€™s a metric option as well, --metric.

Nice script, thanks for the share!

Thanks Robert. I will try your changes.
I was looking for a ā€œmetric optionā€ on the ā€˜liveā€™ (web) version of the program and did not see it, but looking at the executable (that the live web site sits in front of I presume), I see the metric option (thanks Turinbjorn), so will use that to get around the imperial units issue. I thought I had read that the mpcnc firmware would only support metric, so thanks for confirming that. So will load/build the executable version, which I bet even lets you have customizable preamble and epilogue (beginning and ending gcode) so I can get around that ā€˜N1 G00 G20ā€™ first line issue, and generate some new gcode and look it over and then maybe get balsy enough to try my first milling (carving). Will share results as to how well this let you carve picture/images. For some strange reason I have high hopes it will turn out well.

If you want to sneak up on it, start by looking at the code in a g-code simulator, then do a dry run with the router off and positioned well above your spoilboard, and finally do your first test(s) in cheap foam.