Generating G-code with Common Lisp

gcode

Ruin & Wesen are a two person shop creating specialized music gear. As part of their recent MIDI Command development, they got into case manufacturing. They purchased a mini CNC mill to cut the aluminum cases. Unhappy with the software options provide [Wesen] decided to write his own G-code generator. G-code is part of the numerical control used to command CNC machines. He implemented his interpreter using the language he’s most familiar with: Common Lisp (not surprising if you notice the website’s backend). The post covers the design philosophy used and some of the problems that came up. We look forward to future releases since the interpreter can generate milling code using processing.org sketches and cut PCBs directly from Eagle.

You may remember Ruin & Wesen from when they shared their Eagle layout videos.

[Thanks fbz]

10 thoughts on “Generating G-code with Common Lisp

  1. My roomate and I are in the process of building some speaker boxes with our colleges cnc mill, but as far as I know, solidworks cant export any file types that the mill can use. Does anyone know of a good dxf, dwg g-code, ect generator that can combine multiple parts to be cut out of one sheet, and can handle multiple cut depths? (the speakers are flush mounted)

    As for the hack, its interesting, but I’d be worried about damaging my cnc machine with some malformed g-code.

  2. as long as you have some stop/home limit switches on the machine, you have no chance of runaway g-code damaging the machine.

  3. @wolf: the step you are missing between solidworks and g-code is the CAM software. This is where you choose what endmill you will be using, how to cut the paths, how deep, speeds, etc.

    I’m sure your college will have some software that will either be integrated into solidworks (solidCAM), or allow importing of a 3D file (step, sldprt, etc.). Importing multiple designs into one cut should not be a problem.

    http://en.wikipedia.org/wiki/Computer-aided_manufacturing

  4. Occasionally I’ll use unigraphics to generate my g-code, but often I get pissed at it and write my own c++ to generate my tool paths. I totally understand where these guys are coming from.

    if you know exactly what you want the tool to do, generating your own g-code isn’t a terrible idea.

  5. I usually run the simulator in my cnc control software to see what the g-code does. Also I added a security zone feature. You can definitely run into trouble pretty quickly if you’re not careful, but that goes for cam-tool generated g-code as well. Running into clamps, running into sensors, or just breaking tools cause you are not careful or don’t know the material yet. I bought a ton of used bits off ebay to check for things when I first mill new materials, as I had some pretty expensive days in the lab :)

    The software can import g-code and panelize it btw, it also recognizes fly over and mill parts, and can optimize them using a slightluy customized version of the traveling salesman algorithm. I’ll write about this soon :)

  6. I know very little programming, so compiling my own generator has been thus far out of the question. I run Cincinnati lasers for a living and always find myself writing my own code line by line.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s