I’ve used the combination of CR2032 coin cell and piezo speaker before for sound-based kits to good effect (see https://www.tindie.com/products/madlab/mr-whiskers-kit for example) but the effectiveness depends on the particular sound sample used. I wanted the Angry Bee samples to be quite punchy and a piezo speaker doesn’t really have much bass. So I switched to a small moving-coil speaker which has a much lower impedance (8 ohms typically) than a piezo and draws more current. Too much current for a PIC pin to drive directly so I added a BJT transistor. The current draw is also excessive for a coin cell so I needed an alternative. A pair of AAA cells would have worked well but they’re a little heavy and bulky. A better choice, and something I haven’t used before, was a supercapacitor which can deliver essentially as much current as required (but not necessarily for a long time).
I used a 5.5V supercap which can safely be charged to 5V from USB. Supercaps have extremely low internal resistances so will draw a very high current if connected directly to a power supply. I limited the current from the USB port to avoid damaging or shutting it down by adding a series resistor of 50 ohms (actually two 100 ohm resistors in parallel to limit the power dissipation to 1/4W for each resistor). This fixes the current at 100mA and at that current the supercap will effectively be fully charged in 10 minutes or so.
A 5 farad supercapacitor charged to 5 volts will store 25 coulombs of charge, which is equivalent to 25mA for 1000 seconds or over 15 minutes. (Compare that with a CR2032 coin cell with an 800C capacity). That seemed like a reasonable budget to work with. Of course the current consumption most of the time when the PIC is sleeping will be much less than that and when it’s playing a sample it will be higher.
A capacitor can only ever be charged asymptotically to its supply voltage though and when it’s discharged to about 2.3V the PIC will stop working (with brown-out reset disabled to stop it prematurely restarting at a higher voltage than that). So only about half of the charge in the supercap will actually be usable.
A 10 minute charge will store enough energy for more than a hundred triggers of the sample which I was happy with.
The USB connector (USB-A) is fabricated on the PCB itself. The PCBs I ordered were 2mm thick which is a standard thickness but very slightly too thin perhaps for a reliable USB connector. However it worked well enough I found. An ENIG finish on the board makes the USB connector more durable (but not a hard gold surface finish so it will wear eventually perhaps).
I used an LDR as a simple motion detector. Any change in light level (such as a person approaching) can trigger a response. The preset adjusts the sensitivity (in software rather than in hardware).
I used a 47k preset connected to an analogue pin to adjust the light sensitivity and also to act as an off switch when at the extreme end of its travel. The preset is permanently connected to the 5V supply so will draw current even when the microcontroller is in sleep mode. I could have used a pin on the processor to gate the 5V and indeed I did have a spare pin. The current draw though is ~100uA so not really significant.
The same is true of the potential divider for the LDR which is also permanently connected to 5V. The current draw is of the order of 50uA so also not too significant.
There is also a little current leakage from the supercap itself which, according to its datasheet, is about 30uA, plus the current consumed by the PIC itself when in sleep mode. So the total quiescent current draw is approximately 200uA.
I used PWM to output a variable voltage to the speaker. The PWM runs at the maximum processor speed of 32MHz with a duty cycle with a 7-bit range.
There are a pair of 3mm red LEDs for the eyes which flash rapidly when the samples are triggered.
The sound samples are stored packed in flash memory....
Read more »
James Hutchby - MadLab
lion mclionhead
Bruce Land
Alex Fatiuk