Instructables
loading
loading
Picture of Raspberry Pi Alamode CNC Controller
5377b92e26ece203d600014b.jpg
5377b85e26ece2f0fb000031.jpg
5377b81f26ece245b0000097.jpg
536eaa50f92ea168cb00008e.jpg
CNC Diagram.jpg

This is my first attempt at an instructable. I hope it helps someone else.

Switches and Lights and fans, oh my...

Please read through the comments for more details.

I bought a CNC machine some time ago and I was never happy with it. It used a traditional parallel port controller and of course no modern computers have those. So it was always a point of frustration. I used an old Pentium based computer and ran LinuxCNC on it for a while but was still not happy with that. So I started looking for another solution. I decided that I would try to put together an Arduino based controller and try to use USB to communicate with it.

After studying that for a while I came to realize the Arduino was just not going to be able to do all that needed to be done on its own. The Arduino UNO just does not have enough memory or processing capacity to process a design file by itself. So I modified my solution and started working on using a Raspberry Pi as my host computer.

I created a Visio drawing of what I intended to do: It didn't turn out that way and the drawing continued to evolve as I learned more. It kept on changing until I finally got my project completed.

I have now built an Arduino based CNC Controller system that uses a Raspberry Pi as its host computer. The Raspberry Pi processes an "nc" file that contains a design that is described in GCode commands that can be understood by the Arduino. I have used a few tools on my Windows 8.1 Pro laptop to design a few simple things (like tutorials in makercam here: http://www.makercam.com/). This is a great introduction to designing things for CAD/CAM and it is really easy to use.

After creating a design that I wanted to use I wirelessly connected to the Raspberry Pi using WinSCP to transfer design files to the Raspberry Pi. You can get WinSCP here: http://www.soft-now.com/listing/123823/WinSCP?did=11055&pid=1&ppd=search,44532390848,winscp20download,e,,c,0,,,&gclid=CJuIkNHds74CFagWMgodpxMAJw. Its great, you can just drag a file from one window to the other to move files between systems. You will have to know the IP address of your Raspberry Pi to connect to it. If you have gone through the initial setup of the Raspberry Pi and setup a network connection you can get the IP address by using the ifconfig command on the Raspberry PI. A really helpful tool for getting your IP address and seeing that your Pi is online is a tool called the Advanced IP Scanner here: http://www.advanced-ip-scanner.com/. Another great tool is Wireshark: http://www.wireshark.org/

I then used Remote Desktop Connection (Remote Desktop connection is part of Windows and should be on your Windows machine. It can be run by entering mstsc in the Run Open: box) to connect to my Raspberry Pi. Otherwise you could use VNC or TightVNC: http://www.tightvnc.com/. TightVNC is what you need to put on your Raspberry Pi to allow you to use Remote Desktop Connection from another machine. I can now run the Grbl Controller on the Raspberry Pi which in turn connects to an Alamode (an Arduino like board that plugs directly into the GPIO connector on the Raspberry Pi and provides automatic voltage level translation. So that the Arduino can communicate with the Raspberry Pi directly. The Alamode also provides Arduino headers to allow for Arduino shields to be plugged directly into it. So I ended up with a stack of three boards that are tightly integrated due to being plugged directly into each other. The Alamode (Arduino) processes the GCode commands from the Raspberry Pi into signals that are sent to the CNC Controller shield to run the stepper motors and passes the various function signals on to the CNC Controller shield too. They can then be accessed from the external world. All is well so far... But now I have to connect these things to the external world.

 
Remove these adsRemove these ads by Signing Up
1-40 of 144Next »
mark.buttle1 made it!16 days ago

Hi Great machine - I'm doing very well on the final stages of my machine following a very similar pattern to you. Using a Raspberry Pi - Arduino UNO and CNC Shield with A4988 driver and NEMA 17 motors.

I have a question before I turn all my kit on - its about the 4 wires going into the A4988

You have the following 4 wire colour coding

Pin 2B = Black +

Pin 2A = Green -

Pin 1A = Red +

Pin 1B = Blue -

(+ - + - )

However - I have seen someone else wire it

Pin 2B = Red +

Pin 2A = Blue -

Pin 1A = Green -

Pin 1B = Black +

(+ - - +)

I know keeping the pairs together for each coil is important but is the - + as important as I'm seeing many different ways to wire these A4988?

Any advice much appreciated.

The other bit of advice is what is the best way to calculate and set the max current of the A4988 I have

JKM NEMA17 Two Phase Hybrid Stepper Motor 78 Oz-in/48MM/1.8A Motif motors and again finding different calculations and formula - what did you use please?

IMG_2062.PNGIMG_2063.PNG

Hi Mark, congrats on your project? I'm doing basically the same thing but I'm new to this. Would you mind answering a couple questions that might help me get through mine?

did you have all of your boards assembled...the pi, the uno and cnc shield before you started loading all of the software, or did you load the pi, save, shut down and then put the boards together before transfering data to the arduino? What link for loading the boards did you follow? I'm using an alamode/arduino board as per this instructible and performing the steps on the zapmaker link to load the software, Grbl and cnc files and have been having all kinds of trouble getting through it. I'm not sure what I'm doing wrong.

cdtaylor51 (author)  JohnM579 days ago
Not addressed to me but on my Instructable. You really need to following instructions on the Alamode site here: http://wyolum.com/projects/alamode/

I didn't put the CNC Controller board on the stack until quite late in the project. Except for test fitting it. Didn't get driver boards till later on either. But neither of those itemshas much to do with getting te software working either.

Hope this helps. Make sure you go through the web pages for the CNC Controller too.
cdtaylor51 (author)  mark.buttle116 days ago

Congratulations on building a really nice project. Your project is larger than mine is. What do you anticipate making with it? One thing I thought about while looking over your pictures is that with that heavy spindle you might want to use two motors on the axis that moves the spindle. That is really easy to do with the CNC Controller shield that I used. Not sure if you used the same shield or not. I really like the LCD and that illuminated switches. One other switch that you might want to consider is an emergency stop/kill switch just in case something goes wrong. Some people have built what they refer to as a "pendant" for that purpose and to have a means of directly controlling the system too. I am thinking about doing that just for the experience of being able to used it. Otherwise, what a great project. I would really like to see it in action. Thanks for your comments and interest in my project.

Thank you I'm pleased they way it's going.
I'm planning on using it for most of my DIY woodworking projects - and thought I could use something like PhotoVCarve making presents for family. I also have 3 children and thought I could get them into CAD and CNCing!

The motor on the Z axis is being replaced with a bigger stepper - however with the balancing and easy of movement on that axis I'm surprised the pilot .350 amp stepper moves it really well.

BIG RED EMERGENCY button is a must and will be fitted before I turn all on.

Not sure if pendant is the same thing as what I'm thinking but was trying to think of adding like a small joystick to control the axis's like to find 0,0 of work - what's a pendant?

I'm using the v3 Andruino CNC Shield from Hobby Components
http://hobbycomponents.com/shields/568-cnc-v30-arduino-compatible-shield
I'm having issues with getting the end stops to work I got basic open switches - I don't think it's the switch or wiring personally I think it's the GRBL Controller config but when I set the Boolean to 1 on the hard limits $21=1 it errors about homing and sets it back to zero. Not played with it much yesterday but will try again later on and see what's it's doing.

Thanks for your quick and helpful responses
cdtaylor51 (author)  mark.buttle116 days ago

Thanks for looking over my project. I think that the best thing for you to do about the stepper motor wiring is to read through the page for the part and read the FAQ page that is mentioned on the Pololu website for their Allegro’s A4988 stepper motor driver carrier.

https://www.pololu.com/product/1182

There is a very good and thorough video about how to set the current limit for the motor drivers on the product page above and I encourage you to watch and go through the steps carefully as is done in the video.

https://www.pololu.com/product/1182/faqs

The wiring is explained on the FAQ page in detail as is a procedure for setting the current limits for your motors. The pairing of the wires with respect to the winding is really important (meaning: if you get it wrong the motors will not turn or worse you may damage the driver and the motor).

I attached two pictures. In the first one you can see that I used keyed connectors for the stepper motors cables (the white connectors). In the other picture you can see the order of the wires that I used. Mine are wired Blue(1B), Red(1A), Green(2A), Black(2B). I have not looked at my controller for some time as we have moved and other things have taken priority. I looked at my controller to be sure. I miss wired the blue connector for the Z-Axis. I have now corrected that. If you look at the Allegro schematic for the A4988 that should clear it up. I had to rebuild that cable when I changed the order of the of the cables to match the correct color code. No camera at present or I would add a corrected picture. I will try to add another picture when I get my phone back. Sorry if my mistake caused any confusion.

20140510_131052.jpg20140510_135213.jpg
JohnM5715 days ago

Of all things, I'm having a very difficult time setting up my Realtek wireless module.The instructions that came with it instructed to download and exe setup file and the raspberry won't open it. It directs me to the raspberry site. Could use some assistance. Thanks

cdtaylor51 (author)  JohnM5714 days ago

My original Wi-Fi dongle is a D-Link DWA121. I plugged it in and it worked right away. I am not sure that I did anything to get it working at all. I just purchased four other dongles and I am in the process of rebuilding the kernel for the second time trying to get this thing to work. The DWA121 is based on the RealTek chipset the new ones I bought are based on the RALink chipset. You might want to go and take a look at the supported devices list on the RPi site to reduce your problems with getting your device to work. Thanks for looking at my project. I think you will have to go to the manufacturers site or search for an answer on the internet.

cdtaylor51 (author) 15 days ago
A pendant is a sort of remote control to "manually" control a machine. I have seen wired as well as wireless pendants. Custom made and purchased ones. I have also seen a game controller used as a pendant. Some have displays and some don't. Google CNC PENDANT for more info... Thanks for posting.
VidurM115 days ago

Hi cdtaylor, this is probably the most advanced instructable ever... I wanted to ask however....
in your raspberry pi are you creating drawings for each part?
is there a way to interface or import AutoCAD models into the Pi??
Or going further what about importing/converting 3D files directly?? Something like a Step file or some such.... That would have some incredible applications...
Thanks any comments by you will be much appreciated!!

cdtaylor51 (author)  VidurM115 days ago
The only software running on the RPi is the grbl controller. It has specific requirements of what is in its input. I would like to refer you to the grbl wiki for more information about what it can accept. For me sometimes I have more than one file to make a part. For example a Printed Circuit Board might have a trace isolation file, a hole drill file and a router file to remove excess material or to cut the perimeter of the board.

Here is a couple of pics of my plywood DIY CNC Router rig - I've just got a couple more tweaks and bits to make - then its wire it all up so any advice on my previous post would be most appreciated - however no rush as I'm waiting for a nema 23 L bracket to arrive before I can actually finish and turn it on.

Thank you

IMG_2062.PNGIMG_2063.PNGmydiy_cnc_01.JPGmydiy_cnc_02.JPG
ZdravkoP18 days ago
I am interested to make such controller for 250T metal press?
cdtaylor51 (author)  ZdravkoP18 days ago
Not sure if you are asking a question for me. If you make post a picture and tell us about it. Good luck with your project and thanks for your comment.
JohnM571 month ago

Thanks for you response. My machine is simiIiar in table design to a plasma, or router CNC except it is being used for pressure testing of foam materials. That's why the Z axis is just a actuator with a load cell. The table moves to a location and then the actuator drops to mutliple depths while the load cell readings are recorded. I was expecting that the drivers and power supply would be outside of your enclosure design and in a separate one. Ultimately, I'm wanting to input the control signal into my set of drivers. It seems like this should work. The signal going to the driver should be the same regardless of the driver correct?

Can you tell me what value your current limiting resistors are and also the model of your fans.

cdtaylor51 (author)  JohnM571 month ago
I believe that you are correct about there driver signals but you need to confirm what your particular drivers are expecting. The current limiting resistors for the leds are about 500 Ohms. Just check out an led resistor calculator on the internet and decide how much current you want to light up the led and the led calculator will give you the value of the resistor to use. I didn't want leds to be very bright and I want them to last a long time so I used the resistors that I used. You might want the leds to be brighter or less bright. I would suggest that you use a breadboard and try some different resistor values and see what you prefer. I hope this helps.

Your input is a great help, Thank you! I have about 1/3 of the compnents in. I didn't realize the CNC shield had to be assembled, but the supplier sent the link to the assembly instructions so I'll be ok. Adafruit was an awesome find! I really like their approach to marketing their products by educating their viewers on their products and applications. Great for novices like myself. Since I started this project i'm fiinding all kinds of educational stuff on youtube, and the raspberry pi site as well!

cdtaylor51 (author)  JohnM571 month ago
No problem. I would like to see a picture of your build when you get it finished.
cdtaylor51 (author)  JohnM571 month ago
The model number of the fans is in the parts list that I posted in response to a previous comment. Nothing special, just 40x40x10 mm 12VDC case fans.

That is an awesome CNC controller and your wiring is perfect! Thanks for the explaination..
How do you find the grbl controller software? have you compared it to something like LInuxCNC or Mach3/4? Also this would work with a larger stepper motor driver for the likes of a Nema23 or 34 right? or is the output voltages not enough to fire the drivers? Thanks!

cdtaylor51 (author)  troy.dawson.779852 months ago
Thanks for the feedback. You can just Google for grbl and then read the Wiki pages for info on grbl. Grbl is available on github. As for larger motors: the grbl controller board is designed to handle 12 to 36 volts (you would want to read their pages too). There are a few different Pololu stepper driver modules that you can use at different voltage and current settings. Of course you would need to modify the wiring and perhaps provide better cooling if you used different power levels than I did. Just changing the power and the driver modules would be pretty easy to do. My build just used 5 volts and 12 volts. To use 36 volts you would have to bring 36 volts in from an external 36 volt power supply to the CNC controller board and you would need to replace the stepper driver modules with appropriate 36 volt modules. I also used 12 volts for my spindle functions. You may have different requirements than I have.

This is really an awesome CNC project. Thank you for sharing all of this hard work. I'm working on a 3 axis gantry style CNC project now and have been thinking about how to use your design. Instead of a spindle on the z axis i'm using a actuator powered with a servo motor (so I'm not needing any relays for spindle speed, direction or coolant since there is no spindle motor), and stepper motors for the xy. A load cell is set on the end of the actuator. I'm looking to use nema 34 steppers with R1025 drivers. I'm still researching the servo for the Z axis since I need more torque for the actuator. Any thoughts or suggestions?

cdtaylor51 (author)  JohnM571 month ago
Thanks for your interest in my project. There are a lot of things in my project that might be applicable to yours. However it is clear that your project would not fit into a small enclosure like mine did. As for the z-axis, you might be able to use a rotory solenoid actuator to get higher torque. I don't really know what you are doing so I can't really say that would work but it might be worth looking at. Thanks again for your comments and questions.

Sweet Thanks for the reply. I know I would need to use external motor drivers. But I wasnt sure if it works as a relay and therefore could be driven by a lower voltage or if I need to run the actual voltage through the board.

My requirements are to convert a Optimum BF20L Mill which would require Nema34 motor and 2 Nema 23 motors. But the raised voltage may mean I need to use a conventional board as opposed to a GRBL/Arduino setup.

cdtaylor51 (author)  troy.dawson.779851 month ago
You could certainly try using a CNC controller just like mine if you wanted to. As I mentioned previously you would need to provide the right voltage for your motors but there are driver modules that can handle up to 36 volts and 2.2 amps per coil. You could try that and Grbl if you wanted to. If it's too much then you could do something else and still have this controller as a backup or to test with or to use on another project. Personally I think my CNC controller would work (use the 8825 drivers at the correct voltage for your motors and leave the top off of the box until you understand the thermal issues). Alternatively, you may need functions that are not available in Grbl. So you might want to go with Mach or EMC or LinuxCNC or something else and that would mean that you wkuld not be able to use this controller. By the way, I really like the mill you chose. I would suggest that the first thing you do is install a good Digital ReadOut (DRO) on it. Then learn to use it manually. Then upgrade it to a CNC controlled machine. Make the parts to adapt it yourself. Learn all you can about using the machine first. Then you will understand what happened and why it happened when something goes wrong and you will be able to compensate for that intelligently.
cdtaylor51 (author)  cdtaylor511 month ago
Check out this site for a great DIY DRO project:
http://www.yuriystoys.com/?m=1
mark.buttle12 months ago

This is an awesome CNC controller - thank you for spending time and effort sharing the results in such great detail.

I too am going to make a similar CNC controller and if possible would like to know a bit more about your S port and the relay(s) you used and how you have them wired in.

cdtaylor51 (author)  mark.buttle12 months ago
I am not sure what you are asking me here. I reread what I wrote and I don't know what else I could add to that. Here is where I got my relay modules: http://imall.iteadstudio.com/im120710007.html.

They are just relay boards that are controlled with 5 volts and can switch up to 24 volts DC or 120 volts AC. You can get more information on their Wiki page here: http://wiki.iteadstudio.com/5V_Relay.

I replaced the 3-pin header on each module with a polarized locking connector that I had.

As I said, you can do whatever you want or need to do with the relays. I connected them to the functions that are broken out on the CNC controller board. If you needed to do something else then you certainly could but I believe that those are the functions that Grbl is expecting. You could also connect any of the relays to an external solid state relay to control a higher power device.

One thing that I do not yet understand is how to deal with variable speed spindles. The connector that I used for the spindle functions has eight pins, and I used six, so adding additional functions or features should not be too difficult. But I don't know how the Grbl guys are going to bring that function out yet either. There are new versions of things all the time.

I hope that this is what you wanted to know. Thanks for your comment and for reading about my controller.
cdtaylor51 (author)  cdtaylor512 months ago
I just looked at the relays again. The relays get +5V and ground from the power distribution board. The relay control signals are in the white expandable sleeving and connect to the CNC controller shield. I then tied +12V from the power distribution board to the common pin of each relay. Then the normally open pin is connected to the "S" connector. Then I connected ground from the power distribution board to the "S"connector too. I could have tied all of the grounds together and just ran a single ground wire to the "S" connector but not doing so allows for more current and more modulatity. I could have also gotten ground from the CNC controller board but chose to get ground from the power distribution board instead. The pictures don't show this very well. I hope this helps. Keep asking questions and I will keep trying to give good answers.
Sekai2 months ago

nice cnc controller. and very compact.Do you perhaps know how to connect a raspberry pi with a standart paralel port.I have a cnc machine (router) with L297-L298 combination, and i am using an old pentium 4 pc, but i want to make the cnc more compact.so i was thinking of doing with a raspberry pi.

cdtaylor51 (author)  Sekai2 months ago

I think that I misread your comment. One of the reasons that I built my CNC controller was because I was, like you, using an old Pentium based computer because that was the only machine that I had that had a parallel port. That's fine if that is what you want to do and LinuxCNC works very well in that environment but if you want more latitude and to be able to do other things then this environment is very limiting. So I built a completely new controller based on a Raspberry Pi and an Arduino. I have not tried to use an RPi as a parallel port adapter. Here is another situation where the RPi is running Wheezy, which is a time sharing, multiuser, operating system but you would really be better off using a real time operating system. Try Googling "raspberry pi real time os" or "raspberry pi parallel port". My solution completely eliminated the parallel port from my CNC machine and now I just use a wireless connection from my laptop to my CNC controller (RPi). I could also use an Ethernet connection if I wanted to but the wireless connection is just a lot more convenient for me.

cdtaylor51 (author)  Sekai2 months ago
I believe that I addressed this topic before but the way I see it you would need some way to get the higher voltage and current to the stepper motors. Other than that I am pretty sure that the RPi can handle everything else. However the bigger issue is the software and that would take a big effort to create. That is why I did what I did instead. Please see the other comments for more information. Thanks for your comments.
BertieS12 months ago

Nice would you be able to link to any resources for building the rest of the machine? Thanks

cdtaylor51 (author)  BertieS12 months ago

I am not a sponsor of any make of CNC machine. This is a really hard question to answer. I do not know what you intend to do with your machine and this controller is able to control pretty much any 3-axis machine. You could, for example, make a laser engraving machine with this controller. I am not sure what sort of machine you want to get into. Personally, I purchased a 3-axis CNC milling machine from MyDIYCNC when it was a Kickstarter project and paid about $500.00 for it. You can look at their site if you like. http://www.mydiycnc.com/ I believe that their current offering is much better than the one that I purchased. (They offered me an upgrade for $250.00. I have not done it yet but might. I have made some big changes to my machine because I was not able to accomplish what I wanted to do with it but for what it is its okay). I am also impressed with the shapeoko offering. http://www.shapeoko.com/ I believe you can get a machine from either place with or without electronics. If you do that and build a controller like mine you would still need to have stepper motors and limit switches. The two machines are really different in their approaches to motion control. The MyDIYCNC machine uses threaded rods that I believe are inherently not very accurate and they also use their own anti-backlash mechanism that I do not believe is very good either (just my opinion). I have replaced the threaded rods with Hayden Kerk anti-backlash nuts and lead screws that are very accurate (about $50 per axis plus couplings). On the other hand the shapeoko offering uses belts instead of lead screws. A lot of machines have used belts in the past but I like lead screws better. I believe that belts stretch over time and that the machine will become less accurate over time as the belts age. But that is just my opinion too. I think that maybe the best way to go is to get a good, heavy, manual milling machine. Something like this for example: http://www.micromark.com/microlux-high-precision-heavy-duty-r8-miniature-milling-machine,9616.html And then add the CNC stepper motors and limit switches to it along with the CNC controller of your choice. Here is a website that shows how to convert a manual mini milling machine into a CNC mini milling machine. This would be a very nice, very stable, very accurate and repeatable machine and would handle pretty much anything you might want to do in a mini-machine shop. Lastly, look at this site for more information about everything that has to do with home / hobby size machine shops: http://littlemachineshop.com/default.php The more you learn about how all of this CNC stuff works the better you will be able to choose a machine that will do what you want to do with it. Remember that there are also CNC controlled lathes, milling machines, engravers, cutters and even 3D printers (since I published my instructable I have learned that my controller won't quite do all that is needed for a 3D printer. You really need at least 5-axes for that). Grbl only supports 3-axis machines. Good luck, I hope this answer helps. If any one else wants to comment on these ideas please do so.

phuketbot3 months ago

what you realise chang a lot of think about home cnc ,distant control and distant fix ,price , control cnc not in the noisy same room.......

it for that try to do the same, i have a lot of difficult to preparre cart programme; nobody who have realise the cart can upload the img of the raspberry cart per torrent to make the work in some simple clic.

cdtaylor51 (author)  phuketbot2 months ago

There is a good tutorial on building the Raspberry Pi software on the Adafruit site.

Try this: https://learn.adafruit.com/raspberry-pi-kernel-o-matic/overview

Make sure that you have SSH installed first. Also I had a couple of questions and they got back to me right away. Took a LONG time to install Cygwin (SSH) to work with this process.

CharlieZed3 months ago

Great work!

I was wondering if you could provide a circuit diagram for the Power Distribution board in step 8?

cdtaylor51 (author)  CharlieZed3 months ago
I have attached a simple schematic showing how the switches and leds and the Power Distribution and Inverter Board is wired. I hope that this it makes it easier to understand. The connectors on the left side of the schematic get connected to the CNC Controller board. The CNC Controller board provides the four function pins and a ground for each function. Only four of the six inverters in the 7404 chip are used. The connectors in the middle of the schematic represent the 12 pin header that is on the Power Distribution Inverter board and is connected back to the four switches too. The +12V and +5V parts of the schematic represents the power distribution buses on either edge of the board. I connected the power from the external power supply to the rails. I then connected the+5VDC from the rails to the RPi and the Alamode. Followed by connecting the +12VDC to the CNC Controller. Then finally I connected the ground pins for the spindle signals (the three relays) to ground. Again the +12VDC ground is connected to the +5VDC ground. +5V is also the Vcc for the Hex Inverter chip. Let me know if you find anything wrong with my schematic. Good luck on building your own.
PowerInverterBoard.JPG
cdtaylor51 (author)  CharlieZed3 months ago
Thanks for your comment. I thought about a schematic for the power board but it was so simple I didn't do it. You can print big copies of the pictures (both sides) and just build an exact copy of what I did if you want. I will add a schematic in the next couple of days. There is a small schematic showing how the switches and leds are connected that I included in a previous reply too. That might help in the mean time. The other things on the board just simply provide power to different things. There is a +12VDC rail on one side and a +5VDC rail on the other side. Then the grounds are tied together. That is really all there is to it. As I said I will post a schematic in the next few days. I am really busy right now.
cdtaylor51 (author)  cdtaylor513 months ago

Here is the little schematic about how the switches are wired to the functions and to the Hex Inverter (7404 chip) and the leds that are in the swiches. I hope this helps until I can do a complete schematic of the power board.

SwitchWiring.jpg
1-40 of 144Next »