What am I not understanding correctly about Repetier-host, g-code, and other?

Hi everyone. I got my MPCNC up and running, and I successfully ran the test crown file with repetier-host (RH).

Now I’m trying to run a very simple gcode file I made in FreeCAD. I used the marlin postprocessor from this thread: Freecad marlin post processor (because FreeCAD doesn’t have a marlin PP built in).

Here’s where I’m confused. From what I can tell, my gcode file from FreeCAD was failing because it had Z coordinates below zero, which RH…apparently doesn’t allow?

Confusingly though, my test crown gcode file has some Z-1.000 lines (when it’s cutting/plotting I guess)… and I ran that with RH! So what gives?

I found this thread: https://forum.repetier.com/discussion/5081/cant-go-below-z0-even-with-end-stops-disabled-how-to-calibrate-then which says what I found: moving up and down with the “up and down” buttons in RH, it wouldn’t let me go below Z=0, but if I manually entered the gcode command to, it would…

My conception of typical milling (and what the gcode of test crown seems to imply) is that we set our milling bit to just touch the top of the work piece, and set that to be Z=0, and then cuts will be Z < 0, and most movement will be at Z > 0. Is that not right?

If it is right, then how is it supposed to work with RH? And why did RH let me run the test crown script?

lastly, @jeffeb3 said in another thread I made:

Repetier host doesn’t trust Marlin’s coordinate system, and they foolishly don’t know about G92 Z0. You can tell RH you are at 0, with the secret @isathome command.

I actually already have that as a macro in RH. But I’m confused. I see why I’d want to do that (with my pen/mill at the top of my work piece), but how does that solve the problem of RH not wanting me to go below 0? or am I just mistaken about that?

Sorry for the dumb questions,
-A guy who really wants to use his MPCNC

You should be using v0.91 of freecad and the assumption in the marlin.py file is that z0 is at the top of your work. In the path workbench check the depths of each operation and the heights, 5mm is clear, 3mm is safe, if you want something other, update the marlin py file. When picking an operation that is a through cut pick the bottom surface and probably add 1mm. The crown file is something else, it wasn’t done with freecad.


Many thanks for creating the FreeCAD Marlin PP! :smiley: you are a hero!

I think my dinky test gcode from FreeCAD (and your PP) is actually good, and takes that into account: it’s just a block, 10mm high, with a little hex pocket, 3mm deep in it. In the gcode file (attached), the only Z coordinates are -3, 0, and 5.

hex_pocket_1.gcode (3.7 KB)

You are only defining a pocket shape, if you did a profile operation, to cut out something it would be deeper with lower Z values. Your file has the bit going down 3mm, as you describe. So you start the job with the bit touching the wood.


It is possible RH jog has different limits than when you run a gcode file. I would start in the preferences for RH looking for some safety setting to turn off. You can also try sending G1 Z-10 F300. That will go to absolute -10, unless you have it in relative coordinates.

If Marlin is stopping you, then if you did that G1 command, it wouldn’t go negative. Marlin can be configured for stopping at Z=0.

You can also try cncjs as a desktop app. Or part of the v1pi.

Ahhh this is making me insane, I feel like it must be something so simple I’m messing up.

Yeah, that pretty much always works, if I send the gcode manually from RH. It even seems to sometimes go below Z=0 by using the jog? So that’s confusing…

For all of this, just to be clear, I’m using a pen attached to the pen holder, not my Dewalt yet (until I can figure out this nightmare :P). Every time, I manually jog to where I want the “origin” to be, and then run my macro (“script 1” in RH) to zero it:

G92 X0 Y0 Z0

And the X,Y,Z change to 0, so I think that’s working fine.

I ran my hex pocket program just now. It froze at the first G2 command (I put fillets in the corners), line 43 in the file above.

Aha, I thought, it’s that G2 again. So I went back and removed the fillets (and therefore no G2 commands) and made a version without them (attached). This works! Does the whole zigzag pattern

Guys, I think the G2 command is messed up with Marlin or the postprocessor or something? Is that possible? I just ran it with the fillets again, to be sure, and sure enough, it freezes in the same place:

22:38:40.640 : N141 G90*20
22:38:40.642 : N142 G92 X0 Y0 Z0*94
22:38:40.642 : N143 G21*28
22:38:40.645 : echo:N141 G90*20
22:38:40.646 : N144 G0 Z5 F250*54
22:38:40.648 : echo:N142 G92 X0 Y0 Z0*94
22:38:40.650 : X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:1000 Y:-5000 Z:2800
22:38:40.651 : echo:N143 G21*28
22:38:40.651 : N145 M117 ETE 6m 46s*122
22:38:40.653 : echo:N144 G0 Z5 F250*54
22:38:40.658 : echo:N145 M117 ETE 6m 46s*122
22:38:40.658 : N146 G0 X43.1933 Y43.2853 F2000*75
22:38:40.662 : N147 G0 Z3 F250*51
22:38:40.669 : echo:N146 G0 X43.1933 Y43.2853 F2000*75
22:38:40.674 : echo:N147 G0 Z3 F250*51
22:38:40.674 : N148 G1 X43.1933 Y43.2853 Z-3 F180*27
22:38:40.680 : echo:N148 G1 X43.1933 Y43.2853 Z-3 F180*27
22:38:40.685 : N149 G1 X50.6601 Y35.9267 Z-3 F180*22
22:38:40.691 : echo:N149 G1 X50.6601 Y35.9267 Z-3 F180*22

(the next line is the G2.)

One clue might be that, when this happens, to be able to manually control it again, I need to click “kill print”, then Disconnect it, then Connect again, and then it will take manual commands. I thought maybe that might give some clue about what could be causing this trouble.

Here’s what I know:

  1. I successfully ran the test crown (which has no G2 commands, at least my version)
  2. I successfully ran my no_fillet version of this little hex script, did exactly as expected (also no G2)
  3. I tried to run the same exact hex script, but with fillets/G2 commands (hex_pocket_1.gcode above), and that fails as soon as it hits the first G2 command.
  4. In RH, manually jogging to the position X=70, Y=70, Z=0, and then doing the command G2 X80 Y80 Z0 I10 J0, does work.
  5. From there, manually lowering to Z=-5, then doing the command G2 X90 Y90 Z-5 I10 J0, does work.
  6. Trying to replicate the actual program line that’s messing me up: first I manually run G1 X50.6601 Y35.9267 Z-3 F180, works. THEN, I run the line G2 X52.1404 Y30.5591 Z-3.0000 I-3.8481 J-3.9492 F180.00…and it FAILS!

Ahhhh! Insanity.

Mother of god I think I’ve got it. Since I thought it was G2, but then that worked, then I thought it was maybe the negative I in the G2 command, but then that worked, then I thought it was the negative Z in the G2, but then that worked…

the only thing left was the “wordiness” of the G2 command in the program, compared to mine:

G2 X52.1404 Y30.5591 Z-3.0000 I-3.8481 J-3.9492 F180.00

So I instead tried…

G2 X52.1 Y30.5 Z-3.0 I-3.8 J-3.9 F180

And LAWDY it worked!

So I’m pretty sure it’s a thing of the line getting cut off because it’s too long?? I vaguely remember reading, during a frantic fugue state of trying to figure this hellscape out, about a 50 character limit.

If I run

G2 X52.1404 Y30.5591 Z-3.00 I-3.8481 J-3.9492 F180

(exactly 50 characters)… it runs.

G2 X52.1404 Y30.5591 Z-3.00 I-3.8481 J-3.9492 F180.0 — 52 chars: works

G2 X52.1404 Y30.5591 Z-3.000 I-3.8481 J-3.9492 F180.0 — 53 chars: works

G2 X52.1404 Y30.5591 Z-3.000 I-3.8481 J-3.9492 F180.00 — 54 chars: works??

The actual one: G2 X52.1404 Y30.5591 Z-3.0000 I-3.8481 J-3.9492 F180.00 ---- 55 chars: doesn’t work??


Oh man… This is a roller coaster.

You don’t need the Z if the Z doesn’t move. You also don’t need more than 3 places after the decimal. I remember “learning” that lesson at some point. Can you fix these things in the post processor?

Yeah :stuck_out_tongue: as far as debugging I’ve done in my life, this isn’t too bad. At least this has a fast REPL…

I actually didn’t add the Z, that’s just what the CAM/PP does.

It’s actually very easy, thanks to how @ByronM wrote it!

You can see that it takes args, and one of them is “precision”, set to 4 by default.

And, in FreeCAD, there’s a handy arguments field:

Doing this gave…

tada! Damn, check those sweet sweet fillets.

It seems like if we don’t need 3 places after the decimal (ever? even for high precision stuff?), then maybe the default shouldn’t be 4. But maybe it makes sense in some context I don’t know about.


It might make sense for inches, or for the Tim the Toolman’s out there. I know in sandify, I specifically truncate them to 3.

1 Like

ah, that’s very cool, I’ve wanted to make one of those! Maybe someday…

1 Like