Tim Hatch

Weblog | Photos | Projects | Panoramas | About

Go ahead, browse the archives.

XMega Overview 18 Mar, 2013

I’m working on a project using Atmel’s ATXMega series of microcontrollers, which are quite a nice step up from the ATMega series. They’ve been out for a few years, but aren’t very widespread, and here are the best overviews I’ve seen if you’d like to read up on them.

PDF Slides: XMEGA intro_2010.pdf mirror via

Video from linux.conf.au in 2012: David Zanetti, XMEGA Internals (CC-by-SA, or, youtube link at 56:55 in; original is from videos page)

Mantis Mill 15 Aug, 2012

I just realized I forgot to write anything about last year when I put together the Mantis bot 9.1. Cutting took a little planning, but I made it out of a single 2 × 4 sheet with almost no waste and all the remaining pieces are useful for building a second copy. While I didn’t make it for <$100, I did learn quite a bit about what matters for a small CNC machine like this and probably could get the incremental cost to $200 if I built more than one.

The single most expensive parts are a 3/8-12 ACME tap ($80ish) used for making the leadscrew nuts, and the electronics (the Mantis site assumes you can manufacture them yourself, which requires… a bot, or toner transfer (which I haven’t had good luck with)). I was able to use some older reprap boards, which connected with test clips to my parallel port. To date I haven’t had a short, although the clips do tend to fall off.

As you can see from the photo up top, I made it out of plywood with a thinner outer layer than spec’d. This is because MDO is comparatively difficult to find, but you can find 12mm cabinet plywood at a place like Lowe’s or Home Depot. I’ve since found a local lumberyard that stocks MDO in precut 2 × 4 pieces, which I plan to go with for my next project.

What’s good about the Mantis design?

  • The method of aligning the bushings by epoxying after drilling the stacked rails works great.
  • Tapping your own leadscrew nuts isn’t that bad. I haven’t figured out how to make an anti-backlash version yet, and since they get epoxied, are difficult to replace… I haven’t put a whole lot of stress on it yet.
  • Leveling the bed is fun.
  • It basically solves the chicken-and-egg problem, by being able to fabricate everything with standard tools (save the ACME tap). I used a circular saw, jigsaw, vise, drill press, a few drill bits, and a screwdriver set.

What weak points does it have?

Although I understand one of the primary goals was to make a really inexpensive machine, there are several points that I feel could be improved for an additional couple percent in cost.

  • Spindle is weak, noisy, and underpowered. The bearing design is great, but the motor driving it is a toy. Even mounting a dremel works better than the lost cost spindle (and I’m working on an RC brushless design at the moment).
  • Leadscrew-to-motor mounting is difficult. Without access to a lathe, I did my best to center drill the leadscrews, but it wasn’t enough. A redesign of this would end up with a regular skate bearing on the end away from the motor, and a flex coupling on the end with the motor. This would require turning down the 3/8 leadscrew, but with a lathe this wouldn’t be a big deal. It would also mean your motor bearings would last a longer time, and allow for an upgrade with thrust washers too.

What are problems it didn’t solve?

  • G-Code generation. Skeinforge has a mode that can generate subtractive commands, and you can use cad.py… but that’s about it for open source solutions.

So far I’ve done basic engraving with it using a V bit in cardboard and plywood, some drilling with PCB bits, and attempted to make a couple of circuit boards using a 1/64 endmill. My biggest lesson learned so far is that if you crash the bit into your work piece without it spinning, the tip will break.

When I pick it up again next, I plan to construct something more stable for electronics (if I want to keep using EMC2, a parallel breakout board with Pololu drivers; if separate, something based on the reprap Gen7 boards). I’d also like to build a larger one, the ~6 × 4” area is pretty limiting.

3-D Printing Lessons Learned 15 Aug, 2012

I discovered these while assembling my derivative of the Printrbot. Links go to photos that are part of the Printrbot Detail album.

  • Get enough workspace mine’s basically storage. It’ll take longer than you can just leave it on the dining table, and you’ll also want to do the trial runs outside. You don’t want melted plastic smell indoors.
  • Don’t be afraid of adding more zipties to get it to work.
  • Gen6 Electronics have a strange connector that has ramps that are slightly incompatible with the Molex KK ones I have (imagine: 3-pin fan connectors). Solution? Use Molex SL instead (imagine: motherboard speaker connector) which have more space, but are non-polarized.
  • Then you’re going to realize your wires are too short. Build some extension cables rather than trying to solder on longer wires.
  • Heated bed is a must, ABS won’t stick for me without it.
  • For Kapton tape, wider is better. I have ~1.5” and ~2” and the 2” is much easier to work with. Using a plastic card to smooth it will help prevent bubbles. I’ve heard about 8 × 8” squares, but have yet to try one.
  • When your extrusions first happen after the hotend reaches temperature, the hot end is going to rake across your tape joints, ripping them up. A partial solution is to add G-Code that moves to the correct X,Y location ahead of time, with Z up slightly while it heats, then when your program starts it will just be a Z move.
  • You’re going to make quite a few prints before you get one that works. Keep lots of notes (this is distilled from 21 pages of notes kept in Google Docs).
  • As long as your board uses a bootloader, it’s safe to try other firmwares. I settled on Marlin as working really well on my Gen6 board, which only paused on me once and handles acceleration.
  • Your accuracy will be limited primarily by your nozzle and filament size. I use 0.5mm nozzle with 3mm filament, but I know that 0.35mm should work with my hardware, and 1.75mm filament (like the Up! and some MakerBots use) would really improve things.
  • Custom endstop flags are tricky. Get some aviation snips, it’ll make your job easier.

Even with all that, my bot is still a kludge. I have lots of binder clips holding parts on, and the main board isn’t even screwed down to anything. The Printrbot isn’t a ready-to-go kit, but it may well be the best repstrap in terms of availability to print the bot you want to end up with long term.

Printrbot is alive 15 Aug, 2012

Earlier this year, I got wind of the Printrbot 3-d printer kit. After the Kickstarter was funded, but (well before) it shipped, Brook released the source files under an open source license, so I found someone who could print me a set. A common problem in hobby 3-d printers is the chicken-and-egg problem: most reprap printers incorporate printed parts, so how do you get started?

Anyway, after very slowly assembling the v1 parts, there are obviously a few places that the design could be improved. Answering question I had myself before building (based on building a “Pro” sized 8 × 8 with plastic parts, rather than lasercut):

  • 8mm rod is sufficient for the vertical (Z axis): this depends mainly on the weight of the extruder and its associated (X) carriage. I’m using a NEMA-17 motor on a Greg’s Wade’s extruder.
  • The lower frame and its threaded rod with nuts is really easy to put together. Sadly the lower frame doesn’t have a very big footprint, and I have to keep the acceleration that moves the plywood bed (Y axis) turned down or the machine can flip itself.
  • Using different pitch belts works out fine. None of the belts needs to be continuous. However, one of the toothed pulleys needs to be put on backwards (with the setscrew on the side away from the motor) which means you need comparatively long shafts.
  • The extruder holder doesn’t seem to fit standard extruders; I made a substitute out of aluminum angle and lots of spacers.
  • The Z couplers work out okay — I initially had some old steppers (1984 date code) and they would lock up, but newer steppers work out fine without additional bearings, this axis isn’t stressed. Wires are likely to get caught in the screws however.
  • The allowance for the lower motors is enough for average size motors, but not some large ones that I had on-hand.

  • The homing switches are necessary, despite the fact there weren’t any v1 printed parts to hold them. The X one (on the upper left) will get a fair bit of stress because it moves up and down. With the output from Slic3r it needs to home all axes before each print and the X axis again only after it finishes (this could be substituted with a G0 X0 with the same effect), so I need to hold the wire carefully to make sure it makes contact.

Initially I tried a press-fit plastic Y pulley, but it would get soft after a lot of use and slip. With Eric’s help last weekend I replaced it with an aluminum one, and it’s much more accurate now. The only Y problems that remain are from the way the belt pulls it, and the fact the belt is off center. The X axis is using a printed pulley with setscrew, and I haven’t had any trouble from it. The X idler is a little tricky to get right, I ended up mixing a 5/16” bolt I could find locally with a mix of metric and SAE washers.

The space provided for tensioning belts is basically useless; you need to remove an idler, zip-tie to tension, then reassemble.

After completing my build, I started to consider what I’d want in a printer if I started from scratch. The main points, Y axis riding on stationary rails and a belt path like Mendel has (which requires an extra idler), more airflow around the Y motor, something more rigid to hold the top of the Z axis, and printed parts that allow for easier-still customization, all seem to be design goals of Nophead’s Mendel90. For people starting out, I’d suggest that rather than a Printrbot (if you can get someone to make you the necessary parts).

Linting regular expressions in Pygments 09 Mar, 2012

Regular expressions are easy to get wrong.

And I help maintain a Python library that's full of them — Pygments — which uses them to tokenize many languages’ source code (along with a small state machine, more on that later).

Because they’re so easy to get wrong, I’m a bit surprised nobody wrote a linter before. Thus, I present regexlint.

When run against the Pygments tree, it will warn on suspicious constructs, such as [xx] (duplicate character in class) or (x|y||z) (duplicated alternation pipe), along with a lot of higher-level issues.

How many bugs has it found? Here’s the diffstat:

 pygments/lexers/agile.py        |   26 ++++++++++-----------
 pygments/lexers/compiled.py     |   12 +++++-----
 pygments/lexers/dotnet.py       |    8 +++----
 pygments/lexers/functional.py   |    9 +++++---
 pygments/lexers/hdl.py          |   13 +++++------
 pygments/lexers/jvm.py          |   16 ++++++-------
 pygments/lexers/math.py         |    8 +++----
 pygments/lexers/other.py        |   40 ++++++++++++++++----------------
 pygments/lexers/parsers.py      |    2 +-
 pygments/lexers/shell.py        |    6 ++---
 pygments/lexers/sql.py          |    8 +++----
 pygments/lexers/templates.py    |   33 ++++++++++++++-------------
 pygments/lexers/text.py         |   41 +++++++++++++++++----------------
 pygments/lexers/web.py          |   48 +++++++++++++++++++--------------------
 tests/examplefiles/antlr_throws |    1 +
 tests/examplefiles/function.mu  |    1 +