Making Things Talk

From Hack Manhattan Wiki
Jump to: navigation, search


Making Things Talk

Goal: to have a small, very inexpensive board which can be hidden/installed in every day objects to enable them to talk or produce sound effects in response to various trigger conditions.

Should be able to run for weeks (ideally months/year) off max 3 AAA cells, preferably 2 AA/button or one lithium coin cell - in other words, it must spend most of the time in uA sleep modes.

Storage Options

Really only need a few (tens of) megabytes to store clips.

SD/uSD/SDHC

More expensive, unless media cost is considered external to the "kit" and only the socket (if any) included in the BOM. Sockets cost $2 and up.

May not "officially" work at low voltages. Not sure what the quiescent current will be (could it be powered from a GPiO?)

uSD - Can solder wires to the full-size adapter and use that as a budget socket. JR has 2G non-HC uSD for $5.99 and 4G uSDHC for $7.99, in stock in the store.

SD - maybe find older ones (but sockets are more expensive)

Using a file system adds complexity. Can treat the device as a sea of raw blocks for simpler firmware and write to it from linux or some windows implementation of dd - but may want to deal with a (partial) file system implementation in the long run for ease-of-use.

Discrete SPI flashes

$2.45 SST25VF032B-80-4I-S2AF-ND 32 Mbit (4MByte).

Works out to 3 minutes of 20KHz 8 bit (or uLaw) audio, 90 seconds of 16 bit (which when you consider that most clips are <5 seconds actually provides quite a bit).

Rated 2.7-3.6 volts - may not work too well if two cells are run down (will _not_ work on NiCd/NiMh). Would require a regulator to run from 3 cells.

nA quiescent current

STM32f10x Arm Version

Prototyped with the STM32VLDiscovery $12 board. Bare chips cost $2-5 depending on memory, but are 48 or 64 pin PQFP's so more advanced soldering and PCB required

Has a real DAC, so not limited to PWM audio

Enough ram to simplify buffering (especially if a file system is used) and to potentially run custom programs/scripts out of ram after loading them from media (ie, user can customize not only the clips but the algorithms, without actually flashing the "firmware" since it could just load and validate a custom subroutine from "data" memory.

Development: GCC from sourcery. Can use an STM32VLDiscovery to SWD a custom board. Or hack up an ARM jtag. Linux libusb solution for discovery board is not perfect yet, but usable with less dmesg spewage from the broken mass-storage implementation than occurs when doing it with SCSI generic interface. Do need to tell mass_storage module to ignore the board, tricky if that module is already loaded from the initrd on boot. Windows tools allegedly work.

ATTiny 85/861 Version

$2-3 chip. See proof-of-concept at Elm Chan http://elm-chan.org/works/sd8p/report.html ('85) or http://elm-chan.org/works/sd20p/report.html ('861)

The 85/861 have higher rate PWM capability than the other tiny or mega parts, so better audio quality

Main advantage: simplicity, processor available in DIP package for easy soldering

Probably want the '861 because the 8-pin '85 won't have many pins available for trigger input after flash is connected

Only 512 bytes of ram in the largest versions - have to be very careful with audio buffering. Can't run code out of ram.

Allegedly can flash it with an arduino: http://hlt.media.mit.edu/wiki/pmwiki.php?n=Main.ArduinoATtiny4585

Audio Amps

PWM Amp

ie, just drive the speaker digitally using transistors Bipolar half-bridge driver from PNP & NPN transistors - can use a DC block cap in series with the speaker to prevent quiescent current wastage, but the bridge itself will leak a small amount of current.

Use only one transistor and no DC-block cap, but remember to shut the PWM off when not in use.

Ramping up/down from 0% duty cycle to 50% at 1 count/sample period before/after playing a clip avoids audible click/pop.

Loudness of PWM solution compares poorly to an LM386.

TPA701D

$1.40 0.7 Watt but it's an SOIC-8 which means SMT, though at only 8 pins not that bad

Not prototyped yet due to SMT, but should be "better" than the LM386

Probably only 200-250 mW if run on 3v battery supply. Requires two resistors and two caps.

Should go in and out of 1.5 nA shutdown mode without a pop (it's a bridge tied load, no output cap)

Digi 296-1949-5-ND http://www.ti.com/lit/ds/symlink/tpa701.pdf

LM386N

Not under "serious" consideration but grabbed one at RS and breadboarded in up to compare to the PWM solution, and it is much louder. Major reasons for not considering it are figuring out how to shut it down to a low power mode without inducing a pop.

Speakers

Various available for $.50-1.50 also dollar store headphones yield two

Triggers

Ie, ways to cause the device to talk (perhaps unexpectedly!)

  • Low power triggers, can wake from battery-saving sleep mode
    • Tilt switch (ball, not mercury)
    • Timer (at least on arm devices with a 32 KHz RTC)
    • Push button - good for testing/turning on
    • Magnetic reed
  • Higher power, have to poll or only use soon after awake
    • Light sensor
    • Microphone / audio processing
    • Capacitive proximity sensor?

External Interfaces

  • Serial, perhaps pinout for installing FTDI header (can always use something else)
  • USB versions of chips are more expensive, soft USB more complex
  • IR remote/IRDA? (STM32f10x supports IRDA)
  • Radio? Bluetooth serial could be useful for debugging

Shopping List

Digi

  • ATTINY 861's (and 85's?)
  • STM32F100's (32k budget) 497-10500-ND Qty 2
  • STM32F1000 (128k) 497-10498-ND
  • TPA amps 458-1131-ND 2 more?
  • LM386N's?
  • 2 more tilt switches
  • 36mm speaker 458-1129-ND qty 2
  • 40mm speaker 458-1131-ND qty 2
  • Some kind of SOIC-8 proto adapter... what, where?
  • SMT resistors?
  • SMT bypass caps?
  • Electrolytics, maybe 10-100uF?
  • .1uF polyester caps?
  • pin sockets!

Schmartboard

  • PQFP48 0.5mm schmartboard DIP adapter (also maybe the 56 pin cheap ones?)
  • PQFP100 0.5mm schmartboard (general principles?)