Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: redloff on March 02, 2013, 12:46:47 PM

Title: elm-chan's wav player
Post by: redloff on March 02, 2013, 12:46:47 PM
Hi,

I am currently working on a project which involves playing random sound depending on the intensity of light.
I found a perfect project which I would like to use:
http://elm-chan.org/works/sd8p/report.html (http://elm-chan.org/works/sd8p/report.html)

Unfortunately I can not get any sound out of it. I found many potential 'software' issues like wrong fuse bits, hex file, wav file format, etc... but it would help me a lot if someone could simply look at the circuit I made and tell me if I didn't make any stupid mistake using some odd component or something.

Maybe you would also have an idea about what else could I do wrong and how to pinpoint the cause.

Photos of my circuit with detailed description:
(http://87.119.59.91/~redloff/elmchan/top.jpg)
(http://87.119.59.91/~redloff/elmchan/side1.jpg)
(http://87.119.59.91/~redloff/elmchan/side2.jpg)

In case any of the thumbnails here are unreadable all three photos can be found here in full resolution:
http://87.119.59.91/~redloff/elmchan/ (http://87.119.59.91/~redloff/elmchan/)


I would greatly appreciate any help.
Title: Re: elm-chan's wav player
Post by: jwatte on March 02, 2013, 01:59:00 PM
A 4 Ohm speaker will draw a lot more current than your AVR microcontroller can provide. You will need an amplifier circuit, like a LM386, to drive it right. If you don't want to go that way, you will at least need a transistor of some sort to buffer the current draw of the speaker.
Title: Re: elm-chan's wav player
Post by: redloff on March 02, 2013, 02:39:38 PM
ok then, I'm on my way with scrapping 8 Ohm small speaker from an old cell phone.
I also tried  piezo speaker (4.8 Ohm, 0.1 W) before, but with no luck as well.
Title: Re: elm-chan's wav player
Post by: redloff on March 02, 2013, 03:03:21 PM
OK, now I have a samsung avila speaker hooked up and meter shows it has 9.6 Ohm resistance.
Still there is no sound, but thanks anyway, that is at least one step forward.
Title: Re: elm-chan's wav player
Post by: jwatte on March 02, 2013, 07:34:42 PM
Ohm's law says: voltage = current * resistance.
So, current = voltage / resistance.
5V / 10 Ohms = 500 mA, which is a lot more than the 25 mA you should be getting out the AVR output pin.
You need an amplifier or transistor.
Title: Re: elm-chan's wav player
Post by: redloff on March 03, 2013, 06:40:21 AM
Thanks for your input.
I don't know how to explain it by the Ohm's law, but I have already used this speaker for this project with atmega328p (current available on pins are the same afaik):
http://avrpcm.blogspot.com/2010/11/playing-8-bit-pcm-using-any-avr.html (http://avrpcm.blogspot.com/2010/11/playing-8-bit-pcm-using-any-avr.html)
The sound wasn't the purest I've ever heard, but it was loud enough without using any additional amplifiers nor transistors.

On elm's schematics, there aren't any as well:
(http://elm-chan.org/works/sd8p/sd8p_mo.png)

I found one issue with sd adapter wiring, but it's fixed now, I also bought another sd, just to be sure it's ok, as I had a little accident with the previous one (5V instead of 3...)

I'm simply clueless, but not giving up yet.
Title: Re: elm-chan's wav player
Post by: waltr on March 03, 2013, 09:47:07 AM
There could be many different things wrong in hardware or software.
Is the speaker directly connected or through a series cap?

Back up to trouble shoot and put an LED/series resistor on the output pin. Then write some very simple code to blink the LED. Does it blink? If not try another output pin, if now works then the first output could be damaged.
Title: Re: elm-chan's wav player
Post by: jwatte on March 03, 2013, 07:46:42 PM
Try outputting a simple beep asa squae wave. Does that work?
Something like:
Code: [Select]
forever
  pin high
  delay 1 ms
  pin low
  delay 1 ms
There are so many things that can go wrong here with your program, your circuit, your sounds, the SDcard, etc, that you have to test them one at a time.
Title: Re: elm-chan's wav player
Post by: redloff on March 04, 2013, 02:58:06 AM
Shouldn't I be able to see a led getting dimmer/brighter if plug it in instead of speaker?

I replicated arduino board on a breadboard and I'm currently trying different libraries to communicate with sd card and see if that works - this would confirm the card is ok and that it's wired correctly.
The card gets detected but there are yet issues with the fs.

Thanks for the tips.