Machining Druids for the Enhanced Machine Controler (EMC2)

Introduction

I own an NC Sherline mill that is controlled by EMC2 an excellent GPL software running on a Linux PC.

EMC2 has three very good user interfaces. But, for doing anything with it, you have to master an antique langage called Gcode in which every move is hardcoded. This language is the industry standard, and every CA* (CAO, CAM...) program has an option for generating gcode output. While this makes sense for complex parts, writing a program for simple operations like surfacing, or pocketing seems overkill, in addition to being error prone, which is BAD when making actual chips.
So I digged around to see if there was a simpler solution to do simple operations. I found that MACH3, a commercial CNC software similar to EMC, has nice wizards for common operations.
So I decided to experiment designing a druid (the Linux equivalent of a Windows wizard) for EMC, resulting in the Surfacing Druid shown here.

FOR THE IMPATIENT: If you want to try the Surfacing Druid, just download dsurfsa, add execution permissions, and run it. This is the standalone version of the Druid, statically compiled on a RedHat8, which should work as-is on nearly all Linux systems.

BEWARE: This is alpha quality software, that may have bugs. Machining IS dangerous. Use it at your own risk!

Screenshots

Gcode window
The Gcode window.
dsurf main screen
The main screen.
dsurf main screen
A surfacing operation running

Features

The Surfacing Druid helps the Machinist perform surfacing operations. Those operations can be done interactively (if an EMC2 system is running), or the corresponding G-Code can be saved for further use.

The Surfacing Druid provides the following features:

In addition, when connected to an EMC system, you get:

Installation

Download

The download page is here. dsurf.tar.gz always point to the latest version of the source.

In addition, dsurf and dsurfsa are binaries statically compiled on a RedHat8 with emc1.1.7, that should work as-is on nearly all linux systems.

For compiling, you will need also the excellent FLTK toolkit. Install a binary developer version on your Linux distribution, or compile and install it from the source, with png support. A version of fltk is available in the Download page. You can use the following configure options:
"./configure --enable-static --enable-shared --enable-localjpeg --enable-localzlib --enable-localpng"

If you want to build the EMC enabled version, you will need to patch EMC in order to add to EMC the ability to run imultanously ultiple user interfaces reliably. A diff against EMC 2.1.7 is available here. You can apply it against the EMC tree with the command: patch -p0 , then goto emc2.1/src, make clean; make. I use the following options for EMC configure:
./configure --enable-simulator --enable-run-in-place --with-python=/usr/local/bin/python2.4 --with-tclConfig=/usr/local/lib/tclConfig.sh --with-tkConfig=/usr/local/lib/tkConfig.sh.

Compiling

In order to recompile the source, you must have the emc source installed and build with the in-place option.

Uncompress and untar the files under emc2.1/src/usr_intf. Goto dsurf directory and edit the Makefile to adjust the EMC and maybe the FLTKLIBS variables. Then type make. If everything goes well, you will get 2 binaries:

Check with ldd that you are accessing the correct shared libraries.

Starting and Using

Just start the executable.

If it complains about a missing libnml.so (the EMC shared library), adjust the environment variable "LD_LIBRARY_PATH" accordingly (typically: ""export LD_LIBRARY_PATH=/pub/emc/emc2.1/lib:LD_LIBRARY_PATH"), or, as superuser, add the directory containing the needed shared libraries at the end of /etc/ld.so.conf and do "ldconfig" to add the directory to the search path of the Linux loader (cf. "man ld.so").

The Druid by itself is completely standalone, and needs no environment variables, special directories or whatever. It will save its current parameters between sessions in $HOME/.druids/dsurf/lastconfig.xml.

In order to connect to EMC, you must have already an EMC running.
First, select the .ini device configuration file using the "..." button, then click on the "Connect" button. If all goes well, the status will switch from "OFFLINE" to "READY", and the DRO will show the current position. You can select the DRO units, and the currently used coordinates system is displayed.

The Druid will check that all parameters are consistent in real-time, and will highlight in red offending values. When everything is OK, you can have a look at the G-code using the "Show Gcode" button. The G-code window allows you to save the program, or send it directly to the EMC interpreter. It can then be started using the regular EMC user interface.

The "Start" button sends the program as a sequence of MDI operations to EMC. A progress bar is displayed in addition to the expected time to finish.

The "ESTOP" button stops everything. Click on it again to bring back online the system.

Contact

If you have problems or suggestions, you can contact me at  :)

Legalese

Copyright (C) 2007 Michel Gouget.
This software is provided as-is, without any warranty of any kind. Use it at your own risk

This program is free software, according to the GPL.

Enjoy!