Everything is parallel

Or at least multithreaded. I was prototyping some vaguely image-related ideas in Processing, and decided that I wanted to pick which image file I was going to mess with on the fly rather than hard-coding the filename and path into the program. Down the rabbit hole I went.

Processing has a function for using your operating system’s select-a-file dialog. But because of the way that I/O is handled, it can’t just return a value containing/pointing to the file you selected. You have to specify a callback that — oh, wait, the callback can’t return a value either, it has to modify a previously-defined global variable.  (The Processing language reference conveniently sidesteps this twist by providing an example that simply prints the selected file name to the console.)

So I put the file-selection magic in the setup function for my code, which runs before the main loop. The main loop ran, and then the selection dialog popped up. Huh? Oh, right, multithreading. The code in setup() returns as soon as it’s told the operating system what it wants and what callback to trigger. The fact that nothing substantive has been accomplished yet is irrelevant.

I have to admit to feeling just a tiny bit like a real programmer when I added a semaphore to the file-selection callback and the main loop. Now the main loop spins cheerfully at 30 frames a second doing nothing until I pick a file. Oh, and I want an output file too. Good thing my code doesn’t actually do anything.

Posted in possibly useful | Tagged | Leave a comment

The autopilot conundrum

This morning I stopped by a local school where some of the kids had crowdfunded a 3D printer (a printrbot Play) to see if I could help them get it working. I seem to have become the town expert, which is a frightening thought.

The machine had never worked for them. One of the axes apparently jammed somehow either during shipping or initial setup (the kid who was mostly in charge of it described multiple episodes of that rattling noise that comes with a skipping stepper motor and his immediate response of pulling the power plug). And when I got to it, it wasn’t responding at all.

So we reinstalled drivers, swapped in a known-good USB cable, reinstalled Cura, tried Cura on my linux laptop. Nothing. The furthest we got was “Opening serial port …. Closing serial port.” And on the laptop, “lsusb” reported no change when the machine was plugged in. Eep. A blown board didn’t seem that likely, and yet.

So as a last resort we turned the Play on its side and I held the ground shield of a spare USB dongle against the firmware-update pins (we didn’t have a jumper handy) while the kid plugged in power and pressed the reset button. This time “lsusb” reported an Atmel DFU device, which means the printrboard is probably OK, it’s just that the stepper blowback or the constant unplugging and replugging borked its firmware. So tomorrow I drop off a jumper, and the kid finds the instructions for downloading and reflashing. All in a morning’s work.

Except that before we ran through all that diagnosis, these folks were pretty much convinced they’d flushed $400 (plus shipping and filament) down the toilet. When you make a machine that Just Works and can be operated by people with little to no expertise — which Cura also helps enable — it’s really great.

But when anything goes wrong, it’s like throwing a toddler into the deep end.  All the simplifications and pre-built configurations that make a combination like the Play and Cura suitable for schools mean that you’re not going to run into the usual teething problems of getting a printer going. Only the unusual ones, which may even be hard for a relative veteran to diagnose and fix. And that’s a recipe for trouble.

Not that I have any good solutions. Either newbies still have to learn a lot more, or mass-market printers have to become orders of magnitude more bullet- and fo0l-proof (which means more expensive and/or much slower to arrive). Or veteran volunteers need to be thicker on the ground.


Posted in going places, things that don't work | Tagged | Leave a comment

There’s a reason some things are surplus

The 11-year-old has been bugging me for a few years now that he wants to build a crystal radio set, and sourcing the parts individually is something of a pain. So when I saw a kit for cheap at a surplus site, I thought: Cool!

Perhaps not. After a couple of tries we got the antenna wire wound onto the cardboard tube (barely — about half an inch so spare on each side when all the turns are solidly butted against each other) only to find that the holes in the molded, foldable plastic sheet that serves as the frame aren’t quite big enough for the tube.

Sorted that. Turns out the tabs that are supposed to lock the frame together when you fold the sides up, don’t. Sorted that too.

Then the 11-year-old, who had been doing pretty well with the instructions, asked me to interpret a paragraph that apparently referred to the two pieces of extra wire in the kit, one of them as “the second wire” and the other as “the other wire”. We duly hooked them up to the places specified. After spending several minutes with the wire stripper trying to find that tiny little thread of metal inside the tough rubber insulator.

Nothing. Nada. Less than the crackling we got just touching the earphone wires to metal objects.

So the kid went back to playing retro video games while I reread the instructions and looked at the circuit to figure out what it thought it did. Turns out “second wire” and “other wire” are synonyms. Time to undo and redo some tiny bolts and washers. Then I read further in the little booklet and found the instructions for connecting one wire to a cold water tap (because we live in a parallel universe where no one invented PEX or nylon and so all water taps are connected to ground) and then holding the other wire in your hand while with your other hands you hold the kit and move the little tuning ball across the antenna.

Did that, actually got some 60-cycle hum. It’s a beginning, and the kid was not entirely disappointed.


Posted in kits, things that don't work | Tagged | Leave a comment

The gift that never ends

This winter I had the idea of donating my old Cupcake CNC to the local library. Get it out of the basement, I thought. Put it where other people can use it. Find a home for all that extra 3mm filament that ain’t going in any of the printrbots.

What I didn’t realize was how many of the old machine’s quirks I had subsconsciously memorized, and just how finicky the toolchain has become in the years since I started using it. So I’ve been spending a lot of time at the library debugging, re-implementing, fixing, coaxing, undoing smart things that other people have tried to do…

Start with the tools: the only thing that will (apparently) talk to the cupcake is ReplicatorG. Because I’d have to build a machine-description file from scratch for any other host software, and bodging one together for ReplicatorG was painful enough. (Why yes, I did build my own custom geared extruder, and added a 3d-party stepper board to run it because, ages ago, I blew out one of the motor-driver chips on the extruder board that could otherwise be used for stepping.)

ReplicatorG means Skeinforge, with all of its interestingly-organized settings. And Print-O-matic, which gleefully ignores some but not all of those settings. (In particular, it ignores the temperature panel, which is probably a good thing to know before you start wondering why your hot end is extruding at ABS temperatures, no matter how many times you adjust the layer temperatures to be right for PLA.) At one point it seemed that the workflow would involve simply editing the g-code every time to get the right values.

So I got that stuff fixed, and darned if the kid I’d been teaching how to use the thing didn’t change some of the settings,  replug the USB adaptor cable into a whole different board and somehow cover the entire build surface with a thin, irregular layer of oozed PLA. Do you think perhaps I should write just a little bit in the way of documentation?

Today I go in to fix things again, and to substitute an unheated build platform covered in blue tape for the heated one. If all we’re printing is PLA it shouldn’t be a problem. Except, of course, rewriting the machine description file to compensate for the new distance between the platform and the endstop…

Oh, and did I mention that because this is a donated machine and not blessed by the IT department, it can’t thus far be connected to the library network?


Posted in making, things that don't work | Tagged , , | Leave a comment

What time is it?

My next kit build is an Ice Tube clock from Adafruit. Which brings back lots of memories, because one of the first kits I built and wrote about was a nixie clock from Jeff Thomas, who was pretty much the founder of the modern nixie resurgence.

Times have changed since 2003. I’ve got a much better soldering iron, with a finer tip, and I wear serious magnifiers now. I’ve also built enough things that I’ve started to develop a sense of how kit instructions should go and PCBs should be laid out.

Or at least I thought I had. One the one hand, the “build a subsection and then test it before going on” methodology is helpful, especially for people who aren’t that great at soldering or placing components. On the other hand, it’s weird for anyone who’s used to just putting stuff in place, turning the board over and soldering everything. Some of the first things to go in were the tall stuff — sockets, big capacitors and such — which made sneaking the little resistors and caps and diodes in among them a little harder for the thick-fingered.

On the other hand, the step-by step testing came in handy when I soldered the piezo speaker where the inductor was supposed to go (but on the third hand, please more perspicuous positioning for the silk-screen labels — when you have a round outline that says “spkr” inside it, people can be forgiven for thinking that’s where the speaker goes, especially when the leads are a perfect fit.)

The vacuum fluorescent tube is just plain weird, with a bunch of thin, flexible uninsulated wires coming out. Having a set of evenly spaced holes around a circle was probably as good as any other way to connect it, although the holes could have been a touch bigger and made it less terrifying to pull the wires through. (The original nixie clock had this weird procedure where you put individual metal sockets onto the bottom of each tube, then aligned them inside oversize holes and filled in with solder. Tolerances have changed in 50 years.)

Anything with lots of fine leads is a pain. The chip carrier for the high-voltage tube driver had gotten mashed somewhere in the kitting/shipping/storage process, so it took a half our or so to straighten all the pins so they would fit their holes. More interesting because of course you can’t see the inner layers while you’re actually trying to insert the carrier. Maybe I need another level of magnifier.

Does it work? Yep, just fine. It won’t keep nearly as good time as its older cousin, because it uses a mere crystal instead of a surplus cellphone GPS unit, but that’s OK. The instructions for resetting the time are thoughtfully laser-etched onto the bottom of the case, instead of buried in a magnet-activated menu system that requires you to know your offset from GMT. I wonder whether, over the years, the VFD segments will start fading around the edges the way the nixie numerals have.

Posted in kits, probably boring | Tagged , | Leave a comment

I like Octoprint

So I was sitting upstairs where it’s warm, instead of down in the cold basement, and suddenly I had the idea to print something I’ve been noodling on for a while. Click. Click. Click. Move the Octoprint browser window so I could see it while I kept doing other stuff. 23 minutes and 16 seconds later, the part is done. Maybe when I go downstairs to fix lunch I’ll take the part off the bed.

Somewhat appropriately, it’s a piece to adapt the pi camera to a 2x tele-extender from a digital camera I had about 12 years ago. So the field of view on my remote Octoprint window will mostly show the print instead of mostly showing the frame of my printer and the surrounding basement.

Posted in making, possibly useful | Tagged , | Leave a comment

Who needs a laser cutter?

scrollbigscrollkerfWell, I do. Or at least I want one. But cutting out a bunch of parts on a scroll saw in the past few days has given me new appreciation of what can be done with simple tools. The kerf is not much bigger than a laser’s (plus, no soot stains).


I found myself comparing the workflow for this project if I’d had a laser cutter handy versus what I’m actually doing.

I’m making stamp pads for an animal-track unit at the 7-year-old’s school: wood blocks with craft-foam outlines (lifesize) of the tracks of various local creatures. I glued one set of tracks onto a piece of wood, cut out the blocks, then traced around those to make another three sets. Next: apply craft foam to the blocks, stick paper track templates to the foam, cut away everything that’s not track. A few hours work, most of it pretty mindless, the kind of thing you can do watching tv with the kids.

If I had a handy laser cutter, a lot would depend on whether I could get the track images in digital form or had a Glowforge with its magic camera. Otherwise, careful scanning or photography, followed by careful printing to make sure the sizes were right and there was no perspective skew. From there it would be pretty simple: Cut the wood (three times, to make up for only being able to cut 1/4-inch stock) and engrave the track marks on the top panel for a guide. Then cut the craft foam with the same file and stick all the little bits on, using the engraving as a guide. Finish gluing up the blocks. Not entirely sure which would be simpler; most of the work that’s eliminated by the laser is busywork, which could be either good or bad.

But I’m beginning to think about some kind of hybrid workflow for woodworking projects, where the laser does marking, engraving and maybe shallow cuts, followed by real blades. If I had a laser head mounted on something like a 4×8 Crawlbot I could mark everything for even the largest project in a single pass and then cut with a conventional blade.

Posted in making | Tagged , | Leave a comment

Progress is Bad

I’ve been working for a while on a wearable accelerometer/datalogger project, and I came up with a nice breadboard prototype using a spare Seeduino Stalker plus a bunch of other parts. But that’s kinda big to actually wear. Next up: a handy Micropython board: it’s small, it has a real-time clock, it’s way easy to code, but wait: the accelerometer returns all of five bits of resolution. It can tell upsidedown from right side up from sideways, but not much more.

So when I saw Adafruit’s lovely little Feather logging board it seemed perfect. Small, plenty of pins, LiPo battery socket and USB charging. (And unlike my Stalker, the micro-SD holder doesn’t fall open at inconvenient moments.)

What a terrible mistake learning experience.

When I wrote my code for the Stalker, I was using Arduino 1.06, because I hadn’t needed to upgrade (and the newer versions don’t work on my old mac anyway). But the Feather board uses the fancy new Board Manager magic in Arduino 1.6.x to install its pin descriptions and so forth. So off I went to install the newest version.

Now the lovely SDfat library I was using (fast, long file names) wouldn’t install, and even after I tried to install it by hand kept showing up as “invalid library”, because the Arduino folks have decided that there must be Order and Rules for how the files in libraries are arranged. And a properties file. (Which I understand in principle, but in practice “All that stuff you relied on that formerly worked is now broken” does not win friends.)

So I mucked around with that for a while, and complained in forum where a nice person said “Oh, yeah, the latest versions of the IDE aren’t so hot, downgrade to 1.6.5 and your library should work.” And (after a little more mucking) so it did.

New IDE capable of recognizing board, check. New configuration of SdFat library, check. But wait. All the real-time clock breakouts I have are 5-volt only, except for one that’s huge. Time to order a 3.3v RTC. Wait for it to arrive.

Put all the hardware parts together. Test compilation of old stalker program to see if the software parts will fit. Boom. Nothing works. Error messages claim files I know are there are missing. Messing with the include statements just produces more error messages. A search to figure out how I am messing up reveals that oops! the latest version of the core board descriptions file  installed by the magical Board Manager is not compatible with previous versions of the IDE. Tell the Board Manager to install the previous version instead. Hurrah! Everything compiles.

Doesn’t work, though. Feather just sits there when I try to get information from the serial port. All the power lights are on, but nobody is home. Maybe the new RTC really isn’t 3.3volt capable? Wouldn’t be the first time a seller stretched the truth on amazon. I get a regular arduino and try the clock there. Also nothing. Load up the I2c scanning sketch. Nerp.

Hmm, maybe I need pullup resistors? The nonexistent documentation was fuzzy on that point — some I2C devices have them built-in, some don’t. I break out the multimeter, and measure 4680 ohms between the clock line and Vcc, 4720 ohms between the data line and Vcc. Pullups are supposed to be 4.7K ohms. Just for the heck of it I measure between Vcc and ground: 400 ohms. Erm. That probably ain’t right, considering that realtime clocks are supposed to draw a few microamps.

Luckily, the boards were cheap so I’d ordered two of them. I popped the second one into the original circuit and golly if it didn’t come right up where it was supposed to.

Total time spent mucking around on something that should have been a simple swap of one microcontroller board for another: almost two weeks.


Posted in making, probably boring, things that don't work | Tagged , | Leave a comment

A child of the 80s

Sometimes I wonder if the 11-year-old is too retro. His current hobby is playing an emulated version of Street Fighter 2 on his PC. And now that a vintage-gaming store has opened in the next town over, he pretty much wants to buy out their stock. (Lucky there’s still one standard-def TV in the house)

But he’s also kinda modern. So when we came across an ancient Atari-style joystick, he looked at it and said, “Hey dad, how about a Teensy in HID mode?”

We opened it up (which required drilling out one of the case screws that was apparently sealed with glue) and I soldered all the old connector clips to the circuit board, then clipped the wires short and soldered them to a spare Teensy 2.0. Anybody need a 9-pin Atari-style cable with only 6 sockets populated?

He mostly took it from there. I told him which pins I’d attached the wires to, and he fired up a copy of the Arduino IDE, found an example program that read a switch and bodged it to what he needed. Didn’t work. A day or two later he came to me and I thought about it,  realized how foolish I’d been, and said “Change all your pinmodes from INPUT to INPUT_PULLUP.” He did, and now the thing works.

Wonder what he’s going to do next.

Posted in making, toys | Tagged , , | Leave a comment

cleaning out the basement one bright idea at a time

When we were making new year’s resolutions last month, mine was to, y’know, build some of the cool kits and kit-like part collections I’ve acquired over the years.

First up: Solarbotics marble machine. Cute, simple, less than an hour build time if you don’t count waiting for the glue to dry.  Laser-cut frame, less than a dozen solder joints. I only managed to assemble two of the sections backwards, and just broke/lost one piece taking them apart, so I think it was a success. (And thanks, Solarbotics, for making some of the waste pieces from the gear-wheel supports exactly the same width as the tab that aligns the wheel layers.)

It’s a mostly glue-optional kit, because all of the tolerances on the laser-cut pieces are close enough that you have to hammer lightly on the bits to get them to go together, or somehow put all of your weight on one thumb. Which bodes well for it holding together longterm.

If I had been smarter, I would have done a test fit of the electronics and the structural bits before soldering, because some of the placements are not what they seem from looking at the instructions. The spacing of the pads on the circuit board (which is cleverly made part of the back of the solar cell) looks as if you can just tack down the component leads after trimming them to length, but no. The leads also need to be a bit longer than the nominal 3/8″ for some of the components to comfortably clear the body of the gearmotor, and the leads on the big capacitor need to be shorter to clear the marble race. But it all worked out.

The other thing I learned is just how pitifully weak northern sunlight is in the winter. I brought the completed marble machine to our front window to see how it moved; the instructions say it should pulse every 2-5 seconds, but nope. More like every 15-20. Maybe I’ll rethink that rooftop solar-panel installation I’ve been yearning for.

Posted in kits, toys | Tagged , | Leave a comment