Extra line appears in grbl post processor

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
acp693
Posts: 127
Joined: Wed Dec 15, 2021 7:41 pm

Extra line appears in grbl post processor

Post by acp693 »

Hi, I've been successfully using the grbl post processor to generate g-code for my cnc machine. Recently I installed the newly released stable version of Freecad 0.20. Since then, an extra line is inserted before the first Tool change command , the extra line is a G0 command. I have a grbl file which I developed and used last year and opening the same model in version 0.20 and generating a new grbl file with no other changes the post processor inserts an extra line. This causes problems for my controller, resulting in a message box stating that as there is no M3 command the spindle can't be started and do I wish to continue anyway? If I say yes, it proceeds to the first tool change and runs normally starting the spindle after the tool change. If I comment out the extra line, everything runs as it should. The extra line is repeated after the tool change. My question is, how can I get the post processor to stop inserting the extra command? I already set OUTPUT_TOOL_CHANGE = True in the grbl post processor as my cnc machine controller handles tool changes. In any case this doesn't seem to have anything to do with the extra command being inserted. Thanks!

Here's the file from the recent version of Freecad 0.20

Code: Select all

(Exported by FreeCAD)
(Post Processor: grbl_post)
(Output Time:2022-08-21 23:30:24.358877)
(Begin preamble)
G17 G90
G21
(Begin operation: G54)
(Path: G54)         
G54
G0 Z5.000             <----------------------------------------------------------------  EXTRA LINE that doesn't appear in previous version of Freecad
(Finish operation: G54)
(Begin operation: TC: 1mmEndMill003)
(Path: TC: 1mmEndMill003)
(TC: 1mmEndMill003)
(Begin toolchange)
M6 T4.0
M3 S20000
(Finish operation: TC: 1mmEndMill003)
(Begin operation: Drilling)
(Path: Drilling)
(Drilling)
(Begin Drilling)
G0 Z5.000              <-------------------------------------- The extra line seems to be repeat of this line
G90
G99
G0 X-9.500 Y13.500

Same model made with an earlier version of Freecad, works normally with my cnc machine

Code: Select all

(Exported by FreeCAD)
(Post Processor: grbl_post)
(Output Time:2022-04-25 15:43:49.678863)
(Begin preamble)
G17 G90
G21
(Begin operation: Fixture)
(Path: Fixture)
G54
(Finish operation: Fixture)
(Begin operation: TC: 1mmEndMill003)
(Path: TC: 1mmEndMill003)
(TC: 1mmEndMill003)
(Begin toolchange)
M6 T4.0 
M3 S20000.0
(Finish operation: TC: 1mmEndMill003)
(Begin operation: Drilling)
(Path: Drilling)
(Drilling)
(Begin Drilling)
G0 Z5.000
G90
G99
G0 X9.500 Y7.000
G0 Z3.000
G1 Z0.000 F60.000
G81 X9.500 Y7.000 Z-2.000 F60.000 R3.000

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: German/Germany (de_DE)
Installed mods: 
  * BIM 2021.12.0
  * CurvedShapes 1.0.4
  * Curves 0.5.3
  * FeedsAndSpeeds 0.4.0
  * Marz 0.0.26-alpha
  * Silk 1.0.0
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Extra line appears in grbl post processor

Post by onekk »

Code: Select all

G0 Z5.000         
This extrra line is simply a G0 to probably a "safe height" so no spindle command must be issued, it is simply a "rapid move".

Are you sure that is not a problem of the grbl interpreter that is telling you that a "real line" has problem?

Take in account that many "grbl senders" don't take in account comments, so when the sender is reporting error in "line 5" probably only the "live lines" have to be considered (those non being comments)

Plus telling grbl is not telling what version of grbl as there are some differences between 0.8 and 1.1h as example.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
acp693
Posts: 127
Joined: Wed Dec 15, 2021 7:41 pm

Re: Extra line appears in grbl post processor

Post by acp693 »

Thanks for replying,

My cnc controller isn't telling me on what line the error is. I've simply deduced that the only differences between this newly generated file and and a file generated last year is that extra G0 command which upsets my cnc controller. I can of course comment out that line every time I generate a grbl file, but it would be nice if it didn't have to. Also after the tool change, the exact same line appears. In the earlier version of the file, it only appears once and that is after the tool change.

Trying a few other post processors, they all have that extra command, making me believe that the command isn't generated in the post processor at all. Looking through the files though, I have no idea where that command is being generated. Any ideas?
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Extra line appears in grbl post processor

Post by onekk »

From the code you posted it seems that some operation have no "moves" only preparation code, but no real "cut code".

Usually when doing an operation the worflow is something like this:

Code: Select all

- init code
- move to safe height
- move to start position
- tool change
- start spindle
- start cut
- moves that perform the cut
- move to safe height
- stop spindle
....
Or at leaste these are "safe standards" in sense that moving the spindle when it is turning could be an option so no start and stop spindle instructions, but after every cut a "move to safe height" should be a "safe standard" as the subsequent move could go into fixtures or other things (provided that safe height has enough "height" to guarantee a clearance from the "most high" fixture or "stock piece part" )

if you have some operation that are not "performing cuts", all the above sequence is done except from the "start cut" so probably only the move to safe height is performed and probably as the height is already at "safe height" you will find no duplicate "move to safe height".

But without a file, it is hard to tell.

Take in account that some thing have changed in Path WB as it is ever evolving, so it is not unusual that some have changed.

By my personal experience GRBL version is important, as if you have used an "arduino UNO" configuring and setting grbl by yourself or you are using some "ready made" board your mileage may vary, as there are many chinese board around that use "modified versions" of 0.8 or 0.9 GRBL that are quite obsolete, as the last version I know is 1.1 g or h last time I've used it as my CNC is broken now.

Plus there are many variant of GRBL as it depends also on configuration options, so it is very hard to tell where your problem resides.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
acp693
Posts: 127
Joined: Wed Dec 15, 2021 7:41 pm

Re: Extra line appears in grbl post processor

Post by acp693 »

Thank you for taking the time to understand the problem. As I see it the the 'Extra line' G0 Z5.000 is redundant as it's at the start of the file before the tool change. The controller isn't a grbl controller it's one from a German company. The only information I know about it is that it takes commands based on DIN 66025. Up until the upgrade to Freecad 0.20, the grbl post processor worked perfectly. There are other post processors provided with Freecad that worked in the past too, but they all now upset my machine with that Rapid move before the tool change.

Could you tell me in what file that command is being generated? maybe I can see what is causing it and stop it for my machine.

The following two files are of the same project to illustrate the problem I have. The first was made last year and works with my machine perfectly
The other I generated with the latest release of Freecad 0.20, it has the a Rapid move command before the first tool change which upsets my machine.

Edit, I've added the freecad file.

Thank you

Code: Select all

(Exported by FreeCAD)
(Post Processor: grbl_post)
(Output Time:2022-03-01 15:35:31.671420)
(Begin preamble)
G17 G90
G21
(Begin operation: Fixture)
(Path: Fixture)
G54
(Finish operation: Fixture)
(Begin operation: TC: 1mmEndMill)
(Path: TC: 1mmEndMill)
(TC: 1mmEndMill)
(Begin toolchange)
M6 T4.0 
M3 S16000.0
(Finish operation: TC: 1mmEndMill)
(Begin operation: Drilling)
(Path: Drilling)
(Drilling)
(Begin Drilling)
G0 Z5.000
G90
G99
G0 X9.000 Y13.500
G0 Z3.000
G1 Z0.000 F1800.000
G81 X9.000 Y13.500 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 X20.500 Y13.500
G0 Z3.000
G1 Z0.000 F1800.000
G81 X20.500 Y13.500 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 X32.000 Y13.500
G0 Z3.000
G1 Z0.000 F1800.000
G81 X32.000 Y13.500 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 X20.500 Y52.000
G0 Z3.000
G1 Z0.000 F1800.000
G81 X20.500 Y52.000 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 Z5.000
(Finish operation: Drilling)
(Begin operation: TC: 2mmEndMill001)
(Path: TC: 2mmEndMill001)
(TC: 2mmEndMill001)
(Begin toolchange)
M6 T1.0 
M3 S16000.0
(Finish operation: TC: 2mmEndMill001)
(Begin operation: Profile)
(Path: Profile)
(Profile)
(Compensated Tool Path. Diameter: 2.0)
G0 Z5.000
G0 X41.707 Y60.707
G0 Z3.000
G1 X41.707 Y60.707 Z-0.500 F1800.000
G2 X42.000 Y60.000 Z-0.500 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-0.500 F1800.000
G2 X41.000 Y-1.000 Z-0.500 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-0.500 F1800.000
G2 X-1.000 Y0.000 Z-0.500 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-0.500 F1800.000
G2 X0.000 Y61.000 Z-0.500 I1.000 J-0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-0.500 F1800.000
G2 X5.000 Y60.000 Z-0.500 I-0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-0.500 F1800.000
G1 X5.019 Y54.890 Z-0.500 F1800.000
G3 X6.006 Y55.112 Z-0.500 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-0.500 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-0.500 F1800.000
G2 X35.019 Y54.890 Z-0.500 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-0.500 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-0.500 F1800.000
G2 X37.000 Y61.000 Z-0.500 I1.000 J-0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-0.500 F1800.000
G2 X41.707 Y60.707 Z-0.500 I-0.000 J-1.000 K0.000 F1800.000
G1 X41.707 Y60.707 Z-1.000 F1800.000
G2 X42.000 Y60.000 Z-1.000 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-1.000 F1800.000
G2 X41.000 Y-1.000 Z-1.000 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-1.000 F1800.000
G2 X-1.000 Y0.000 Z-1.000 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-1.000 F1800.000
G2 X0.000 Y61.000 Z-1.000 I1.000 J-0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-1.000 F1800.000
G2 X5.000 Y60.000 Z-1.000 I-0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-1.000 F1800.000
G1 X5.019 Y54.890 Z-1.000 F1800.000
G3 X6.006 Y55.112 Z-1.000 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-1.000 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-1.000 F1800.000
G2 X35.019 Y54.890 Z-1.000 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-1.000 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-1.000 F1800.000
G2 X37.000 Y61.000 Z-1.000 I1.000 J-0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-1.000 F1800.000
G2 X41.707 Y60.707 Z-1.000 I-0.000 J-1.000 K0.000 F1800.000
G1 X41.707 Y60.707 Z-1.500 F1800.000
G2 X42.000 Y60.000 Z-1.500 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-1.500 F1800.000
G2 X41.000 Y-1.000 Z-1.500 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-1.500 F1800.000
G2 X-1.000 Y0.000 Z-1.500 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-1.500 F1800.000
G2 X0.000 Y61.000 Z-1.500 I1.000 J-0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-1.500 F1800.000
G2 X5.000 Y60.000 Z-1.500 I-0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-1.500 F1800.000
G1 X5.019 Y54.890 Z-1.500 F1800.000
G3 X6.006 Y55.112 Z-1.500 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-1.500 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-1.500 F1800.000
G2 X35.019 Y54.890 Z-1.500 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-1.500 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-1.500 F1800.000
G2 X37.000 Y61.000 Z-1.500 I1.000 J-0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-1.500 F1800.000
G2 X41.707 Y60.707 Z-1.500 I-0.000 J-1.000 K0.000 F1800.000
G1 X41.707 Y60.707 Z-2.000 F1800.000
G2 X42.000 Y60.000 Z-2.000 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-2.000 F1800.000
G2 X41.000 Y-1.000 Z-2.000 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-2.000 F1800.000
G2 X-1.000 Y0.000 Z-2.000 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-2.000 F1800.000
G2 X0.000 Y61.000 Z-2.000 I1.000 J-0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-2.000 F1800.000
G2 X5.000 Y60.000 Z-2.000 I-0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-2.000 F1800.000
G1 X5.019 Y54.890 Z-2.000 F1800.000
G3 X6.006 Y55.112 Z-2.000 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-2.000 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-2.000 F1800.000
G2 X35.019 Y54.890 Z-2.000 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-2.000 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-2.000 F1800.000
G2 X37.000 Y61.000 Z-2.000 I1.000 J-0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-2.000 F1800.000
G2 X41.707 Y60.707 Z-2.000 I-0.000 J-1.000 K0.000 F1800.000
G0 Z5.000
G0 Z5.000
(Finish operation: Profile)
(Begin postamble)
M5
G17 G90
M2

Code: Select all

(Exported by FreeCAD)
(Post Processor: grbl_post)
(Output Time:2022-08-22 17:37:23.706081)
(Begin preamble)
G17 G90
G21
(Begin operation: G54)
(Path: G54)
G54
G0 Z5.000
(Finish operation: G54)
(Begin operation: TC: 1mmEndMill)
(Path: TC: 1mmEndMill)
(TC: 1mmEndMill)
(Begin toolchange)
M6 T4.0 
M3 S16000.0
(Finish operation: TC: 1mmEndMill)
(Begin operation: Drilling)
(Path: Drilling)
(Drilling)
(Begin Drilling)
G0 Z5.000
G90
G99
G0 X9.000 Y13.500
G0 Z3.000
G1 Z0.000 F1800.000
G81 X9.000 Y13.500 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 X20.500 Y13.500
G0 Z3.000
G1 Z0.000 F1800.000
G81 X20.500 Y13.500 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 X32.000 Y13.500
G0 Z3.000
G1 Z0.000 F1800.000
G81 X32.000 Y13.500 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 X20.500 Y52.000
G0 Z3.000
G1 Z0.000 F1800.000
G81 X20.500 Y52.000 Z-3.000 F1800.000 R3.000
G80
G0 Z3.000
G0 Z5.000
(Finish operation: Drilling)
(Begin operation: TC: 2mmEndMill001)
(Path: TC: 2mmEndMill001)
(TC: 2mmEndMill001)
(Begin toolchange)
( M6 T1.0 )
M3 S16000.0
(Finish operation: TC: 2mmEndMill001)
(Begin operation: Profile)
(Path: Profile)
(Profile)
(Compensated Tool Path. Diameter: 2.0)
G0 Z5.000
G0 X41.707 Y60.707
G0 Z3.000
G1 X41.707 Y60.707 Z-0.500 F1800.000
G2 X42.000 Y60.000 Z-0.500 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-0.500 F1800.000
G2 X41.000 Y-1.000 Z-0.500 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-0.500 F1800.000
G2 X-1.000 Y0.000 Z-0.500 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-0.500 F1800.000
G2 X0.000 Y61.000 Z-0.500 I1.000 J0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-0.500 F1800.000
G2 X5.000 Y60.000 Z-0.500 I0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-0.500 F1800.000
G1 X5.019 Y54.890 Z-0.500 F1800.000
G3 X6.006 Y55.112 Z-0.500 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-0.500 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-0.500 F1800.000
G2 X35.019 Y54.890 Z-0.500 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-0.500 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-0.500 F1800.000
G2 X37.000 Y61.000 Z-0.500 I1.000 J0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-0.500 F1800.000
G2 X41.707 Y60.707 Z-0.500 I0.000 J-1.000 K0.000 F1800.000
G1 X41.707 Y60.707 Z-1.000 F1800.000
G2 X42.000 Y60.000 Z-1.000 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-1.000 F1800.000
G2 X41.000 Y-1.000 Z-1.000 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-1.000 F1800.000
G2 X-1.000 Y0.000 Z-1.000 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-1.000 F1800.000
G2 X0.000 Y61.000 Z-1.000 I1.000 J0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-1.000 F1800.000
G2 X5.000 Y60.000 Z-1.000 I0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-1.000 F1800.000
G1 X5.019 Y54.890 Z-1.000 F1800.000
G3 X6.006 Y55.112 Z-1.000 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-1.000 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-1.000 F1800.000
G2 X35.019 Y54.890 Z-1.000 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-1.000 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-1.000 F1800.000
G2 X37.000 Y61.000 Z-1.000 I1.000 J0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-1.000 F1800.000
G2 X41.707 Y60.707 Z-1.000 I0.000 J-1.000 K0.000 F1800.000
G1 X41.707 Y60.707 Z-1.500 F1800.000
G2 X42.000 Y60.000 Z-1.500 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-1.500 F1800.000
G2 X41.000 Y-1.000 Z-1.500 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-1.500 F1800.000
G2 X-1.000 Y0.000 Z-1.500 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-1.500 F1800.000
G2 X0.000 Y61.000 Z-1.500 I1.000 J0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-1.500 F1800.000
G2 X5.000 Y60.000 Z-1.500 I0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-1.500 F1800.000
G1 X5.019 Y54.890 Z-1.500 F1800.000
G3 X6.006 Y55.112 Z-1.500 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-1.500 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-1.500 F1800.000
G2 X35.019 Y54.890 Z-1.500 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-1.500 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-1.500 F1800.000
G2 X37.000 Y61.000 Z-1.500 I1.000 J0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-1.500 F1800.000
G2 X41.707 Y60.707 Z-1.500 I0.000 J-1.000 K0.000 F1800.000
G1 X41.707 Y60.707 Z-2.000 F1800.000
G2 X42.000 Y60.000 Z-2.000 I-0.707 J-0.707 K0.000 F1800.000
G1 X42.000 Y0.000 Z-2.000 F1800.000
G2 X41.000 Y-1.000 Z-2.000 I-1.000 J0.000 K0.000 F1800.000
G1 X0.000 Y-1.000 Z-2.000 F1800.000
G2 X-1.000 Y0.000 Z-2.000 I0.000 J1.000 K0.000 F1800.000
G1 X-1.000 Y60.000 Z-2.000 F1800.000
G2 X0.000 Y61.000 Z-2.000 I1.000 J0.000 K0.000 F1800.000
G1 X4.000 Y61.000 Z-2.000 F1800.000
G2 X5.000 Y60.000 Z-2.000 I0.000 J-1.000 K0.000 F1800.000
G1 X5.000 Y55.056 Z-2.000 F1800.000
G1 X5.019 Y54.890 Z-2.000 F1800.000
G3 X6.006 Y55.112 Z-2.000 I0.491 J0.122 K0.000 F1800.000
G2 X7.000 Y56.000 Z-2.000 I0.994 J-0.112 K0.000 F1800.000
G1 X34.000 Y56.000 Z-2.000 F1800.000
G2 X35.019 Y54.890 Z-2.000 I-0.020 J-1.041 K0.000 F1800.000
G3 X36.000 Y55.056 Z-2.000 I0.485 J0.115 K0.000 F1800.000
G1 X36.000 Y60.000 Z-2.000 F1800.000
G2 X37.000 Y61.000 Z-2.000 I1.000 J0.000 K0.000 F1800.000
G1 X41.000 Y61.000 Z-2.000 F1800.000
G2 X41.707 Y60.707 Z-2.000 I0.000 J-1.000 K0.000 F1800.000
G0 Z5.000
G0 Z5.000
(Finish operation: Profile)
(Begin postamble)
M5
G17 G90
M2
Attachments
Template.FCStd
(38.74 KiB) Downloaded 34 times
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Extra line appears in grbl post processor

Post by onekk »

At a first glance you have to see why these "stanzas" are included, as they are "not operational", they simply do some tool change

Code: Select all

(Begin operation: TC: 1mmEndMill)
(Path: TC: 1mmEndMill)
(TC: 1mmEndMill)
(Begin toolchange)
M6 T4.0 
M3 S16000.0
(Finish operation: TC: 1mmEndMill)
I think that the command issue after G54 is simply the "go to safe height" I have some doubt that this simple command wiil create problems, as it is perfectly "formed".

Code: Select all

G0 Z5.000
As it is a replication of the line slightly below even in the "old file"

Code: Select all

(Begin Drilling)
G0 Z5.000
You could try to see if LinuxCNC postprocessor will emit similar commands.

It is strange that the controller is wanting the spindle running for a G0 move as it is a rapid move, and usually spindle is off when doing rapids, at least at the beginning and at the end of the cut, when you have to move from/to Home position.

Your file seems OK, but I could not say it for sure as I know very little about working with GUI in Path WB (I've done some work with Scripting but sadly I have not tested anything as my CNC is broken).

Probably you have to check if in the controller manual there are some informations about the command formats.

@sliptonic do you have some idea if it is possible to suppress the:

Code: Select all

G0 Z5.000
issued (probably) after a:

Code: Select all

G54
in the output gcode with grbl postprocessor?


Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Extra line appears in grbl post processor

Post by sliptonic »

Each operation is atomic. It's responsible for parsing its own geometry, settings, and generating its Commands. It doesn't know where the previous operation left the cutter.

To be safe, the first thing each operation _should_ do is move up to a safe/clearance height before transiting to its start location. That's what Drilling does. It isn't desirable to suppress those G0 Z<safeheight> commands in he operation. If they cause problems in final output, say by commanding the machine to go to a location where it already is, then it should be the postprocessor that suppresses them. Every control I've worked with, however, just ignores duplicates.

An argument could be made that a fixture operation doesn't need to emit the G0 move (or any move) because simply switching the coordinate system should never result in movement.

I'm with the others. I don't see why a well-formed G0 move should cause problems.
acp693
Posts: 127
Joined: Wed Dec 15, 2021 7:41 pm

Re: Extra line appears in grbl post processor

Post by acp693 »

Onekk, Thank you for looking at this again.

If I understand it correctly, the G54 command is simply declaring a 'Work Offset'. Why would it have to move at all directly after a G54 command if the next command is a tool change? With my cnc machine controller, it expects a tool to be in the machine and the length measured before moving - it makes sense, how can it move to a declared position if a tool isn't in the spindle and the length of the tool known? My machine on reaching the Rapid move command moves to the xy zero point plus 5mm on the z axis. How can I change the tool if it is 5mm above my block I'm about to mill.

So my machine runs as follows with Freecad generated g-code ( the Linux post processor adds the rapid move command after the G54 command and so does the Mach3Mach4 post processor, all of the post processors I've tried add the G0 command now in Freecad irrespective of the job):

run g-code

Machine moves to park position (xmin, ymax, zmax)and tells me to insert tool no.0. Machine measures tool length

Machine rapid moves to zero point on the xy axis and max z height above the stock on machine with the spindel not spinning

Machine issues a warning that no M3 commands are in the g-code file and that the spindel won't be started, and would I like to proceed anyway?
I say "yes", otherwise by pressing "no", the job is cancelled

machine rapid moves the z axis to 5mm above the stock, spindel stays stationary

Machine then moves to park position again and tells me insert tool no 4, the correct tool listed in the G_code file - in fact the first tool listed.

Machine measures tool, starts spinning, does a rapid move to the xy zero point and +5mm on the z axis then proceeds with job correctly


If I delete the the rapid move line after the G54 command the machine simply tells me straight away to insert tool no 4 ( the correct tool) measures it , starts the spindel spinning, does a rapid move to the zero position plus 5mm on the z axis and starts the job. Previously, G-code generated with Freecad did this, there were no G0 rapid moves directly after the G54 command.

It seems that irrespective of the job, even a simple job, say cutting a horizontal face, starts with the G54 command directly followed by a G0 rapid move on the z axis, then a command to change tools.

I know I can simply delete the rapid command directly after the G54 command, but I'm not the only one using the machine, my wife uses it too and I'm not always there to assist in deleting the correct command. But it seems to me that the G0 command after the G54 command is not correct anyway. Hopefully Sliptonic can shed some light on this if it is correct behaviour or not. As it seems that all the post processors add the G0 command it's probably not the post processor scripts that are the problem.

Thanks again, btw, Freecad is amazing software and I'm very grateful to be able to use it. :)
acp693
Posts: 127
Joined: Wed Dec 15, 2021 7:41 pm

Re: Extra line appears in grbl post processor

Post by acp693 »

sliptonic wrote: Tue Aug 23, 2022 3:52 pm
An argument could be made that a fixture operation doesn't need to emit the G0 move (or any move) because simply switching the coordinate system should never result in movement.

You posted while I was writing, thanks. I hope the description of the behaviour helps to understand the problem I have. If Freecad previously didn't add a rapid move after the G54 command, why does it now? Also as you stated, G54 is simply a declaration of work offset, no movement is necessary after this command? Could you tell me in what file this rapid move is being generated so that I can see if I can suppress it for my case?

All the jobs I've tried with the present version of Freecad and all the post processors I've tried add the G0 command after the G54 command, then a tool change, then the same identical Rapid move is done after the tool change command.

Thanks again
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Extra line appears in grbl post processor

Post by sliptonic »

acp693 wrote: Tue Aug 23, 2022 4:15 pm
Could you tell me in what file this rapid move is being generated so that I can see if I can suppress it for my case?

https://github.com/FreeCAD/FreeCAD/blob ... ure.py#L92
Post Reply