Let's Make Robots!

Converting an STL file to Gcode to drive a CNC mill or lathe

As mentioned in my blog, "Multipurpose Mini Machine" DAGU wants to develop a low cost CNC machine kit. The models shown here will not be the final product, they are simply what I used for testing the quality of the components.

Part of the kit will be an Arduino compatible controller. Ok, I know, nothing new so far.

What I hope will be new is that I want to be able to make an object just by inserting an SD card with an STL file on it. I want it to be self contained without needing a PC to drive it. The advantages are:

  • Simplicity - no cables or wireless links to your PC.
  • If your computer crashes it won't affect production of the parts.
  • Your computer is not slowed down because it is trying to drive 1 or more machines.
  • Your laptop is not tied to the machines, you can take your laptop with you while the machines keep on working.

I know there is software availble now that converts STL to gcode, perhaps the most well known is Skeinforge. The problem is I think the process is unecessarily complex. To begin with you need to install Python. Then it is recommended to install Psyco to speed it up. Then you can install / run Skeinforge. Then you need to configure the program Then you can generate your gcode. Admittedly, once this is done you can put your gcode onto an SD card.

I just want to put the STL file straight into the controller and have the machine do the rest. Maybe I am just dreaming but from what I have read of the STL file format I think it is possible. It is all simple trigonometry and floating point math. Although the Arduino is not a fast processor, it is still much faster than the actual machine. I think it should be possible for the Arduino to convert the STL file on the fly.

At this point I want to know:

  • Am I re-inventing the wheel? Is there an Arduino Library or easy to use software already?
  • Am I missing some important factor that makes this project impossible?
  • Is this project impractical in some way?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

... for the input. 

DXF of maybe SVG is probably a better option.

As for processing the file on the Arduino, well no existing firmware does that, all are processing gcode.

As a firmware on the arduino for a CNC milling machine I would recommend GRBL or Teacup.

For the toolpath generation HeeksCNC comes to mind.

My best results were with EMC2 on a PC controlling the drivers directly trough the parallel port. Nowadays the port is kinda gone but I think a RaspberryPi could do the job.. but there seems to be no interest of the comunity to port it.

Possibly the best choice would be one the Atom based boards running EMC2.

skeinforge and its ilk are meant for slicing an stl file. While the output is gcode, the file is for an additive process, and not, a subtracitve process.

I will agree that 3d printers show that an arduino is fast enough to control a machine. I do not believe that the arduino is fast enough to decode an stl file, and, run the machine at the same time. Another issue I see, while it is good to attempt to "dumb down" the system for machining parts, you are also taking some control away that could be useful.

One of the issues I remember that a machinist has to take into account is hold-downs. If you aren't at the machine watching what is going on, you may come back to a rather seriously crashed machine. When I was going to school for CNC programming, one point that was made more than once was, CNCing was a good process for producing more than one part. For one offs a manual mill/lathe will take less time hands down, because of the set up time required for the CNC equipment. Even current production CNC equipment has operators to swap parts, examine them to make sure the machine is producing them properly, and, adjust the program/machine when the parts are not meeting specifications.

As to actually producing millable/latheable gcode, I would suggest pyCAM, or, something like it. Quality CAM software can take into account the size of bit you are using and warn you when you are trying to cut something that just isn't possible(ie. If you have a part with a 3mm radius and you are attempting to cut with an 8mm endmill, the CAM software will warn you and force you to change tools. In the end, I believe attempting to put the conversion "and" machine control on the arduino will lead to many a crashed machine, and, broken parts/bits/tools.

Yes, if I write my own code it must slice the STL. It would be a big job and I'm not sure I'm good enough. I have since learned that there may be a gcode pluggin available for Sketchup in the near future. This may solve a lot of issues for me.

 

 

Hmm, converting an STL file to Gcode is a LOT of floating point math. Something an ATmega is very slow at, I think that is the reason nobody has bothered to do that on an Arduino (yet). Maybe it's good project for the new Arduino Due? (Due does not have an FPU though, but it's 32bit 84MHz)

Albeit of-topic let me suggest you to include a bluetooth option, making it possible to upload gcode to the machine wirelessly. It's a pain to move SD cards back and forth between computer and machine.

There is no problem with adding sockets for bluetooth and Xbee. I had intended to do this anyway. Because an STL (or gcode) file can be quite large it would still need to be stored on an SD card while the Arduino processed the file and made the part.

In this case I think Xbee is better because it has built in error checking. I don't think the bluetooth modules do this.