Jump to content






Building a Cheap DIY CNC Machine (1st attempt)

Posted by Nathan House, in Completed Projects, CNC 20 July 2011 · 55,834 views

Completed Project CNC
A cheap & easy to build CNC Machine for drilling PCBs

After etching my first Printed Circuit Board (PCB), it immediately became clear that drilling the holes was going to be a problem. Not only are there a lot of holes in most PCBs, but the drill bits are so small that any horizontal movement results in the bit breaking. Although buying a drill press would solve the bit-breaking problem, drilling all those holes will still take a tremendous amount of time. The alternative is a CNC Machine.

Commercial CNC machines cost thousands of dollars, but with effort you can build your own for much less. Thankfully, there are many well-documented hobby CNC projects on the internet to help us through this process. A great source of inspiration for me was "Tom's Easy to build Desktop CNC Mill:"And here are a few more CNC Machine designs that stood out:I have found from experience that starting without plans generally results in great tragedy (at least when I build things). I therefore decided to design the machine in Autodesk Inventor, in order to have detailed building plans to follow. A few pictures of my design are below:


Posted Image

Posted Image

Posted Image

Posted Image


I did not have any experience with Inventor, so I had to teach myself. I didn't go into extreme detail with the Inventor design, like putting every nut and bolt into the assembly, but I was able to see what the machine would end up looking like and also get dimensions of parts from it - which was a great help when I started building it.

To make the seemingly overwhelming task of designing and building a CNC machine more manageable, I broke the project up into sub-projects:

The CNC machine

Design the machine.
  • Sketch the basic design on paper.
  • Model the full machine in Inventor.
Purchase the necessary parts
  • Buy parts using dimensions from Inventor – allowing for a margin of error.
  • Parts for the frame include 2x4's, bolts, nuts, washers, screws, skate bearings, and acrylic (plexiglass).
Build the machine
  • Start by building the frame out of 2x4's.
  • Put the aluminum trim channels on.
  • Build the X & Y axis platforms out of plexiglass (bottom & top decks).
  • Attach bearings to acrylic platforms so they slide securely along trim channels.
  • Etc..
The stepper motor controller
  • This board provides power to the motors and, when told to do so buy the microcontroller, turns the motors in either direction.
  • Read more about the stepper motor controller..
The microcontroller
  • My CNC control system is designed like this: User -> PC -> Microcontroller -> Stepper Motor Controller -> Motors.
  • The PC program (below) sends the hole locations and system commands to the microcontroller, which in turn sends the step signals to the stepper motor controller.
  • Details on the PIC18F4550 microcontroller board.
The software
  • The PC program parses an excellon drill file that the user loads for hole coordinates.
  • After calibration (including adjusting coordinates for board misalignment) the user can start drilling.
  • The PC program is like the "host," controlling everything, sending commands to the microcontroller.
  • More information about the PC program is available here.
Microcontroller firmware
  • The microcontroller is connected to the PC over USB and does only what the PC program tells it to.
  • When hole coordinates are received, step signals are sent to the motors until the drill location is reached, at which point the drill routine is started.
  • When the hole is drilled, the microcontroller lets the PC program know it's ready for the next hole.
  • The PIC18F4550 CNC machine firmware can be downloaded here.
Here are some pictures of the finished machine:


Posted Image

Posted Image

And a video of a test run: (note that I've made a lot of improvements since this video was made, including fixing the extremely annoying freezing problem).

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

Unfortunately I've been having trouble with the accuracy of my machine. It's very precise, but it seems to lose accuracy at certain places on boards. There could be several causes for this:
  • Software - PC software (calculating the hole coordinates), or firmware (the step routine).
  • Electronics - I made all of the electronics myself, including the microcontroller board and stepper motor controllers. There could be a problem with electrical interference, bad PCB design, or who knows what else.
  • Mechanical - I believe the problem is mechanical. I'm using super-cheap threaded rod for my leadscrews and equally inexpensive coupling nuts. My linear rails (trim channel) and ball bearings may also contribute to the problem. I'm planning on running a battery of tests with the machine to try to determine if there's a pattern to the accuracy problems, such as it being inaccurate around the same place every time, which would mean the problem is mechanical.
Although the machine is having some accuracy problems, I feel that it's turned out pretty well. It was extremely cheap to build, a wonderful learning experience, and hopefully with a little tinkering I'll get the accuracy to where it should be so that I can use it to regularly drill PCBs!

The next challenge is to figure out a way to drill boards with different hole sizes and how to change the drill bit on-the-fly!

  • 0



Comments from previous blog:

I m facing certain problems with my cnc machine interfacing with stepper motors ,can i have the program which you have used in your dsesign because my design is almost the same as your.
hope you reply

with regards
yugandhar


Your presentation of your project is very good ,but on your download page none of the programs or code for the
controller are downloadable by that I assume that you don’t intend to provide them, I would like to build one of these but I need the turn key windows ap software as will as the firmware for the uP if you don’t mind, if you intend this as a commerical product then please email requirement to obtain the above.Thanks in advance.
Charles


Thanks. No, this isn’t commercial, just a hobby. I am planning on uploading both the PC software and microcontroller firmware. I haven’t done so already because I keep making changes/improvements. I’ll try to clean up the PC software and get it uploaded soon.

I’m rewriting the step routine in the microcontroller software because the stepper motors were losing steps. I think this was because the program didn’t “ramp up” the speed of the motors (they just always ran at the same speed).

I may not get all of this finished for a few weeks because of final exams.


Your design is pretty good and your presentation of it on here is very good. I read in a PICList post that your are working on the accuracy. One thing you will need to do is switch from wood to steel for the base. Wood is not stable at all and will allow too much variation. If you are getting +/-14 mils accuracy now that is better than I would have thought with the wooded base. You also need to be certain that the base is fairly heavy, relative to the size of the overall machine of course. That weight will reduce vibration and help with your accuracy. I am not a fan of stepper motors but they are cheaper than genuine servo motors and drives so I agree with using them on this project. You should be able to get around +/- 1 to 5 mils accuracy with them and a more stable base. Oh, I guess I need to tell you a little something about me, I have been a CNC specialist in the industrial woodworking and plastics fabrication industry for the past 26 years or so. I am semi-retired and just do some consulting now. The one thing I have learned over those years is that you must start with a stable base or else you won’t be able to obtain any real degree of accuracy.

Randy Abernathy


Love the mill design, and congratulations on getting it up and running.

You may be interested at the conversation we are having over at:
http://www.cnczone.c...html#post878877

I notice your code doesn’t use Bresenham so the drill doesn’t follow a straight line from point to point… not that this matters for your application, but it would prevent it’s being used as a mill, and the solution isn’t terribly difficult.

Also, your ramping doesn’t provide constant acceleration, which is an error I’ve made myself: Lets say you have a motor that is already running at 1 step per 500uS. If you change the step rate to 1 per 250uS, it’s running twice as fast, right? And that was a change of 250uS per step. If you change it to 1000uS (1mS) it’s running half as fast. But that was a change of 500uS per step. Is that where the difference comes in? As your time between steps is decreased, the same change in step delay is a greater percentage of the total delay, and so has a greater effect on the speed of the motor. And that assumes you change the step delay ever constant time interval.. if you change it every step, then the problem is worse because the same change is being made more often when it also has a great effect; when the step delay is slower…

I think there are good solutions to that problem, but so far all of them involve tables and more computing power in the firmware than I have available in the little PIC board I’m using. In YOUR board, that PIC can probably do the math required or just store a huge table.

I’ll be very interested to see where you go from here.


Thanks for both your comments.

The problem with switching to a steel base is that it would cost a lot more. The wooden base seems to handle the vibrations well, but the top part of the machine (the z-axis) is not sturdy at all and is definitely affected by the vibrations. I’m designing another cheap CNC machine right now that has a more typical gantry and will hopefully be much sturdier.

James, you’re right that the ramping is not linear. I’m “new” to using stepper motors and was under the impression that a non-linear acceleration ramp was OK. Maybe it’s not?


hello,
i went thro whole project found very intresting. But i really need it for actual pcb drilling for the pcb’s i make for my projects. have u overcome the accuracy problem stated ? or can u suggest some other diy design.

thanks

deepak


I believe there are three causes for my accuracy problems.

1. The top part of the machine, where the dremel is attached, is not stable enough. When the dremel is running the whole top part vibrates and this probably messes with the accuracy.

2. Calibrating the machine with the software I wrote is kind of hard, and it’s easy to not get it calibrated well. I’m not sure how software like Mach3 handles the calibration, or if it’s any better, but the could affect the accuracy as well.

3. I think using aluminum trim channel and skate bearings as the linear rails might also be hurting the machine’s accuracy. Check out my post on using drill rod instead: http://robotenthusia...-cnc-machines/. I’m planning on trying something similar to that idea (or maybe the exact idea) this summer. I started a discussion on CNC Zone about this: http://www.cnczone.c...would_work.html

    • 0
  • Report
Hi

Dear Sir,

Can you make for me Hex file and Program C code for PIC18F4550 USB * open source
I want to make CNC machine 4 Axis (Stepper Motor) Running on the computer by USB
Similar to those on this site:
http://www.planet-cnc.com/
You may find this site an open source files
But I am Beginner in the field of electronics
All I want to make a pic with my own program
Can you help me

My Email: bold25@live.com
Best regards
Bold
    • 0
  • Report
may i know what software do you used in this project?thanks a lot for this wonderful project.
    • 0
  • Report

may i know what software do you used in this project?thanks a lot for this wonderful project.


Hi, thanks for your comment.

The PC software is available in the downloads section (here: CNC Controller), as is the PIC18F4550 firmware (here: PIC18F4550 - CNC Machine firmware).
    • 0
  • Report
    • 0
  • Report

Sorry, I 'm new to the world of pics, and I would love to know which file is the one that loads in the pic 18F4550 , in the folder you've shared

    • 0
  • Report

Hi Alejandro,

 

This is the code I put on the PIC: http://www.foxytroni...chine-firmware/

 

Hope that helps!

    • 0
  • Report