How to wire an arduino-based 3-axis CNC machine

 by aggrav8d
Featured
IMG_0180.JPG


I've seen a number of tutorials about how to build the platform for a 3-axis CNC milling machine.  I have not seen anyone tackle the tricky subject of the electronics.

Here now is my attempt to do so.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts

You'll need:

- an arduino. I chose duemilanova. (depends on the board you get)
- 3 stepper motors.  I chose NEMA 17s . ($15/ea)
- 3 EasyDrivers from Sparkfun . ($15/ea)
- some Cat5 ($2?)
- a 12V power supply for the steppers ($5?)
- a soldering iron
- some electrical tape
- an optional female plug is not a bad idea (<$1)

TIP: Don't get a 6ft or 10ft Cat5 cable.  Buy your cat5 by the foot from any computer or electronics store. That stuff has one wire inside instead of lots of little fibers.  Little fibers are a huge pain to work with. 

1-40 of 138Next »
qw623 says: May 15, 2013. 4:02 PM
I'll hopefully be able to release a schematic/EAGLE file for a complete self containing driver using an Arduino, 3 easy drivers along with maybe an Ethernet shield. Thanks for the instructions, now I have something to go off of!
MakeItWithJason says: May 4, 2013. 10:26 AM
You, sir, are a bada$$.

Thanks.
nreed4 says: Feb 7, 2013. 7:54 PM
Could you add a fourth stepper motor to pins 1 and 2? Could you also control a heatbed and an extruder (nichrome wire), because I am trying to build a 3d printer. Also how do you control the z-axis with only one motor.
junkrigsailor says: Feb 1, 2013. 6:33 AM
Thanks. I still don't understand how you program the Arduino to understand G code. Could you please go into a little more detail? Or post another Instructable?
Sorry I seem so ignorant and lost. It's because I am. I'm trying to learn this as a 65 year old guy who grew up in a world where things like Arduinos were beyond our wildest imaginings.
aggrav8d (author) in reply to junkrigsailorFeb 1, 2013. 3:23 PM
try http://www.github.com/i-make-robots/drawbot/ or
http://www.github.com/i-make-robots/delta-robot/ . Both are robots that listen to gcode from the serial connection and then do...things.
junkrigsailor says: Jan 31, 2013. 9:58 AM
How does the Arduino know which way and which motor from the G code via USB? Does it just natively "speak" G code?
aggrav8d (author) in reply to junkrigsailorJan 31, 2013. 9:56 PM
I program my arduino to understand gcode, then figure out which motor to move (and which direction) based on the gcode instructions.
A good example of a system I built with two motors is my polargraph drawing robot, the Makelangelo: www.marginallyclever.com/drawbot
Lee_Smith says: Jan 25, 2013. 1:53 PM
is there any reason why the delay has to increase between rising edges? would it be fine if you left it at 160? also how does i<3400 come out to 4000 microsteps?

Sorry for all the questions but i'm very fascinated in this for my arduino. Also I am in the process control and automation field professionally and for max torque out of stepper motors it is best to keep them running at lower speeds. Depending on your power supply voltage just about anything over 10 revs/second starting dropping torque considerably.
aggrav8d (author) in reply to Lee_SmithJan 27, 2013. 12:36 PM
The changing speed is only to demonstrate the effect on the stepper.
aggrav8d (author) says: Jan 27, 2013. 12:33 PM
Lee - I think you've spotted a few typos in my code. thanks for that!
m4r7in says: Nov 28, 2012. 10:58 AM
Hey, awesome tutorial but have you got any idea how to connect it without the easyDriver? (any helpfull sources would be great too!)
Thanks!
aggrav8d (author) in reply to m4r7inNov 28, 2012. 12:46 PM
I also use an Adafruit Motor Shield, and sometimes I'll use a RAMPS arduino shield depending on my budget. When I first made this tutorial I didn't know about those other, already available boards.
pmaz545 says: Oct 18, 2012. 6:08 PM
I have yet to purchase the Arduino and Drivers; however, I successfully downloaded the code, and verified it in the IDE.

1) I plan to use software and create g-code
2) how do I set that part up? When plugging the software, via USB through my computer, will it just work?
aggrav8d (author) in reply to pmaz545Oct 18, 2012. 6:32 PM
I would suggest looking into GRBL. It might need some tweaking. Good luck!
MisterBusiness says: Oct 7, 2012. 11:07 AM
Awesome.
Dave Sehl says: Sep 26, 2012. 3:34 PM
Can this be donde with an adafruit motor shield like this
http://www.adafruit.com/category/products/81
and one easy driver? I already have the motor shield
aggrav8d (author) in reply to Dave SehlSep 26, 2012. 3:38 PM
Actually, I built a skycam that using two adafruit shields and some custom software. Note that they were not always 100% in sync but for slow movements it made no difference.

for more info check out http://www.marginallyclever.com/2012/08/skycam-assembly-gallery-and-robot-debugging/ . I'm also selling this as one of my kits now.
Dave Sehl in reply to aggrav8dSep 26, 2012. 3:53 PM
Looks cool
JesusB says: Aug 8, 2012. 5:47 PM
I'm new to all of this so I'm having a hard time finding out where the 5 out goes to. Thanks for your time!
pfred2 says: Jul 14, 2012. 4:40 PM
Seems a little weak and slow to me. What does the Arduino do for you? CNC machines I am familiar with don't have a microcontroller and just connect drivers up directly to microcomputers. I got the PC I use for free. My stuff runs better than what I'm seeing here.

http://www.youtube.com/watch?v=cgbeyNNBZ68

That is cooking with some gas.

In case you didn't get enough:

http://www.youtube.com/watch?v=fHPKaHLzXes

I put up two articles on this site about how I did it:

http://www.instructables.com/id/TB6560-Microstepping-Bipolar-Chopper-Stepper-Motor/


http://www.instructables.com/id/Parallel-Port-Break-Out-Board-BOB/

Ain't no thang but a chicken wing. I mean come on.
aggrav8d (author) in reply to pfred2Jul 27, 2012. 2:58 PM
Hi! I see you're trying to piggyback on my instructable and demonstrate your insecurities in the same breath. That's really ambitious of you!

If you'd like to get a larger readership, use more positive language and lower the barrier to adoption - add a list of parts, where you can get them, and how much they'll cost. Explain schematics for those who haven't learned to read them. Remember most people on instructables are here because they don't know how. If they could play at your level, what would they need your lesson for? If they can't play at your level, how is talking down to them going to help?

I look forward to not hearing from you again, as I imagine it will be more of the same. You've made a great first impression. Please don't do it again.

Have a nice day!
PaulMakesThings in reply to pfred2Jul 27, 2012. 2:18 PM
Some might see this as rude, but as I see it, competitiveness is part of the spirit of innovation. I often see an instructable with a method I think is not as good as mine and want to do a post like this. While it may seem rude its actually helpful to people like me who came here looking for home CNC driver plans, who can take or leave alternatives suggested. So thanks.

I don't mean this as a put down to this instructable though, even if this option is not chosen it's good to see how it would be done.
brute4x4 says: Jun 26, 2012. 12:36 PM
its strange when i use this code 2 of my 3 steppers stall. but when i connect all my steppers to the same 2 dir/step pins( that work) they all work.. i've tried changing the output pins but have the same outcome.

any idea what could cause this?

when i had grbl installed it did the exact same thing. i think i may have messed up my arduino.

side note i have tested all driver boards and steppers in different configurations everthing is working just not all together at once.
aggrav8d (author) in reply to brute4x4Jul 27, 2012. 2:53 PM
I would double check you have enough amperage to drive everything at once.
muhsien5806 says: May 28, 2012. 6:48 AM
Sir
I've copied and pasted this code into an Arduino sketch, but when verifying, I get an error message that "easydriver does not name a type". How do I rectify this?
aggrav8d (author) in reply to muhsien5806May 28, 2012. 6:58 PM
I can't imagine how you are getting that error. Are you sure you've copied it correctly? You may have a problem with line endings.
niksa77 says: Apr 11, 2012. 3:21 PM
(removed by author or community request)
aggrav8d (author) in reply to niksa77Apr 11, 2012. 3:31 PM
650ma maybe too low for one motor. Check rating. NEMA17 need peak 2A.
niksa77 in reply to aggrav8dApr 12, 2012. 6:03 AM
(removed by author or community request)
bufalloo says: Mar 28, 2012. 10:40 PM
I'm still confused. I'm having trouble finding how to interpret G-code to the stepper drivers. If possible, could you give me some pointers on how to find some sample code to do this? For example, could this be configured to be used with replicatorg for 3d printing?
aggrav8d (author) in reply to bufallooMar 29, 2012. 9:17 AM
http://www.instructables.com/id/100-Mural-drawing-robot-also-works-as-a-giant-et/

open source code for this other tutorial does it.
acl9865 says: Mar 13, 2012. 4:20 PM
Hey,
When I bought my arduino it came with a 9v wall wart. I have a variable DC power supply at home, what voltage would you recommend supplying to the Nema 17's?
aggrav8d (author) in reply to acl9865Mar 14, 2012. 8:10 AM
ask whoever sold you the NEMA17s. I run two of them for my latest project at 12v2a with no trouble. I'd guess 12v and 1a for each.
acl9865 in reply to aggrav8dMar 14, 2012. 5:01 PM
Ok thanks. Did you end up building a frame for yours? I'm trying to find the most cost effective way of providing linear motion. Rack and pinion is pricey, all thread gets mixed reviews. Would you recommend 1 motor on each side of my longest length to prevent binding from one side being powered while the other isn't?
aggrav8d (author) in reply to acl9865Mar 14, 2012. 8:25 PM
I would ask the real CNC experts at CNCZone.com, they'll know a lot more than I would.
happytriger2000 says: Mar 3, 2012. 6:59 PM
Hi,
I'm getting this "avrdude: stk500_getsync(): not in sync: resp=0x00" right after uploading it to my Arduino Duemilanov, what does it mean?, is the uploading completed fully?
aggrav8d (author) in reply to happytriger2000Mar 4, 2012. 12:42 PM
"The most common cause of this error (IMO) used to be people choosing the Duemilanove 128 when they had the newer Duemilanove 328. Click on -> and make sure you have the right board chosen, and try again."

-- http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1248528012/all
-- http://www.google.ca/search?q=avrdude%3A+stk500_getsync%28%29%3A+not+in+sync%3A+resp%3D0x00&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
happytriger2000 in reply to aggrav8dMar 4, 2012. 5:47 PM
Hiya,
I took a screenshot of the chosen borad = arduino Duemilanove w/ AT328, opent attachment.
Actually I was looking for the Gcode interpreter code, but not sure if the above code is the right one. I want Arduino to accept Gcode and run the Stepper motor. I have a Arduino borad, a PMDX 122 board 3 x 3phase stepper Driver w/ Motor, power supply ready, and the code which I haven't figure out yet.

thanks
happytriger2000 in reply to happytriger2000Mar 6, 2012. 5:43 AM
Oops, the code provided was only a sample code to run stepper motor, sorry my fault.
kotten says: Jan 11, 2012. 3:55 PM
If someone made it this far, it means that they now can control the stepper driver with Ardunio but Ardunio doesn't yet know how to interpret G code? If that is correct, then the next step would be to install a GCode Interpreter in the Arduino Library, such as mentioned here: http://reprap.org/wiki/Arduino_GCode_Interpreter.

Are you aware of Grbl http://dank.bengler.no/-/page/show/5470_grbl?ref=mst
or http://www.contraptor.org/arduino-gcode-interpreter. And how do they relate to what you are or have done?


1-40 of 138Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!