Dr. Lawlor's Code, Robots, & Things

October 23, 2014

Monkeys, Typewriters, and Shakespeare

Filed under: Random Thoughts — Dr. Lawlor @ 6:39 pm

This Wednesday we did our first ACM student chapter coding challenge, verifying the infinite monkey theorem:

“A monkey pounding keys on a typewriter for an infinite time will eventually generate the complete works of Shakespeare.”

Clearly, we don’t have infinite time, but computers are faster than monkeys, and a virtual monkey doesn’t need bananas or people to clear the typewriter jams (and clean the cage).  Also, the crucial role of “monkey editor” needs to be automated.

Surprisingly, the default C++11 random number generator std::default_random_engine repeats every 4 billion keystrokes, which happens within only a few minutes.  std::mt19937 did not repeat during the duration of this test.

Shakespeare’s word length distribution is approximately:

0 19 101 588 1871 3295 4443 4963 4486 3486 2372 1584 860 476 219 92 39 15 9 7 0 1 0 1 0

That is, there are 0 words with 0 letters, 19 words with one letter (a, i, and other letters counting section titles and abbreviations), 101 two-letter words, etc.

The spacebar is bigger than the other keys, which is good because otherwise the median monkey-word has length 26.  By varying the size of the spacebar, we can set the average word length.

In typing 1.8 trillion keystrokes (on a quad-core machine over the course of a few days), billions of short words were generated, but the longest Shakespearean words generated were only 9 letters long:


This is all of them.  The full bard is 5 million characters long.  Monkeys, get crackin’!

October 13, 2014

Extrusion Multiplier: why your 3D printer won’t print

Filed under: 3D Printing — Dr. Lawlor @ 12:54 am

I’ve realized one single parameter, the extrusion rate multiplier, can control whether your 3D printer makes a brittle, stringy object (multiplier too low); a strong, watertight object (multiplier just right); or just jams up and fails halfway through the print (multiplier too high).  This multiplier is called different things in different slicers, but it’s basically the fudge factor that together with filament diameter determines how much plastic squirts out of the extruder during the print.

  • Multiplier too low: not enough plastic, and the top of the object is missing material (not watertight), the layers split apart easily (they’re not thick enough to bond together well), infill is detached from the object perimeter, and the part is overall undersize.  The printer prints, but often parts detach into a pile of spaghetti, and are too weak to use for anything.

    3D printer stringy brittle object

    Rate multiplier too low–not enough plastic for the layers to fuse into one solid part.  25mm / 1 inch diameter part.

  • Just the right amount of plastic, and the part looks great, with a very subtle “waffle” pattern on top.  The printer works reliably, and the part is strong and has correct dimensions.

    3D printer correct look

    Rate multiplier correct: just the right amount of plastic, part fuses correctly.

  • Multiplier too high: too much plastic, and the part will get wider and wider at each layer as excess material squirts out in all directions.  This results in ugly blobby parts that look like an over-iced cake, increases the size of parts and decreases the size of holes, and makes stringing worse as the head plows through excess plastic.  But eventually (1) excess material sticking up catches the extruder head and tears the part off the bed, or (2) the back pressure on the extruder gets too high and the filament shreds under the drive wheel.  Either way, the printer will continue thinking it’s printing happily while it cooks the filament in the hot end into carbonized char, sometimes clogging it up until you tear the hotend apart and clean out the nozzle.

    3D printer malfunction: too much plastic, lumpy ugly part

    Rate multiplier too high: excess plastic is squirting upward and in all directions. Surface is lumpy and ugly.

These three outcomes can be separated by a multiplier difference of only a few percent!

Here’s how to set the extrusion multiplier in your slicer.  You’ll need to re-slice the part to use the new value.

  • In MakerWare, “Create” a new custom filament profile, “Edit Profile”, under extrusion you’ll find “feedstockMultiplier”.
  • In Slic3r, “Filament” tab, “Extrusion Multiplier” (right below Filament Diameter).
  • In Skeinforge, “Craft”, “Dimension”, “Filament”, “Filament Packing Density (ratio)”.

For ABS, everybody recommends 0.85.  Most of my filament seems to work better around 0.88, but it depends on the color.  Filament that has absorbed humidity from the air boils and bubbles during printing, requiring a multiplier as low as 0.80.  PLA squishes less (see nophead describing the complexities of measuring extrusion rate), so needs a larger value, typically 0.95.  This is all assuming you’ve measured the filament diameter with digital calipers and entered it exactly.

With a correct rate multiplier, the print dimensions are correct.

With a correct rate multiplier, the print dimensions are correct.

3D printer lumpy output

With rate multiplier too high, the part is lumpy, holes are too small and the outside is too big.

There are several complexities here:

  • The amount of plastic needed for the first few layers depends almost completely on your platform height and levelness, not on the feed multiplier.  But the effect of not enough plastic (gaps, poor adhesion) and too much plastic (extra squirting out, extruder problems) are the same.
  • If you print at less than 100% infill, you’ve got space for any extra material to go, so you might be able to bump up the multiplier a few percent without any problems.  I usually use 100% infill, because I want stronger parts, so I have no wiggle room!
  • If you use a big layer height, like 0.3mm or bigger, the multiplier isn’t as crucial because there’s lots of space for extra filament to spread into.  At small layer heights, like 0.2 and especially 0.1mm, the multiplier needs to be perfect.
  • If the part curls at all, the corners pushing up acts like the multiplier is too high.  You can compensate somewhat by knocking a few percent off the multiplier, although you may lose watertightness in flat areas.
  • If the filament diameter changes through the spool (cheap eBay filament, I’m looking at you!), one value won’t be perfect everywhere.  For cheap filament I set the multiplier artificially low by a few percent, and ignore the lack of watertightness.

When people show amazing prints from a “tuned” printer, one of the things they tune is the rate multiplier.  Try it!

Create a free website or blog at WordPress.com.