Saturday, January 21, 2012

Yule-themed gloves (or, inconsequential blinking lights)

I recently had the idea to make a coin-cell-powered cycling signal glove for myself; to 'prototype' the idea, I decided to put together a set of holiday-themed blinky-light gloves as a christmas present.  The objective was to make the electronics as unobtrusive as possible; they ended up being barely bigger than a CR2450 coin cell battery.

Here are the gloves, in 2D and 3D:


Hardware
There are two halves to the 'hardware': the glove side (gloves, LEDs, wiring and connector) and the battery module side (battery, switch, controller and connector).

The overall electrical diagram for the project is below (sorry for the handwritten schematic; my philosophy is, if I'm not going to make a board or do any complicated simulation, the circuit doesn't get any further than dead trees)


As you can see, it is super simple.  The module is basically a battery, a capacitor, a switch and a breakout of the ATTINY85 to the connector.  The gloves are just LEDs and current limiting resistors (all of the resistors ended up being 30Ohm) wired common-cathode to the connector.

The battery modules were hand-made as small as possible; I roughed up the plastic of the CR2450 battery clip to allow the capacitor, ATTINY, switch and connector to be superglued directly to it.  I then made a bunch of tiny end-stripped lengths of wire-wrap (because it was on hand) and hand-soldered all the connections.  Since the connectors are 0.1" spacing and completely break out the pins of the ATTINY, this solution also had the benefit of making programming and debugging easy.


The gloves were just a bunch of fun arts+crafts work.  The green is felt, attached to some cheap CVS gloves with white string (surgeon's knots, in case anyone cares).  Each LED was soldered to two lengths of wire; the wires were then passed all the way through the gloves using large-gauge sewing needles.  The gloves were then turned inside-out, and the wires carefully routed to the wrist (with thread ties every so often; see immediately below).


The wires from the LEDs were then terminated through current-limiting resistors into the connector.  These connections, as well as those on the battery module, were mechanically stabilized with two-part epoxy.  The battery module is shown plugged into the glove with the wrist of the glove rolled up below.


Here is a document outlining the mouser order that contained all of the components used here, except the 10Ohm resistors, hookup wire, gloves and felt.

Software
As you can imagine, the software is exceptionally simple.  There are two firmwares, one for each glove.

Tree Glove
Here, I wanted the 'star' LED to flicker and the other LED pairs to randomly turn on and off at about 2Hz.  At any given time, no fewer than 1 and no more than 3 red LED pairs would be on at the same time.

The 'star' LED is driven by one of the PWM channels; 8 levels of amplitude seemed sufficient to me.  The evolution of the brightness levels was a random walk; it was equally likely to stay at the same level or rise or fall by 1, 2 or 3.  Any over/underflow beyond the [0 7] range is reflected back.

Instead of implementing a random number generator in software (Dec. 25 was fast approaching), I pre-generated a sequence of random bytes using MATLAB, and hard-coded them into the source.  The lower four bits specify which LED pairs are on, and the upper 3 bits specify the PWM duty cycle.

Source and hex.

Wreath Glove
For this one, I wanted all of the LED pairs to flicker independently.  Four amplitude levels for each LED pair seemed sufficient.  Additionally, this allows me to pre-generate and hardcode the necessary random bytes without reusing too many of the bits and thus doing unfortunate things to the independence between the channels). Bits 7:6 determine the level of pair 4, 5:4 -> pair 3, 3:2 -> pair 2, 1:0 -> pair 1, 4:3 -> pair 0.

Unfortunately, the ATTINY85 doesn't have five PWM output channels, so I had to improvise.  I could have simply implemented a five-channel PWM in software, driven by timer overflow interrupts.  However, since I only need four levels, including 'off'', I was able to use the timer overflow and two compare interrupts to set/clear the LED port according to the commanded level:

0-------->COMPa-------->COMPb-------->OVF

All levels (except 'off') result in a port being set at the OVF interrupt; only the 'high' and 'medium' levels are set at the COMPa interrupt; and only the 'high' level pairs are set at the COMPb interrupt.

Source and hex.

Lessons
Overall, this project turned out better than I would have expected.  I was especially pleased with the way the flickering star ended up; the walk frequency and pattern ended up looking exactly like I wanted.  Additionally, the battery modules ended up being nice and small, and with the epoxy ended up being reasonably comfortable.

The biggest thing that I would have changed is the choice of wire.  The wire I used was a stiff, insulated solid-core wire that I happened to have on hand.  This was fine for the holiday gloves, since they are not going to be used much and the wires are all on the back of the hand, thus safe from excessive flexing.  However, moving forward to the turn signal cycling gloves, I will have to find wire which can flex repeatedly without breaking.

No comments:

Post a Comment