Need a bit of advice on successfully running gcode program from FreeCAD

Hey all. I built the MPCNC (the “burly” I believe, it was a couple years ago), and now I’m trying to get it to work again.

The good news is that in terms of hardware and connectivity, I think I’m good. I have repetier-host, and if I go to the manual control tab, I can move the CNC head around in all dimensions. All good!

My question is about running a gcode program. I made a little example program in FreeCAD (just cutting a shallow pocket out of a 3D rectangle), and selected the grbl postprocessor, and output it.

Then, I go to repetier host, load the file, and hit “print”. It does do something, moves the head up a bit in the Z-direction, but then quickly just stops. It appears to not understand some commands, according to the echos in the logs. Here they are:

22:34:42.509 : Printer reset detected - initializing
22:34:42.509 : start
22:34:42.509 : echo:Marlin bugfix-2.0.x
22:34:42.512 : echo: Last Updated: 2018-01-20 | Author: (V1 Engineering, Ryan, 302)
22:34:42.512 : echo:Compiled: Jun  8 2019
22:34:42.515 : echo: Free Memory: 3688  PlannerBufferBytes: 1456
22:34:42.517 : echo:Hardcoded Default Settings Loaded
22:34:42.517 : echo:  G21    ; Units in mm (mm)
22:34:42.519 : echo:  M149 C ; Units in Celsius
22:34:42.520 : echo:Filament settings: Disabled
22:34:42.522 : echo:  M200 D3.00
22:34:42.522 : echo:  M200 D0
22:34:42.522 : echo:Steps per unit:
22:34:42.525 : echo:  M92 X80.00 Y80.00 Z1600.00 E200.00
22:34:42.525 : echo:Maximum feedrates (units/s):
22:34:42.529 : echo:  M203 X120.00 Y120.00 Z30.00 E25.00
22:34:42.530 : echo:Maximum Acceleration (units/s2):
22:34:42.532 : echo:  M201 X400.00 Y400.00 Z200.00 E2000.00
22:34:42.537 : echo:Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>
22:34:42.537 : echo:  M204 P400.00 R3000.00 T400.00
22:34:42.541 : echo:Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J<junc_dev>
22:34:42.544 : echo:  M205 B20000.00 S0.00 T0.00 J0.00
22:34:42.544 : echo:Home offset:
22:34:42.544 : echo:  M206 X0.00 Y0.00 Z0.00
22:34:42.546 : echo:Material heatup parameters:
22:34:42.547 : echo:  M145 S0 H196 B92 F0
22:34:42.549 : echo:  M145 S1 H240 B110 F0
22:34:42.549 : echo:PID settings:
22:34:42.552 : echo:  M301 P17.98 I0.98 D83.62
22:34:42.655 : N1 M110*34
22:34:42.656 : N2 M115*36
22:34:42.656 : N3 M105*36
22:34:42.656 : N4 M114*35
22:34:42.694 : N5 M111 S6*98
22:34:48.164 : N6 T0*60
22:34:48.182 : FIRMWARE_NAME:Marlin bugfix-2.0.x (Github) SOURCE_CODE_URL: PROTOCOL_VERSION:1.0 MACHINE_TYPE:V1 E CNC EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
22:34:48.182 : Cap:SERIAL_XON_XOFF:0
22:34:48.182 : Cap:EEPROM:0
22:34:48.183 : Cap:VOLUMETRIC:1
22:34:48.185 : Cap:AUTOREPORT_TEMP:1
22:34:48.185 : Cap:PROGRESS:0
22:34:48.186 : Cap:PRINT_JOB:1
22:34:48.186 : Cap:AUTOLEVEL:0
22:34:48.186 : Cap:Z_PROBE:0
22:34:48.188 : Cap:LEVELING_DATA:0
22:34:48.189 : Cap:BUILD_PERCENT:0
22:34:48.189 : Cap:SOFTWARE_POWER:0
22:34:48.191 : Cap:TOGGLE_LIGHTS:0
22:34:48.191 : Cap:CASE_LIGHT_BRIGHTNESS:0
22:34:48.191 : Cap:EMERGENCY_PARSER:0
22:34:48.192 : Cap:AUTOREPORT_SD_STATUS:0
22:34:48.194 : Cap:THERMAL_PROTECTION:1
22:34:48.196 : Cap:MOTION_MODES:1
22:34:48.197 : N7 M20*22
22:34:48.213 : N8 M80*19
22:34:48.230 : X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:0 Y:0 Z:0
22:34:48.230 : N9 M105*46
22:34:48.245 : echo:DEBUG:INFO,ERRORS
22:34:48.245 : N10 M220 S100*80
22:34:48.246 : Begin file list
22:34:48.259 : End file list
22:34:48.264 : N11 M221 S100*80
22:34:48.266 : echo:Unknown command: "M80"
22:34:48.270 : N12 M111 S6*84
22:34:48.271 : N13 T0*8
22:34:48.271 : N14 M155 S1*85
22:34:48.275 : echo:DEBUG:INFO,ERRORS
22:38:46.109 : N15 G1 X1 F2100*48
22:38:46.955 : N16 G1 X2 F2100*48
22:38:51.056 : N17 G1 X-8 F2100*22
22:45:44.436 : N18 G1 Y10 F2100*12
22:45:55.971 : N19 G1 X2 F2100*63
22:46:20.268 : Preferred name from /home/hambone/Documents/pocket_test_1.gcode to pocket_test_1
22:46:28.861 : N20 G17 G90*67
22:46:28.862 : N21 G21*41
22:46:28.862 : N22 M3 S0*83
22:46:28.872 : N23 G0 Z20*96
22:46:28.875 : echo:Unknown command: "G17 G90"
22:46:28.878 : echo:Unknown command: "G21"
22:46:28.878 : N24 M117 ETE 13m 39s*112
22:46:28.878 : echo:Unknown command: "M3 S0"
22:46:28.896 : N25 G0 X35.295 Y35.3083*41
22:46:28.896 : N26 G0 Z18*110
22:46:28.904 : N27 G1 X35.295 Y35.3083 Z10 F300*4

I’m not sure why. You can see that my board uses the Marlin firmware (is that the right term?), which is obviously a bit different than grbl. However, I found a thread on the FreeCAD forums (that it won’t currently let me link to…) where the guy had the same exact “unknown command” errors…but it’s not clear what the solution was.

I think I’m almost there, given how much stuff is working… but I just can’t get the final pieces to fit together. Can anyone tell me what I could read or try to figure things out? thanks!

Well, my experience with FreeCAD consists of a couple of rectangles with holes in them, but I believe you may be using the wrong post processor. I’m hazy on the details, but GRBL and Marlin both process GCode, but their control commands and such differ. Is there a Marlin post-processor? If there is I would start there. I’m also pretty sure someone with more experience in the matter will be along shortly.

Welcome to the Forums.

Ah there unfortunately isn’t a Marlin PP :frowning:

I guess it’s because I’m a new user, but it won’t let me post this thread from the FreeCAD forums where the guy had the same issue (but if you google “Post for MPCNC with Marlin firmware” it’s the first hit).

The guy seemed to imply that his GRBL postprocessed code, from FreeCAD, still worked with his Marlin firmware…somehow. He said:

so if someone google searches MPCNC and FreeCAD like i did earlier today and finds this post: use GRBL post processor, and check the output gcode. the speeds need to match your needs in mm per minute . you don’t need to set mm/min in FreeCAD unless you want to . the post processor will convert to mm/min for you.

set your feeds in the tool controller, and set your travel speeds in the SetupSheet object.

And… I’m not really sure what he means by that.

I poked around a bit and found a post process. I know nothing about it:

Hmm, OK, so the lines in your code, like “N15 G1 X1 F2100*48”, is setting a feed rate of 2100 units. If you look at the marlin boot status, it lists the max feed rates of “echo: M203 X120.00 Y120.00 Z30.00 E25.00”. Now the GRBL gcode output is most likely mm/min, when Marlin is expecting the feedrates in mm/sec. Maybe try manually changing those F2100s to F10s, just to be safe, and send that to the machine. That would set your feedrate at 10mm/sec which isn’t very fast and shouldn’t cause to much pain if something goes horribly wrong. :fire: :firecracker: Just keep your hand on the E-Stop :sweat_smile:

As for those unknown command errors, not that it will help your current problem, but for reference…

M80 is a command to turn on a power supply with a 5v signal pin, probably not enabled in your firmware.

G17 is for setting the CNC workspace plane (to XY to be specific)

G90 is to set absolute positioning, which is on by default, but probably errored because it was on the same line as the G17

G21 set all units to millimeters, but this was already set in the firmware and is probably ignored.

M3 S0 Is for spindle or Laser control, if enabled.

ah yeah, I actually found that :slight_smile: It does look promising. I’m trying to put it in the location of the other postprocessors on my system (/snap/freecad/16/opt/local/FreeCAD-0.18/Mod/Path/PathScripts/post/ in Ubuntu 20.04), but it’s giving me annoying stuff about copying it…

$ sudo cp /snap/freecad/16/opt/local/FreeCAD-0.18/Mod/Path/PathScripts/post/
cp: cannot create regular file '/snap/freecad/16/opt/local/FreeCAD-0.18/Mod/Path/PathScripts/post/': Read-only file syste`Preformatted text`

even though I’m doing it as sudo already… So I’m not sure what’s going on there.

Lord…FreeCAD is testing me.

Okay, this looks promising! It’s very late here though, so I’ll have to try these tomorrow. Thanks again :slight_smile:

Okay, quick little update: you can apparently enter a custom postprocessor as a macro, and if it has the “” format, it just shows up in the postprocessor list for the job :slight_smile:

So I did that and output the file with marlin. However, I’m still getting those errors… so now I think it might be about the feed rate thing you mentioned.

Marlins F unit is mm/min, so F2100 is good.

Have you ran the test crown premade gcode?

Can you paste the gcode, not the console output?

I know Marlin won’t understand all of those. It also won’t read commands put on the same line. New commands need new lines.

Usually, something like a G17 will print a message, but just continue on. NBD.

There was a user that did a whole foss tools write up, but he used grbl, not marlin, with freecad.

I haven’t ran the test crown, let me give that a try :slight_smile:

Here’s the code I was running, after using the postprocessor in FreeCAD:
pocket_test_marlin.gcode (6.2 KB)

(I think it was failing at the same place as when using the GRBL PP, though.)

I think I have a hot lead maybe. It always moves the head (just has a pen attached right now) a few steps, but fails right after the last command in the console output I posted above. It appears to actually do everything I posted there, and shows it in the repetier-host tool path as well.

However, the next command (what I suspect is breaking it) is a G2 command (the first G2 command in the gcode I posted just now). I searched a bit and found this thread: Arcs on Marlin and Dual End Stops - #13 by jamiek

in which it appears a bug was discovered with the G2 code in Marlin! The guy did a PR, I’m not sure if it was accepted, and I’m not sure exactly which Marlin is on my board. But maybe that’s it, if my version is outdated? (it’s at least a year old, maybe more)

Anyway, I’ll try that tomorrow. I should reaaaally get to bed now :stuck_out_tongue:

edit: actually it’s in the output I posted above:

22:34:42.509 : echo:Marlin bugfix-2.0.x
22:34:42.512 : echo: Last Updated: 2018-01-20 | Author: (V1 Engineering, Ryan, 302)

So…yeah, it probably definitely has that bug?

Those arc issues were related to slow movements, and they were sort of optimizing them. It shouldn’t just stop completely.

That version of software may be old or new. The bugfix is a moving target. Where did you get it? Ryan also marks his firmware with a number, like 425. 504, etc.

I’m honestly surprised arcs are more commonly a problem. The arc starts at the previous place, goes to the next XY, and has a center of IJ. That seems tricky to define on your own. I wonder if the Z is affecting it.

That bug is specifically when soft-stops are enabled (which is only true for dual-endstops unless you have manually enabled it) and when an arc move hits the edge of the workspace, it would go in a crazy direction instead of doing the ‘natural’ thing and remaining with in the workspace. The PR was accepted so it’s fixed in current versions. Your 302 build would have that bug but I don’t think that’s the reason for what you’re seeing.

Your “pocket test marlin” gcode looks okay to me, and ncviewer shows what looks like a reasonable job.


Ah, gotcha… I thought I found it :frowning:

I guess I was just assuming because the date about the firmware in the console output said it was from 2018, and the post about the G2 was from 2019.

So…about the firmware. I was working on this with a few friends when we first built it, and it was one of them who installed the firmware. It was long enough ago that he definitely doesn’t remember where he got it :man_facepalming: Is there a way I can talk to the board to find the version?

or, could I just flash new firmware to make sure I’m using the right thing?

I’m honestly surprised arcs are more commonly a problem. The arc starts at the previous place, goes to the next XY, and has a center of IJ. That seems tricky to define on your own. I wonder if the Z is affecting it.

hm do you mean, aren’t more of a problem?

thank you!

Hmm… I definitely don’t have endstops built in, and I don’t think I put them anywhere in my programs/code… Ahhhh what a mess.

Is there a simple solution here that only requires spending a bit of money?

Since it seems like even if I got this fixed, Marlin is its own hurdle, are there any simple/cheapish boards that would let me use the same motor drivers, but run GRBL instead?

I found this guy’s site, which seems maybe good?

But there’s some note about needing a modified version of GRBL…uggghhhh. Why can’t anyone just use the standard thing!

We can probably walk you through flashing the board with newer software. It isn’t rocket surgery. If you want to go that route, post a pic of the board with your stuff connected so we can tell what you have and what features you have wired in.

If you do want to just buy your way out, the boards in the shop come preconfigured and flashed with recent versions of firmware.

Marlin supports a ton of boards (like 50) but it needs to be configured. We have a few common configurations covered (22 right now).

Grbl only officially supports the arduino uno with a grbl shield. There are lots of forks for other boards, but then you are dealing with non mainstream edits.

I know it’s complicated, but there is only so much we can do to make it easy. Ryan sells boards ready to go. We have some common configurations ready to flash. Board manufacturers are always going to try to get their board in your mind as one option. :man_shrugging:

Yeah. Typo.

1 Like

oh sorry I don’t mean to be entitled or sound ungrateful! I’m incredibly impressed and thankful for the massive amount of work you guys have done for this project, it’s really amazing :slight_smile:

I’m cool with flashing the board, I’ve flashed firmware a few times so I think I could figure it out from a guide if there is one.

I guess my main hesitation is that it seems like Marlin may be a bit of a constant stumbling block. I’m not criticizing Ryan’s choice to use it, I’ve read his reasons and they seem totally fair (and again, I don’t want to look a gift horse in the mouth :stuck_out_tongue: ).

Basically, because FreeCAD and other CAM programs I might use don’t seem to output Marlin gcode, it seems like every time there’s a problem I’ll have to worry that it might be a Marlin vs “other” problem. I got that guy’s script, which seems to run… but also output a G21 command that the console output said Marlin didn’t recognize… (is that because the Marlin units are always mm or something?)

But, if the simplest and smartest thing to do is just flash the board and use it, I wouldn’t mind. It seems like it’s at least worth a try, since it would be pretty easy and a potentially quick solution. Could you link me to a guide? thanks again!!

Share a pic of your board. I can point you to the firmware that is closest. There are instructions for arduino and platformio in the docs. Platformio is the future. Arduino is limping along with support.

Sure! I took some pics, but googled the name on the board, and it’s this one exactly:

I don’t mind using whatever, as long as it works on Ubuntu :slight_smile:

(oh and I have five A4988 drivers on it. They were calibrated a while ago, I think. And I’m guessing that the fact that the manual control seems to work well should mean they’re decent enough?)

G21 requires that //#define INCH_MODE_SUPPORT be uncommented in the firmware config (it actually enables G20 as well). Just FYI…