NerdKits - electronics education for a digital generation  
Did you know that SPDT stands for "Single Pole, Double Throw"? Learn more...

You are not logged in. [log in]

Everything Else » SD card for PCM sound

November 26, 2009
by pbfy0

I wrote a program for reading a SD card and playing the sound on it. It can also take sound from the computer over the UART and load it into the SD card. You send the nerdkit 'l' and then PCM data in binary. use libsndfile (compile & install) and pcm2nlsv to get PCM audio with values separated by newlines. Here's a pinout of a SD card

pinout

and the connections are this:

SCK -- 1.8K -- SD pin 5 -- 3.3K -- GND
MISO -- SD pin 7
MOSI -- 1.8K -- SD pin 2 -- 3.3K -- GND
SS -- 1.8K -- SD pin -- 3.3K -- GND
SD pin 3 -- GND
SD pin 6 -- GND
SD pin 4 -- LD1086V33 -- VCC

I can't find the source right now, but I'll post it when I find it.

November 27, 2009
by pbfy0

I found the source, and I changed it so it takes a number in ASCII instead of bin. here it is. I'll make a perl script to send a file with PCM values separated by newlines, and post it when I'm done.

November 27, 2009
by pbfy0

Libsndfile should be here.

November 27, 2009
by pbfy0

I have the perl script, here, and I have the complete process for getting a wav file onto the chip.

1) install libsndfile
    *) download it
    **) cd, ./configure, make, make install
2) compile & install pcm2nlsv
    *) download from http://nerdkits.pastebin.com/f185f2ff8
    **) run gcc -o pcm2nlsv pcm2nlsv.c
    ***) if you want, copy pcm2nlsv to /usr/bin
3) run conversion commands
    *) run these commands
    sndfile-convert -pcmu8 <infile> <outfile.raw>
    pcm2nlsv <infile.raw> <outfile>
4) upload file
    *) upload the program in the previous post
    **) run this:
    ./sound.pl <infile> <port>

<infile> for sndfile-convert is any music file

<outfile.raw> for sndfile-convert is <infile.raw> for pcm2nlsv

<outfile> for pcm2nlsv is <infile> for sound.pl

<port> for sound.pl is the serial port address. Only do steps 2 & 3 if you're repeating the sequence. Remember, the C program is UNTESTED.

November 29, 2009
by pbfy0

I noticed an error in the code, here's the fixed one.

March 09, 2010
by pbfy0

the SS pin on the connections table should be connected to SD pin 1 where it just says SD pin

March 20, 2010
by brian

I thought SD cards ran off 3.3 volts, doesn't the NerdKit use 5V?

March 22, 2010
by pbfy0

the LD1086V33 is a 3.3 volt regulator, and the resistors regulate the data levels.

Post a Reply

Please log in to post a reply.