Putting It All Together

A friend had approached me about helping to complete a cosplay project in short order. It was to be a backpack for a cyborg character, with some lighting effects. Normally I’d decline, but there were NeoPixels involved. I’m sure you understand.

The backpack itself was an assemblage of sporting goods, hardware and thrift store parts, along with some 3D printing and a paint job to give it a weathered look. There are whole blogs and forums and web sites devoted to these topics in depth, much better than I could cover here, so we won’t dwell on this aspect in this guide, which is mostly software.

The electronic parts — most from Adafruit — included:

Battery Selection

Folks are often surprised at my recommendation for alkaline cells in cosplay projects instead of something more modern and rechargeable. All battery types have pros and cons. Cosplay is an unusual situation…traveling, away from home and one’s workbench…the choice isn’t necessarily made on technical merits, but on Murphy’s Law and the “KISS principle.”

  • Nickel-metal hydride (NiMH) cells: forget to pack your charger and you’re out of commission. Someone “helps” by putting alkaline cells in your 4-cell holder and fries your 5V electronics (four NiMH=4.8V, alkaline=6V).
  • USB power bank: most will automatically shut off when connected to a low-current circuit. Also, USB plugs do not latch strongly and they stick way out.
  • Lithium-polymer (LiPo) cells: Somewhat fragile, potentially flammable. Because cosplay can limit vision and mobility, and because costume materials are sometimes themselves flammable, adding an incendiary device to the mix really scares me. Also the pack-the-charger problem again. A USB charge circuit can be built in, but this adds cost and complexity to something you only use a few times a year.

Alkalines may not be “sexy” but they’re ubiquitous and cheap (unless purchased in a hotel gift shop, don’t do that). You can travel light and buy them at your destination. And no probing from the TSA.

(I’m not saying to never use other varieties…all have a place in portable projects…just that this route is beginner-friendly and is affordable. The alkaline battery holder is four bucks!)

Doing The Math™

So this circuit has 16 regular-size (two 7-pixel Jewels, two Flora pixels) and 60 mini NeoPixels. Doing The Math to estimate a worst-case current use for all these pixels:

16 × 60 + 60 × 35 = 3060 mA

Three amps! Consider, your typical alkaline AA cell has a capacity around 2,500 mA…so this would run for less than an hour, assuming the battery could even deliver that kind of current (no…they fare best under one Amp, the lower the better).

Switching out batteries all day is no fun. Cosplay is powered by caffeine, adrenaline and foolishness and ideally should go on for hours. Time to put all those strategies to use…

Designing The Code

I did not actually plan everything out and budget for power, instead just running with power-saving approaches I’ve internalized from prior projects. Basically, the more “off” the pixels — the more “spaces between the notes,” the better. I had a hunch that four or possibly five hours’ run time could be achieved…

Some artistic license could be taken, proportions were different and time was short, but I didn’t have complete freedom in color selection…for example, the big “vacuum tube” things had to be purple (a secondary color)…partly because it’s based on an existing toy, partly because the cosplayer loves all things purple.

Original figure on left, cosplay on right. Photos used with permission.

Graphing the brightness of the “vacuum tubes” — there’s two big ones up top, and two smaller ones on the side — these could have simply been lit solid purple and call it done, but I added sine waves to both (except for the one red pixel at the center)…partly to make it more visually interesting, partly to save power. For the NeoPixel jewel, each pixel is 60 degrees out of phase along the wave.

The smaller tubes never go to full brightness, it just wasn’t necessary and looked more “balanced” with the large ones.

These graphs aren’t very precise, they’re just to give an impression of what the software is calculating. Also, these are the perceived brightness levels before gamma correction. The actual duty cycle assigned to the LEDs is a fraction of this!

The hoses are even more subdued. Though the Mini Skinny NeoPixels are already somewhat dimmer than the full-sized variety, the brightness was further turned way down on these. Power saving, of course, but also because I didn’t want the LEDs to be overly distracting and upstage the rest of the costume.

The compulsion to run a rainbow cycle on NeoPixel strips is a force of nature. But again, so as not to overpower the rest of the suit (which is mostly muted colors), the palette was kept toward the cyan side of things. Think of early computer graphics, with all its garish, overdone colors…the medium gained respectability as artists dialed down the palette toward nature.

Rather than just sine-waving pure cyan, there are two waves slightly out of phase, so you see pulses of green-cyan-blue travel down the line. It really looks as though there’s some purple mixed in as well, but this is just a reflection of the vacuum tubes.

Again the graph is before gamma correction is applied. The actual “on” time of any of these LEDs is tiny.

Oh, of course! I’ll use Arduino’s Serial Plotter window to actually graph some gamma-corrected sine waves so you can see the real difference…

Blue is the perceived brightness, red is the gamma-corrected level issued to the LEDs.

First image depicts a sine wave with the peaks at full brightness (255). Average perceived value is 50%. Average corrected duty cycle is 33%.

Second image is a half-brightness wave (127 max — the vertical scale is stretched here, note the values on left). Average perceived value is 25%. Average duty cycle is 5.5%. Big change!

How’d It Go?

There are many vagaries in trying to do math and estimate the total current draw and run time. Instruments and meters are one option. Sometimes it’s just easier to pop in a fresh set of batteries, switch it on, take note of the time and check on it periodically. As the battery runs down, at some point the voltage will drop to a level where the microcontroller locks up. The LEDs will stay lit in their last configuration for a while, but no longer animate. Take note of that time, subtract the starting time, and there’s your run time. If it’s insufficient, get into the code and adjust your levels and effects for better efficiency.

I’d hoped for a five hour run time. Nothing too scientific, just gut feeling with the LED count and the numbers I was using in the code. The actual run time for this project was sixteen hours from three AA batteries! So all those NeoPixels are sipping a mere 160 milliamps (~2,500 ÷ 16), not the 500 mA I’d guesstimated. Even with the secondary colors, it’s getting a 19-fold improvement over the crude rule-of-thumb estimate. You can make cool stuff work with modest batteries! If space and weight were at a premium, I probably could even have run this from AAA cells (about half the capacity of AA’s).

Think about that for a moment: in terms of average, overall duty cycle, the LEDs are off something like 95% of the time. We just notice all the motion and colors.

This “Guggenhat” project with hundreds of NeoPixels also does its job just fine with lowly AA batteries.

Scale the run time down by at least 20 percent to allow yourself some emergency reserve…conventions are full of surprises. Also, it’s futile to keep track of the cumulative run time when using this off-and-on over a weekend. So if you’re doing something important…a masquerade event, a video shoot, surprising the artist with your homage…put in fresh batteries! Eking out those last few joules is not worth ruining a performance before an audience! Save any partially-run cells and use them in your TV remote or something.

Last updated on 2018-01-17 at 05.05.25 PM Published on 2017-05-03 at 02.45.38 PM