CNC machine

re-innovation has just taken delivery of a CNC machine (Computer Numerically Controlled, for those who like to know). This machine will help with rapid prototyping of PCBs and cutting holes in enclosures and making parts. This blog post will include all the details relating to setting up and configuring the machine, along with problems encountered along the way. Free open-source programs have been used for the whole implementation, from designing PCBs to controlling the machine.

This CNC machine is a Chinese-made unit bought from a UK based distributor. It is basically a XY plotter, but with a spinning cutting blade, rather than a pen and control over the Z axis so that different depths can be cut.

This was bought as a ‘learning’ machine to drill the holes into the PCBs we produce (which is a very laborious task). I hope to get the machine to also mill PCBs for fast fabrication of prototypes and to cut out component parts and mill holes in enclosures.

I will update this blog post as I go on with more information and problems.

The unit itself seems to be a very robust unit. The parts are thick alunimium with 3 NEMA stepper motors to control the XYZ and a ‘re-furbished’ spindle to hole the drill bits/milling bits.

This work area of the machine is 300mm x 200mm (A4 basically), so this is called a ‘desktop’ CNC.

The controller box seems less well built. I heard something rattling inside and opened it up to find a random nut rolling about inside. Also one of the wires on the power supply was loose (i.e. not screwed in). This was sorted out before the unit was switched on. In the future I might upgrade the motors and controller boards, but I now have it working so I’ll learn some more first.

I decided to use EMC2 as the control software. This is free and open source with a very active user group. EMC2 is an amazing and very powerful CNC controller package (Enhanced Machine Controller).

I found an old Pentium 4 desktop machine and installed Ubuntu 10.04 onto the machine. This worked well.

I then realised that EMC2 must use a real-time kernel (api) as it must have accurate control over the machine. It also means that USB cannot be used to control the unit (except with more circuitry), as there is latency in USB (i.e. it wont do things exactly when you tell it – it might wait a while or be hung up ding something else).

I downloaded the EMC2 live disk. This allows you to install the real-time api with not too much hassle. It took me a long time to do this with quite a lot of messing around, but that was mainly due to my lack of knowledge with Linux. If you download the EMC2 live disk and use that then you should have few problems.

The next part came with sorting out the configuration files for the CNC machine. I was given guidance from the seller to do this. I also managed to find this document which is for the same unit, but with different branding. It has the set-up for MACH3 (a commercial CNC control package, which works for Windows).

My most recent config details are as follows:

****put in the config process and screen captures here****

Success! I managed to get something cut out. I then snapped the routing bit, but hey!

I realised that the distances were not accurate – this was sorted out by changing the number of steps in a revolution until the distance moved was exactly correct. The config files above give the most recent parameters.

I use KiCAD to draw schematics and to produce PCBs. It is another powerful, free, open-source package, which has its own quirks and learning curve, but I will leave that to another post. KiCAD can produce the industry standard ‘Gerber’ files for PCB production. It will also produce ‘Excellon’ type drill files. I encourage you to open these files up in a text editor. They are basically lists of X and Y coordinates where the various holes have to be made. Please note that when producing the drill files you must click the ‘simplified header’ box and unclick the ‘mirror Y direction’. Otherwise the next steps will not work (believe me, this took a long time to figure out, but seems so simple now)

If you use any PCB package that produces ‘Gerber’ files then you should be OK with this process.

g-code is used by the machine

Convert to g-code I found a program called ‘pcb2gcode’. This is terminal based program but works well (again after a load of head-banging and finding little bits of info, hence this post).

First thing to do is to download the ‘pcb2gcode’ tarball from here. When it has downloaded, click on the .tar.gz file. Then click on ‘Extract’ and choose a location to extract to. You must follow this next part exactly, I had trouble as I did things in slightly the wrong order.

Open a terminal. cd to the extract location an enter the pcb2gcode directory. I followed these instructions, which say type:

This might work for you. This did not work for me – I got an error when I tried to ‘make’ the file. The error states: “cannot find the library `/usr/lib/”.

The fix for this is also given on the instruction pages, but I will guide you through it as it was a bit complex to me.

Open this up first. It is a game called Dark Radiant, but obviously they have had the same error and have produced a ‘fixed’ library. To install you must first go to System -> Administration -> Software Sources.

In Ubuntu 10.10, Software sources is hidden, so you need to do the following (from here): Hover the cursor over the Applications/Places/System words. Do a right click and go to ‘Edit Menus’ from that list. Navigate to Administration and click the check box next to software sources. Close that and go back to System -> Administrator and you should now see Software Sources. Click on it and it will open up.

Then click on ‘Other Software’ tab and the click on the ‘Add’ button. Enter ppa:orbweaver/darkradiant as the APT. Then close it and go to ‘Synaptic Package Manager’. Try to find gdk-pixbuf and check the installation or re-inastallation button. This should bring in the slightly updated packages required.

Now – last bit – you must then go to System -> Administrator -> Update Manager and do an update check (this is what I did not do and I kept getting the same error).

Now go back to the package folder (where you extracted pcb2gcode to) and re-type the lines above in a terminal. It should now install. This took me a couple of days to figure it all out.

Edit – 24/2/11

Problem with noise on stepper motors

I found that when the spindle was rotating I would get random noise signals on all axis X,Y and Z. These would move very slightly back a forth. This is obviously not good for accuracy, although you cannot really tell when a straight line is produced. I found this post relating to the problem. Its not so flattering about Chinese machines, but suggested the solution might be to isolate the spindle from the rest of the machine. I tried this as a test and it totally removed the random noise problem.

So I have now insulated the bolts which hold the spindle and this has greatly reduced the noise (although not fully  РI think my insulation is not perfect, its just tape around the bolts). I will look into a more permanent solution).

I have also been looking at other programs to convert DXF files into G code. I found this program (dxf2gcode) and its really nice and simple and just works.

I use Corel Draw for some of my designs, I can export DXF from there, but to make any of the converters work then you must choose one of the early DXF formats, rather than the later autocad ones – this was another nugget of information which would have saved me a couple of hours….

Here are some photos of the machine in action:

Leave a Reply

Your email address will not be published. Required fields are marked *