Let's Make Robots!

Driving a CNC machine directly from an STL file with a DAGU Spider controller

I want to drive a CNC milling machine using only an Arduino processor and an STL file. The STL format was chosen because it is very simple for me to understand and almost all 3D CAD software can export an STL file.

In my forum post here: http://letsmakerobots.com/node/34958 the feedback I go was basically.

  1. Arduino processor not powerful enough
  2. Why bother, free software available

In short, I think the Arduino is powerful enough if the code is only processing the model one slice at a time. The machine is much slower than the processor.

As for why - I like a challenge and I want to simplify the software toolchain. I don't want to have to delve into the depths of some freeware to tweak it to work with the next piece of freeware to work with my machine. I admit this project will really test my programming skills. It will be mostly floating point 3D trigonometry.

My Arduino code will already be optimized for my machine. You just need to tell it basic information like what material you are cutting so it can adjust the cutting tool speed and depth of the slices. If it can read an STL then it will work with almost any CAD software.

I have already designed my controller but it will be a few weeks before I have the sample PCB. While I wait I am starting with the basics using a Spider controller that's been fitted with an ATmega2560 MCU so that I have more memory to work with. I am using a Micro Magician just to provide 3.3V for the SD card. The LCD is 128x64 pixels.


First Goal: Reading the SD card and select the file you want from the directory displayed on a graphics display LCD. I am just learning to use the GLCD and SD card libraries so this will take a while.

I have loaded 11 test files on the SD card. Most are simple shapes drawn on Google Sketchup and exported using a pluggin by Jim Foltz. Jim tells me his STL exporter follows the protocol described in Wikipedia.

There are 3 files draw in Solid Works. These are very large complex models. One has over 80,000 triangles in it. This will be a good test of my code where I can experiment with optimizing my code.

I finally got a few days to work on the code but I've run into some problems with the SD library. I've got my code so you can scroll up and down through the directory and select the file you want but after scrolling up or down 24 times it seems the "rewindDirectory()" command stops functioning. For now this is not a big problem as I only have a small list of files in the root directory.



Comment viewing options

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


First of all i am new to Let's make robots and i have seen you project as i am working on one my self and it does need PC to load Gcode.

Good luck and keen to see you project complited.

Best of both


I just finished my GRBL CNC milling machine. I would like to put another Arduino in front of the Arduino running GRBL. That could very well run a STL to G-Code program like you suggest. 

I look forward to follow your progress.

In the meantime, I will program my "Front-Arduino" to run G-Code files from the SD card. I add a 4x20 lcd and buttons to yog, pause, reset and set position by g92-code. Using an Aduino with GRBL already loaded in between my "Front-Arduino" and the CNC does that I don't have to think about processing G-Codes while GRBL already does this perfect.


Nice approach and good luck with the math :-)


Regarding 3D trigonometry: I suggest you get familiar with vector geometry/linear algebra :)

Yes I was quite good at vectors when I was 16. Now that I am 42 I am just happy to have a vague memory of what a vector is.