Makergear M2 Filament Drive Motor: Status Check

A friend had his Makergear M2 filament drive motor stop driving the filament; the problem turned out to be a severely worn pinion gear on the motor shaft. Perhaps Makergear got a pallet of bad motors, as the problem seems to affect a batch of printers made during the middle of 2013, more or less.

The motor on my printer came off the line in early 2013, if that’s really a date code:

M2 Extruder motor - data sticker
M2 Extruder motor – data sticker

There’s no manufacturer, but the 104022 number matches up with a Kysan motor. The description doesn’t say anything about the interior of the gearbox, but that’s not surprising. The gear ratio is 5.2:1, not the 5:1 I’d been assuming, which gets compensated out later on.

The pinion gear is worn, but not severely, and the three planet gears are in fine shape:

M2 Extruder - planetary gears
M2 Extruder – planetary gears

Slather everything with lithium gear grease, stuff the parts back in place, and it’s all good.

The socket-head set screws may have a bit of threadlock, as they’re firmly set in place, and, as you’d expect, Harbor Freight hex wrenches are made of butter-soft steel that’s totally useless in sizes below about 2.5 mm. In fact, those screws rounded the end of an old Craftsman wrench, so maybe they’re slightly oversize.

Forester Trailer Hitch: Wiring Installation

Unlike the trailer hitch installation instructions, the wiring installation instructions left a bit to be desired. Basically, you can’t get the trim panels off the interior until you know where they hid the snaps and latches, but you can’t find the snaps and latches before you remove the trim panels.

N.B.: this applies to a 2015 Forester. Subaru deliberately moves the connector around for each model and year, for reasons that certainly make sense to them.

Remove everything from the back end of the car that isn’t firmly affixed.

Remove the rivets from the left-side foam block by prying their heads with a big screwdriver; maybe you can get a needlenose pliers under there. They’re surprisingly difficult to get out, due to that nasty barb on the end:

Forester cargo compartment foam block rivet and socket
Forester cargo compartment foam block rivet and socket

Release the left side of the trim strip across the back of the compartment by pulling the front corner forward to unlock the latch that engages the trim panel on the left edge. Then you can pull the strip upward to locate the green rivet about a foot from the left end, stick a screwdriver under there, and pry it out of the frame. I didn’t do that, with the unhappy result that the rivet stayed in the frame:

Forester hatch trim - snap rivet location
Forester hatch trim – snap rivet location

If that happens to you, just pry the rivet out of the frame, slide it into the trim strip, and (when the time comes), ram it back into the frame.

A captive plastic cover over the bolt securing the cargo tiedowns yields to a fingernail, if you know that’s what you must do:

Forester cargo tiedown - screw location
Forester cargo tiedown – screw location

Remove the bolt and tiedown, which greatly simplifies pulling the side trim panel away from the frame:

Forester trailer wiring connector location
Forester trailer wiring connector location

The trailer hitch connector lies tucked far up inside the recess, taped to the wiring harness with blue tape. Slit the tape, pull the connector free, worm the aftermarket wires up in there, latch the connectors together, and reinstall everything in reverse order.

Subaru could, if they wanted to, add a foot of wire to that harness, tape it near the bottom edge of the trim panel, and eliminate half an hour of dealer labor charge. I think I understand why they don’t do that, but I don’t have to like it.

It’s faintly possible that someone with very thin arms could reach the connector without dismantling the butt end of the car, but the fingers on the end of that arm might not have enough strength to latch the connectors.

The electrical box fit neatly against the rear of the compartment, behind the foam block. A bit of razor knife artistry carved a notch for the fuseholder and the wiring coils up neatly inside an existing recess:

Forest trailer hitch - wiring in cargo compartment
Forest trailer hitch – wiring in cargo compartment

Until I install lighted hitch nuts (you could look it up), I think deploying the trailer connector through the hatch makes more sense than running the wiring through one of the holes in the spare tire well and exposing the connector to the elements. I don’t intend to do much trailer hauling …

Generating Button Images With ImageMagick

Starting with the hints and commands at ImageMagick Advanced Techniques for Gel Effects, I came up with a script that spits out colorful gel-flavored buttons:

convert -size 120x64 xc:none -fill red -draw "roundrectangle 10,10 110,54 8,8" \
#display gel_shape.png
convert gel_shape.png \
  \( +clone -alpha extract -blur 0x12 -shade 110x0 \
  -normalize -sigmoidal-contrast 16,60% -evaluate multiply .5\
  -roll +4+8 +clone -compose Screen -composite \) \
  -compose In  -composite \
#display gel_highlight.png
convert gel_highlight.png \
  \( +clone -alpha extract  -blur 0x2 -shade 0x90 -normalize \
  -blur 0x2  +level 60,100%  -alpha On \) \
  -compose Multiply -composite \
#display gel_border.png
convert gel_border.png \
  -font Verdana-Bold  -pointsize 20  -fill white  -stroke black \
  -gravity Center  -annotate 0 "Jelly"  -trim -repage 0x0+7+7 \
  \( +clone -background navy -shadow 80x4+4+4 \) +swap \
  -background snow4  -flatten \
convert gel_button.png -type truecolor Gelly24.bmp
display -resize 300% Gelly24.bmp

I could not ever figure that stuff out on my own.

For some reason, WordPress chokes when uploading the starting shape as a PNG file, so here it is as a JPG with a black border replacing the original transparency:



With the gel highlight:


Adding a border:


Adding text, shadow, and background:


Adding the drop shadow may increase the image size ever so slightly, so the -repage 0x0+7+7 operation may require resetting the exact image size.

The final step converts the PNG image into the 24-bit uncompressed BMP format required by the Adafruit routine that slaps it into the TFT display:

Adafruit TFT display - timing demo
Adafruit TFT display – timing demo

The smaller buttons came directly from The GIMP, with full-frontal manual control over everything. Obviously, that doesn’t scale well for many buttons that should all look pretty much the same, because you want to get your fingers out of the loop.

But, obviously, when you do this on a mass scale, you want better control over the colors and text and suchlike; that’s in the nature of fine tuning when it’s needed.

I’m not entirely convinced I want gel-flavored buttons, but it was a fun exercise.

Saddest Arduino Demo

The Adafruit 2.8 inch TFT Touch Shield for Arduino v2 seems just about ideal for a small control panel, such as one might use with a modified sewing machine. All you need is a few on-screen buttons, a few status display, and a bit of Arduino love: what more could one ask?

So I gimmicked up some small buttons with GIMP, made two large buttons with ImageMagick, and lashed together some Arduino code based on the Adafruit demo:

Adafruit TFT display - timing demo
Adafruit TFT display – timing demo

The picture doesn’t do justice to the display: it’s a nice piece of hardware that produces a crisp image. The moire patterns come from the interaction of TFT display pixels / camera pixels / image resizing.

It’s not obvious from the Adafruit description, but the display is inherently portrait-mode as shown. The (0,0) origin lies in the upper left corner, just over the DC power jack, and screen buffer updates proceed left-to-right, top-to-bottom from there.

The gotcha: even with the Arduino Mega’s hardware SPI, writing the full display requires nearly 4 seconds. Yeah, slow-scan TV in action.  Writing the screen with a solid color requires several seconds.

After commenting out the serial tracing instructions from the Adafruit demo and tweaking a few other things, these timings apply:

Writing background
Elapsed: 3687
Writing six buttons
Elapsed: 529
Overwriting six buttons
Elapsed: 531
Rewriting buttons 10 times
Elapsed: 1767
Overwriting 2 large buttons
Elapsed: 1718

The timings work out to:

  • Background: 240×320 → 48 µs/pixel
  • Smaller buttons: 50×25 → 71 µs/pixel → 88 ms/button
  • Rewriting one button: 71 µs/pixel
  • Larger buttons: 120×64 → 56 µs/pixel → 430 ms/button

The button images come from BMP files on a MicroSD card and 8 KB of RAM won’t suffice for even a small button. Instead, the transfer loop buffers 20 pixels = 60 bytes from the card, writes them to the display, and iterates until it’s done.

Trust me on this: watching the buttons gradually change is depressing.

Yes, it could work as a control panel for the sewing machine, but it doesn’t have nearly the pep we’ve come to expect from touch-screen gadgetry. On the other paw, Arduinos are 8-bit microcontrollers teleported from the mid-90s, when crappy 20×4 LCD panels were pretty much as good as it got.

The SPI hardware clock runs at half the oscillator frequency = 16 MHz/2 = 8 MHz = 125 ns/bit. Clocking a single byte thus requires 1 µs; even allowing that each pixel = 3 bytes = 6 SPI operations, there’s a lot of software overhead ripe for the chopping block. I’d be sorely tempted to write a pair of unrolled loops that read 20 pixels and write 20 pixels with little more than a pointer increment & status spin between successive SPI transfers.

It’ll make hotshot C++ programmers flinch, but splicing all that into a single routine, throwing out all the clipping and error checking, and just getting it done might push the times down around 20 µs/pixel. Admittedly, that’s barely twice as fast, but should be less depressing.

However, even with all that effort, the time required to update the screen will clobber the motor control. You can’t devote a big fraction of a second to rewriting a button at the same time you’re monitoring the pedal position, measuring the motor speed, and updating the control voltage. That’s the same problem that makes Arduino microcontrollers inadequate for contemporary 3D printers: beyond a certain point, the hardware is fighting your efforts, not helping you get things done.

A reasonable workaround: no screen updates while the motor turns, because you shouldn’t have any hands free while you’re sewing.

There’s also no way to make up for not having enough RAM or video hardware. The same display runs full-speed video on a Raspberry Pi…

The Arduino source code, hacked from the Adafruit demo:

// 2.8 inch TFT display exercise
// Crudely hacked from Adafruit demo code: spitftbitmap.ino
// 2014-07-03 Ed Nisley KE4ZNU

  This is our Bitmap drawing example for the Adafruit ILI9341 Breakout and Shield

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution

#include <Adafruit_GFX.h>    // Core graphics library
#include "Adafruit_ILI9341.h" // Hardware-specific library
#include <SPI.h>
#include <SD.h>

#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

#define SD_CS 4

unsigned long MillisNow, MillisThen;

void setup(void) {


  Serial.print(F("Initializing SD card..."));
  if (!SD.begin(SD_CS)) {


void loop() {
  Serial.println(F("Writing background"));
  MillisThen = millis();

  bmpDraw("Test1.bmp", 0, 0);

  MillisNow = millis();
  Serial.print(F("" Elapsed: ""));
  Serial.println(MillisNow - MillisThen);

  Serial.println(F("Writing 6 small buttons"));
  MillisThen = millis();



  MillisNow = millis();
  Serial.print(F("" Elapsed: ""));
  Serial.println(MillisNow - MillisThen);

  Serial.println(F("Overwriting 6 small buttons"));
  MillisThen = millis();



  MillisNow = millis();
  Serial.print(F("" Elapsed: ""));
  Serial.println(MillisNow - MillisThen);

  Serial.println(F("Writing small button 10x2 times"));
  MillisThen = millis();

  for (byte i=0; i<10; i++) {

  MillisNow = millis();
  Serial.print(F("" Elapsed: ""));
  Serial.println(MillisNow - MillisThen);

  Serial.println(F("Overwriting 2 large buttons"));
  MillisThen = millis();  



  MillisNow = millis();
  Serial.print(F("" Elapsed: ""));
  Serial.println(MillisNow - MillisThen);


// This function opens a Windows Bitmap (BMP) file and
// displays it at the given coordinates.  It's sped up
// by reading many pixels worth of data at a time
// (rather than pixel by pixel).  Increasing the buffer
// size takes more of the Arduino's precious RAM but
// makes loading a little faster.  20 pixels seems a
// good balance.

#define BUFFPIXEL 20

void bmpDraw(char *filename, uint8_t x, uint16_t y) {

  File     bmpFile;
  int      bmpWidth, bmpHeight;   // W+H in pixels
  uint8_t  bmpDepth;              // Bit depth (currently must be 24)
  uint32_t bmpImageoffset;        // Start of image data in file
  uint32_t rowSize;               // Not always = bmpWidth; may have padding
  uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
  boolean  goodBmp = false;       // Set to true on valid header parse
  boolean  flip    = true;        // BMP is stored bottom-to-top
  int      w, h, row, col;
  uint8_t  r, g, b;
  uint32_t pos = 0, startTime = millis();

  if((x >= tft.width()) || (y >= tft.height())) return;

//  Serial.println();
//  Serial.print(F("Loading image '"));
//  Serial.print(filename);
//  Serial.println('\'');

  // Open requested file on SD card
  if ((bmpFile = == NULL) {
//    Serial.print(F("File not found"));

  // Parse BMP header
  if(read16(bmpFile) == 0x4D42) { // BMP signature
//    Serial.print(F("File size: "));
//	Serial.println(read32(bmpFile));
    (void)read32(bmpFile); // Read & ignore creator bytes
    bmpImageoffset = read32(bmpFile); // Start of image data
//    Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
    // Read DIB header
//    Serial.print(F("Header size: "));
//	Serial.println(read32(bmpFile));
    bmpWidth  = read32(bmpFile);
    bmpHeight = read32(bmpFile);
    if(read16(bmpFile) == 1) { // # planes -- must be '1'
      bmpDepth = read16(bmpFile); // bits per pixel
//      Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
      if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

        goodBmp = true; // Supported BMP format -- proceed!
//        Serial.print(F("Image size: "));
//        Serial.print(bmpWidth);
//        Serial.print('x');
//        Serial.println(bmpHeight);

        // BMP rows are padded (if needed) to 4-byte boundary
        rowSize = (bmpWidth * 3 + 3) & ~3;

        // If bmpHeight is negative, image is in top-down order.
        // This is not canon but has been observed in the wild.
        if(bmpHeight < 0) {
          bmpHeight = -bmpHeight;
          flip      = false;

        // Crop area to be loaded
        w = bmpWidth;
        h = bmpHeight;
        if((x+w-1) >= tft.width())  w = tft.width()  - x;
        if((y+h-1) >= tft.height()) h = tft.height() - y;

        // Set TFT address window to clipped image bounds
        tft.setAddrWindow(x, y, x+w-1, y+h-1);

        for (row=0; row<h; row++) { // For each scanline...

          // Seek to start of scan line.  It might seem labor-
          // intensive to be doing this on every line, but this
          // method covers a lot of gritty details like cropping
          // and scanline padding.  Also, the seek only takes
          // place if the file position actually needs to change
          // (avoids a lot of cluster math in SD library).
          if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // Bitmap is stored top-to-bottom
            pos = bmpImageoffset + row * rowSize;
          if(bmpFile.position() != pos) { // Need seek?
            buffidx = sizeof(sdbuffer); // Force buffer reload

          for (col=0; col<w; col++) { // For each pixel...
            // Time to read more pixel data?
            if (buffidx >= sizeof(sdbuffer)) { // Indeed
    , sizeof(sdbuffer));
              buffidx = 0; // Set index to beginning

            // Convert pixel from BMP to TFT format, push to display
            b = sdbuffer[buffidx++];
            g = sdbuffer[buffidx++];
            r = sdbuffer[buffidx++];
          } // end pixel
        } // end scanline
//        Serial.print(F("Loaded in "));
//        Serial.print(millis() - startTime);
//        Serial.println("" ms"");
      } // end goodBmp

  if(!goodBmp) Serial.println(F("BMP format not recognized."));

// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.

uint16_t read16(File &f) {
  uint16_t result;
  ((uint8_t *)&result)[0] =; // LSB
  ((uint8_t *)&result)[1] =; // MSB
  return result;

uint32_t read32(File &f) {
  uint32_t result;
  ((uint8_t *)&result)[0] =; // LSB
  ((uint8_t *)&result)[1] =;
  ((uint8_t *)&result)[2] =;
  ((uint8_t *)&result)[3] =; // MSB
  return result;

Interplak Water Jet: End of the Line

The brittle tubing on Mary’s Interplak water jet continued to disintegrate, so I replaced the entire tube with Tygon:

Interplak water jet - interior
Interplak water jet – interior

Nisley’s First Rule of Plumbing: Never, ever look inside the pipes delivering water to your faucet.

Interplak handle - interior view
Interplak handle – interior view

That’s not quite inside the pipes, but it’s pretty grotendous, isn’t it?

As expected, flexible tubing doesn’t transmit the pressure pulses nearly as well as the OEM rigid tubing, so we finally bought a new Waterpik. At least you can get replacement tubing for Waterpiks, but I’ll wait until it fails before stocking up.

Contrary to what you might expect, I cut the Interplak’s cord, harvested the motor windings, and dumped the carcass in the trash.

Turtle Teleportation: Love Road

We spotted another turtle while on a grocery ride:

Turtle on Love Rd - as spotted - 2014-07-02
Turtle on Love Rd – as spotted – 2014-07-02

Although this is certainly meddling in the turtle’s affairs, it seemed reasonable on a torrid day with plenty of hot asphalt to cross:

Turtle on Love Rd - pickup - 2014-07-02
Turtle on Love Rd – pickup – 2014-07-02

I made the (possibly unwarranted) assumption that the turtle wanted to cross the road; I’ve been wrong before.

In any event, this must be what teleportation feels like:

Turtle on Love Rd - delivery - 2014-07-02
Turtle on Love Rd – delivery – 2014-07-02

There’s not really much on that side of the road, other than an inactive oil spill site left over from when Love Oil ran a tank farm. That’s why it’s called Love Rd, of course.

Perhaps someone else will help the turtle cross the road in the other direction…



Forester Trailer Hitch: Installation Notes

Start with loose parts rattling around inside a battered cardboard package:

Trailer hitch receiver - as received
Trailer hitch receiver – as received

I backed the Forester up to put the rear tires over the edge of the garage apron, which provided enough room to work underneath without jacking the thing; there’s a chock under the left front wheel, never fear.

The instructions from were entirely adequate, so there’s not much point in a detailed writeup. Their time estimate (an hour) seems grossly understated, but I wasn’t in any hurry.

A morning of pleasant wrenching produced a good-looking, albeit nearly invisible, result:

Forester trailer hitch - installed
Forester trailer hitch – installed

Both hitches bolt directly to the frame and I have no idea what effect that has on the collision behavior. My guess is that the Subaru hitch would be more bendy, if only because it has a much lower load rating, but that probably doesn’t make much difference.

Some notes:

Remove the muffler, which is trivially easy on a new car, and reuse the crushable gasket, which is probably not recommended. After releasing the muffler, you can ease the mounting pins out of their rubber supports without applying any lube or issuing many curses. The tailpipe remains in place, conveniently away from the proceedings.

As others have noted, remove the heat shield, snip a few square inches from the inside front corner, and reinstall with only three screws. I chopped clearance holes for the hitch bolts using a box cutter, but you could probably just punch them right through the butter-soft aluminum sheet.

The instructions suggest drilling / rasping the center mounting holes to 1-1/8 inch diameter. Being that type of guy, I used a step drill to get a 1 inch hole, filed slots on the front and rear sides to accommodate the reinforcing plates, then filed the corners where the slots meet the hole for the carriage bolt heads. The bolts and plates just barely fit, but that leaves more metal on the frame;  I doubt any of that matters.

I felt badly about leaving steel filings inside the frame, but there’s no practical way to extract them. I didn’t prime-and-paint the raw edges, either, as they’re buried deep inside the hitch frame; I may regret that decision.

Wear eye protection: those six fish wires have lethally sharp and very whippy ends.

You can support the hitch on your chest to maneuver it into position, but an assistant must hold it in the proper alignment while you fiddle with fish wires, bolts, and nuts.

I don’t know what happens to the raised bump in the frame under the heat shield, but I suspect it gets crushed flat after torquing the nuts on either side.

When you reinstall the muffler, remember to take the gasket off the mounting pin where you put it for safekeeping before maneuvering the pins back into the hangers …

The Official Subaru OEM Hitch Assembly Instructions commence with loosening the taillight housings and then get complicated. That hitch mounts on a crossbar that completely replaces the bumper beam inside the dress cover, the receiver extends through a small square section of the cover that you cut out as part of the process, the mount occupies the two rearmost holes in the frame members, and it doesn’t require trimming the heat shield. It also costs nigh onto $800 including dealer labor.