Wednesday, November 24, 2021

3D printer control using OctoPrint

A big portion of our Makerspace is devoted to our fabrication lab (fablab!). 3D printers do the additive manufacturing and the laser cutter handles the subtractive. We currently have five 3D printers running pretty well: four cheaper, smaller Monoprice Select Mini V2s using PLA and a larger Creality Ender 3 that uses PETG. The Minis are maybe five years old now and have more than made up for their initial $200 cost. Even the Ender 3 was good value at ~$350 CAD a few years ago.

I'm still a big believer in running smaller, cheaper 3D printers. This is especially true in an elementary school environment where volume (ie class sizes) dictate production flow. The advantage of one larger, better printer (our Ender 3) is it can handle larger print volume (230mm x 230mm x 250mm) at much higher detail. The technology has advanced enough that cheap printers can be optimized or calibrated easily and can produce dependable prints before maintenance or parts are needed.

Student designs are typically handled through three different platforms. For early primary, we use hand-drawn designs that are converted to vector drawings using Adobe Capture. Simple 3D extrusions can be handled in Illustrator or Inkscape. Older primary use Blox 3D or Reality Composer on iPads. Intermediate students exclusively use Tinkercad, either manipulating 3D shapes or using Codeblocks.

A recent Grade 6 project involved making loaded dice for a Math UnFair project. Students used Tinkercad Codeblocks to create dice with an unfair proportion of outcomes. At a good-quality layer height of 0.175mm using PLA I was able to print a class of 25 dice in about four hours. This rapid production scheme allows for more iterative designs from students and greatly improves the speed of the design cycle.

The Minis apparently have wifi capability but I never bother to use it. Instead, I slice models in Cura and copy the resulting gcode to memory cards that are physically inserted in the printers and started. The Ender 3, however, has OctoPrint installed in addition to its memory card reader.

OctoPrint is a lovely web server built on Raspian and optimized for Raspberry Pis. It's intended as a web frontend for 3D printers physically plugged in. In our case, it runs locally without external connection and is connected to our Ender 3. OctoPrint allows for remote uploading and starting (even slicing!) of files, but I mostly use it to monitor longer print jobs.

Our Ender 3 is optimized for silky-smooth high-quality prints using PETG and mesh bed levelling. As a result, print jobs tend to be quite long. Benchy, for example, takes about 90 minutes! This timelapse was made using Octolapse, a fun plugin for OctoPrint that extrapolates timings for webcam snapshots to make models appear to grow out of the bed. You can configure it to take snapshots at specific times, such as when the extruder is out of the way or simple stop-motion effects.
The built-in timelapse feature of OctoPrint works well too

I used to run OctoPrint on an old Pi 2 Model B but it had quite a bit of lag on it, even when it wasn't communicating with the printer for a printjob. I swapped it out for a Pi 4 and it runs much, much better but that seems to be a bit of overkill. It tends to run quite hot so make sure you check temps using "vcgencmd measure_temp" every so often. There's probably a plugin for that, but it's easy enough creating a bash alias and having it displayed. (Edit: I just installed the Resource Monitor plugin that appears to poll the same info).

A few last tips: 
  • OctoPrint runs headless by default so make sure to have a spare monitor handy to check the IP on boot. 
  • If you're using the official Raspberry Pi imager you can also press Ctrl - Shift - X in the imaging menu to enable SSH, set locale and write wifi SSID login before flashing to a memory card. Very handy if you want to just connect to "http://octopi.local" on boot. 
  • When uploading files do NOT use the "upload to SD" card option; it runs painfully serial slow. You're better off uploading directly to the Pi memory card and running from there.
  • While OctoPrint works great on a Pi it would work similarly well on an old Chromebook. It may even be better since you don't really need the mobility/portability of a Pi, the GPIO pins or power constraints.