Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

SD shield with netduino firmware 4.1 alpha 7


  • Please log in to reply
17 replies to this topic

#1 mehmetg

mehmetg

    New Member

  • Members
  • Pip
  • 5 posts

Posted 17 February 2011 - 07:57 AM

With alpha 7? Do I still need to short pins 4 and 10 to get the sd card mounted?

I am trying to run the following sample and running into volume not found exceptions....

public static void Test()
{
Debug.Print("SDCardTest.Test\n");

StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_D5);

string[] directories = System.IO.Directory.GetDirectories(@"\");
Debug.Print("Directory count: " + directories.Length.ToString());

for (int i = 0; i < directories.Length; i++)
{
Debug.Print("Directory: " + directories[i]);
}

string[] files = System.IO.Directory.GetFiles(@"\SD1");
Debug.Print("file count: " + files.Length.ToString());

for (int i = 0; i < files.Length; i++)
{
Debug.Print("filename: " + files[i]);
//FileStream fs = new FileStream(files[i], FileMode.Open, FileAccess.Read, FileShare.None, 512);
//StreamReader sr = new StreamReader(fs);
//Debug.Print("contents: " + sr.ReadToEnd());
}

StorageDevice.Unmount("SD1");
}

Thanks in advance.

Mehmet

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 17 February 2011 - 08:31 AM

mehmetg, The alpha releases hard-code pin 10 for chip select behind the scenes. You'll need to "short" D4 to D10 for now if you're using D4 for chip select. We'll enable the variable-CS feature in an upcoming beta (in the next few weeks). Chris

#3 mehmetg

mehmetg

    New Member

  • Members
  • Pip
  • 5 posts

Posted 17 February 2011 - 04:40 PM

Chris, Thank you for the information. The sample code I am using is setting the card to use D5 as chip select. I am a little confused as I am kind of new to this. Should I use D4 and short the physical pin to D10? Thank you, Mehmet

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 17 February 2011 - 10:18 PM

Thank you for the information. The sample code I am using is setting the card to use D5 as chip select. I am a little confused as I am kind of new to this. Should I use D4 and short the physical pin to D10?


Hi Mehmet,

Which pin does your shield use for "chip select" of the SD card? Whichever one it uses...place a jumper wire between that pin header and D10. If it uses D10 (which many shields with SD use), you're already set.

We'll expand this capability in the beta...

Chris

#5 mehmetg

mehmetg

    New Member

  • Members
  • Pip
  • 5 posts

Posted 18 February 2011 - 05:40 AM

Chris,

I have checked out the schematic for the arduino shield and it looks like it's using #8... I went ahead and removed pin 8 of the shield and jumpered it to pin 10 so pin 10 would connect to the shields CS line. arduino micro sd shield drawing....

I still get the volume not found exception... Could it be the hex converter on the sd shield causing the problem?

Thanks,

Mehmet

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 18 February 2011 - 08:01 AM

Hi Mehmet, The shield looks like it should work. Two questions: 1. Exactly which line of code is throwing the exception? 2. What MicroSD card are you using? Brand? Capacity? Was it formatted FAT16 or FAT32 on your PC? Chris

#7 mehmetg

mehmetg

    New Member

  • Members
  • Pip
  • 5 posts

Posted 18 February 2011 - 06:05 PM

Chris, I tried a generic 4GB(fat32) and a Sandisk 2GB(fat16 works with netduino plus), with the same result. It's telling me that the volume is not found when I try to mount it calling this function: StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_D5); I'll post the exact exception output when I have access to the device again. I also checked the CS line going into the hex_converter which is a NXP 74hc4050d and as specified the netduino is working at 3.3V. I was wondering how the NXPchip would behave trying to shift voltage from 3.3V to 3.3V. I'll try to hook it up to a scope or a meter over the weekend and see... Any other pointers you could provide would be really appraciated. Thanks, Mehmet

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 February 2011 - 12:17 AM

Hi Mehmet, If the "hex converter" chip is reducing the voltage from 5V to 3.3V, it may be reducing the 3.3V to ~2.2V. Usually level conversion chips convert to a fixed voltage (and can read either 3.3V or 5V). Hmm. If you card works with the Netduino Plus, then it should work with the Netduino and an SD shield. If not, then it's an issue with the shield. Just have to figure out what the problem is exactly... Chris

#9 mehmetg

mehmetg

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 February 2011 - 07:58 AM

Chris, I finally got it to work. Now my challenge is to create directories and files on the card. Are there any samples for that on here? I can't search for sd as it is a 2 letter word. Thanks, Mehmet

#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 February 2011 - 08:29 AM

I finally got it to work. Now my challenge is to create directories and files on the card. Are there any samples for that on here? I can't search for sd as it is a 2 letter word.


Hi Mehmet,

Good news!

Take a look at System.IO.FileStream in the .NET MF online docs. Or just search for StreamReader or FileStream on the forums amd you'll find a few...

Chris

#11 Dezorian

Dezorian

    Member

  • Members
  • PipPip
  • 24 posts

Posted 28 February 2011 - 02:16 PM

Chris,

I finally got it to work.
...


You got it to work with the Sparkfun SD Shield with voltage converter chip? Any special actions required?
I've got a Sparkfun shield with voltage converter too any i'm a bit confused. The netduino supplies 3.3V spi signals, so you the shield doesn't actually require a voltage converter on the shield? So that was only for Arduino?

Thanks for the info.

#12 Dezorian

Dezorian

    Member

  • Members
  • PipPip
  • 24 posts

Posted 07 March 2011 - 10:26 PM

You got it to work with the Sparkfun SD Shield with voltage converter chip? Any special actions required?
I've got a Sparkfun shield with voltage converter too any i'm a bit confused. The netduino supplies 3.3V spi signals, so you the shield doesn't actually require a voltage converter on the shield? So that was only for Arduino?

Thanks for the info.


For everybody having the same question, for 4.1.0 alpha 7: just short pin 8 and 10 for the sparkfun shield with voltage converter. Then it works with something like this:

StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Cpu.Pin.GPIO_Pin8);
            FileStream filestream = new FileStream(@"SD\filename.txt", FileMode.Append, FileAccess.Write, FileShare.None);
            StreamWriter streamWriter = new StreamWriter(filestream);                
            streamWriter.WriteLine("WriteSomeText");
            streamWriter.Close();
            filestream.Close();
            StorageDevice.Unmount("SD");


#13 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 11 March 2011 - 07:44 PM

Sorry to hijack this thread but my SD shield (coolcomponents.co.uk version) has other descriptions at each pin.
The weirdest thing is that the pins have other names on the back:

Posted Image

Any suggestion on how to connect this one?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#14 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 12 March 2011 - 10:05 AM

Never mind, I'm a newbie... I used google and found it out: http://en.wikipedia....ower_supply_pin VDD and VSS are other means for V+ and V- :) I got it working with that shield like this: RSV: Unused /CS: Pin 10 DI: Pin 11 VDD: 3V3 CLK: Pin 13 VSS: Gnd D0: Pin 12
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#15 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 15 March 2011 - 09:28 AM

Never mind, I'm a newbie... I used google and found it out: http://en.wikipedia....ower_supply_pin
VDD and VSS are other means for V+ and V- :)

I got it working with that shield like this:
RSV: Unused
/CS: Pin 10
DI: Pin 11
VDD: 3V3
CLK: Pin 13
VSS: Gnd
D0: Pin 12

Cheap trick: if you just want some quick and dirty onboard storage, I think you could actually just solder jumper wires directly onto most sd cards' cs, clk, di, do, vcc (3.3v) and gnd connectors. I'm gonna try this myself since I got a lot old and "small" sized (below 1 Gb) that I don't use anymore anyway. I probably need to be careful not soldering too hot for too long.

If I solder on twin wires I can use a dummy in the other end too so that I even can stick it into a pc for occasional file management while disconnecting it from the netduino. Sure, I could even have a dipswitch and a header for easy access, but then price is getting closer to a bob :P Better yet, carefully break the sd apart, take the chip(s) out and use the plastic cover for a dummy in the other end. :D

This trick should work on any sd that boots in spi mode.

Edited by hanzibal, 15 March 2011 - 09:32 AM.


#16 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 15 March 2011 - 10:24 AM

I've used a micro SD breakout board as above and that does nothing more than expose the card's pins. SPI access to the card worked just fine. I can't see why some careful soldering directly to a SD card wouldn't work, if that's your thing. SD (full size) breakout boards do seem strangely more expensive than the micro version.

#17 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 15 March 2011 - 04:27 PM

I've used a micro SD breakout board as above and that does nothing more than expose the card's pins. SPI access to the card worked just fine. I can't see why some careful soldering directly to a SD card wouldn't work, if that's your thing. SD (full size) breakout boards do seem strangely more expensive than the micro version.

Exactly, I recently purchased a full size SD bob (before I realized the above) and it was twice the price for a micro and roughly equal to the price of my vs1053 mp3 decoder chip so pricing is definately wrong somwhere.

#18 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 17 March 2011 - 09:00 PM

The SD breakout board pictured above works fine with the Netduino Mini too. Obviously the pin connections are different and you'll need to get 3.3V from somewhere. (I happen to be using an OLED screen that conveniently has a 3.3V output.) /CS: Pin 13 DI: Pin 14 VDD: 3V3 - you'll need to sort this yourself CLK: Pin 16 VSS: Gnd D0: Pin 15




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.