Who ate too much Pi?

Calibration, that’s what you need.  If you want to be the best, if you want to beat the rest, oh-ho-ho, calibration’s what you need.  I apologise to anyone too young to remember the TV programme Record Breakers but i couldn’t resist.  Calibration of my printer proceeds apace.  Today I’ve been checking the vertical movement of each carriage independently, and guess what?  If I command them all to move 100mm, they all move slightly different distances.  I think this is down to variations in printed pulley size, but this time I can compensate in the firmware.  So I measured the distance each carriage moved, and calculated the effective pulley diameter which would cause this movement.  That value replaces the nominal one in the firmware, and all is well.

Or it would be, except that I noticed that the value of pi I was using in the firmware was 3.1515926 which as everyone knows, is wrong (it should be 3.1415926).  Yes, if you are picky it should be 3.1415927, but frankly an error in the second decimal place is somewhat more important.  It’s not a huge error (around 0.3%), but it just shows that when you check everything, you should check EVERYTHING.  I wonder how many more little errors are lurking in the system?

Having changed possibly the most fundamental part of the calibration definitions, I now need to go back over the whole printer calibration routine, because the chances are that some of the other tweaks have actually been trying to mask these errors.  What fun.

Eccentricity

Generally regarded as a Good Thing in an Englishman, eccentricity is rarely desirable in pulleys.  The drive mechanism of my printer uses six pulleys, all of which have themselves been printed.  In my ongoing pursuit of accuracy, I have discovered that some of these pulleys are not entirely circular, nor are they mounted entirely concentrically on the motor spindles (though exactly what ‘concentric’ means if the pulley is not circular is perhaps open to debate).  I’d really like to machine some small tolerance parts out of aluminium, but I don’t have access to a lathe (if you’ve got one, I’d love to use it for an afternoon…).  So how do I work with what I’ve got?  I need some way of ensuring circularity and accuracy of diameter.  The material is PLA, so it’s not too difficult to shape; I should be able to use the stepper motor itself as a lathe spindle, and turn the pulley in place.  My Idea is to print a bracket which will allow me to mount a dial gauge for measuring the pulley, and a makeshift cutting tool to pare it down.  I designed and printed one.

P1000705

Wonder of wonders, it printed pretty well!  I must be doing something right.  Now I can measure the variation in the pulley radius as it rotates:

P1000725

It turns out that the deviation is about half a millimeter over a full revolution.  Not, perhaps, a huge amount, but on a 20mm diameter pulley this is 2.5%. This does not mean that over a 100mm movement the carriage will move 2.5mm to much or too little – indeed, it’s possible that it could be completely accurate at specific points – but the linear motion will not be consistent with relation to the stepper motor steps.  Straight lines will wobble.  So now all (all?) I need to do is to drive the stepper motors at constant speed and pare down the pulleys to a constant and known diameter, than that’s one more inaccuracy removed.  We’ll see how that goes.

Concerning calibration

Or, Why You Should Always Listen To People Who Know More Than You.

There are many 3D printer designs out there.  I took ideas from some of them, and designed my own.  I’ve built it, and it kind of works.  My prints are dogged by a number of problems.  Principle amongst these has been a distinct slant to all the printed items (and by ‘distinct’, what I really mean is ‘45 degrees’).  This is not conducive to making precision parts for sundry other projects, which is the main purpose of the printer.  After fiddling round the edges for a while, and managing occasionally to get half-decent small prints, I realised it was time to do it properly.

In building my printer, I knew I would not have access to precision tools.  Any parts I made would be cut by hand with a saw.  Holes would be drilled with a hand-held drill.  High accuracy was not going to be the order of the day.  I naively didn’t think that this would be a problem – the machine is software controlled, after all, and it should be possible to account for misalignment of parts by judiciously tweaking the code.  It’s only software, after all.

This approach is feasible.  Software is flexible, and all sorts of hardware faults can be catered for in the software.  If, that is (and this is a big ‘if’) you know what they are.  Without accurate measuring tools, how do you know what errors need to be accommodated?  With the infinite flexibility that software configuration offers, it’s easy to get into a situation where more and more settings can be tweaked, but the settings become pure guesswork.  If something prints successfully, you don’t really know why, but you use those settings next time.  Post hoc ergo propter hoc

Also, adding all those settings involves time and effort.  Especially if you are using printer control firmware written by someone else, and you have to hack new tweaks into it.  This is labour that could be better used reducing the errors in the system rather than trying to accommodate them.

The better way

I’ve come to the staggering conclusion that it’s best to get the hardware as accurate as possible first.  To most people (including may writing on the web) this is blindingly obvious.  It took me a little longer to realise.  Having finally got the idea through my thick skull, though I set about re-engineering the hardware.  Firstly, I disassembled the arms and print head, and measured everything as accurately as I could.  It turned out that two of the delta arms were 1mm longer than the rest.  I picked one arm to use as a reference (and marked it) and reworked all the others so that they were as close to the same length as I could make them.  I estimate variation to be no more than +-0.1mm now.  Everything else seemed to be correct, so I reassembled it all.  Not much change there, really.  I then used a try square to adjust the print bed to be as perpendicular as I could to the vertical beams.  I had previously been adjusting this to try and level the prints, when really I should have been adjusting the print mechanism to move parallel to it.  Too many adjustment points, not enough logic.

The second part of the process is to use a consistent and structured set of steps to calibrate the system in a repeatable manner.  I found a nice article on how to do this sensibly, from which I quote: “First, and foremost, build your printer as accurately as you can.”  I second that.  In the article, much of the calibration is done with small adjustments to the carriage end-stop screws.  Well, my design doesn’t have them.  I can shift the end stops, but not under fine control.  I thought I would do this in software.  So I needed to add adjusters to my carriages.  How could I make them?  If only I had a 3D printer…

The nice thing about small, non-precision parts is that the calibration errors don’t show themselves quite so much.  So I was able to print three small blocks with holes to allow me to add adjustment screws to the carriages. 

P1000592

These are the first parts I’ve printed which actually form part of the printer itself.  A small achievement, but quite a satisfying one. 

P1000599

With the new adjusters in place (superglue is a wonderful thing), and following the calibration plan closely,  I’ve finally managed to print some things which are (almost) straight and (almost) the right size.  Here’s a print head, straight after printing and before tidying up.

P1000608

It’s not perfect.  I’ve still got some tweaking to do with feed rates, temperatures and so on, but the RepRap Wiki has an excellent guide to printing problems which should help me sort these out.  Things are definitely looking up, and I should be producing upgraded parts for the printer itself Real Soon Now.

Solid printing at last!

The hot end is assembled and fitted.  The filament drive extruder is assembled and fitted.  Even the LCD panel is fitted and (mostly) working.  this means that I can now print solid plastic parts.  In theory.  In practice, there are teething troubles.

  1. Levelling the bed.  Layers of plastic must be deposited at thicknesses of less than 0.35mm.  If the print bed is not level with respect to the print head motion, then it might, at different points on the bed area, print in mid-air (bad), or drive the print head into the print bed (bad), or simply print too thin a layer (bad but not terrible).  I’ve made a bit of a rod for my own back by giving my print bed three adjustment screws, but it is doable.
  2. Calibrating the print head motion.  This is still not quite right.  Assuming that the glass print plate is flat (and it’s float glass, so it should be), then my print head seems to move in Z (the vertical axis) slightly as it travels over the X and Y axes.  It’s as if the notional Z-plane is a very slight dome, higher in the centre.  This makes printing larger objects (more than about 100mm diameter) impossible at present.  It’s undoubtedly fixable, but may require a software tweak.
  3. Ensuring that the extruder drive doesn’t slip.  This has been a big problem.  Forcing a plastic filament down a PTFE tube and through a heated nozzle only a fifth of its diameter actually takes quite a bit of force.  The extruder drive pushes the filament by pressing a rotating knurled wheel against it.  The problem is that if the resistance from the nozzle is too great (for example, if the clearance between the print head and the print plate is too small, leaving no room for the hot plastic) then the knurled wheel rotates and grinds into the filament rather than pushing it along.  This means no molten plastic at the print head, and a failed print.  Careful adjustment of the force on the filament seems to have fixed this for now.

Having said all that, I have actually managed to print something:

P1000557

It’s not really that impressive.  A simple 10mm cube, cunningly printed in blue plastic on blue masking tape, so it’s hard to see.  Careful positioning of the ruler ensures that you can’t see that it actually came out 9mm in each dimension.  Did I mention that calibration is still an issue?

Flushed with success printing a tiny cube, I thought I’d try something bigger.  One of the printer’s own components, in fact.  The next picture shows two versions of the pen-holder used to replace the hot end while I was testing.  No prizes for guessing which one I printed, and which came from  Rob’s printer.

P1000571

Still, it’s a start.  For scale, here is the part in the printer, just finished:

P1000569

Initially flushed with success, I spent the next few days completely unable to get the printer to do anything but produce failed prints.  Here’s the sort of thing I mean:

P1000573

The problem here is that the first layer of plastic hasn’t stuck properly to the print bed, leaving holes (not the round ones, they are deliberate).  Or possibly the extruder drive mechanism has slipped.  Or both.  Either way, it’s junk.  I have quite a few of those.  Gradual tweaking and experimentation has improved matters now, though, and I have managed to print out some reasonable parts:

P1000575

These are two copies of the same object (actually part of the print mechanism), using different layer thicknesses.  The further of the two uses thinner layers.  It takes longer to print, but is much more successful.  For scale, the holes you see in the parts are 3mm diameter.  These are quite small parts.  The layers in the better print are 0.2mm thick.  With a bit of sanding to remove the rough edges, this part should be quite usable.  It will be amusing to replace the printer’s parts with items it has printed itself.

Some like it hot

Over the last couple of weeks, I’ve got the printer to a point where I can send it G-Code commands in the reasonable expectation of it carrying them out.  At the moment, the print head only has a pen mounted in it, so I can check its positioning, but it will draw things on a piece of paper.  There’s a rather poor quality video of it doing a calibration test print (or should that be a test plot?) here: http://www.youtube.com/watch?v=oY7v93ZDG_8.  There is still a little bit of levelling to do on the glass plate which acts as the print bed, and I need to come up with a good strategy for calibrating the print head position, but it’s ready for the next step.

Now that I’m finally reasonably confident that the printer is capable of enough accuracy and repeatability, it’s time to make it actually squirt plastic.  For this I need a roll of plastic filament, a ‘hot end’ to melt it and deliver it through a tiny nozzle, and a mechanism to push the filament through the hot end (an extruder).  This is a delta configuration printer, and one of its distinguishing features is that the print head is capable of moving very fast.  This is helped by the low weight of the print head.  To keep the weight low, it is desirable not to mount the extruder on the print head (as most cartesian printers do) because it has fairly heavy stepper motor in it.  Instead, the extruder is connected to the print head by means of a flexible PTFE tube through which the filament is pushed, in a Bowden cable-like arrangement.

The hot end parts have arrived.  I’ve gone for a popular design, the J-head Mk V.  In an exploded view, it looks like this:

P1000349

Though it looks a bit complex, it’s actually very simple.  The shiny aluminium cuboid/cone combination is the hot part.  This has a big hole in it in which to mount a power resistor or a heating element (the photo shows both) and a small hole in which to mount the tiny glass bead  thermistor.  The heating element heats the hot part up, and the thermistor measures the temperature.  Both are linked to the controlling arduino, so that the hot end temperature is maintained as close a possible to the optimum for melting the plastic in use.  the beige machined cylinder in the centre of the picture serves as a holder for the hot nozzle, a guide for the filament and as a thermal insulator.  it’s made out of a high-temperature plastic known as PEEK.  The purpose of the slots is to help airflow, so that the mounting end stays cool enough to attach to the print head (which is, in my case, made out of plastic which will melt at the temperature of the hot end) while allowing the hot end to deliver plastic-melting heat the the filament before it gets squirted out of a really tiny (0.35mm) hole.

Rob has very kindly printed the plastic parts for the extruder mechanism:

P1000343

It’s fascinating to see just how far removed we are from conventional manufacturing techniques.  The body of the extruder is a mass of complex shapes, involving curved and tapered surfaces.  It would be a nightmare to make with conventional machinery.  With 3D printing, of course, the shape complexity is almost irrelevant.  If it’s a valid 3D shape, it can be printed (with some minor limitations, like overhangs).   I’m using Airtripper’s design for an extruder, because there is no need to reinvent the wheel.  It requires only three bought-in parts: a couple of small bearings and a toothed pulley which grips and drives the filament.  This last part I have had to order from Denmark, and it seems to be taking some time to arrive.  Watch this space.

Pink plastic printer parts printed

Last weekend, the ever-generous Rob very kindly printed out a whole batch of parts for my 3D printer:

Printer_parts

With the ones he’s already done for me (and a few bearings, nuts and bolts and bit of carbon fibre rod) these comprise enough to build the printer completely, apart from the ‘hot end’.  So that’s what I’ve done over the last few days.  Although the parts were printed to quite high accuracy, with holes in the right places, there was still a fair bit of smoothing, trimming and tapping of holes to be done.  I also had to drill one or two new holes where I had forgotten to design them in.  This is version 1, after all.  The assembled result looks like this:

Printer_assembled

It’s a bit of a monster.  At least I’ll be able to print large things (think ‘traffic cone’) if I want to. 

Here’s a close up of the print head.  The bit in the middle is a holder for a pen, so I can do some tests for accuracy before I fit a hot extruder.

tool_head

I’m sure you want to see it working.  There is a video on YouTube, which shows it moving around at a variety of speeds.  Now I need to get a printing platform in place, hack the Marlin firmware in the controller to support a delta configuration, and start doing some serious tests.

It’s Alive!

Yesterday, Rob very kindly printed a few more components for my 3D printer: a stepper motor mounting bracket, the top end idler pulley bracket, an idler pulley and a drive pulley.  The drive and idler pulleys are version 2 components.  I had to modify them to allow for a phenomenon I’m choosing to call squeezage.  This is the behaviour of molten plastic which causes it to extrude slightly sideways when deposited from above, resulting in circular holes being slightly smaller in diameter than expected.  I don’t have a lathe (yet), so I was unable to modify the version 1 pulleys with enough accuracy to make them fit the bearing and shaft.  Here are the new components:

WP_20130312_010WP_20130321_001

And here are pictures of them all fitted to the printer frame:

P1120156P1120157P1120152

As you have doubtless come to expect, most of the pictures (the ones not taken with a phone) are blurred because of my camera’s focusing fault.  I really must buy a new camera.

This morning I fitted the high-strength fishing line I’m using in place of a drive belt, set the tensioner in place, temporarily wired up the controller board and fired up Pronterface to see if I could make the carriage move up and down.  Astonishingly, everything just worked.  You can see a (rather dull) video of it on YouTube if you really have nothing better to do.  If you can bear to watch right to the end of the video (it’s only a couple of minutes), you’ll get some idea of the size of the printer.  It’s a bit bigger than I originally intended – but if I ever need to print something the size of a traffic cone, I’ll be well set up.

The next step is to do some tests to see how accurate and repeatable the motion is.  When I’m satisfied with that, I’ll fit the other two sets of drive components, and then it will be time to connect up the print head and its support arms.  Watch this space.

When good cameras go bad

“Fuzzy” is a word that should only ever be applied to felt.  Ignoring the colour, can you spot the difference between the two images below?  They are scaled down, but if you click on them you should get a larger version of each.

Panasoniccanon

Obviously, the one on the left is out of focus.  Both photos were taken of the same target, at the same distance.  The sharp one one is taken with my wife’s Canon Ixus 105, and the fuzzy one with my Panasonic Lumix TZ7.  For some reason, my camera has decided to stop taking clear photos and has taken it upon itself to do everything in soft focus.  It’s impossible to see this in the (relatively low resolution) viewfinder, but it’s obvious when you look a the full size image.  I’ve tried every setting on the camera, and every factory reset possible.  The lens is clean, and nothing seems to be jammed or problematic.  The thing simply won’t take sharp pictures.  Just to add insult to injury, here’s the same picture taken with my phone camera (using the phone’s built in ‘flash’, which causes the horrible reflection):

phone

The upshot is that I am no longer able to take pictures with my camera which are good enough to post here.  This is irritating, because I’ve got progress on the printer which is just dying to be documented.  I guess I’ll just have to buy a new camera.

Scary maths

Or how to convert from x,y,z coordinates to delta robot position

With a simple cartesian robot (or printer), the mechanism moves directly along rails in each of the x, y and z directions.  If you want to move a print head from the origin to, say, (10,10,20) you simply direct the motors to move it 10mm along the x axis rail, 10 along the y axis rail and 20 along the z.  You get the idea.  With a delta configuration, it’s not so simple.  Moving any one of the carriages which run up and down the three vertical struts will cause movement of the tool head in x,y and z simultaneously.  Calculations are required to work out how to move all three carriages at the same time to move the print head to the right place.  Fortunately, they are not too hard (and don’t need too much processor power for the Arduino to cope with).

Suppose we want to move the extruder nozzle to a particular point.  We’ll call this the tool position, and it will have coordinates (tx,ty,tz).  We want to calculate the positions of the three carriages (the bits that move up and down the struts) based on the tool head position.  We’ll call the carriages A, B and C.  Looking down from the top of the printer, Carriage A is on the X axis, carriage B is 120° anti-clockwise from A, and Carriage C is 240° anti-clockwise from A.  The positions of A, B and C are:

A2 = (a2x,a2y,a2z),
B2 = (b2x,b2y,b2z) and
C2 = (c2x,c2y,c2z).

The diagram below shows this a bit more clearly:

image

Because we know that the arm length (la) is fixed and that the carriages can only move up and down (so we always know their x and y coordinates) we can calculate the carriage positions from some simple trigonometry.  First, we need to know the positions of the other ends of the arms (which I’m calling the the pivot points).  These are

A1 = (a1x,a1y,a1z),
B1 = (b1x,b1y,b1z) and
C1 = (c1x,c1y,c1z).

The diagram below shows how we can calculate these.  It’s a schematic view of the tool head, looking down from above.  We have to take into account the distance between the extruder nozzle and the pivot points, because it’s a finite size:

image

Pivot A

Pivot B

Pivot C

a1x = tx + po
a1y = ty
a1z = tz + to
b1x = tx + po * cos(120)
b1y = ty + po * sin(120)
b1z = tz + to

c1x = tx + po * cos(240)
c1y = ty + po * sin(240)
c1z = tz + to

Once we know the locations of the pivot points, it’s straightforward to use Pythagoras’ theorem to calculate the distance in the x-y plane from the pivot to the carriage, and then use Pythagoras again to calculate the height the carriage must be above the pivot.  the next diagram shows the geometry, looking at it side-on:

image

Firstly, we know the carriage head positions in x and y, because they are fixed to the strut positions:

Carriage A

Carriage B

Carriage C

a2x = sp
a2y = 0
a2z = ?
b2x = sp * cos(120)
b1y = sp * sin(120)
b2z = ?

c2x = sp * cos(240)
c2y = sp * sin(240)
c2z=?

The x-y plane distances of the pivots to the struts are given by:

aa = sqrt((a2x-a1x)*(a2x-a1x) + (a2y-a1y)*(a2y-a1y))
ab = sqrt((b2x-b1x)*(b2x-b1x) + (b2y-b1y)*(b2y-b1y))
ac = sqrt((c2x-c1x)*(c2x-c1x) + (c2y-c1y)*(c2y-c1y))

And then the heights of the carriages above the pivot are calculated thus:

ha = sqrt((la*la) – (aa*aa))
hb = sqrt((la*la) – (ab*ab))
hc = sqrt((la*la) – (ac*ac))

so the heights of carriages above the floor of the printer (which is what we wanted to find), are then simply

a2z = tz + to + ha
b2z = tz + to + hb
c2z = tz + to + hc

And there it is.  The maths isn’t particularly hard, and I’ve described it in a procedural way to make it easy to implement in code should you so desire.  Calculating the other way (determining the nozzle position starting with the positions of the carriages) is harder, because it its necessary to calculate the intersection point of three spheres.  Fortunately, we don’t need to do that to drive a printer!