Basic 3d Printing with OpenScad

In Geometry we’re using OpenScad to create basic, 3d geometric solids and printing them to get to know the 3d printers.

A basic example is creating a cylinder with a radius of 10 mm and a height of 5 mm. The code in OpenScad looks like this (OpenScad Cheat Sheet):

cylinder(r=10, h=5);

and it looks like:

A simple cylinder in OpenScad

After we Render the object, we export it as a 3d .stl file. This we can load into the 3d printer software.

  • For our smaller, Prusa, printer, the program is PrusaSlicer. You’ll need to slice the object and then export the G-code. The program that actually prints the object is Pronterface.
  • For the larger Lulzbot printer, we use the Cura program and can print directly from the software once we’ve sliced the model.

The end result, on the Prusa printer looks like this:

3d Printable Microscopes

A few interesting, low-cost but potentially lab-grade, microscopes that would be great Makerspace projects for students.

OpenFlexure: Out of the University of Bath, this has a Raspberry Pi at the core that can control the stage, focus, and sensor (using the RPi camera module). Since it’s modular the cost varies with the image quality you’re aiming for, but it looks like you can achieve even high resolution results relatively cheaply. They have great detail on their website, including their own version of Raspbian to install on the Pi, so this looks like an good starter project.

UC2: I really like the look of this building block, LEGO-style, system. It seems extremely flexible and there are some interesting projects that go beyond your standard microscope. There are a lot of designs you can go with, including an Arduino or using a Raspberry Pi and camera, but they claim to get good results just with smartphones. This is a big, sprawling project, which suggests a slightly steeper learning curve.

Hat tip to Maggie Eisenberger for introducing me to these.

Volumes of Revolution

3D printed volumes.
3D printed volumes.

It can be tricky explaining what you mean when you say to take a function and rotate it about the x-axis to create a volume. So, I made an OpenScad program to make 3d prints of functions, including having it subtract one function from another. I also 3d printed a set of axes to mount the volumes on (and a set of cross-sections of the volumes being rotated.

The picture above are the functions Mrs. C. gave her calculus class on a recent worksheet. Specifically:

 y = e^{-x}+2

from which is subtracted:

 y = 0.5 x

Chessboard Project

The chess board.
The chess board.

For our annual fundraiser’s silent auction, I made a chess board. The structure was made of wood–I learned how to use dowels to attach the sides–but the black squares were cut out of the material they use for matting the borders of pictures. My student drew “cheat sheet” diagrams of each of the black squares in bright gel pen colors. The squares were laid on a white grid and the entire top epoxied with a clear glass-like coat. We also made two sets of chess pieces with the 3d printer (rounds versus squares).

It turned out quite well.

Chess board with 3d printed pieces.
Chess board with 3d printed pieces.

Transformations and 3D Printing

My pre-algebra class is working on transformations, so it seemed a good opportunity to try some 3d printing. I showed them how to create basic shapes (sphere, triangle, and box) and how to move them (transform) in a three-dimensional coordinate system using OpenScad.

Students create their car models using OpenScad.
Students create their car models using OpenScad.

Then we started printing them out on our 3d printer. Since it takes about an hour to print each model, we’re printing one or two per day.

The students were quite enthused. The initial OpenScad lesson took about 15 minutes, and I gave them another 55 minutes of class-time to work on them with my help. Now they’re on their own, more or less: they’ll be able to make time if they get their other math work done. A couple of them also came back into the classroom at the end of school today to work on their models.

Our first 3d printed car model.
Our first 3d printed car model.

And I think they learned a bit about transformations in space.

3d Printing at School

The  RepRap 3D printer.
The RepRap 3D printer.

One of the key ideas behind the design of the RepRap 3D printer we just built is that you should be able to print as many of the components as possible. So you can use your 3D printer to build other 3D printers. As a consequence, the printer does not come as a nice little box. It looks a bit jury-rigged. Multicolored coils of wire snake everywhere; circuit boards and integrated chips are exposed; nuts, bolts and stainless steel rods are accessible for easy adjustment; and the plastic–printed–components are still rough from the printer. It is all function, no aesthetics. All of which make it a wonderful teaching tool.

The three students who built it got a crash course in robotic assembly. They learnt how to wire a power source, strip and solder wires, and construct the motor-controlled bed and extruder. They also learned how to use constructive solid geometry (using OpenSCAD) to create 3d shapes–I required them to design and print their own models before I would let them download object files from the internet.

On the down side, though they did have to plug a RAMPS motor shield, stepper-driver chips, and connecting wires into the Arduino microcontroller, we did not have much time to go into the detail of what it all was about. Also, we only edited an existing configuration file when we tried to calibrate the machine, so they did not learn how the programming works. Having to use the Arduino did inspire me to get one, and I was quite impressed with their starter kit, so I’m working on a “Microcontrollers for Beginners” type class or elective that I can offer over the next school year.

OpenSCAD: Creating 3d Objects for Printing

To create a rectangular prism and then take a circle out of the center requires just a few lines of code.
To create a rectangular prism and then take a circle out of the center requires just a few lines of code.

OpenSCAD bills itself as “The Programmers Solid 3D CAD Modeller”. It does this job pretty well, which is probably why I like it so much. Like POV-RAY, which I’ve used before, you create primitive objects–spheres, boxes, cylinders, etc.–and add or subtract them from one another to create the three-dimensional shapes you want.

Unlike the more graphical 3d modeling programs, like SketchUp (which I’ve played with in the past), in OpenSCAD you have to specify in the script the exact dimensions of your primitives, and how to rotate them and translate them to get them where you want them to be in space. This makes it a great language to use in geometry class, or anywhere else you want students to learn about co-ordinate systems.

The script to create the box with a circle cut out of it (see figure above) is:

difference() {
	cube([40,40,50], center=true);
	sphere(25);
}

Vpython requires students of make similar geometric movements of their objects and renders them nicely in 3d, but given the incentive that they can print up a tangible result of their work, I’d be willing to bet that students, especially younger ones, would be quite motivated to work with OpenSCAD. Vpython does retain the advantage that it is able to do animations, while you can only print static objects. In addition, OpenSCAD is more of a scripting language than a programming language like Python (see some of my Vpython programs here).

Student models a "fez" he modelled in OpenSCAD. This was the first object, other than the test cube, that was printed on our 3d printer.
8th grader models a “fez” he modelled in OpenSCAD. This was the first object, other than the test cube, that was printed on our 3d printer.

The OpenSCAD documentation is quite good. I also found it easy to find instructions on how to create a 3d object from a black and white image, simply by extruding it in the third dimension (by iamwil on the Cubehero Blog and by I Heart Robotics).

One note: I’m using OSX 10.6.8 at the moment, and the current version of OpenSCAD does not work on it. Since I’m loathe to upgrade, I had to use the prior release of OpenSCAD-2013.06.dmg.

Building a 3d Printer

Building the printer.
Building the printer.

I took three students to a workshop were we’re building a 3d printer. It’s run out of the Whitfield School. We spend today putting together the electronics to run the five motors we need to get the thing to work, and starting to put the frame together.

The frame is based on the RepRap Prusa i3 (via DIY Tech Shop), and the plastic parts that hold the rods, electronics and other metal bits together are 3d printed themselves.

Students learn to solder.
Students learn to solder.

The motors is run by an Arduino, which is great because I’ve been thinking about using one to operate the doors to the chicken coops.

Notes on hardware

Microcontroller

  • Arduino Mega 2560 R3
  • RAMPS Shield 1.4
  • RepRap StepStick Pololu A4988 (I think) stepper driver (plus heat sinks)

Filament: 1.75 mm PLA