Yesterday, my son and I were looking at the “Quantum Bit” toys sold by ThinkGeek. These are LED lights with plastic cases that flash briefly then fade after a second or so. We tried reverse-engineering them from what we could see through the clear cases, then building the electronics to see if we got it right.
A rather blurry closeup of the “quantum bit” toy. The two white LEDs are triggered by the vibration switch in the middle. There are two coin cells on the back of the PC board to power the device. In addition to the vibration switch, the electronics seem to consist of 2 capacitors, 3 resistors, and a transistor.
The key to the device is a vibration switch that consists of a spring coiled around, but not touching, a metal wire. Shaking the device causes the spring to move around and touch the wire briefly. Those brief contacts are turned into longer pulses by the electronics.
The first thing I did was to look at the flashes with a phototransistor, a 1kΩ resistor, and an oscilloscope (because I happened to have a phototransistor wired up from a previous project). I could see very rapid turn-on for the LEDs (faster than the response time of the phototransistor circuit), followed by moderate-speed exponential decay, followed by a slower, very dim fade:
This 50ms/division, 2V/division trace shows a couple of bounces of the contact, followed by the exponential delay. It took me several tries to get a clean single hit like this—most often I got a series of decaying pulses, as the spring bounced back and forth and made multiple contacts.
From the decay curve, I estimated a decay time constant of about 28msec initially, slowing down as voltage dropped. We guessed that the circuit consisted of a couple of capacitors connected by the vibration switch: one slowly charged by the coin-cell batteries in the device, the other rapidly charged from the first when the vibration switch makes contact, then slowly discharged through a resistor and the base-emitter junction of an NPN transistor. We guessed which resistor was the one that produced the decay, and (with some struggle through the distorting plastic casing) read its value as 3.3kΩ. That gave us a capacitance around 8µF (other measurements of the decay got different time estimates, so we guess that the capacitor is 4.7µF or 10µF, those being popular sizes for ceramic capacitors).
The other two resistors are 22Ω and are probably series resistors to limit current through the LEDs (that is probably not necessary, given the high internal resistance of the batteries).
We tried duplicating the circuit using a different LED and a pushbutton in place of the vibration switch:
The resistor R1 limits the current through the LED and also sets the charging time for C1—it approximates the internal resistance of a pair of coin cells. C2 and R2 provide RC decay (down to the threshold voltage for the base-emitter junction). Once the voltage has decayed enough, the base current is limited by the characteristics of the transistor rather than resistor, and the decay slows way down.
This circuit worked fine and gave flashes of light that lasted about the same amount of time as the original device. I tried reducing R1 to 50Ω to get brighter flashes with the green and blue LEDs of an RGB LED, and the flash and fade looked a lot like the white LEDs of the toy.
While we were looking at vibration switches, we decided to redesign the SparkFun “Wake on Shake” device, which uses an ATtiny2313A microprocessor and an ADXL362 accelerometer to control a pFET. The idea is that the microprocessor samples the acceleration occasionally and turns on the pFET for 5 seconds. They claim that the device takes only 2µA at 3.7V, which seems almost reasonable, since the ADP60-3.3 regulator takes 1µA, the ATtiny takes 2µA (assuming the microproccesor is powered down without a watchdog timer, woken by the ADXL362), and the ADXL362 takes 0.27µA when in motion-triggered wake-up mode. But using microprocessors and accelerometers for this task seems like overkill—the whole thing should be doable by a vibration switch and a few analog parts, at considerably lower cost.
We set out to do a design with a somewhat wider voltage range and lower power budget (say 1.8V–5.5V and only 1µA) controlling a beefier pFET (lower on-resistance) at a lower parts cost. The design of the LED flashing circuit won’t work for us, because we want the pFET either to be all the way on or all the way off—not heating up in the linear region. The switch and RC circuit are fine, but we can’t read the RC delay with just an NPN transistor—it doesn’t provide a sharp transition. Instead we chose a low-power comparator, the TS881, which can operate on less than 400nA and that has a supply voltage range of 0.85V to 5.5V. Initially, I just planned to use the output of the comparator to drive the pFET gate directly, but my son wanted to add the capability to have an external active-high “wake” signal that kept the output on, and that turned off quickly (not with the 5-second delay) when removed (possibly under the control of the circuit that normally gets 5 seconds of power, so that it can keeps its power on until it is done). To add this extra functionality, we put in another stage between the comparators and the pFET:
After C1 is charged by the vibration switch, it discharges through R1. The comparator output is high as long as the voltage on C1 is more than 1/3 of the supply voltage, which turns on Q2, which then turns on the pFET.
The pFET was chosen to have a very low threshold voltage (so it could be turned on even with low-voltage supplies—the pFET threshold is the main limitation on how low the voltage can go) and a low ON-resistance, so that moderately high currents could be handled. With a minimal pad layout, I calculated that the pFET could handle about 2A. With 2oz copper and a square inch of board space on the back as a heat sink, perhaps 4A. Note: if the pFET is used to power anything with significant current, one would want a much larger bypass capacitor than the 4.7µF shown here—something like a low ESR aluminum-polymer electrolytic capacitor with over 100µF of capacitance.
The NPN transistors were chosen to be a cheap pair in a single package (reducing assembly cost slightly).
The timing capacitor was chosen to be a film capacitor, to get better precision on the capacitance and less temperature dependence. Unfortunately, this limits the amount of capacitance, unless a large through-hole capacitor is used. That in turn requires a large resistor to get the RC time constant, which puts strong constraints on how much leakage current is permitted on anything connected to the charged node. If the 5-second on-time can be allowed a large fluctuation in duration, then C1 could be a 10µF ceramic capacitor and R1 a 470kΩ resistor, but the bypass capacitor on the other side of the switch would have to be made much larger, to ensure that C1 is fully charged in the momentary contact of the vibration switch.
The voltage divider takes up to 5.5V/20MΩ (183nA), the comparator up to 750nA, and the leakage through the NPN transistors when off about 20nA each, and about 300nA leakage through the pFET for a power budget of about 1.3µA when the circuit is not activated (SparkFun hadn’t counted the pFET leakage, and adding that to our power budget put us over our arbitrary 1µA limit). We originally had nFETs instead of NPN transistors for the comparator output and WAKE inputs, but think that they would leak more current in the presence of noise on the WAKE line. The pullup resistor adds up to 2.5mA of current when the pFET is turned on, which is probably a bad thing if the load is small.
If you don’t need the functionality of the WAKE line to hold the circuit on, a simpler circuit will do, without the power consumption of the pullup resistors:
Without the need for “wake” functionality, the extra OR-stage of bipolar transistors can be eliminated, if the inputs of the comparator are swapped.
If the WAKE function is supposed to do the same thing as shaking (providing about a 5-second ON time, rather than turning off quickly), then the bare circuit above can be made to have the WAKE function:
Here an nFET is put in parallel with the vibration switch, so that the WAKE signal has the same effect as vibration. My one concern is that the leakage currents through the source of the nFET will make the RC decay computation wrong—both drain-source and gate-source leakage currents could be a problem. Unfortunately , these are specified on data sheets at quite different operating conditions than we have here. One could also use an optoisolator in place of the nFET, but the dark current may be enough to charge the capacitor.
Warning: none of the Shake’n’Wake circuits here have been tested (only the LED flashing circuits)—this is all paper design. I think that everything here should work (except the nFET for WAKE in the last schematic, which I suspect has too much leakage current), but it has not been built and tested. Long experience leads me not to trust paper designs, so I recommend that you not rely on these designs, until you have prototyped and tested them. I probably won’t bother to, as most of the parts are surface-mount parts, and so a bit of a pain to work with.