Input

To start with, made a hello.mic.45 board and worked out on paper how the input circuit works.

Did not want to use a separate power source, so removed the 5V regulator and powered directly from FTDI using this modification to the traces



This gave nice sound input (once I got the Tiny45 and electret orientations right!):


Here when "singing" a fixed vocal sound:


Thoughts on the input circuit here (to the differential ADC with 20x gain):




Programming it:

(while powering from FTDI)

make -f hello.mic.45.make
sudo make -f hello.mic.45.make program-avrisp2

dhcp-18-111-104-176:desktop adammarblestone$ make -f hello.mic.45.make
avr-objcopy -O ihex hello.mic.45.out hello.mic.45.c.hex;\
avr-size --mcu=attiny45 --format=avr hello.mic.45.out
AVR Memory Usage
----------------
Device: attiny45

Program: 568 bytes (13.9% Full)
(.text + .data + .bootloader)

Data: 201 bytes (78.5% Full)
(.data + .bss + .noinit)


dhcp-18-111-104-176:desktop adammarblestone$ sudo make -f hello.mic.45.make program-avrisp2
Password:
avr-objcopy -O ihex hello.mic.45.out hello.mic.45.c.hex;\
avr-size --mcu=attiny45 --format=avr hello.mic.45.out
AVR Memory Usage
----------------
Device: attiny45

Program: 568 bytes (13.9% Full)
(.text + .data + .bootloader)

Data: 201 bytes (78.5% Full)
(.data + .bss + .noinit)


avrdude -p t45 -P usb -c avrisp2 -U flash:w:hello.mic.45.c.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9206
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "hello.mic.45.c.hex"
avrdude: input file hello.mic.45.c.hex auto detected as Intel Hex
avrdude: writing flash (568 bytes):

Writing | ################################################## | 100% 0.20s

avrdude: 568 bytes of flash written
avrdude: verifying flash memory against hello.mic.45.c.hex:
avrdude: load data flash data from input file hello.mic.45.c.hex:
avrdude: input file hello.mic.45.c.hex auto detected as Intel Hex
avrdude: input file hello.mic.45.c.hex contains 568 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.17s

avrdude: verifying ...
avrdude: 568 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

dhcp-18-111-104-176:desktop adammarblestone$

(after removing the ISP connection)

dhcp-18-111-104-176:desktop adammarblestone$ ls /dev/tty.*
/dev/tty.Bluetooth-Modem /dev/tty.Bluetooth-PDA-Sync /dev/tty.usbserial-FTF6JU97
dhcp-18-111-104-176:desktop adammarblestone$ python hello.mic.45.py /dev/tty.usbserial-FTF6JU97

How this program manages to sample fast enough to record audio (300-3500 Hz): it uses a buffer

//
// free-running sample loop
//
for (i = 0; i < NPTS; ++i) {
//
// initiate conversion
//
ADCSRA |= (1 << ADSC);
//
// wait for completion
//
while (ADCSRA & (1 << ADSC))
;
//
// save result
//
array_lo[i] = ADCL;
array_hi[i] = ADCH;
}
for (i = 0; i < NPTS; ++i) {
//
// send result
//
put_char(&serial_port, serial_pin_out, array_lo[i]);
put_char(&serial_port, serial_pin_out, array_hi[i]);
}

Neil discussing alternative circuits: