New library for PWM playback from SD cards: SimpleSDAudio

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.

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...

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.

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..

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?

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!

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

Another thing: I don't like the solutions from sparkfun levelshifter site because most of them are pretty slow. Better use a voltage divider with two resistors per line as described in SimpleSDAudio.h. This is proven to work even at fast SPI speeds as required for my lib.

if you really want to test this..

I suggest grabbing a few resistors.. and making a voltage divider, so that your LOGIC level will work correctly..

I have read about the voltage dividers being 'slow' (or too slow even).. but I have tried and tested this myself.. and it works fine for me & initial testing.

IMHO (again Im a noob! <--- disclaimer!) .. you have +5v Arduino/board.. (period)

In order for the SD card to 'work'.. you need an Arduino that RUNS @ +3.3v logic...
or
A voltage divider between Arduino & SD card.

+5V------4.7k-----(x)-----10k------gnd

this will be for mosi, sck, and cs

MISO does not need a level shifter.

is this already correct?

Follow this diagram (worked for me)

not sure the 4.7k / 10k will work..but other diagrams seem to elude to it works fine:

make 100% sure that your +3.3v output pin on the Arduino is REALLY outputting only +3.3v

Hi,
I think both voltage dividers will work, if you don't have those 1.8k and 3.3k resistors also the 10k/4k7 solution should do it. BUT: Do you really have a ~~CrApDuInO+~~gizDuino+ (the plus version)? In such a case please tell me exactly how the menu item under "Board" inside Arduino-IDE is called that you use. I can help you to get it running even on such strange Arduino board but it will need some "special handling".

I have the CRAPduino that appears on this site #?!! site.. http://www.e-gizmo.com/KIT/Gizduino.html

Only 4.7k and 10k resistors are available with me now.

The 3.3 volts pin on my crapduino outputs about 3.3 volts so it's correct.

In my voltage divider with 4.7k and 10k, i get a 3.3 to 3.4 volts accross 10k.

I use 1.0.3 IDE. Board: Gizduino (mini) with atmega 328. Programmer: AVR ISPmkII.

Ok, at least this Arduino clone has a ATmega328, better than the one with the plus at the end. If you do your wiring correct and with levelshifters it should work with the lib.

should work now...

voltage divider in place of the level shifter...

+3.3v output ON the +3.3v pin..

Can you run any other SD or sdFat libs to check the SD communication at all?? (be sure to check the CS pin used in the sketch)

Level Shifters. One of the more important but rarely addressed subjects. for the record either the 3K9 or 4K7 resistors will work fine. There is a slightly different method that can be used to give true level shifting. Instead of 2 resistors (Besides the bus pull-ups) a single mosfet is used. There is truly an added advantage in that the device is fully bi-directional it is described in this app note: AN10441. I have attached it to this post.
basically the Drain connects to the 5 V side (data - I/O), The Source connects to the 3V3 side (data - I/O) and the gate connects to 3V3. I had a bunch of 2N7000's and for the 3 or 4 I've built they've worked well. A BSS138 is recommended for this device and 2 or more? should fit nicely on one of those small SMT prototype boards. I also chose the 2N7000's because I had a bunch of them but I've not found it necessary to "Select" devices to make functional 2 wire translators, all have worked and I also use them in preference to the BSS138 because I breadboard everything and interconnect and a test all of any modules before I have an idea of what the final PCB is going to be.
As a note: Adafruit sells inexpensive level shifters for 2, 4, 8 channels but I've not bothered as it takes a fet/channel and a jumper not the 6 wires that breakout board does for 2 channels.

Bob

AN10441.pdf (52.4 KB)

That Gizduino+ is a Sanguino clone. The SPI pins are on Digital pins D5, D6, and D7:

D5 - MOSI
D6 - MISO
D7 - SCK

and yes, level shift your pins. A simple resistor divider, as suggested, or you can use a 74HC4050 (CD4050 can be used if you can't get it locally).

connections using CD4050:

SD Card Pin----CD4050 Pin-----Gizduino+
CS--------------15 14-----D4
MOSI-----------12 11----D5
SCK------------10 09----D7
MISO----------------------------D6

the CD4050 connections can also be used with your Gizduino mini:

SD Card Pin----CD4050 Pin-----Gizduino mini
CS--------------15 14-----D4
MOSI-----------12 11----D11
SCK------------10 09----D13
MISO----------------------------D12

Unfortunately, it still doesn't work
This is my connection.
CS---------D4
MOSI------D11
SCK-------D13
MISO------D12

If I turn on the crapduino and upload absolute minimum, what readings should I get from this pins: D4, D11, D12 and D13 provided that I have not made any connection yet.

Because I am getting:
D4: 0.1 volt
D11: 5volts
D12: 0.1 volt
D13: 0 volt

are you using a level shifter?

have you made a resistor based voltage divider??

follow the images/wiring that was posted for you.

yes, I'm using a level shifter.
I followed the second circuit. Resistor values are 4k7 and 10k.
If I supply my level shifter with 5 volts, the drop across 10k with respect to ground is around 3.37 to 3.4 volts.
This means that my level shifter is OK.

If I turn on my crapduino, what voltage should I read from the SPI pins?

Can you take a picture of your setup and post it here?

Are you using an SD Card or a Micro SD Card in an adaptor?

What's the error code thrown out by the BareMininumWithDebug example, error code: 1 or error code: 08?

if it is error code 1, if your not using a shield, check your connections and contacts with the SD-Card pins. if it is error code 8, try level shifting using 1.8k and 3.3k resistor.

I recently had a problem with my setup above using CD4050. So i ditched that setup and use resistor divider with above values. I am using a micro-sd on an adaptor.

also if no error code and it is saying in the serial monitor "Initialising SD card...Wiring is correct and a card is present....... playing EXAMPLE.AFM.found.playing" lean-in, or put the speaker, closer to your ear, the audio volume is quite low. that it can be unnoticeable when your in a noisy environment.

and my *duino is even more crappier than yours XD :smiley: :smiley: XD and it's from five years ago...