Go Down

Topic: My first CNC machine Arduino Mega controlled!!!! (Read 53367 times) previous topic - next topic



Cool, I am attempting to make my own as well, though I am new to arduino.


@aventgps and anyone who can help. I am building a 3 axis CNC router and was very happy to find this forum post about controlling a CNC with a ArduinoMega! I have my stepper motors and I bought some drivers for them, I thought about making my own but I lack of patience got the better of me and I bought some. I have done some preliminary tests and successfully got the arduino running one stepper using the stepper library in the arduino IDE.  

Next step is where I am struggling, I found the reprap site also but didn't find much on it about the arduino setup (anyone have a good link?) I uploaded a modified reprap sketch for the stepper control with the parameters for my steppers. Where I am stuck is then implementing the Gcode control to the arduino. What do you use for this? There are a lot of options out there some people use pearl scripts, ReplicatorG  or there is the reprap software. I am trying to use a mac to control it but I could use linux if needs be. I have been trying to use ReplicatorG and it is promising but it says there is no serial interface connected, I can't believe it would not work over USB, I am assuming you have it working with usb? Is anyone else using this or could someone describe there software setup along with the arduino sketch and Gcode control?

Another area I am not sure about is will I need to modify the code for my drivers a bit more. The drivers worked for the stepper library with the pulse control but the drivers also have a two pin direction control, are there pins assigned for this in the reprap stepper control?
Any help would be great, thanks!



I've been lurking in this thread for a while trying to come up with ideas, and now I'm getting ready to begin the build.  I had a small business in High School building Adirondack chairs, they're easy enough to build, but cutting out all the pieces is really time consuming.  I've wanted to experiment with building a CNC machine for years, but now I have a good excuse to make an attempt.

The machine I'm working on will (for now anyway) be a 2-axis 2D cutter using a Rotozip cutting tool to basically fulfill the role of a band saw and a drill press.  I'm putting it together using a Duemilanove and the  from Adafruit Stepper Motor shield.  The horizontal axes will be driven by bipolar stepper motors harvested from an old DMX-controlled DJ light, while the vertical axis will most likely be controlled by a simple DC motor with limit switches since I don't need precision, it just has to be able to pull up, move, then plunge back into the wood.  I might try a router bit in the tool, but since I'm only planning on cutting 1" thick wood, I see no need to go out of my way designing a vertical axis at this time.

I'll post updates as this rolls along.  Here's one now because I forgot to mention it earlier.  I ordered the stepper motor shield a week or so ago, but while I was waiting for it to come in the mail, I noticed that my local electronics shop had ULN2003A Darlington chips in stock.  I bought a 4 pack (for $3.00USD) and started playing with one the other night to see if I could get the motor running off of the 12vdc feed from an old ATX computer power supply.  I figured I'd play with this to get an idea for the coding as I waited for my motor shield.  Somehow (most likely alcohol induced) I managed to insert the ULN2003A into my breadboard backwards.  I wired everything up using the 4-wire schematic from the Arduino Stepper library reference page, and it didn't work.  Eventually it donned on me to make sure the chip was in right, and that's when I realized that I had just sent 12vdc straight into 4 of the digital pins.  I went to unplug the arduino, but I touched the ATmega328 and got a first degree burn (which was a good indication that I did something wrong).  So with my arduino dead as a doornail, my motor shield arrived the next morning, and here I sit with no arduino to play with until my new one arrives within the next day or so.


Loving this project, I run an open space maker group in Nottingham called LAB.  CNC router is way up there on the list of things to make!


hello people, i am back from a lot of work....... very glad to see people making arduino cnc machines....


Hi aventgps!, i'm venezuelan,  please How i can buy a Arduino Mega?. i wanna do a cnc machine for printed circuits, excuse me, my english is no very good.   Thanks!


@kdragon you can get an Arduino Mega from loads of online shops that will ship internationally such as:



I don't know of any Venezuelan suppliers unfortunately. On a cautionary note, this is an ambitious first Arduino project for anyone and I might suggest that if you just want this for PCBs it might be simpler and cheaper to buy a CNC kit or pre-made one such as this or something similar:


Even making one yourself unless you have at least some of the parts like the stepper motors you will be looking at about a $300 build. Lead screws, nuts, stepper drivers, and bearings etc all add up very quickly! So weigh up time versus cost versus satisfaction of making it yourself. Hope this helps.


@ Daithi, thanks for answering, I am instructing me in how to buy in dollars from my country. You know, a fellow student and I made a cnc machine but only drilling we do, we made a software for milling and bring the printed circuit but does not satisfy us. Us at that time we did not have the economic resources to do so, in fact, the step motors of photocopiers got damaged and so many other components, because the country did not exist or were very expensive. Now we want to improve the machine to collaborate, teach and promote the elaboration of projects in the country. Thanks again!! and be following in the themes of the forum.


Does anybody know of an existing Arduino-based G-Code interpreter that is compatible with the Adafruit motor shield?  This shield uses it's own library and is not compatible with most G-Code interpreters. including the RepRap one.  I tried asking about this in the Adafruit forums, but they seem to be avoiding my question and keep telling me to just use their library, which doesn't include a G-code interpreter.


@Parcanman Try this one it was made using processing and is cross platform but it does require an Arduino Mega:

It worked great for me but I can't guarantee it will work with your drivers as I don't know much about them. There isn't much variation in the control signals used by different drivers and any differences can be ironed out easily enough in the code.

Another option for Gcode interpreter that works with Arduino is:

That was made for use with Makerbot but does have a 3 axis CNC option but it does need the Makerbot firmware on your Arduino.

If you look back a little earlier in this thread there is a link to another Gcode interpreter modified by Aventgps, which might be your best bet it is hosted here:

Let us know how you get on with those.



Can you please post a material list for your project. I would like to build one. I just need a idea of things to get. THANKS ;D


Can you please post a material list for your project. I would like to build one. I just need a idea of things to get.

I can tell you the first two things you will need:

1. Time
2. Money

You are also going to need an idea of the capabilities of the machine you are looking to create; the accuracy vs. repeatabilty, what kind of tooling you plan to use, etc - so you know what kind of parts to get.

All of this can add up super-quickly (for instance, I bought a small micro-mill from Harbor Freight a couple of years back, but I have yet to buy any tooling, or even take the grease off, because I am looking at around $300.00 over the $400.00 I spent on the machine just for tooling! And this is a manual-style vertical mill).

If you want high accuracy and repeatability, you are going to need to use acme-thread lead screws and anti-backlash nuts, etc; that stuff is hella expensive! If you want low to OK accuracy (depending on what you can come up with to reduce backlash), regular all-thread can work. You are also going to want a drill-press to drill your holes for any machine, so everything is square. You might be able to get buy with a hand-held drill and some eyeballing...

Really, the cheaper option might just be to buy a manual vertical mill and attach stepper motors in place of the handles (although things get complex with the Z-axis, because you usually have to devise a counter-balance system for the mill head, which usually isn't there for a manual mill).

Even so, expect to spend at least $300 for the motors and drivers alone; even a reprap machine has expensive motors and drivers, but they are able to get away with less because they are moving a large spinning mill bit against wood, metal, and plastic, so less torque (and lower current requirements) are needed, meaning the motors and drivers can be smaller and cost less. For larger CNC mills, the motors alone can set you back several hundred dollars, while the drivers are very expensive ($100+ per axis) - and then there's the power supply to consider (you may need a 24-48 volt DC @ 20+ amps to drive the thing; those aren't cheap).

I would suggest you do a LOT more research before deciding if this is a project for you; yes, you can make such a machine cheaply that will do some work, but it won't be that accurate (but it will teach you a lot, I suppose). If you are serious about having a mill that will do real work for you, though, you need to research your options, what is needed, etc. There are tons of resources on the internet if you just take the time to google "homemade/homebrew CNC machine". There are entire forums like this one dedicated to the topic, in fact. Look around, many people have built such machines (many people have spent a lot of money doing so, too).

aventgps can post his list if he wants, but the fact you are asking this indicates that you need to do a wee bit more research on the topic before you even begin to open your wallet.

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.


The design of the machine really has to be entirely based on what it is you plan to use it for.  The machine I'm building is intended to cut wood using a RotoZip cutting tool.  I'm going to use it to cut basic shapes for making Adirondack chairs, so mine doesn't need the kind of precision that you would need for machining.  I'm also trying to build this one as cheaply as possible, I figure I'll get it working, work out as many bugs in the design as I can, and hopefully once I get a better idea as to where I'm going with it, I'll use it to cut parts to make a better machine in the future.

My machine is made structurally out of about $15 worth of lumber and a few $5 aluminum angle irons that I cut to the lengths needed.  The structure is built out of pine 2x4"s and 1x3" pine "strapping".  My X axis is about 15" long (with 10" possible travel) using a cog belt, and my Y axis is 4' long (with 40" possible travel) and uses a common V-thread rod.  The gantry is made out of the strapping and has two 3/8" steel rods with the cog belt between them, with a carriage made of strapping with nylon spacers used as bushings to slide on the rods.  The gantry rides on rollers designed for those glass shower curtains (4-pack for $3 at Home Depot), and they roll on 3/4" aluminum angle irons mounted to a 1x4' sheet of pine that also doubles as the work surface.  Since I'm only doing 2D cutting with this machine, I'm using a servo for the Z axis just to raise and lower the bit.

The Acme-thread (square thread) rods are better for this, but like crOsh said, they're "hella" expensive.  The more common "V-thread" rods are cheap ($6 for a 4 foot one), and with a nut fixed to a rod to drive the gantry and enough oil (PB-Blaster in my case) it seems to run well enough.  The other nice thing about the V-thread is that it can fit standard lock-nuts.  The rod runs through ball bearings I salvaged from an old skateboard (you can get an 8-pack of them brand new for 15 bucks, but go to an actual skate shop, the "replacement" ones they sell at most places are way overpriced).

Both stepper motors, the cog belt and pulleys, the parallel cable that I spliced to connect the gantry to the driver, and the power supply all came from an old InkJet printer I found on the side of the road on trash day.

If you're creative enough when it comes to finding parts, then don't let the money aspect sway you away from attempting this, my whole bill of parts is under $100 since so many of the parts are coming from other places and things.

I am finding out that it might be too much effort for me to get the Adafruit motor shield to drive this, so I'm probably just going to create my own driver, I might set out on that today, even sacrificing parts from the AF shield if needed (those L293Ds are hard to find offline, and I don't feel like waiting for them to come in the mail).  I'll just build a driver based on the RepRap one so I can use their G-code interpreter.


Nice project!
I'm going to try to build one but I don't know how to choose my motors...
Any ideas? Servo motors or stepper motors? Which power?

What kind of motors did you use?

Sorry for my bad English but I'm French  ;)

Go Up