backplot options: use the EMC2 interpreter gcode module

124 views
Skip to first unread message

Michael Haberler

unread,
Dec 17, 2010, 2:50:41 AM12/17/10
to heeksca...@googlegroups.com
thinking about G-code backplot, I note that an alternative to 'roll your own parser' + XML  is to use the existing rs274ngc interpreter as it comes with emc2

it is a fairly underdocumented corner of emc2, but it's used in Axis and all there ready to use from Python. What the interpreter does is to map G-code into calls to 'canonical functions' which are basis for controlling the machine as well as generating the backplot. By using the gcode module from Python it's possible to parse a G-code file, and have the resulting 'canonical commands' be executed as calls into Python methods.

I reverse-engineered an example, see http://git.mah.priv.at/gitweb/rs274-python.git/tree/master:/src

This parses a g-code file and reports a few calls through the canonical interface. It should be straightforward to adapt this to generate a file to stuff into the CAD package, or to directly feed a geometry into it.

You need to have emc2/lib/python on the PYTHONPATH if you use emc2 run-in-place.

See the emc2/src/emc/rs274ngc/gcodemodule.cc for details, this maps the canonical format to Python method calls.  It is scantily documented but fully functional.
to get an idea about the canonical format, see emc2/src/emc/canterp/canterp.cc .


-m

dan falck

unread,
Dec 17, 2010, 9:12:16 AM12/17/10
to HeeksCAD - Developers Mailing List
Here is another stand alone version (for mills only) of it from pre
emc2 days:

http://code.google.com/p/rs274ngc/





mark

unread,
Dec 19, 2010, 9:31:52 PM12/19/10
to HeeksCAD - Developers Mailing List
There are a number of differences between the one in EMC2 and the one
Dan mentions. I'd go with the one in EMC2, as it has many more
features and supports more axes.
Mark

Michael Haberler

unread,
Dec 20, 2010, 2:41:06 AM12/20/10
to heeksca...@googlegroups.com


2010/12/20 mark <mpi...@gmail.com>

There are a number of differences between the one in EMC2 and the one
Dan mentions. I'd go with the one in EMC2, as it has many more
features and supports more axes.

Yes, and somebody else keeps it in working order for us which is a hard-to-beat deal. It is used in - at least - the Axis UI - and if it breaks it will be fixed in no time flat.

I've started a HeeksPython py file to do backplot, and it's somthing like a 50-line effort
unfortunately one of the calls into HeeksPython still segfaults

Looking at the code I assume it should be possible to build the gcode module on Windows since it is largely agnostic of the EMC HAL and realtime environment

-m


On Dec 17, 9:12 am, dan falck <ddfalck2...@yahoo.com> wrote:
> Here is another stand alone version (for mills only) of it from pre
> emc2 days:
>
> http://code.google.com/p/rs274ngc/

Mark

--
You received this message because you are subscribed to the Google Groups "HeeksCAD - Developers Mailing List" group.
To post to this group, send email to heeksca...@googlegroups.com.
To unsubscribe from this group, send email to heekscad-deve...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/heekscad-devel?hl=en.


Reply all
Reply to author
Forward
0 new messages