Sd card

hi if i put a few music tracks on an sd card, name say 1.mp3, 2.mp3 and 3.mp3 what steps would i have to go about to get the mega8 to play the tracks through a 3.5mm audio jack, say if you pressed a push button the first track would play etc. i dont need an lcd or anything, just very basic.

thanks
alex

Hello.

Reading and SD card and playing an MP3 are going to be anything but basic. If you want to make things significantly easier, you can buy a chip that is designed to interface with SD cards and another that is designed to play MP3s, and then use your mega8 to control those ICs.

- Ben

well that sounds easy enough… is there an example you know of anywhere?

I found this:
electronicdesign.com/Articles/In … cleID=6160

does anyone have any ideas of how the circuitry would look between this, an SD card and the mega8 to play through headphones???

I have no experience with reading SD cards and playing MP3s using microcontrollers, so I can’t really give you much help. If I were in your position I would google around to find out what ICs are out there that might fit my needs, and then I would read their datasheets to learn how to interface with them. Once you find a part number, you can usually google for that part number (e.g. “VNH2SP30 datasheet”) to find its datasheet. You can also often find the part and its datasheet at digikey.com.

- Ben

Sparkfun has a ‘ready to go’ board here. It’s built to interface with an ARM microcontroller, so it might be a pain to run it from an AVR, but it also has a little multi-switch that you can use to perform basic play/pause type functions directly. They say it has an SD-card socket, I guess it’s on the other side?

-Adam

wow thats perfect adam thanks… it says you can plug in a uext connection to control from microcontroller, is it hard to control arm from avr? will there be a library for controlling it?

I had to look it up (can you believe there’s no Wikipedia page on it? Maybe I’ll write one!) and a UEXT connector is I2C, RS232, SPI interfaces and power in one ten pin header. An ATMega8 has both I2C and SPI hardware, and I think there are hardware configuration examples in the data sheet, and example programs for both protocols in Orangutan-Lib.

By the way, SparkFun just resells this board in the US, the manufacturer’s page has some more info and pictures here.

While you’re thinking about buying one of these, keep in mind that although this device takes care of decoding and playing files for you, interfacing with it is still going to be a complicated task. You may be able to find guidance on the SparkFun forums, but you might also want to keep trying simpler exercises and build up to these more complex projects.

Whatever you pick though, good luck!

-Adam

yeah i thought that might be difficult. I thought about removing the switch on it, and attaching it to pins on the mega8, but that would give me choice over which track to play, just the next or last one… its also designed to be controlled by an arm microcontroller, which sounds like it will be even harder to control… i am surprised more people havent wanted to do this kind of thing - you know talking teddies and things surely dont have that compliated stuff going on!

hey! what about this!
mictronics.de/?page=mp3stick

all the firmware and sourcecode is there, its written in c on an avr. i would need the screen, and already have the avr (the mega8) can remove the button and control it from code - do you think simplifying it and modifying the code would be that difficult?

EDIT: dont bother rading this one, i found better - check posts below…

this is interesting, they say it can be programmed by many microcontrollers, please can someone who understands its datasheet have a look and see how hard it would be to play a requested (by the microcontroller) mp3.

sorry, datasheets is something i still have to learn to follow, especially for an entire board…

hi sorry last post didnt actually give a link. This guy on avrfreaks has done almost exactly what i;m after, he used a mega8 aswell. looking at his code, (everything is in the fourth down zip on the page) is it possible to get it to play a song with a certain name and remove all the buttons. in other words depending on a situation - lets say a termperature was too high, would it be possible to modify so that a track was played to say - "temp to high"
link is:
avrfreaks.net/index.php?modu … pe=project
ta guys

alex

That does look pretty neat, it has a pretty crazily wired little circuit though. That’s almost the same MP3 decoding chip that the little player board from Olimex is based on (he’s using a VS1003, the Olimex board uses a VS1002). If you do go ahead with this project I would still go with the “ready to play” board, or at least this breakout + basic components board (well, I would go with the ready to play board, since the breakout board costs almost as much!). Unless you want to add surface-mount soldering to your adventure.

I’m reminded of that scene in speed, where Keanu Reeves is trying to defuse the bomb under the bus, but his little cart thing breaks and he stabs the gas tank with his screwdriver to have something to hang on to until they can pull him back in that convenient removable floor panel:

What a wonderfully terrible movie!

-Adam

1 Like

i couldnt agree more, my little project is giving me enough troube as it is, but i had understood (probably wrongly) that the ready to go board was based on ARM and therefore to program would be difficult with the avr mega8, so thats why i asked about that one… if you think it would be to difficult, and your the expert, then as little hardware electornics as possible is definately preferable… do you think it wouldnt be too difficult to control functions of the olimex board…i need it to be able to play a certain track, rather than the next one or the last on or a random one, for instance if a temp sensor gets above a certain temperature it plays a track “temp too high” or something…

what d’you reckon

I would probably go with the ready to play board since it has the SD slot, a battery socket, and even a 3.3V dc/dc voltage booster and a battery socket (note, you’ll probably want to run your AVR at 3.3v too, to keep the interface simple, you can probably power it off of the mp3 board).

The VS1002d is itself a little microcontroller with some free space for users to put their own code on it, but the board doesn’t have an ARM microcontroller, it just has a connector that brings all the power and communication pins out on wires. The connector has a particular layout (UEXT) that lets you easily plug it into one of the ARM development boards SparkFun sells. It should be just as easy (well, just as hard really) to run it from an AVR, but this board would mean a lot less electronics overhead for you. I should look a little more into this UEXT thing, I’m not so sure they meant RS-232 as opposed to TTL level serial. Glancing through the datasheet, it looks like it has a UART for debugging information, and an SPI interface for controlling the chip. which would mean your AVR could communicate in all the protocols wired into the UEXT connector.

It’s still going to be crazy complicated compared to your timer project, but what’s the point of only doing things you already know how to do, right?

-Adam

Thats the way to look at it, you cant keep learning the same stuff…

trouble is, once i had somehow found out how to connect it to my microcontroller, i think i;d be a little lost as to where to go next, any got to try your modifications to my timer code now…

I was looking for info on the UEXT connector, and discovered this topic on the SparkFun forums. It clears up the ways you can use the board a little bit, but apparently documentation and support for the board is bad/nonexistant. I’m not sure this is something I would even want to approach as a hobby project, until there’s at least a complete, correct schematic available!

By the way, the answer to my earlier serial protocol confusion seems to be that the UEXT connector does typically use the RS-232 protocol on the serial pins, but there is no level shifter curcuit on the Mod-MP3 board. Instead it has a separate connector for the VS1002 MP3 decoder’s UART interface, and the UEXT connector pins that would normally be RS-232 TX and RX are repurposed (one is now a reset pin!). If that all sounds terribly confusing it’s because it is!

-Adam

so does that put me back to the avr-freaks mp3 player???

Not necessarily, this just probably shouldn’t be your first digital interfacing project.

Actually someone on that SparkFun forum pointed out that you could get much the same functionality by getting a cheap little USB-drive MP3 player and faking out the button inputs with a microcontroller.

-Adam

yeah i saw that and thought about it, but dont think i can get it to “select” a certain track by doing that. Because i have an old mp3 player that i considered doing that with (something that actually is within my expertise!), but i really want to be able to choose which track to play???