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.

Thursday, November 4, 2021

RGB LED Matrix Panel

A while ago I had purchased a cheap LED matrix panel from Adafruit. I had intentions of using it as a scrolling menuboard for our Makerspace vending machine project. I re-discovered it and finally spent some time figuring it out.


The panels are relatively simplistic. Mine had 32 LEDs across and 16 down, totalling 512. They run off 5 volts with a maximum draw of 2.5 amps if all LEDs are on. The data interface is HUB75 with 12 total pinouts: 6 data and 6 control.

My first mistake was using the "official" tutorial Adafruit supplied. I spent some time wiring it with jumper wires to a Raspberry Pi, but of course just like Hal with his light bulb I ended up in a spiralling chicken-and-egg situation of missing power supplies, Linux distros, and diagnosing SSH connections when I forgot to enable it in the first place. I even had to build a HDMI monitor because I forgot how to run headless Pis. Ugh.
All I wanted to do was make a colourful sign...

Once I sorted everything it still didn't work! Unknown to me at the time, the Adafruit wiring diagram was outdated because the RGB libraries had been updated which switched around the wiring!

Long story short, I switched to an Arduino Uno. If you're looking to do a similar project here's what I noticed:
  • Adafruit's RGB Matrix library works well. Make sure you install it in your Arduino library.
  • Arduino Unos work but their limited memory makes flicker-free scrolling text a bit trickier. Either use a Mega or strip down the code to make it fit.
  • Maximum current is 2.5amps but for our static "Makerspace" message the draw was a constant 400mA so I powered the matrix off the Arduino 5V pin. I wouldn't recommend this if you have more LEDs lighting up since the maximum draw off the 5V pin is between 400mA-900mA.
  • The code uses the function matrix.Color333(r, g, b) to specify a colour of the LED. The range is from 0-7, so red is 7,0,0 and white is 7,7,7.
  • Ardunio Cloud's limit of 200 seconds/day in compile time is not nearly enough. Stick with the physical editor.