Skip to content
Ryan Schmidt edited this page May 14, 2017 · 1 revision

gsGCode

copyright 2017 ryan schmidt / gradientspace

Notes:

Consumer FDM/FFF GCode: http://reprap.org/wiki/G-code

Reading GCode

GenericGCodeParser parses a text gcode file and constructs a GCodeFile representation. This class is a work-in-progress, but can currently handle Makerbot GCode and Biesse ISOCode. It does not understand anything about the code, it just parses it into GCodeLine objects which store the line type (G,M,etc), primary code, parameters, comments, line number, etc.

IGCodeInterpreter implementations scan through a GCodeFile and do something with each line. The client registers a IGCodeListener implementation, and the IGCodeInterpreter will call functions in this interface based on the codes it sees (ie LinearMove, Arc, etc). Currently this is somewhat limited to interpreting the movement path. Currently MakerbotInterpreter and BiesseInterpreter implementations are provided.

GCodeToPlanarComplex is a IGCodeListener that converts the paths to geometry3Sharp segment and arc objects.

Assembling & Writing GCode

Note: currently under development with a Makerbot Replicator 2 as the first printer supported. Some classes are currently customized to this machine, expect generic versions of these classes in the future, once I figure out the proper abstractions.

The basic strategy to generate GCode files is to first construct a GCodeFile representation of the lines, and then write it in a suitable format. Currently StandardGCodeWriter is provided, which writes Makerbot-style GCode.

GCodeBuilder is a helper class that provides low-level GCode functions which create GCodeLine objects, which are then passed to a IGCodeAccumulator implementation. GCodeFileAccumulator is a basic implementation that appends the lines to a GCodeFile. This is the lowest-level way to robustly generate a GCode stream.

To represent print settings, there is a hierarchy of objects MakerbotSettings : SingleMaterialFFFSettings : PlanarAdditiveSettings, with relevant settings at appropriate levels.

MakerbotAssembler provides a higher-level interface to a GCodeBuilder based on a MakerbotSettings instance. The API is along the lines of "move-to", "retract", etc, which are then converted into the appropriate GCode commands via GCodeBuilder. This is also where knowledge of the standard header & footer gcode resides.

Concept

The Metaphor in this system is somewhat akin to a programming language compiler stack. At the Slicer level we will have a MakerbotCompiler which operates on a set of paths. The set of paths, generated by the slicer, is effectively the 'program' to run. The Compiler converts the paths into a lower-level set of states and operations which the Assembler understands. The Assembler then uses the Builder to generate machine-level controls (gcode, analogous to microcode in this case).

Clone this wiki locally