Go Down

Topic: New library for PWM playback from SD cards: SimpleSDAudio (Read 47860 times) previous topic - next topic

purgedsoul

Forgive me for asking this, I'm just recently learning about SPI and I2C. But can I use an I2C device (specifically an accelerometer e.g. ADXL345) together with this library? My plan is to play a sound based on the accelerometer's inputs.

Tuttut

The audio lib uses a timer and the hardware SPI. I2C is often a different hardware in uC, so I2C should still work beside the audio lib. For additional SPI devices also software-SPI might be an option and that way it should be possible to run SPI devices on pins not already used by the audio lib as well. So just give it a try.

meowth08

Hi,

I used arduino with atmega324.
Connected sck of sd card to sck of arduino.
miso of sdcard to miso of arduino.
mosi of sd card to mosi of arduino.

I connected cs of sd card at pin4 of arduino.
and tried to get audio output at pin 9 and then at pin 10 but no luck.
I tried the examples at simplesdaudio.

My speaker is 8 ohms 1 watt.
What could be the problem?

Tuttut

1: I don't know if the lib work with ATmega324 and I don't know Arduinos with that processor. The typical processor is ATmega328.

2: Have you use level-shifters or does your Arduino run with 3.3V only? If the Arduino is 5V you need level-shifters or you could broke your SD card. The simplest way to build a level-shifter is using two resistors for every of the four input pins at the SD card. A description can be found in file SimpleSDAudio.h.

3: You have to power the SD card as well - connect GND to pin 3 and 6 of SD-card and connect pin 4 to the 3.3V output of the Arduino.

4: If there is no sound try the example BareMinimumWithDebug first and look at the output from the serial port. This can give you an indication if your wiring is still wrong or if there is something wrong with the filesystem on card or the file. You can post this output here in the forum to get more help.

meowth08

Quote
1: I don't know if the lib work with ATmega324 and I don't know Arduinos with that processor. The typical processor is ATmega328.

It is sold here. http://www.e-gizmo.com/KIT/gizduino+%20164,324,644.html
Quote
2: Have you use level-shifters or does your Arduino run with 3.3V only? If the Arduino is 5V you need level-shifters or you could broke your SD card. The simplest way to build a level-shifter is using two resistors for every of the four input pins at the SD card. A description can be found in file SimpleSDAudio.h.

It has 3.3V.  No need for level shifters.
Quote
3: You have to power the SD card as well - connect GND to pin 3 and 6 of SD-card and connect pin 4 to the 3.3V output of the Arduino.

Did that already.
Quote
4: If there is no sound try the example BareMinimumWithDebug first and look at the output from the serial port. This can give you an indication if your wiring is still wrong or if there is something wrong with the filesystem on card or the file. You can post this output here in the forum to get more help.
It failed the first test. And I am not certain where to connect the cs pin. Digging the datasheet of 328 and 324 does not help. I am having a hard time understanding both.

meowth08

Do you think this board will work for this library?

http://www.e-gizmo.com/KIT/Gizduino.html

xl97

I think the library has the CS pin default to pin 4 (D4)

but there is a line in sketch that allows you to set it to whatever pin you want..


meowth08

After connecting the SPI pins on corresponding pins, CS to pin 4, 100 ohm resistor to pin 10 and then the speaker, I tried measuring the 3.3 volt supply from the board and it went up to 4.3 volt. I think it's not normal. What might be the cause?

xl97

I thought the default out put was from pin 9?

and the bonus/extra pin that could be used was pin 10?

I also have never used a resistor... but instead a 100uF cap...

No clue on the voltage spike.. where your measuring?..with what?..etc..etc..


meowth08

My board has a 5V and 3.3 V.

I directly connected the MOSI, MISO, and SCK of the SD card to the MOSI, MISO, and SCK of my arduino.
I also directly connected the VCC pin of my SD card to the 3.3V of the arduino.
After connecting everything, I checked the voltage at the 3.3V pin of my arduino.
I used a fluke to measure the voltage. I got a reading of 4.3 volts.

I'll try the 100uF. It might work.
Also, I'll try connecting the audio out to pin 9.

Tuttut

Hi, I looked over the Gizdino+ schematic: It runs on 5V, so you need level-shifters and you should test the 3v3 pin before with a multimeter to ensure that at least there is 3.3v. Second, the gizdino+-thing has sanguino pinmap, but datasheet says that there is a mapping for arduino-compatibility. Whatever, in the end you must ensure that the hardware spi pins are connected correctly to the card, so mosi to mosi, miso to miso, clk to clk and cs to pin 4 - but i dont know if in arduino or sanguino or gizdino numbering. Even if that is all correct i dont know if it will work because that clone is not very compatible to arduino. better go for the real one - at least take one with the correct cpu. the gizdino-non-plus version may work, but beware - the statement that it is 3.3v seems to be a bad typo to me...

xl97


My board has a 5V and 3.3 V.

I directly connected the MOSI, MISO, and SCK of the SD card to the MOSI, MISO, and SCK of my arduino.
I also directly connected the VCC pin of my SD card to the 3.3V of the arduino.
After connecting everything, I checked the voltage at the 3.3V pin of my arduino.
I used a fluke to measure the voltage. I got a reading of 4.3 volts.

I'll try the 100uF. It might work.
Also, I'll try connecting the audio out to pin 9.


I believe you are referring to the outputs/pins....

but this does NOT mean your board runs on +3.3v logic level..

example the Arduino UNO has +5v & +3.3v output pins....

however the boards runs on +5v logic...  (even though there is a regulator outputting +3.3v on a pin or two)



I have tested/used this library on custom boards, Uno/Duemilanove (+5v)..  and even minimal Arduino circuits running on +3v, 8Mhz internal clock  (ie: no crystal no caps..etc)


First thing is to get an SD shield that properly works with your set-up..




meowth08

#132
Feb 22, 2013, 08:55 pm Last Edit: Feb 22, 2013, 09:07 pm by meowth08 Reason: 1
Hi,

Thanks for the replies.
I had a little experiment that may help you help me.
I measured SCK of SD car to gnd: 0V
MOSI = 4.4V
MISO = 5V
CS = 5V

Added later: I guess this already shows the error on interfacing.
Do you think this http://www.sparkfun.com/tutorials/65 can already correct the error?

Tuttut

Hi,
is it so hard to believe that your board is running on 5V and not on 3.3V even that #*&! website says something different? That you measured the 3.3V line at 4.2V is a sign that your SD card is fighting a deathly battle against the 5V. What happens is the following: The SD card is connected to 3.3V at VCC, but at 5V at one of the other pins. An internal protection diode in the card tries to clamp the excess voltage at the pin with 5V to the 3.3V supply, but that supply is also weak because the crapduino uses some 3.3V from the USB-seriell-converter chip instead of a powerful extra regulator. This way the 3.3V regulator looses the battle and its output voltage rises to 5V minus the typical diode foreward-voltage of 0.7-0.8V = 4.2V. This is not how it should be done! You can destroy your AVR, the USB-Seriell-Converter or the SD card. I don't know how long this battle can take place and who will win, but you might have already broken something. Hint: Try if your SD card still works within a PC before spending more time frying stuff...

Believe it: YOU NEED LEVEL-SHIFTERS or a SD-shield that has those!

meowth08

The SD card is still working.
It still contains the DING, DONG, and EXAMPLE.

I will then construct the "DIODE" from this site.
http://www.sparkfun.com/tutorials/65

Go Up