Sunday, 24 July 2011

Milling about

Since the backlash compensation went in I've had a lot of toothach. I'm not blaming the machine, no, I'm blaming the dentist. The toothache stopped me from doing what I wanted with the project as I've been trying to code the necessary file convertor to drive the machine via an SVG. Reading an SVG in, then recognising the parts of the path element, then figuring out the best way to handle the relative vs absolute coordinate stuff mid-stream (that struck me as quite odd), would normally be all in a day's work for me, but with my head being addled from the pain I only managed to get it completed on Friday night.

Here is the and I am using right now

With said new code in place, I managed to get the machine to draw (pretty accurately) direct from a file.

So, new code in hand I decided it was time to do some real cutting. I added a mount for the dremel, added a clamp to the bed, clamped in some
of the left over perspex from the build, and attempted my first CNC engraving job.

First attempt wasn't too bad, there is quite a bit
of slop as the engraving head was dragged quite quickly across the work so there are some diagonals on the word, but it was nice to see it actually cutting. I've now added a tooling movement rate to the script so it moves slower when it thinks it's cutting.

I tested some aluminium next, but the engraving head was useless at cutting it. This just kept aggravating me until I noticed I did have a milling
bit, a small, ball headed milling bit. So, first thing I did was set up the same run again, but when I did I found the dremel wanted to dive into the work. I didn't understand until
after I'd had to emergency stop the whole operation as
the dremel almost went through the 1.5mm aluminium when it picked up and put down again. It turns out that the battery pack I'd been using to power the steppers had finally got to the point where it could no longer power the Z axis stepper well enough to enable it to lift the heavy dremel out of the work. Of course, these are steppers, so they don't know they have failed, so when it was told to head back down into the work, it duly complied and dug down even further.

I wonder how difficult it would be to add an encoder to each of the axes just to see if I can catch this kind of error quicker. Anyway, for now, I'm just going to wait until I can afford to buy a barrel socket and plug it into an AC adaptor, and also, because of how noisy it is, I'm going to try to find an alternative to the dremel. I have a couple of 24V motors out of a printer which, when tested merely with their already attached drive gears, can cut aluminium. How to add a chuck to these, that's another question.

Wednesday, 20 July 2011

Whoops, posted this in the wrong blog.

(This was posted a while back on my non-CNC blog)

Firstly, update on what I've done:

I soldered myself a stripboard with the h-bridges. I hadn't really thought about how I was going to do it until I reached the point of doing it, so was taken aback when I noticed that my initial plan to mount the ICs in series across the board would have involved a lot of awkward wiring to make it possible to remove the ICs when I move up to a 5 axis. I had a think about it and went totally the other way with the layout, moved the IC sockets to the top of the board (strip lines going across the board from side to side) and just had the signal entering on the left and power lines out on the right. This configuration meant I only had to jump between the tracks the number of times I had to convert from signal to IC and from IC to power (plus a few for power+ and signal+) only 24 wires to solder. Easier to layout too.

Once I had the board ready, I started making sure that the arduino code was up to scratch to drive the three independent steppers. First test was just to pump the same signal to all three, which found a couple of loose connections quickly fixed, and a major issue with forgetting to drill out the tracks between the signal in and power out. I'm glad nothing exploded, but I guess the signal never got anywhere because the stepper was sinking the signal line so it never reached the h-bridge's threshold. Better luck than judgement though.

The first thing I noticed was that the new machine was an order of magnitude more accurate. I made some test scripts with circles as I'd found that normally circles are really hard to do well if your machine is not set up right. There are two reasons for this, a circle relies on very small changes in velocity, and especially around the axes, there is a good chance of any backlash effect being amplified by the very slow motion of the non-dominant motive axis. Also, any code that has to deal with speed control is going to deal with a very small small and a max speed at the same time, stretching the driver's accuracy to the limit.

The new machine does have backlash, about 0.25mm, so I coded up some backlash compensation into my arduino. Basically, this just runs the steppers at full speed in the direction of the motion until it takes up the slack if it detects that there would be any slack to take up before continuing with the real command to move the axes. This seems to work quite well, and you can see it in the video as the sudden spin when an axis slows right down and has to take up the slack before heading slowly in the other direction.

I had a bit of trouble getting the arduino to reliably call back once it had finished working. Sometimes the arduino doesn't call home to say it's finished, and that leaves the script dangling, waiting to issue the next command. I know it's not the arduino stalling as the keyboard exception in my python script (hit Ctrl-C to break the sequence) makes the arduino force the axes to head home if anything goes wrong. So, I made the script have a timeout on waiting for the callback. Now, when it's left hanging, it asks the arduino directly if it has actually finished or just forgot to say so.

Without the software backlash compensation, the circles where terrible, but with it, you can hardly see that there is any backlash at all.

With these software changes, the machine is now mostly working. The next hardware stage is to mount the dremel on the z axis and try cutting rather than drawing. But I think some more software updates first: I think I should try to add some text capability or the ability to import svg paths. Either would be great for any simple 2D engraving, but I think possibly essential for when I get to the next stage of machine rebuilding. The bit where I make the machine make the parts for the 5-axis variant.

So, just to show how noisy it is and also to show the whole setup, live and drawing, including the backlash compensation in full effect, here is a video of the machine... I have yet to name it... drawing some more calibration and test stuff.

Monday, 11 July 2011

Z axis

Got a bit of time at the weekend, so managed to finish of the Z axis on the new metal machine.

I've changed the stepper connections to tubing, X and Z are using some tough plastic fuel line from the RC cars I had, and the Y axis is using some softer stuff (also fuel line, but probably not aged into being hard).

I've got to add the mount for the Dremel (I had anticipated the weight, so I've beefed up the strength of the gantry), put the H-bridges on a PCB so I can control the steppers from my arduino, then write the control software. That should keep me busy for the rest of the week.

Tuesday, 5 July 2011


Okay, so I'm a bit thick. The video of the desktop CNC has the rods connected via rubber tubing, which I don't have, but I had seen nice metal couples, so thought I might make my own.

Two things wrong there. Firstly: making your own CNC couples without a set of taps for making the clamping work, or a drill press for drilling out the holes without masses of error, or some aluminium in the right shape so I don't have to break something, is very very very hard. Secondly, I do have something that resembles rubber tubing. I have quite a bit of heat-shrink tubing that is overwise sitting there staring at me saying "hey, over here. I want to hug your shaft!"

So, tonight, I'm going to drill out proper bolt holes in the beds to lock the polymorph in place, and then I'm going to shrink on the steppers to the studding. That means, apart from software, I'm almost ready for a full XY demo. :)

Monday, 4 July 2011


I took the plunge, bought some stuff, and waited for it to arrive. Saturday afternoon I started, but only after realising I didn't even know where my saw was. I had to pop out for bolts twice, get a new saw, and even a new drill bit (the one I was using bent double, must have been mild steel), but at least most of the expense was on things that are reusable. Unfortunately for me, I don't have many of the tools I need, and the ones I have are Imperial, so almost worse than useless as I'd probably end up mixing and matching and making a mess of everything.

The steppers, the studding (threaded rod), the coupling nuts, the new ICs to power the steppers and the perspex all came by post from eBay sellers. The rest, I picked up from B&Q, and was surprised that it's not all that overly priced.

Working from a plan inspired by the video on how a guy built a CNC from plumbing, I cut, drilled, bolted, and filed until I ended up with an XY bed.

Adding the steppers with aluminium mounts and sticking the locking nuts to the beds with polymorph (polycaprolactone) and superglue (krazy glue or cyanoacrylate for non-US) meant I could test out the steppers.

The only fail so far has been the stepper motors not being gripped enough by the nuts even though they are filled with polymorph and then superglued on. I guess I will have to wait for the taps and dies to arrive so I can make properly grub screw locking connector collars for the stepper shafts and the studding.