What GCodes does the firmware understand as I am attempting to write a post processor for Solidworks CAM (unless someone already has one but I couldn’t find it) but I am unsure what it knows and what it doesn’t and if there are certain gcodes (or mcodes) that it doesn’t know that is where the fun begins to see if SW CAM pp can manage that.
For Marlin you can start here. Grbl has a slightly different list.
Note that not all codes are enabled by default. Some avoid G2 and G3, almost nobody uses G5. Most don’t have hardware for G38.2, and G53 through G59.3 are not common, I forget if they are enabled by default. Inches are not supported unless the firmware config is modified. Rotary axes are not implemented so workarounds are necessary for those.
So there is nothing new added to Marlin in other words?
Not quite sure what you mean by new, but broadly speaking no, nothing new.
Alright as I thought it was a fork of Marlin to be more CNC specific but if nothing has changed then just use the latest bugfix? I see almost 6k commits past the MPCNC version is why I am asking.
Grbl and Marlin have a lot in common, and a lot of differences. The MPCNC firmware tracks bugfix-2.0, but most of the differences are in the configuration. Things like disabling the thermistors, enabling some features, and on some versions, enabling dual endstops. But nothing to so with gcode parsing or dealing with the commansa any differently.
The trick to writing a post processor for Marlin (besides avoiding uncommon gcodes) is to manage the speeds and G0.
On Marlin, G0 is a shortcut straight to G1 (under the standard configuration). And the feed rate is sticky. Where postprocessors have bit us in the past is with code like this:
G1 X100 F1800 ; 30mm/s X
G0 Z5 ; The Z speed is now 30mm/s. That's too fast
Or
G1 X1 Y1 Z-1 F1800 ; The combined speed here may be too high for Z
Or
G1 X10 F1800
G1 Z-5 ; You're seeing a pattern here, right?
Semicolons for comments, checksums and line numbers aren’t enforced. Adding the ability to disable arcs (G2/G3) by configuration is big, because they are often broken…
That’s what I can think of off the top of my head.
Been dealing with Marlin since 2012 and 2.0 (use it on my CoreXY) is a huge step up and arc is in there but you have to fine tune the arc as its default is 1mm per step (I read this from a dev on github). I always got mad that G0 and G1 were the same routine and one is just the alias of the other. Never been fixed and to be honest I am still unsure what the difference is.
My Z on my coreXY can’t handle speeds above 3mm/s (4mm/s it may buck) as I switched to a 3:1 gear system and switched from 8mm/rev to 2mm/rev leadscrews so 12:1 reduction make my steps/mm 4800. After that I fell into a hole with Marlin and found some bugs in Marlin they fixed due to my discoveries etc… but the first one I found is that Marlin 2.0 was no longer enforcing the max feedrates and that one tore me a new a** that cost me several days of 12h days to track down. They finally, with the help of another, decided to bring back the old way of enforcing it but what I did was this to make sure all plays nice (per gcode file):
M201 X1500 Y1500 Z25 E1500 ; sets maximum accelerations, mm/sec^2
M203 X240 Y240 Z3 E60 ; sets maximum feedrates, mm/sec
M204 P1500 R1500 T1500 ; sets acceleration (P, T) and retract acceleration ®, mm/sec^2
M205 X16.00 Y16.00 Z0.40 E5.00 ; sets the jerk limits, mm/sec
M205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec
What I can’t figure out is the programmer for making the PP because I can load a known working one and do nothing but write it out then load it into the cam and it will crash. I compared both files in a hex editor and they were different so not as easy as that for sure so I am trying to find something to help with this (videos etc…) but with it crashing Solidworks this is not going to be easy.
I can’t help you with that… people always say “you get what you pay for”, but at least with FOSS, you have a chance to fix it. It seems like a lot of very expensive software has really crummy apis (hard to work with, or just broken).
Well, I have managed to work some of this out so far but what a learning trip this is and I am not yet able to turn off arcs.
;Marlin GCODE
G0 G71 G90 G54 G64 G40
M6 T4 ;16MM CRB 2FL 32 LOC
S4378 M3
G0 X35.43 Y3.11
Z2.50
G1 Z-8.00 F122.32
X-35.43 F489.29
Y-3.11
X35.43
Y3.11
X-35.43
Y-3.11
X35.43
Y3.11
G0 Z2.50
Z-5.50
G1 Z-14.75 F122.32
X-35.43 F489.29
Y-3.11
X35.43
Y3.11
X-35.43
Y-3.11
X35.43
Y3.11
G0 Z2.50
Z-12.25
G1 Z-15.00 F122.32
X-35.43 F489.29
Y-3.11
X35.43
Y3.11
X-35.43
Y-3.11
X35.43
Y3.11
G0 Z2.50
Z25.00 M9
T1 S12000;6MM CRB 2FL 19 LOC
S12000 M3
G0 X40.43 Y6.36
Z2.50
G1 Z-3.00 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
I am learning but the issue is the nomenclature is not what a non CNC person is used to as our 3d printer calls things differently. I am going step by step but first I need a way to stop the arc and I bet I can’t (might take programming which is even deeper).
Marlin doesn’t support multiple commands on one line.
This seems backwards? Is that an M3 command?
There should be another G0 on the second line. There hasn’t been a feedrate set yet, so whatever the previous command is will determine the speed.
??
Maybe you didn’t want me to proof read this. Not sure. If so, sorry
Yep, I knew all of that but I am very glad you went through it and I now have it like this:
;Marlin gcode
G71
G90
G54
G64
G40
M6 T4 ;16MM CRB 2FL 32 LOC
M3 S4378
G0 X35.43 Y3.11
G0 Z2.50
G1 Z-8.00 F122.32
G1 X-35.43 Y3.11 Z-8.00 F489.29
G1 X-35.43 Y-3.11 Z-8.00
G1 X35.43 Y-3.11 Z-8.00
G1 X35.43 Y3.11 Z-8.00
G1 X-35.43 Y3.11 Z-8.00
G1 X-35.43 Y-3.11 Z-8.00
G1 X35.43 Y-3.11 Z-8.00
G1 X35.43 Y3.11 Z-8.00
G0 Z2.50
G0 Z-5.50
G1 Z-14.75 F122.32
G1 X-35.43 Y3.11 Z-14.75 F489.29
G1 X-35.43 Y-3.11 Z-14.75
G1 X35.43 Y-3.11 Z-14.75
G1 X35.43 Y3.11 Z-14.75
G1 X-35.43 Y3.11 Z-14.75
G1 X-35.43 Y-3.11 Z-14.75
G1 X35.43 Y-3.11 Z-14.75
G1 X35.43 Y3.11 Z-14.75
G0 Z2.50
G0 Z-12.25
G1 Z-15.00 F122.32
G1 X-35.43 Y3.11 Z-15.00 F489.29
G1 X-35.43 Y-3.11 Z-15.00
G1 X35.43 Y-3.11 Z-15.00
G1 X35.43 Y3.11 Z-15.00
G1 X-35.43 Y3.11 Z-15.00
G1 X-35.43 Y-3.11 Z-15.00
G1 X35.43 Y-3.11 Z-15.00
G1 X35.43 Y3.11 Z-15.00
G0 Z2.50
G0 Z25.00
M9
T1 S12000;6MM CRB 2FL 19 LOC
M3 S12000
G0 X40.43 Y6.36
G0 Z2.50
G1 Z-3.00 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
G1 X35.43 Y8.11 Z-3.00
G2 X40.43 Y3.11 R5.00
G1 X40.43 Y6.36 Z-3.00
G0 Z2.50
G0 Z-.50
G1 Z-5.94 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
G1 X35.43 Y8.11 Z-5.94
G2 X40.43 Y3.11 R5.00
G1 X40.43 Y6.36 Z-5.94
G0 Z2.50
G0 Z-3.44
G1 Z-8.88 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
G1 X35.43 Y8.11 Z-8.88
G2 X40.43 Y3.11 R5.00
G1 X40.43 Y6.36 Z-8.88
G0 Z2.50
G0 Z-6.38
G1 Z-11.81 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
G1 X35.43 Y8.11 Z-11.81
G2 X40.43 Y3.11 R5.00
G1 X40.43 Y6.36 Z-11.81
G0 Z2.50
G0 Z-9.31
G1 Z-14.75 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
G1 X35.43 Y8.11 Z-14.75
G2 X40.43 Y3.11 R5.00
G1 X40.43 Y6.36 Z-14.75
G0 Z2.50
G0 Z-12.25
G1 Z-15.00 F411.48
G3 X38.68 Y8.11 R1.75 F1645.92
G1 X35.43 Y8.11 Z-15.00
G2 X40.43 Y3.11 R5.00
G1 X40.43 Y6.36 Z-15.00
G0 Z2.50
G0 X-40.43 Y3.11
G1 Z-3.00 F411.48
G2 X-35.43 Y8.11 R5.00 F1645.92
G1 X-38.68 Y8.11 Z-3.00
G3 X-40.43 Y6.36 R1.75
G1 X-40.43 Y3.11 Z-3.00
G0 Z2.50
G0 Z-.50
G1 Z-5.94 F411.48
G2 X-35.43 Y8.11 R5.00 F1645.92
G1 X-38.68 Y8.11 Z-5.94
G3 X-40.43 Y6.36 R1.75
G1 X-40.43 Y3.11 Z-5.94
G0 Z2.50
G0 Z-3.44
G1 Z-8.88 F411.48
G2 X-35.43 Y8.11 R5.00 F1645.92
G1 X-38.68 Y8.11 Z-8.88
G3 X-40.43 Y6.36 R1.75
G1 X-40.43 Y3.11 Z-8.88
G0 Z2.50
G0 Z-6.38
G1 Z-11.81 F411.48
G2 X-35.43 Y8.11 R5.00 F1645.92
G1 X-38.68 Y8.11 Z-11.81
G3 X-40.43 Y6.36 R1.75
G1 X-40.43 Y3.11 Z-11.81
G0 Z2.50
G0 Z-9.31
G1 Z-14.75 F411.48
G2 X-35.43 Y8.11 R5.00 F1645.92
G1 X-38.68 Y8.11 Z-14.75
G3 X-40.43 Y6.36 R1.75
G1 X-40.43 Y3.11 Z-14.75
G0 Z2.50
G0 Z-12.25
G1 Z-15.00 F411.48
G2 X-35.43 Y8.11 R5.00 F1645.92
G1 X-38.68 Y8.11 Z-15.00
G3 X-40.43 Y6.36 R1.75
G1 X-40.43 Y3.11 Z-15.00
G0 Z2.50
G0 X-35.43 Y-8.11
G1 Z-3.00 F411.48
G2 X-40.43 Y-3.11 R5.00 F1645.92
G1 X-40.43 Y-6.36 Z-3.00
G3 X-38.68 Y-8.11 R1.75
G1 X-35.43 Y-8.11 Z-3.00
G0 Z2.50
G0 Z-.50
G1 Z-5.94 F411.48
G2 X-40.43 Y-3.11 R5.00 F1645.92
G1 X-40.43 Y-6.36 Z-5.94
G3 X-38.68 Y-8.11 R1.75
G1 X-35.43 Y-8.11 Z-5.94
G0 Z2.50
G0 Z-3.44
G1 Z-8.88 F411.48
G2 X-40.43 Y-3.11 R5.00 F1645.92
G1 X-40.43 Y-6.36 Z-8.88
G3 X-38.68 Y-8.11 R1.75
G1 X-35.43 Y-8.11 Z-8.88
G0 Z2.50
G0 Z-6.38
G1 Z-11.81 F411.48
G2 X-40.43 Y-3.11 R5.00 F1645.92
G1 X-40.43 Y-6.36 Z-11.81
G3 X-38.68 Y-8.11 R1.75
G1 X-35.43 Y-8.11 Z-11.81
G0 Z2.50
G0 Z-9.31
G1 Z-14.75 F411.48
G2 X-40.43 Y-3.11 R5.00 F1645.92
G1 X-40.43 Y-6.36 Z-14.75
G3 X-38.68 Y-8.11 R1.75
G1 X-35.43 Y-8.11 Z-14.75
G0 Z2.50
G0 Z-12.25
G1 Z-15.00 F411.48
G2 X-40.43 Y-3.11 R5.00 F1645.92
G1 X-40.43 Y-6.36 Z-15.00
G3 X-38.68 Y-8.11 R1.75
G1 X-35.43 Y-8.11 Z-15.00
G0 Z2.50
G0 X40.43 Y-3.11
G1 Z-3.00 F411.48
G2 X35.43 Y-8.11 R5.00 F1645.92
G1 X38.68 Y-8.11 Z-3.00
G3 X40.43 Y-6.36 R1.75
G1 X40.43 Y-3.11 Z-3.00
G0 Z2.50
G0 Z-.50
G1 Z-5.94 F411.48
G2 X35.43 Y-8.11 R5.00 F1645.92
G1 X38.68 Y-8.11 Z-5.94
G3 X40.43 Y-6.36 R1.75
G1 X40.43 Y-3.11 Z-5.94
G0 Z2.50
G0 Z-3.44
G1 Z-8.88 F411.48
G2 X35.43 Y-8.11 R5.00 F1645.92
G1 X38.68 Y-8.11 Z-8.88
G3 X40.43 Y-6.36 R1.75
G1 X40.43 Y-3.11 Z-8.88
G0 Z2.50
G0 Z-6.38
G1 Z-11.81 F411.48
G2 X35.43 Y-8.11 R5.00 F1645.92
G1 X38.68 Y-8.11 Z-11.81
G3 X40.43 Y-6.36 R1.75
G1 X40.43 Y-3.11 Z-11.81
G0 Z2.50
G0 Z-9.31
G1 Z-14.75 F411.48
G2 X35.43 Y-8.11 R5.00 F1645.92
G1 X38.68 Y-8.11 Z-14.75
G3 X40.43 Y-6.36 R1.75
G1 X40.43 Y-3.11 Z-14.75
G0 Z2.50
G0 Z-12.25
G1 Z-15.00 F411.48
G2 X35.43 Y-8.11 R5.00 F1645.92
G1 X38.68 Y-8.11 Z-15.00
G3 X40.43 Y-6.36 R1.75
G1 X40.43 Y-3.11 Z-15.00
G0 Z2.50
G0 Z25.00
G0 X-1.45 Y-7.76
G0 Z3.00
G1 Z-3.00 F411.48
G41 G1 X-1.02 Y-8.19 Z-3.00 F1234.44
G3 X-.60 Y-8.36 R.60
G1 X38.68 Y-8.36 Z-3.00 F1645.92
G3 X40.68 Y-6.36 R2.00
G1 X40.68 Y6.36 Z-3.00
G3 X38.68 Y8.36 R2.00
G1 X-38.68 Y8.36 Z-3.00
G3 X-40.68 Y6.36 R2.00
G1 X-40.68 Y-6.36 Z-3.00
G3 X-38.68 Y-8.36 R2.00
G1 X.60 Y-8.36 Z-3.00
G3 X1.02 Y-8.19 R.60
G40 G1 X1.45 Y-7.76 Z-3.00
G0 Z3.00
G0 X-1.45 Y-7.76
G0 Z0
G1 Z-6.00 F411.48
G41 G1 X-1.02 Y-8.19 Z-6.00 F1234.44
G3 X-.60 Y-8.36 R.60
G1 X38.68 Y-8.36 Z-6.00 F1645.92
G3 X40.68 Y-6.36 R2.00
G1 X40.68 Y6.36 Z-6.00
G3 X38.68 Y8.36 R2.00
G1 X-38.68 Y8.36 Z-6.00
G3 X-40.68 Y6.36 R2.00
G1 X-40.68 Y-6.36 Z-6.00
G3 X-38.68 Y-8.36 R2.00
G1 X.60 Y-8.36 Z-6.00
G3 X1.02 Y-8.19 R.60
G40 G1 X1.45 Y-7.76 Z-6.00
G0 Z3.00
G0 X-1.45 Y-7.76
G0 Z-3.00
G1 Z-9.00 F411.48
G41 G1 X-1.02 Y-8.19 Z-9.00 F1234.44
G3 X-.60 Y-8.36 R.60
G1 X38.68 Y-8.36 Z-9.00 F1645.92
G3 X40.68 Y-6.36 R2.00
G1 X40.68 Y6.36 Z-9.00
G3 X38.68 Y8.36 R2.00
G1 X-38.68 Y8.36 Z-9.00
G3 X-40.68 Y6.36 R2.00
G1 X-40.68 Y-6.36 Z-9.00
G3 X-38.68 Y-8.36 R2.00
G1 X.60 Y-8.36 Z-9.00
G3 X1.02 Y-8.19 R.60
G40 G1 X1.45 Y-7.76 Z-9.00
G0 Z3.00
G0 X-1.45 Y-7.76
G0 Z-6.00
G1 Z-12.00 F411.48
G41 G1 X-1.02 Y-8.19 Z-12.00 F1234.44
G3 X-.60 Y-8.36 R.60
G1 X38.68 Y-8.36 Z-12.00 F1645.92
G3 X40.68 Y-6.36 R2.00
G1 X40.68 Y6.36 Z-12.00
G3 X38.68 Y8.36 R2.00
G1 X-38.68 Y8.36 Z-12.00
G3 X-40.68 Y6.36 R2.00
G1 X-40.68 Y-6.36 Z-12.00
G3 X-38.68 Y-8.36 R2.00
G1 X.60 Y-8.36 Z-12.00
G3 X1.02 Y-8.19 R.60
G40 G1 X1.45 Y-7.76 Z-12.00
G0 Z3.00
G0 X-1.45 Y-7.76
G0 Z-9.00
G1 Z-15.00 F411.48
G41 G1 X-1.02 Y-8.19 Z-15.00 F1234.44
G3 X-.60 Y-8.36 R.60
G1 X38.68 Y-8.36 Z-15.00 F1645.92
G3 X40.68 Y-6.36 R2.00
G1 X40.68 Y6.36 Z-15.00
G3 X38.68 Y8.36 R2.00
G1 X-38.68 Y8.36 Z-15.00
G3 X-40.68 Y6.36 R2.00
G1 X-40.68 Y-6.36 Z-15.00
G3 X-38.68 Y-8.36 R2.00
G1 X.60 Y-8.36 Z-15.00
G3 X1.02 Y-8.19 R.60
G40 G1 X1.45 Y-7.76 Z-15.00
G0 Z3.00
G0 Z25.00
M5
G28
M30
There is no way around it you must use arcs with Solidworks. Look through that and see what is still funky, please.
T1 S12000;6MM CRB 2FL 19 LOC I see it but I don’t know exactly what it is. Any Marlin command for that? I know it is xhanging my tool but not sure what the T1 S12000 does.
Tool selection. Pretty sure marlin doesn’t support it.
I am wondering what to do in those cases? I find it odd to see a T1 on a line by itself for a tool change but at the start it used a M6 command to change the tool and that is what confused me. Besides all of that why a spindle speed of max if a tool is being changed out? That sounds like an accident about to happen to me.
Marlin won’t do any tool change procedure that is useful to us, AFAIK. T1 is used to select an extruder:
I couldn’t find it in the web reference, but it is in the source code. Rep rap also says it is available, and doesn’t say anything about an S parameter.
https://www.reprap.org/wiki/G-code#T:_Select_Tool
Marlin also doesn’t support M6. We want Marlin to forget it has an extruder, so I’m doubtful the T1 will be of any use to us.
@guffy wrote the fusion post processor and there was a lot of work put into what gcodes would be used instead of a tool change. A lot of relative movements and M0 User Comment
to guide the user through it, and a probe to get the new Z.
Yes, I am doing the same but after a day of constant trying I can’t figure out how to get it to ask you where your safe space is at. What I attempted should have worked but nothing ever showed up so I am not certain if it can be done (I was doing stuff from 2013 and for Camworks which is what this is based upon). I asked around but nothing.
What’s the problem with arcs and why the need to get rid of them?
I’ve never made a solid works post processor but if you really need to I’d think it would be easy enough to write a python script to replace your G3 arcs with G1 line segments.
I am not sure what is wrong with arcs but I do believe Ryan said to not use them but if it wasn’t him someone told me. My biggest complaint is that SW Cam is not allowing the end user to put in something (in this case the coordinates). I easily could write a C++ program that would replace SafeX, SafeY, SafeZ with your values but that is pretty primative and I would love to keep it all in one. Cam works used to allow this so I am not sure what SW did.
Looking better.
This isn’t supported. It looks like it is trying to do some roughing pass/finishing pass definition. G70 would then run the finishing pass, or something.
Many Marlin machines don’t support this, but if they don’t, I don’t think it is a huge deal, as long as they don’t expect multiple coordinate systems to do anything.
Not in Marlin.
Here’s the problem again with no feedrates defined for G0.
Why did this speed get so much higher?
This move will be ignored, because it’s on the same line as the G40. There is a G41 a few lines later that is the same way.
What language/format is the post processor? I’m guessing since you know how to do it in C++, you know it can’t be done, I’m just curious.
To remove arcs, from the math perspective, you’d have to find the center of the circle, then determine the angle to each point, make sure you have the right circle (G2 or G3) and then trace along the circle. You’d need a complete programming or scripting language and at least trig functions. That kind of stuff is always tough to get right, too. Too easy to go the wrong way around the circle, pick the wrong circle, etc.