# "Self-Replicating" 3D Printers: Complex Designs with OpenSCAD

CS 480: Robotics & 3D Printing Lecture, Dr. Lawlor

Here are the OpenSCAD designs we built in class last time:
• Spiky Sphere is a trivial sphere, with plates unioned onto it.
• Switch Head is a switch faceplate, with my face attached.
Generally speaking, the trick to not getting overwhelmed in an OpenSCAD design is the same trick in programming anything--find the simplest way to break the work into manageable pieces.

One common problem with printed parts is the plastic will crack at high-stress points.  Mechanical engineers will tell you a sharp inside corner acts as a stress riser, so you want to at least bevel, and preferably round off, all your inside corners.  You can do this by unioning a cylinder or torus, but where slanting edges intersect, it can be difficult to compute the location of the cylinder centerline.

One way to simplify complex designs is to switch to 2D outlines, which you then extrude with linear_extrude.  Enlarging a 2D design with offset(r=+3) adds rounded corners to the outside, but moves the outside edges as well.  If you then shrink the design, the outside corners and flat faces are left unchanged, but all the inside corners are rounded.
• offset(r=+3) alone adds rounded outside corners, but shifts walls outward.
• offset(r=-3) alone adds rounded inside corners, but shifts walls inward.
• offset(r=-3) offset(r=+3) rounds all inside corners, but leaves flat walls unchanged.
• offset(r=+3) offset(r=-3) rounds all outside corners, but leaves flat walls unchanged.
This same trick works in 3D, using a minkowski sum with a sphere to compute a positive offset, but minkowski performs poorly on complex shapes, and no simple implementation of a negative offset in 3D exists in OpenSCAD.

## Self-Replicating Printers

There are a number of 3D printer designs that are "self replicating", in the sense that the printer itself consists mostly of printed parts.  Until we can build a semiconductor fabrication printer, you need to add "vitamins" such as control electronics and motors, as distinguished from the "food" like filament that you feed the printer with.

A 3D printer is a fairly complex mechanical device, with lots of moving parts, so 3D printer designs are some of the most complex OpenSCAD programs available.

The Rostock derivative Kossel printer (source code on github, or browseable) is a delta 3D printer.  It's parts are each OpenSCAD files, sharing a common set of named configuration parameters in a small configuration scad file.
• For example, "extra_radius" is a fudge factor added to the hole sizes, to compensate for printer slop.
• "motor_shaft_diameter" is the diameter of the stepper motor shafts.

The Mendel90 printer (source code on github) is a cartesian 3D printer.  Again, each part is an OpenSCAD file, but Chris built a very full-featured configuration and inventory management system.  I was able to use his Mendel90 design to much thicker guide rods and a much bigger print area, in my Alaska90 3D printer.
• Chris uses vectors like classes, so "NEMA17" (a type of stepper) is defined as a list of motor parameters, like shaft diameter, body size, etc.  OpenSCAD definitely needs classes, so you could say NEMA17.width instead of NEMA_width(NEMA17), but this is a decent workaraound.
• This means a statement like "X_motor=NEMA17;" can set a half-dozen parameters in one simple operation.   NEMA_width(X_motor) can then extract the correct value.
• He's defined a bill of materials (BOM) system so the CAD automatically generates a text file listing everything needed to build the printer.  The bom generating methods are:
• stl: calls for an STL output file, which needs to be printed
• assembly / end: surrounds parts for a sub-assembly