## Saturday 5 February 2011

### Polyholes

When Reprap machines print holes they tend to come out undersized, even if the linear dimensions of an object are spot on. There are several effects that all make holes smaller than they should be: -

Faceting error
When CAD systems convert cylinders to triangles they produce a polygonal prism, so holes represented in an STL file are polygons with their vertices on the circumference of the original circle. That means the sides of the polygon are inside the circle, shrinking it by cos(π / n).
You need 10 vertices to reduce the error to 5% and 22 for 1%. So this error quickly becomes small as n increases but that creates another error:-

Segment pausing
When a circle is broken into a lot of little segments the start up time for a segment becomes significant. Reprap in the past has suffered from this really badly and I am unsure what the current status is. Slow serial comms and complex floating point firmware add pauses where extra filament can ooze from the nozzle.

I have never suffered from pausing because I use a 100Mbit Ethernet connection, which has a very low latency, and the data is transmitted in binary and in the units my firmware works in. This means that no further processing is required other than calculating which of the three axes has to go the furthest. However, I use trapezoidal acceleration on each segment, so for very short segments the average speed will be a little lower.

Arc shrinkage
When a flat strip of filament is bent into an arc there is too much plastic on the inside of the curve and too little on the outside. That makes both the inside and outside edges a smaller diameter than they should be. Adrian calculated a formula for it here: http://reprap.org/wiki/ArcCompensation. The formula comes out with a figure that is too small though. I think there is a secondary effect:

Corner cutting
When filament is dragged round a corner it likes to take a short-cut. This depends on how elastic the filament is and how much it is being stretched. I think when the nozzle moves in a circle the filament is continually trying to cut the corner and ends up forming a smaller diameter circle. I think this is the dominant effect on my machines.

Obviously, if you lie to Skeinforge about how wide your filament is that will make holes even smaller, but that is just a calibration problem.

Ideally all these effects should be compensated for in the slicing software but what has happened instead recently is that people are using parametric values in OpenScad to tweak the holes to come out right on their machines. That is the wrong approach because when the holes comes out smaller than they should be, without the slicing software compensating for it, then the infill doesn't meet it as tightly as it should do.

When I started printing Prusa Mendel parts I found the values in the configuration file far too big. I have also noticed this when downloading some designs from Thingiverse. That implies that my holes shrink less than a lot of other peoples, which is odd because all the effects above don't depend on the machine, apart from segment  pausing.

Some of the holes in Josef's parts are octagonal. That made me realise that polygons with low vertex counts don't shrink. The inside of the hole is defined by straight lines and they get extruded in the correct place. What does happen though is that the corners of the polygon are rounded. As long as the polygon has a small number of vertices, the corners are far enough from the circle that they can be rounded without impinging on it. The ideal number of vertices is when the corner cutting just meets the circle.

I decided to investigate this using OpenScad. I made a script that generates holes from 1 to 10mm with vertex counts from 3 to 8, 10, 16 and 32. The diameter of the holes is increased to make the polygon edges tangential to the circular hole. I.e. removing the faceting error by dividing by cos(π / n).

difference() {
cube(size = [95,125,3]);
for(i = [1:9]) {
assign(v=[3,4,5,6,7,8,10,16,32][i - 1]) {
assign(shrink =  cos (180 / v)) {
echo(v,shrink);
for(d = [1:9]) {
translate([d * d + 5 - ((v == 3) ? 3 : 0), 13 * i, 0])
cylinder(h= 20, r = (d/2)/shrink, $fn= v); } } } } }  I printed the resulting shape on HydraRaptor and used drill shanks to gauge the hole sizes. Not terribly accurate as the shanks tend to be a little smaller than the tip. I inserted the drills in the highest vertex count hole that it would fit in. A pattern emerged that the seemed to indicate the maximum number of vertices you can have before the hole shrinks is twice the hole size in mm. The only drill I couldn't fit was the 1mm drill because you can't have a polygon with only two sides. The "1mm" triangular hole did at least leave a hole though, whereas higher polygon counts fill in completely. To test this simple rule I made a new shape with holes from 1mm to 10.5mm in 0.5mm steps with the number of vertices set to twice the diameter and the diameter increased by cos(π / n). module polyhole(h, d) { n = max(round(2 * d),3); rotate([0,0,180]) cylinder(h = h, r = (d / 2) / cos (180 / n),$fn = n);
}

difference() {
cube(size = [100,27,3]);
union() {
for(i = [1:10]) {
translate([(i * i + i)/2 + 3 * i , 8,-1])
polyhole(h = 5, d = i);

assign(d = i + 0.5)
translate([(d * d + d)/2 + 3 * d, 19,-1])
polyhole(h = 5, d = d);
}
}
}


I found that all my drills bigger than 1mm fit. The large ones are a snug fit and the smaller ones a little loose, probably because with only a few tangential points touching there is little friction.

These two tests where done on HydraRaptor extruding 0.375mm filament from a 0.4mm nozzle. I printed this the test again on my Mendel with 0.6mm filament through a 0.5mm nozzle and the drills still fit, so it seems universal, at least amongst my machines. It would be interesting to see if others get the same result, so I have put the files on Thingiverse.

My goal is to work out how to print circular holes the correct size, but this seems like a good hack for OpenScad designs to allow holes to come out the right size, regardless of the printer or whether it compensates hole diameters. For example, one would expect circular holes to come out right on a professional printer, so if you have oversized circular holes in your model they will come out too big. However, if you use these low vertex count polygonal holes they should still come out the right size as one would also expect a professional printer to print polygons at least as accurately.

## Monday 10 January 2011

### ABS on PETG

I have been using PET tape on my heated bed for a long time now. It works very well as long as I clean it with acetone about every 100 hours. It does need a high temperature (145°C) for the first layer with some types of ABS though .

It seems to last forever, the only failure mode is that large thick objects with sharp corners can defeat the adhesive and raise blisters at the corners near the edge of the bed. I solve that by building little heat shields to keep the corners warm. I am always on the lookout for something better though. It would be nice to get rid of the lines where the tape butts against itself.

A friend gave me a sheet of 1mm thick PETG to try. I clipped it onto my heated bed, and thinking it would behave like PET tape, I ran a build using the same temperatures.

Big mistake, PET has a glass transition at 75°C so it went soft and floppy. The object stuck to it very well and was hard to remove, but after getting a knife under one corner, it peeled cleanly. However it left an impression in the PETG.

The base of the object is flat but the filaments are more ridged because they sank into the sheet rather than being squashed.

When the sheet cooled down it warped badly, so that was the end of that experiment. I did have a small offcut though so I tried again at 70°C.

This time the object warped badly. It stayed stuck to the PETG but it warped the sheet. The adhesion was less and the object was easily peel-able. The PETG warped where the object was but the rest of it stayed flat. The heat of the object must have been enough to tip it over its glass transition locally. It left an impression, but not as deep as the first time.

The filaments on the bottom were squashed tighter, not as smooth as when using tape.

So a failed experiment. It is a shame because at high temperatures it bonds very well but, unlike PC, it still peels, but it is no good if it doesn't remain rigid. Wikipedia does say that PETG has a lower melting point than PET. It doesn't mention how it affects Tg, but it gives the Tg of PET as 75°C. Odd then that PET tape doesn't go soft at 75°C. My next trial will be Mylar, which is another form of PET (BoPET).

## Friday 31 December 2010

### Frequency limit

I currently do my infill on Mendel at 36mm/s. The machine can go faster but the extruder flow rate maxes out at about 40mm/s when extruding ABS at 0.6mm, so 36 is a good safety margin for reliability and quality.

Although the speed is limited there is no real limit on how fast it can change direction. Suppose you make something 2.4mm wide with 0.5mm filament. E.g. a Mendel spring: -

Each wall will be 0.6mm wide leaving a 1.2mm gap in the middle. That gets filled with a zigzag infill where the head moves to within 0.3mm of each wall, so the head moves about 0.6mm on each stroke. At 36mm/s that makes 30 complete oscillations every second. 30Hz is a pretty high frequency for a mechanical system!

What actually happens is my y-axis starts to resonate. Over a few cycles the amplitude of the oscillation builds up and the infill overshoots the outline leaving a serrated edge.

The torque of a stepper motor is zero at rest and increases as it is displaced, so in that respect it behaves like a spring. That springiness together with the inertia of the rotor gives a resonance at hundreds of Hertz, known as mid band resonance. When the load is rigidly coupled, as in this case, the mass of the load brings the resonant frequency down.

As I don't get any missed steps I think the springiness might actually be in the belt rather than the motor. Timing belts have metal cables in them so that they don't stretch, but that makes them stiff, so they don't like to bend round a tight radius. That means the belt has some springiness being pulled round the pulley. A bigger pulley would be better but that would reduce the effective stiffness of the motor, so might actually make things worse. A lighter bed would be good but I haven't found a way to ensure it is flat without going to 6mm tooling plate.

I fixed the problem in software by slowing down the infill that has a high frequency content. I examine each infill path, one axis at a time, and convert it into a list of lengths between changes in direction. I then find the shortest wavelength over three cycles (less than three cycles is not long enough for the resonance to build up). I do this for X and Y directions and save the shortest of the two wavelengths. When I extrude the path I work out the frequency from the pre-calculated wavelength and the desired speed. I then compare that with a limit for each machine and reduce the speed if the frequency limit would be exceeded. I could have a separate frequency limit for each axis but I don't like the idea that the orientation of an object affects how it builds, so I pick the worst axis when deciding the limit.

I set the frequency limit to 20 Hz on my Mendel and 16 Hz on HydraRaptor. HydraRaptor does not show the overshoot problem, but it makes horrible growling noises and shakes the house. The machines make more interesting noises now because each infill run that hits the limit is extruded at an arbitrary lower speed. The overshoot is completely cured.

The builds are a bit slower and in some cases a long infill path will be slowed down by a short section that is high frequency, often a section between a hole and the outline. A more complicated solution would be to isolate the high frequency section and extrude the rest of the path at full speed.