Monday, October 12, 2009

It's Alive!

I've made a lot of progress since my last post.  You'll have to read for the long version, but the trailer is that the CNC gantry router is now semi-operational and has been used for an actual project.  Here's how it looks as of last night:


Operable 3-axis gantry router in my garage

Yes, it's still a bit of a mess with wiring all over the place.  You know the old joke such-and-such is the technology of the future and always will be?  There should be some corollary related to cleaning up a  project once its working and begging for new features ("Cleaning up is the next step and always will be?").
The astute observer will notice a few changes since the last post.  The long 3rd axis which I have designated "Z" is now mounted securely to the overhead gantry and the router is mounted to it.  The especially astute observer will also note that the router mounted is not the $22 harbor freight special I mentioned in my last post but a $80 DeWalt.  I'm sure no one saw that coming. More on this later....


Shot of the mount location for the Z-axis

Mounting the Z axis required a little custom hardware.  As can be seen in the picture above the carriage on the X-axis consists of a flat piece of stainless mounted to the linear bearing below and to the ball screw nut via a bracket on the right (viewing from the front of the machine).  Since the picture I have removed the tall upright piece of aluminum with the big rectangular hole in it along with the black chunk attached to the back of it.  This left the flat piece of stainless with two threaded holes in the top to mount the Z axis with.   The 3rd axis already had a nice custom-milled mount with two screw holes on the bottom so all I needed to connect it to the X axis carriage was a an angle bracket.  Since the 3rd axis is so long and heavy and this joint is fairly critical to the stiffness of the machine, I decided to make this bracket out of 303 stainless rather than aluminum.  I know, probably massive overkill but I have had bad luck with small threads in aluminum stripping anyway and making this block out of stainless solved this problem as well.


An angle-bracket only an engineer could love

I realize it is probably difficult to visualize how it all fits together.  The bracket shown above sits on the flat stainless steel block attached to the x linear bearing.  There is one hole barely visible on the left side of the base of the bracket which is where one of two screws go to attach it to the flat stainless piece. The two holes on the vertical face are threaded to receive screws that penetrate through the 3rd axis mounting bracket.  Anyway, the details aren't terribly important - here's how the assembly looks together:



3rd axis mounted on gantry.  The ball screw which is vertical in the picture is actually the x-axis and the third axis is mounted to the left.  You can see the angle bracket shown in the picture above right in the middle of the picture.  The 3rd axis mounting bracket is the black anodized piece immediately to the left of the angle bracket.
Once the third axis was mounted I had to attach the router to its carriage.  Attaching to the carriage is relatively straightforward as it has 4 threaded holes.  There are a million ways one could hold a router.  I think the solution I came up with is a very good combination of simplicity and rigidity:


The router mount

What you are looking at is an aluminum plate with 4 mounting holes, a 90 degree V-slot on the left half and 4 slots for hose clamps.  Hose clamps are really good at holding round things (like a router housing) and the V-slot functions both to align the router body vertically and to "dig in" a little to keep it from rotating.  When the two hose clamps are tightened down, the router is held very securely.  The four counter-bored holes on the right are for attaching the mount to the Z-axis carriage.

So I originally designed this mount for the cheapo harbor freight roto-zip tool I bought for $22.  I made the mount, put the rotary tool on and started cutting.  After breaking 3 small diameter drill bits trying to drill in a PCB, I took a closer look.  I rotated the bit in the tool slowly and to my horror saw the end wobbling back and forth by as much as 1/8".  My first thought was that the collet was no good so I went to Home Depot and found that the Roto-Zip brand collets do in fact fit in the Harbor Freight knockoff but the runout was as bad or worse.  So pulled the bit and collet out, whipped out a small dial indicator and indicated the inner surface of the collet holder on the tool.  It was about .007" out of concentricity which doesn't sound bad, but is if you consider that this will be multiplied the further out the tool gets.  Then I put the collet in with a tool and measured the runout on the tool.  Same order when considering that I was measuring further from the probable axis of the eccentricity - something like .010-.012".  Then I tightened down the collet nut and the runout went to .038".  So it appears that either the nut or the bearing tapers on the collet is terribly non-concentric on this tool and when you tighten it down it just goes to hell.  Rather than screwing anymore with the stupid I think, I just went to Lowes and bought a $80 DeWalt laminate router.


DeWalt laminate router mounted in the holder

The one saving grace of the Harbor Freight tool was that the motor section of it was cylindrical.  Good luck finding a new consumer-grade handheld tool resembling anything close to a pure conic-section these days.  Thank Apple or Ideo or someone but every damn tool I looked at had some big "ergonomic" bump or groove or taper or curve which made holding it mechanically hard.  The DeWalt was the closest but but it's body was still tapered towards the cord-end.  In order to get it mounted with no significant angular misalignment, I clamped the mount plate down on a mill, threw a 1/4" dowel pin the router tool holder and ran it back and forth under a dial indicator.  Initially there was about .8 degree of misalignment, but by shimming the cord-end up with some stiff EPDM rubber, I was able to get this down to less than .1 degree.  I also measured the runout of the tool holder with the same 1/4" dowel pin. At a distance of about an inch from the face of the collet nut, the runout is less than .002" - pretty darn good.  Unfortunately it only has a 1/4" collet so I had to get one of those stupid 1/4"-1/8" adapters for the little tiny 1/8" cutters I bought.  The runout was worse with the adapter, but still a huge amount better than the harbor freight tool.  And the result was that I was able to drill PCB's!...

This was the first thing I cut so I had everything turned down a lot - rapid is slow, feed is slow and I had the router running on 24VDC from teh power supply to keep the speed (and noise) down a bit.  But it worked!

The drilled PCB


I did have a bit of trouble getting the step/in ratio dialed in on the different axis'.  Apparently whoever designed the machine decided it would be a good idea to use 10mm pitch lead screws for the Y and 3rd (my Z) axis but a .2 inch pitch for the X-axis.  The combination of metric and imperial screws made my head hurt for a few minutes and resulted in a few misaligned holes in the above PCB, but I think I have the issue ironed out now.  I don't know what kind of masochistic designer mixes imperial and metric, but note to self - don't do it.  I got the general feeling in looking at the design of the machine this started as that the designer had never touched a machine before but was probably real comfortable plugged into a  CAD station for 8 hours a day.
So high off my first success I embarked on cutting something.  I threw in the cheap, dull and wobbly (yes harbor freight) 1/8" end mill I bought and double-stick taped some balsa wood down the the laminate table I made.


Results are not terribly bad considering the tool.  I switched to a somewhat better small diameter tool and cranked up the feed rate a little.  The result was noticeably better:


Cutting a balsa circle on a cnc router

Finally I decided to do something a little more complex.  The EMC2 website has a very good list of open-source CAM codes.  I have always wanted to try the Inkscape GCode converter plugins so I downloaded the python scripts, threw them in my Inkscape Extensions directory and fired up Inkscape.  It took a little tinkering to get some of the python dependencies right on my Inkscape installation since it includes a lot of pre-compiled shared libraries that I had elsewhere on my system.  Suffice to say it was a slightly aggravating, but not harrowing by any means, experience.  Since GCode is all lines and arcs, the GCode export script will only export paths made of line segments.  So you have to make sure to convert text to paths and bezier paths to line segments only (which is documented on the Inkscape GCode page).  Here's what I came up with:

And here's the result:


Text engraving using Inkscape for Gcode generation


Not bad for a first evening of routing!
The next project (aside from cleaning up wiring of course, ::cough::) is to build a speed control for the router.  To quote my friend John Lawler, the router sounds like a million souls dying when running at full power.  And there are probably a lot of situation where you want a) lower speeds and b) regulated speed control.  Definitely if I decide to try milling some aluminum on the set up.  So the PCB shown drilled above is to do PWM control of the router motor with an AVR Mega32.  I still need to figure out a tachometer scheme for the router motor and one thing I am a bit intrigued by is the techniques described here, here, or here.  The idea of using brush commutation EMI to measure speed occurred to me but of course was not unique and a search on Google Scholar turned up the links above.  I may just try it...

Sunday, September 27, 2009

Building a table-top CNC router

I've been looking for a project to do in my spare time for a while now and the one I've always had on the back of my mind is a 3-axis gantry CNC router. A CNC gantry router would be a really nice tool to do things like cutting and drilling PCB's, machining small aluminum parts and for my wife to surface jeweler's wax with. At work I used EMC2 and some Probotix stepper controllers and stepper motors to retrofit one of our small lathes. It turned out great, was a pleasure to do and ignited an even greater hunger for CNC machinery in me.

A shot of "the thing" after I had taken the imaging mechanism off the X-Y gantry

What finally catalyzed my initiative to begin was a gadget I found at a surplus warehouse in Morgan Hill, CA that was both a huge bargain and about 80% of the hardware I needed to build the thing! I'm a little bummed I didn't take a picture of it before I began stripping it down because it was a pretty interesting contraption that I think came out of
some kind of optical inspection equipment. But you can see a crappy picture of it post-partial-tear-down above.

It consisted of a 2-axis stepper/ball-screw gantry with a high quality computer vision system camera mounted to it facing downward. The camera was pointed through a slotted aperture with about 30 red SMD LED's all around it to illuminate the subject. The whole camera assembly could be swiveled 90 degrees with a rotary pneumatic actuator (so really a 2.5-axis gantry or something). A third stepper/ball-screw axis was separately attached to the base and had a pneumatically actuated gripper to grab whatever was to be inspected I suppose. I imagine the thing came out of an electronics quality control machine in a fab somewhere here in Silicon Valley, but that's just speculation. So here's what I got for my $200 bucks:

  1. 3 good quality Pacific Scientific unipolar stepper motors
  2. 3 working Centent CN0162 microstepping stepper controllers - kind of an old design but those babies were like $500/each new 10-15 years ago.
  3. 3 ball-screw linear axis assemblies with high-quality linear bearings. Ball screws, for those that don't know, are wonderful for CNC because they have almost no backlash. Essentially all high quality CNC machines use ball screws.
  4. A rigid custom-machined aluminum gantry attached to a ~24in x 20in 1/2" aluminum base
X-axis ball screw


Centent CN0162 Microstepping controller (1 of 3)

In addition, I can get about $150 on e-bay for the camera (which I have no use for right now) so the out-of-pocket cost to me was about $50.

The thing that really blows my mind about this thing is how much money was spent making it
initially. Ball screws aren't cheap and all of the sensors and other components are extremely high quality. The whole thing is made of custom milled aluminum parts bolted together. You can see at least 8-10 of these parts on the separate 3rd axis to the right. I did a rough tally of the 3rd party components in the device and I got a number in the $4000-$5000 range. With all the custom machining on top of that, this thing cost somebody $10k+ to build.

Anyway, I mentioned earlier that I had used EMC2 at work retrofit a lathe. The EMC2 LiveCD makes installing it on an old computer brain-dead and the only downside I can see is that you need hardware with a parallel port. In looking around the web a bit I noticed that the hard-core machine retrofitters all use EMC2 for control while the hobby/tinkerer/Arduino crowd are much more attracted to RepRap software and controls. I imagine this is due to the respective origins of the two projects but it's a bit unfortunate because I see some replication of effort between the two projects. Yes, RepRap is a FDM system and EMC2 is a general purpose machine controller, but I've seen at least one project (RepRap Cartesian Bot) doing 3-axis router control with RepRap. I actually really like the new RepRap control architecture but I chose to go with EMC2 because:
  • I'm familiar with it
  • I already have stepper controllers that will be easy to integrate with a parallel port interface
  • It will run a full-featured G-Code program (the RepRap's G-Code interpreter is fairly limited as far as I can see)
  • The AXIS interface to EMC2 is extremely nice and customizable using Python
The eventual goal of the project is to have a full functional 3-axis router that is versatile enough to cut anything from foam to aluminum and is robust enough to do some real precision work.

Progress To-Date

The first thing I set out to do was strip the machine of everything I didn't need for the router and get it set up in my garage with the computer that would be controlling it (my wife's ancient HP from college).

The setup

EMC2 is very well setup for stepper motor control has a nice GUI tool called stepconf wizard for setting up the parallel port I/O and relevant timing for the stepper controllers.

Stepconf wizard. Credit AXIS website.

The Centent controllers have optoisolators on the step and direction inputs and while I suspect the parallel port would have been able to drive them, I went ahead and used a ULN2803 darlington array to drive the optoisolator LED's. The anodes of the optoisolator LEDs are tied to the 5V supply and the step and direction inputs are connected to the cathodes making them ideally suited to be driven with an NPN transistor array such as this.

Schematic of parallel port output buffer

After a bit of tinkering and one fried 7805 voltage regulator, I got the all three axis of working with EMC2.

The prototype wiring. The ULN2803 and 7805 voltage regulator are both soldered to the prototyping PCB on the right. It will be cleaned up later...

Just for the heck of it I taped a permanent marker to the gantry and used it to draw the EMC2 AXIS logo. It came out surprisingly well considering the marker was not held very well and the cardboard was flexing in the middle.

Worlds worst pen-plotter

Check out the video...


Future...
The next step is to make a rigid mount for the third (Z) axis on the gantry assembly. The third axis is pretty heavy as it exists now and I'm a little concerned about whether the XY axis will be able to control that much momentum. If worse comes to worst, I can machine off a lot of the material on the Z axis or even shorten it a bit to make it lighter.

The z-axis is a heavy beast

I spent a long time thinking about what to use for the spindle. On e-bay you can find some high power water-cooled router spindles but they're a bit pricey and, because they are 3 phase, require a variable frequency 3 phase drive. A water cooling system is not the end of the world, but it adds complexity. Dremel tools are often used, but they're probably underpowered and possibly not up to machining aluminum. I was at Harbor Freight the other day and saw this "Electric Cutout Tool" for $25. They also have a small handheld router for $22. Now I'm not saying that these are any more up to serious cutting than a dremel tool, but the cutout tool has a 1/2 hp motor in it and for $25, how can you go wrong?

The $25 harbor fright, I mean freight, special. What could go wrong??

Once I finish mounting the 3rd axis to the XY gantry, I will work on mounting the cutout saw. Because the saw uses a universal motor, doing speed control with a microcontroller should be fairly straightforward. I'm planning to use an AVR to do feedback speed control using speed set points from EMC2. I will probably used rectified PWM control rather than phase delay AC control in order to get better control properties and higher torque. I may even make the control board Arduino compatible... but we'll see. More on this little sub-project later.