Hack: Elecrow Laser Engraver Tool Protocol

Disclaimer: Contains Amazon Affiliate and direct links to products.

This is Part II of our Elecrow Laser Engraver Tool hackery:

What We Did

Roughly:

  • Sniff USB (under both Windows and OS X)
  • Identify packets to/from the ELET (Elecrow Laser Engraver Tool)
  • Isolate individual commands by pushing app buttons and seeing what was sent and received
  • Formalize those commands for repeatability

This is the same process you’d use to reverse engineer any protocol, e.g., if you want to find out how the littleBits app talks to their CodeKit board, or what commands are being sent to your cheap ESP8266 120V relay controller, or pretty much anything.

How We Did It

The first step in figuring out how the Elecrow app was talking to the engraver was to sniff the USB connection. Under Windows we used USB Analyzer. Under OS X we used Wireshark, but needed to bring up the interface so Wireshark could track it:

$ sudo ifconfig XHC20 up

(And conversely bring it down when we were done.)

Wireshark is pretty great, by the way, but provides very complete information, which isn’t always what we need. In this case we needed to filter by the source, so we clicked the “Fan” icon and looked for likely suspects in the Wireshark display.

We knew from Windows USB sniffing that the fan on/fan off commands were four bytes long, but under OS X we were seeing the entire block of 32 bytes plus the payload data from the Elecrow software, so our first guess was to look for something that was 36 bytes long:

Wireshark: Find the Device
Find the Source, Luke

Once we had that we could set a display filter to see just this data, and add a column to display it:

Getting this data into something we could (trivially) look at and dissect was a dive back into the world of Wireshark. First we saved just our filtered packets:

Wireshark: Export Displayed Packets
Export Displayed Packets

Then fell into the following workflow (roughly):

  • Capture and filter data as shown above
  • Export the selected packets via Export Specified Packets…
  • And only exporting the “Displayed” packets (as per our filter)
  • Run tshark to save off just the “Leftover Capture Data”…
  • …and strip out the newlines via tr so they didn’t muck up the analysis
  • Turn this into a binary file with a quick-and-dirty script
  • Analyze the result

Here’s the tshark command to save just the isolated data (and strip out the newlines to create a clean binary file for analysis):

tshark -r test2.pcap -T fields -e usb.capdata | tr -d '\n' > outfile

The Python script, lifted off the net somewhere, but it’s trivial to implement in any language:

import binascii
import sys
string = open(sys.argv[1],'r').read()
sys.stdout.write(binascii.unhexlify(string)) # needs to be stdout.write to avoid trailing newline

Under OS X we tried out Synalyze It! and it was okay, but we found the grammar creation to be a bit fraught. Honestly for this it wasn’t worth the effort since (a) the messages were short anyway, and (b) we pretty much knew we were going to replace the controller board, but it was interesting.

(It did, however, highlight the need for one of our old, old projects that’s been on the backburner for a number of years–our Data File Disassembler, that we’ll bring into the modern age Real Soon Now.)

To sanity-check our assumptions we cobbled together a small NodeJS app and we were able to turn the fan on and off (04 00 04 00, 04 00 05 00 respectively) under a separate app, but that was as far as we wanted to take it. Knowing (a) it was a custom protocol that (b) didn’t work with anything else was enough for us.

The initial protocol hacking notes are in a Github repo. If we (or anyone else) develops any tools around its native protocol we’ll try to keep the repo updated. If nothing else, we may include a tool that’ll wrap up the protocol capture so the binary files can be downloaded to an RPi which could then be used to send duplicate commands to a printer, allowing semi-automated printing without having to use the included application.

What’s Next

In Part III we’ll start grafting on a commercially-available SainSmart controller we hope will be a drop-in replacement (delta the GRBL configuration) for the controller board that comes with the ELET. Hint: worked out of the box, just needs configuration and endstops.)

Resources

Products

Print: Another Paintbrush Holder!

Front View, Loaded

Our first paintbrush holder got enough attention that we figured we’d discuss another one we designed and printed. This one has a more-organic shape, holds a few more brushes (and in our opinion it’s easier to get at them), and presented an interesting problem with Fusion 360 regarding patterns on path, and how to make sure you can process edges they way you want. (TL;DR: Press/Pull a bit more than the space you need to take up.)

Patterns on Path

Taking a (modified) version of our “kidney bean” shape we want to create a bunch of “slots” for our brushes:

Pattern on Path Idea
Pattern on Path

There’s a quick look at this process in our Youtube Video, or you can keep on readin’.

We’ll use a symmetric direction, so they wrap around both sides of the path at once, use the “Spacing” direction to the outsides of each “slot” are about 0.625″ apart. One thing to keep in mind is that our Orientation setting needs to be “Path Direction” so each extruded “bar” is tangential to the path:

Fusion 360 Pattern on Path "Orientation" Setting
Choose Your Orientation Wisely!

Here’s the thing: even though our original extruded bar is making good contact with the inner and outer walls in the center location, we run into a problem on the sharp inside wall curves:

Bodies don't meet flush
Uh-oh.

If we try to fillet the edge of the extruded bar it won’t join with the inner wall:

Bad fillet
Just No.

What we need to do is Press/Pull the extruded “bar” before patterning so it makes contact with both the inner and outer walls, all the way around the path:

Press/Pull Into the Walls
Press/Pull Into the Walls

Now when we pattern even those tight-radius inner-wall corners will have full contact with our separator “bars”. After patterning we can combine all the separate bodies, and create a fillet the way nature intended:

Resources

Print: Simple Paintbrush Holder

Front view, loaded with brushes

Disclaimer: This post contains an affiliate link to a product we bought, then promptly printed a version we liked more. But go buy one via the affiliate link anyway–it’s not that it didn’t work, it was just held too many brushes.

We needed additional brush holders that we mostly like this one we bought off Amazon:

Brush holder
Inspirational brush holder

It actually holds too many brushes for what we typically need, so we thought we’d spin out a customized one all quick-like, and use some 1/2″ ID copper tubing for supports. Since it wouldn’t be too wide, we figured a single, central support pillar would be sufficient (it is, but we also filled one with sand capped with silicon for extra heft just in case).

Here’s what we ended up with:

Design

We whipped up a screencast real quick that covers the bulk of the design process. IRL we parameterized everything so we could use other support material (like dowels or acrylic) and change the wall thickness (these are 1.5mm which is a little thin, but worked well on our MakerBot Method). We didn’t parameterize the number of slots; we’ve had mixed results doing that in Fusion 360.

TL;DR: Make a hole the size of your supports. Make the circles for each “row” of brushes you want. Draw a line from the center point to the edge of the outside circle. Offset those on each side by 1/2 the wall thickness you want. Make a circular pattern of those.

Then extrude up the height of the holder (we used 1cm). Duplicate all this for the bottom, and extrude around 2mm so the base is solid (keeps those drips off your table!) and you’re basically done. We filleted and chamfered everything as well.

Lessons Learned

This was about a four hour print on our MakerBot Method with the default settings. Faster than Amazon Prime delivery, and it suited our immediate needs better.

Overall we’re pretty pleased with how it turned out, although a little more slop for the support piece might have been beneficial–it was a tight fit, but the dimensional accuracy of the Method saved us from all sanding whatsoever, and the PLA it shipped with was plenty strong to stand up to a bit of pushing.

Resources

Products

Mini-Review(s): Box Cutters

Disclaimer: Contains affiliate (and direct) links to some reviewed products.

Have boxes? Want to open them? Get you a box cutter for a great good! TSA aside, box cutters are great: yes, we all have our multitools and combat knives strapped liberally around our body, but for all-round utility, it’s hard to beat the simple box cutter. (And they make serviceable weapons in an emergency, and raise fewer eyebrows than a wave-opening Emerson Karambit, our go-to death-dealer of choice.)

From simple to elaborate, from light to heavy–we’ll give a quick overview of the ones we have laying around the shop, and discuss why some are better than others, what our daily carry is, and why.

(We won’t discuss scrapers, which are something different, but maybe some other time–they’re also super-useful, but not as fun for… cutting boxes.)

MOAR BOXCUTTERS!!1!

A pile of box cutters
Pile o’ Box Cutters

These are a few of our around-the-shop cutters (tragically this is not all of them; we have more tools than sense). There are three main “classifications” of box cutters: flippers, sliders, and “always-on” (those come with sheathes). We’ll work in reverse-order.

Always-On

Pull them out of the sheath, cut a box: it’s as simple as that. The problem with them is that they essentially require a sheath or container. They may be suitable for bench mounting (and we have one stuck on to one of our CNC tables) but for daily carry it’s a non-starter. Why?

Sheathes add bulk, and unless it’s sized exactly right, and it’s a pretty tight clip, you either need to hold on to the sheath to deploy, or push down on the sheath while you draw the cutter. So why would you want one at all?

Rigidity: these are easily the solidest variety of box cutters. With a heavy frame and no moving parts you’ll break the blade before you have any other mechanical problems. They’re worth having on hand for that reason alone, but if you’re anything like us, you’ll use them only rarely, or only when you’re near where one is mounted. They’re also fine in a toolbox or tote, but in general, we think they’re more specialized.

We only have a few varieties of these, but we like the Stanley for overall durability, even if the sheath feels a bit cheap, and the belt clip… well, there’s a clip, it’ll go on a belt, but deploying is a bit of a pain.

Sliders

These push the blade out the front. They’ll either use a standard box cutter blade (the trapezoidal ones) or a custom blade, often with snap-off blades to get to the sharp part.

Mechanically they’re generally quite sound, and less prone to failure and breakage than a flipper (up next) because they just run on a track–there’s no pivot to get gunked up and even a pretty dirty one can be easily forced open.

The snap-off blades are a bit more specialized; they’re wonderful for foam cutting (hard to beat, in fact) especially if you sharpen them. For this variety we like the DeWalt (they’re yellow!) and a Kershaw sharpener. The downside is that they take only specific blade types and shapes. They’re also (generally) thinner than their “conventionally-bladed” counterparts so for heavy-duty use you’re better off elsewhere. That said, the blades are much longer (good for foam, bad for cardboard)/

Either type is fine in a pocket (as long as you remember to retract the blade… be safe, kids!) but don’t always include a belt clip. Without the belt clip, at least for us, their use as a daily carry is limited, but they’re great in a toolbox. The DeWalt snap-off cutter has a pocket clip that’s quite robust, and while we don’t carry one daily, when we need to, we can, with confidence.

For “conventionally-bladed” sliders we like the Stanley Fat Max.

For snap-off we like the DeWalt DWHT10038, and use a Kershaw stowable sharpener between cuts. (“Between all cuts?!” you ask? Depends; for foam, pretty much–but we have dedicated units for foam. For general cutting, not really. But for foam it’s arguably worth the extra effort.)

Flippers

For daily carry we like flippers, in particular this Milwaukee flipper, because it’s a one-handed opener, basically a gravity-operated switch blade: it swings really easy. This is also its greatest weakness–there’s a bit of rattle-and-shake when it’s in the locked position. But the convenience and extra functionality (a strap cutter and wire stripper) make up for it for most uses.

We’ll give an honorable mention to our pals at Home Depot for their Kobalt stainless steel flipper. Make no mistake–it does not flip; you have to want to open this bad boy. But when it’s locked it’s nearly as solid as any always-on box cutter, and we have several, mostly in toolboxes and glove boxes.

Products

The Stanley fixed-blade as we have it doesn’t appear to be sold any more, and since we don’t own any newer versions, we don’t know if we can recommend it or not, so no link to that for you.

The Kobalt Stainless Steel may be available at your local Home Depot, but searching for it proved… somewhat irritating, so we gave up. It’s not a daily carry anyway (too heavy, too hard to open) but man, is it solid.

Affiliate Links

Direct Links

Build: Arduino Tachometer (Reflective Style)

Disclosure: This post contains affiliate (and direct) links to some parts off Amazon for making a (relatively) hand-held device as well as the commercial product we replaced.

In the first book of the Maker’s End Inspiration Series, Arduino Inspiration, we’re controlling some computer fans to make a pleasant desk fan. To get some data on various fans, we needed a tachometer. So we wrote a different book. Because reasons.

Thus the first Maker’s End MEMO (Maker’s End Mini-Overview) publication, MEMO#001: Arduino, Interrupted, in which we provide a quick (but thorough) introduction to using interrupts on Arduinos of various flavors. As preparation for releasing a kit of the tachometer we started prototyping case designs in case we wanted to print the case instead of building a carrier plate for a commercially-available case (jury’s still out).

In this post we’ll take a quick look at the prototype case and code, discuss miniaturizing designs (spoiler: don’t!), and see where we go from here. There’s actually a video showing some of the design and wiring process, but it turned out to be really boring, so we didn’t post it :p

We whipped up a quick-and-dirty tach using a reflective sensor (read: when light bounces off of something back into the sensor it’s a “pulse” and we count it as a revolution) using the STEMTera for prototyping, then moved it as-is onto an Arduino Nano clone with USB power bank. (The kit will use a simple battery pack or LiPo.)

We 3D-printed a small mounting plate so we had something we could use and to start exploring the design space of such a small tool that still uses off-the-shelf parts without a custom PCB so we had a tool we could use around the shop. It’s roughly equivalent to a cheap “laser”-based reflective tachometer we also got off of Amazon as a simple way to test performance. Not quite as pretty, but customizable, accurate-enough, and a cute little project.

Any of these parts can be substituted. We built one with a different IR sensor and a white monochrome OLED, with essentially no code changes. We also have one that uses a 18650 or LiPo batter with a built-in charger and voltage converter–or just use a board with a built-in LiPo charger like an Adafruit Feather: we’ll post a followup article that uses a Feather that’ll send the data to your phone or to a computer for data storage as well.

Build the Circuit

There are two circuit “chunks”, both quite simple. First is hooking up the reflective sensor, second is hooking up the OLED. The Adafruit part comes with the resistors necessary for operation–we went ahead and made a slightly more “self-contained” sensor unit by soldering the resistors onto the sensor and running breadboard-ready wires for the initial prototype.

The OLED hookup, since it’s an I2C OLED, is as easy as hooking up Vcc and Gnd to the appropriate pins, and SCL/SDA to (in our case) the Uno (or Nano) A4/A5, the default I2C pins.

While we prototyped on an Uno, the “final” version uses a Nano (clone), so we’ll show that circuit–it’s the same on the Uno, though, in case you want a giant tachometer (or also go the smart route and prototype on something large).

Write the Code

The code is (roughly) as simple as you’d expect. There’s not a whole lot to talk about, but we’ll break it down anyway. The code for the kit version will be available on Github; the code here is just the prototyping to make sure it was accurate-enough.

Administrivia

It’s just a bunch of library headers (we don’t need all of them for our initial example, but the kit code uses them).

#include <Wire.h>

#include <gfxfont.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>

#include <Adafruit_SSD1306.h>

// Useful constants
#define IR_LED  12    // Turns on IR emitter
#define IR_IN    2    // Input from IR sensor
#define DELAY  500    // Milliseconds between display updates

// Initialize OLED
// OLED_RESET is connected to SDA on OLED.
// NOTE: It's *analog* Pin 4 on the Arduino.
#define OLED_RESET 4  // Pin for OLED SDA connection
Adafruit_SSD1306 display(OLED_RESET);

// Revolution tick/pulse counter.
// NOTE: Volatile!
volatile unsigned int rev;

// For calculations/results.
unsigned long int rpm;      // Current RPM
unsigned long int maxRpm;   // Maximum calculated RPM
unsigned long int time;     // ... time.
unsigned long int prevTime; // The time before!

Interrupt Service Routine (ISR)

The ISR is the “meat” of the code even though it’s a single line long. ISRs can be confusing to new programmers, which is why MEMO#001: Arduino, Interrupted will exist–to demystify them. The only thing we do in the ISR is increment a value–the count of how many times we received a signal (pulse) from the IR sensor, which in turn pulses on each revolution of what we’re measuring.

void rpmCount() {
  rev++;
}

We’ll put up a few more posts on interrupts in general. Suffice to say that in Setup (below) we’ll tell the Arduino to run rpmCount every time we get a pulse, which just tells the code to add one (increment) the number of revolutions. We’ll see the rev value later, because we’ll clear it out when we display the current revolutions per minute (RPM).

Setup

Most of the setup method is self-explanatory: we do a bunch of stuff to the OLED so we can display the current RPM. We set a bunch of values to known startup values (zero in this case), set our IO pin directions, and turn on the IR emitter.

void setup() {
  Wire.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);

  display.clearDisplay(); // clearing the display
  display.setTextColor(WHITE); //setting the color
  display.setTextSize(1); //set the font size
  display.setCursor(0, 0); //set the cursor coordinates
  display.print("Tachyons are Go!");
  display.display();
  delay(500);

  // Start clean!
  rev    = 0;
  rpm    = 0;
  time   = 0;
  maxRpm = 0;

  // Set up IO
  pinMode(IR_IN, INPUT);
  pinMode(IR_LED, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);

  // Set up interrupt handler
  attachInterrupt(digitalPinToInterrupt(2), rpmCount, FALLING);
  
  digitalWrite(IR_LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
}

The only thing of note is this:

attachInterrupt(digitalPinToInterrupt(2), rpmCount, FALLING);

attachInterrupt “hooks up” an Arduino (really the processor interrupt) to a given pin, runs the provided code (rpmCount), every time the signal rises, falls, or changes: here we care when the pin changes from high (5V) to low (0V) because that’s what the sensor is wired to do.

The digitalPinToInterrupt function allows us to provide the Arduino pin number instead of knowing what CPU-level interrupt is used for a given pin. This can be different across Arduino boards (and non-Arduino boards programmed in the Arduino environment), so it’s a safer bet to use this convenience method.

Loop

The “meat” lives in loop as with many an Arduino sketch. And yes, we’re using delay here–sorry! You’ll undoubtedly will read (or have read already) that using delay is generally a bad practice, and for the kit code with a UX, it’ll go away (and it has to!). But for prototyping a simple tach with no UX it’s fine. We’ll be discussing this, and how to avoid delay, in MEMO#001: Arduino, Interrupted and in subsequent posts.

void loop() {
  delay(DELAY);

  detachInterrupt(digitalPinToInterrupt(2));

  long currTime = millis();
  long idleTime = currTime - prevTime;

  rpm = 30 * 1000 / (millis() - time) * rev * 2;

  if (rpm > maxRpm) {
    maxRpm = rpm;
  }

  time = millis();
  rev = 0;

  display.clearDisplay(); // clearing the display
  display.setTextColor(WHITE); //setting the color
  display.setTextSize(1); //set the font size
  display.setCursor(0, 0); //set the cursor coordinates
  display.print(rpm);
  display.display();

  prevTime = currTime;

  attachInterrupt(digitalPinToInterrupt(2), rpmCount, FALLING);
}

Most everything is related to talking to the OLED, but note we detach the interrupt via detachInterrupt before performing the RPM calculation and write to the OLED: this results in missed pulses for the duration of that code, but we don’t want to interrupt writing to the OLED or update the rev count during the calculation.

Usage

Because it’s a reflective tach whatever you’re measuring will need something shiny. We stuck on some reflective tape that came with the cheap reflective tach we purchased on Amazon.

Fan showing how to place shiny tape
Fan with Shiny Tap

Some things won’t need additional shiny, like a disc with holes in it, or may need to work the opposite way, e.g., you’ll need to stick black tape on in order to break the beam. Some measurements would require handling multiple pulses-per-rev. The code handles none of this, nor is there a way to switch modes–when the kit is released we’ll have UX to handle at least some of these concerns.

How Accurate Is It?

We tested against a cheap reflective tach (link in Products section) and were consistently within 1-5%, so it’s “accurate enough” for what we needed. With minor code tweaking it should be pretty much dead-on, but for quick checks of computer fans, an electric drill, and a Dremel tool, we were pleasantly surprised with how close it was to a cheap (albeit trashy) commercial model. Plus we can customize it to our heart’s content, which is never a bad thing.

Is It Worth Building?

Debatable, but ultimately, we think so. Our cheap commercial tachometer was $20 and the only thing our hacked version doesn’t have (but is trivial to add) is storing the max, min, and last measurement (although we’d need to add some non-volatile storage, or keep the device on in a power-sip mode).

Our build was roughly $10 (we over-spent on the OLED, but it was what we had laying around when we needed it) and could probably be even cheaper. If you bump up the cost to $20, we could add more functionality:

  • More storage (via an SD card)
  • Wireless connectivity (via WiFi, BLE, or other radio)
  • Swappable inputs (via a jack for various sensors, like break-beam)
  • Software continuously hackable
  • Multiple power options

We might switch to a different board for some of this, which would increase the price, but something like an Adafruit Feather or a random ESP board with on-board WiFi is still really cheap, and opens up a world of remote monitoring possibilities.

BUILD FTW!!1!

Resources

Products

Print: Vacuum Dust Collector for Wall Drilling

Rounded version of dust collector

Disclosures: This is one of our designs; the STL is available on Thingiverse. There’s also Amazon Affiliate and direct links to the Rigid “toolbox style” vacuum mentioned because it has quickly taken over our “Oh we always need a vacuum right here” needs: we have one under our main work desk and one under the pallet rack where our 3D printers and one of our CNC machines live.

We had to do a bunch of drilling into the wall in an area that was already populated with furniture. The solution? Spend hours designing and tweaking a 3D-printed dust collector. The design went through two major iterations: an angle-y one, and a roundier one.

Design Process

We do most of our print designs in Fusion 360. For the most part, a great app (but often crashes on coils) and for relatively simple stuff like this, perfectly adequate. The plethora of online resources for learning and using make it hard to beat for the pro-am maker.

More angled vacuum dust collection attachment
First, angled version

The original design (more angled version) worked great, but wouldn’t stick to the wall by itself. Why was the air path not an oval? Not sure–that’s just how it started out. Why was sticking to the wall by itself valuable? When working solo it’s actually convenient when drilling into wall studs; when just plowing through drywall you don’t need two hands on the drill anyway.

Rounded version of dust collector
More-rounded version; sticks to the wall!

We corrected most of the airflow problems by un-boxing the air path to the collection inlet and de-complicating some of the geometry where the main dust collection hole is.

One issue we ran in to (and why there’s such an aggressive taper) is that keeping the drill from bumping into the DC attachment we had to rotate one or the other or both. While it definitely has an impact on airflow, it also means we don’t have to get all wrist-twisty to complete even deep holes.

What’s Next?

We’ll put up some designs for other hose diameters (notably a 1 7/8″ one for our new Rigid “toolbox style” vacuum, which we’re loving!) and we’re likely going to further widen and smooth out the main airflow path into the hose so it’ll be even suckier.

We’ll also be doing quick reviews of both our Ryobi One+ (18V) tools and cute little Milwaukee M12 (12V) tools, which we’ve started using for almost all of our work: they’re perfectly adequate for most “utility” drilling, lighter, and smaller than the Ryobis.

Why did we start messing with the Milwaukee M12 series? We specifically wanted something small, light, and versatile–and they had an M12-powered inspection scope. That started the buying spree, and now we’ve duplicated many of our Ryobis with the smaller M12 form factor, and couldn’t be happier. But we’ll keep using both.

Resources