Tuesday 8 October 2013

Getting a CNC mill

We've just got hold of a cheap CNC milling machine, which ought to come in handy when building hardware prototypes.

What's a CNC mill?

Everyone's heard of 3D printers. A CNC mill is a bit like a 3D printer in reverse. Instead of building up an object by adding material in layers, a CNC mill starts out with a solid piece of material (a block of wood, aluminium, etc.), and carves away unwanted material until you're left with the finished part. The quality is higher than 3D printing. When Apple sells a high-end product that was 'carved from a single piece of aluminium', they're talking about CNC milling.

Unlike 3D printers, CNC milling machines haven't started to become 'consumerised' yet. You pretty much have to know the machine inside out in order to use it. Fortunately, they aren't particularly complicated machines, and we do appreciate the fundamental simplicity. There are two main bits to understand:

  • A spindle holds an engraving bit. It spins the engraving bit at high speed (like a drill) to carve out material.
  • The spindle can be moved around in three dimensions (X, Y, Z axes) to different co-ordinates by a program script (called G-code) running on a connected PC. When you move the move the spinning engraving bit through a path where a piece of wood happens to be, wood is carved out by the spindle (unless you go too deep too quickly, or forget to spin up the spindle first, in which case you're likely to stall the machine or break something).
    The machine has a set of three motors, one for each axis of motion. Each motor turns a long screw that moves the spindle along its respective axis.

What did we go with?

We went with a YOOCNC 3020 machine. This machine is sold on eBay under a variety of brand names (just search for CNC 3020), and is just about as cheap as you can get a new machine without building your own from scratch. By all accounts, it's a machine loved by amateurs, hated by professionals, and requires the odd few modifications to overcome the inevitable design flaws. We're new to all this, so we haven't been spoiled enough to demand anything better.

Setting up the machine

The CNC machine is controlled by a PC through the parallel port interface that many motherboards no longer include (although there are cheap PCI cards available on eBay that will add a parallel port to any motherboard). The PC must provide the correct impulses in real-time, or else the CNC machine stutters or the PC application that controls it gets out of sync with the machine's actual position. That usually means that you set aside a PC that's dedicated exclusively to CNC work and nothing else.

There's a special Ubuntu-based operating system called LinuxCNC (formerly known as EMC2), which provides software for controlling a CNC machine and uses a customised Linux kernel optimised for the real-time demands of CNC machines.

For controlling the machine, I put together a PC with a 1.5GHz Via C7-D processor, 1GB of RAM, and an old 4.3GB Quantum Bigfoot hard drive that cost around $900 in 1996. I used an older version of LinuxCNC/EMC2 because the new version is based on a more bloated version of Ubuntu). The Via C7 line of CPUs came out a few years ago as a competitor to the Intel Atom. Despite mediocre performance in many desktop and gaming applications, they provide great real-time characteristics which made them well-suited to industrial applications.

Limitations of the machine

On this particular machine, the spindle control is all-manual. You have to flick a switch to turn it on, and slowly rotate a variable control to take it up to full speed. (More expensive machines allow the spindle rotation to be controlled by the computer.) The machine comes with a sticker attached warning you that you'll blow one of the internal fuses if you spin it up too fast:

The emergency stop button on the front panel is purely a software input to the PC through one of the parallel port pins, so if you have it set up correctly, it'll instruct the PC to stop moving the machine along the X, Y, Z axes, but it won't cut the power to the rotating spindle. (Looking inside the controller box though, there is an unused pin header on the power supply board for an emergency stop input for the spindle. Perhaps with a bit of work, the controller box could be modified to incorporate the spindle into the emergency stop.)

A problem we noticed fairly early on is that some engraving dust tends to get sucked into the controller box by the inbuilt cooling fan. We'll discuss this later in another blog post.

Another issue is that there are no limit switches or inputs on the controller box. What does this mean? Well, a CNC machine always knows how to move, say, 52.4mm along the X axis from its current position, but it has no way of knowing its absolute position, or how close it is to slamming into the end of its range of motion and stalling one of the motors (or, in the case of this machine, pinching the Z axis motor cable). Without limit switches, you have to zero (or 'touch-off') the spindle position relative to your work-piece each time you use it. With limit switches, the PC software can automatically home the machine to a default position each time you use it, and automatically ensure that the spindle doesn't go outside an allowed safe range of motion.

The good news is, it is possible to add limit switches to this particular machine: the PCB inside the controller box provides the capability, although there's a bit of soldering required. We'll cover this in another blog post later.

Finally, the documentation leaves a bit to be desired. Parameters are provided for a Windows program called Mach3, but EMC2 requires a few extra parameters. We found we had to start with what was given and work backwards to determine the rest.

No comments:

Post a Comment