Command line utility to 'clean' GCode

And there’s another new release (the actual prebuilt releases are still uploading, but the code is there for the ‘built-it-yourself’ types).

There’s a certain set of GCode commands that should always be present.
But many are just simply assumed to be ‘set to’ some default, which you don’t really know what that is…

This release sets up a limited set of GCode commands as a ‘preamble’. When the first movement command is detected, any of these ‘preamble’ codes that have not yet been seen are injected into the GCode above that movement command.

This also adds the concept of a ‘Context’ (i.e. the state as identified by the various commands seen so far, or the state that is desired), the preamble is the first such ‘Context’.

This sets up for working with the Plane Selection GCodes (G17, G18, G19).

1 Like

… and now they’re up there Releases · md8n/GCodeClean · GitHub

1 Like

I assumed optimistically that the --annotate would interpret all of the G-codes with a comment something like M3 (Spindle ON CW Rotation) but all I got was (Preamble completed by GCodeClean). Am I right or wrong? Thanks

Well - it should annotate everything

This is the newest feature. But if you add --annotate as well it should get you a comment on almost every line

Just tried it out, and it ignored --annotate
(YABF) - yet another bug fix

OK that’s fixed and the source code is already up on GitHub - I’ll now start work on the releases

Thanks for letting me know.

Simple spindle warm up. You are spectacular is all I can say. Thanks

G21 (Length units: Millimeters)
G90 (Set Distance Mode: Absolute)

M3 (Turn Spindle: Clockwise)
S0 (Set Spindle Speed 0 rpm)

(Preamble completed by GCodeClean)
G94 (Set Feed Rate Mode: mm or degrees, per minute)
G17 (Plane selection: XY)
G40 (Cutter Radius Compensation: Off)
G49 (Tool Length Offset: None)
(Preamble completed by GCodeClean)
G0 X0 (Linear motion: Rapid, X0mm)
G0 X0 Y-70 (Linear motion: Rapid, X0mm, Y-70mm)
G0 X0 Y-70 Z-60.5 (Linear motion: Rapid, X0mm, Y-70mm, Z-60.5mm)
S5000 (Set Spindle Speed 5000 rpm)
G4 P10 (Dwell, Canned Cycle: Dwell Time)

S10000 (Set Spindle Speed 10000 rpm)
G4 P120 (Dwell, Canned Cycle: Dwell Time)

S5000 (Set Spindle Speed 5000 rpm)
G4 P10 (Dwell, Canned Cycle: Dwell Time)
S0 (Set Spindle Speed 0 rpm)

G4 P5 (Dwell, Canned Cycle: Dwell Time)
M5 (Turn Spindle: Stop)
M2 (Program End)

v0.8.5.3 is up in GitHub right now, and the releases for OSX, Windows and Linux are going up currently.

This one includes the first steps in proper plane handling, so that’s G17, G18 and G19.

I’ve already seen some improvements in the DedupLinearToArc functionality (by which I mean it screws up less).

2 Likes

That’s how I write my stuff here at work. One deployment at a time. :slight_smile:

v0.8.5.4 is up in GitHub right now, along with the releases for OSX, Windows and Linux.

  • This fixes issue #1 removing the redundant (and according to the spec wrong) G0 command right at the start of some GCode files, e.g. those generating by Fusion 360.
  • The DedupLinearToArc function has also been improved to ‘screw up even less’. There still seems to be an issue in a handful of cases, current suspect is movement through the 3rd axis relative to the current ‘plane’.
  • A little bit of refactoring to remove some redundant constant values.
2 Likes

v0.8.6.0 is now up on GitHub, and the releases for Linux, OSX, and Windows as well.

This fixes the mis-handling of the I J K arguments, as a result I think this is now pretty close to being v1.
I’d appreciate anyone who wants to throw their own gcode at it to see how it compares.

I have attached 07_slot_cutting.zip which shows my results Please advise. Thanks

Forgot --annotate
it works now
sorry
Still want to visit Botany Bay

1 Like

Glad I could help :grinning:

1 Like

Version 0.8.7.0 is up on Github align with the releases for Windows, OSX and Linux

https://github.com/md8n/GCodeClean/releases/tag/0.8.7.0

This release was inspired by @Thormj’s thread https://forums.maslowcnc.com/t/buffering-and-making-sure-im-up-to-date/ and what MakerCam :nauseated_face: (which uses Flash :face_vomiting:) give him for GCode.

So it now converts very short arcs (G2 and G3) into straight lines (G1).
And then ironically it feeds that back into the LinearToArcDedup algorithm, which results in much better curves.

I’ve also added command line options to set the general tolerance value (this affects the clipping of decimal places, and some maths operations), and an arcTolerance value for the above function.

3 Likes

Version 0.8.8.0 is now on Github along with the release for Linux, OSX and Windows

This is a partial answer to all those “why does it pointlessly raise and lower z-axis?” type of issues that we all have.

  • First, all positive z-axis values are clamped to a single value. The default is 0.2"" or 5mm.
  • Second, there is a command line option to change this value to something else (within limits).
  • Finally, the existing deduping algorithm will remove some of the now pointless duplicate z-axis movements.

I’d appreciate it if anyone can reply with GCode files that have the “uppy downy thing” happening (AKA “Raveling Nancy” for those who know their Blackadder).

3 Likes

Version 0.8.8.2 is now on Github along with the release for Linux, OSX and Windows

Well … who would have thought that GCode line numbers could be such a pain in the …

Anyway, here’s a minor release for them.

2 Likes

I know it’s called GCodeClean and it does a few M-Codes but would it be possible to get the rest of the M-Codes? Sorry to be a bother. Thanks
M0 (Program Stop)
M1 (Optional Program Stop)
M2 (Program End)
M3 (Turn Spindle: Clockwise)
M4 (Turn Spindle: Counterclockwise)
M5 (Turn Spindle: Stop)
M6 (Tool Change)
M7 (Coolant: Mist, On)
M8 (Coolant: Flood, On)
M9 (Coolant: Mist and Flood, Off)
M10
M11
M13
M19
M21
M22
M23
M24
M30 (Program End, Pallet Shuttle, and Reset)
M41
M42
M43
M44
M48 (Speed and Feed Overrides: Enable)
M49 (Speed and Feed Overrides: Disable)
M52
M60 (Pallet Shuttle and Program Stop)
M98
M99

The ones that have labels are from the NIST spec.
The others are form ‘other’ things. What device are you targetting to get those codes?