replace SD card with USB stick

Hi all,

I've got a (probably advanced) question, where two collegues of mine argue whether it's doable or not.. :slight_smile:
I recently bought this board from sparkfun: www.sparkfun.com/products/12000

What this does is basically reading .wav files from a microSD card and play them. Fair enough, this works great.

What I'd like to do in my project, is replace the microSD card with a USB stick, OR being able to connect that same microSD card to a PC to put new files on it (without having to physically remove the card from the player). Basically I'm looking for a user-friendly way to put files on the card without having to use cardreaders etc. I figured that moving a simple USB stick back and forward is common practice these days. Not so for a microSD card. (at least, not for everyone.)

After reading this thread: DIY USB SD Card Reader for PC/Mac possible? - Project Guidance - Arduino Forum
I purchased a few VUB300 chips as suggested. I soldered one to a breakout board and am now able to test it. I thought this chip would do the trick, but a colleague of mine very much doubts that. He claims that 'fooling the board into thinking that it's reading from a SD card, while it's actually a USB flash drive', is actually the inverse of what the chip is designed to do.

This might be possible, but then I would think I could do my second suggestion: connect the entire thing through the VUB300 to my PC and access it from there without moving a USB stick. But I'm guessing that would give problems because the SD memory would potentially be accessed by the PC AND the board together..

I'm a bit stuck. Any suggestions are greatly appreciated!

Thanks!
Jens

I had a similar issue, i also bought one of those USB converters but it didn't work out.
So my solution was to create an application that works along with the COM port, then i can upload and download the files that i'm saving on the SD card

I think you just need to mux the IO signals to the SD card. See Page 11 of the datasheet. Insert some hardware between the VUB300 and the SD socket, and between the '328P SPI/SS signals and the SD socket, and decide which set of signals get control of the SD card.
74HC125 would do it - need 2 for the VUB300 since it access the card with 4-bit interface. Need 1 for the SPI interface (SCK, MISO, MOSI, SS) since it uses serial interface.
Then just need a means to decide who gets control.
Maybe have '328 monitor the CLK pin, allow the switch over only when it does not see activity.

328 can't drive USB stick without a host shield, something with MAX3241E on it. Sparkfun makes such a shield. I designed one into a card, I didn't do the software behind it, don't know how it turned out.

I think you just need to mux the IO signals to the SD card. See Page 11 of the datasheet. Insert some hardware between the VUB300 and the SD socket, and between the '328P SPI/SS signals and the SD socket, and decide which set of signals get control of the SD card.
74HC125 would do it - need 2 for the VUB300 since it access the card with 4-bit interface. Need 1 for the SPI interface (SCK, MISO, MOSI, SS) since it uses serial interface.
Then just need a means to decide who gets control.
Maybe have '328 monitor the CLK pin, allow the switch over only when it does not see activity.

328 can't drive USB stick without a host shield, something with MAX3241E on it. Sparkfun makes such a shield. I designed one into a card, I didn't do the software behind it, don't know how it turned out.

:slight_smile: Ehm... I'm not following entirely. I'm lacking some basic knowledge I guess. With the 328P, do you mean the atmega328?

jensvanhoof:
What I'd like to do in my project, is replace the microSD card with a USB stick

Very difficult. The SD card has a very simple SPI interface, USB is complicated.

jensvanhoof:
What I'd like to do in my project, is replace the microSD card with a USB stick, OR being able to connect that same microSD card to a PC to put new files on it (without having to physically remove the card from the player).

Why can you physically remove the USB stick but not the SD card? That's not fair!

With a cheap adapter the SD card can be plugged into any PC just like a USB stick.

Yes.
Altho, never mind. I thought you were trying to control between Arduino and PC, which one was to access the SD card. That sparkfun card is not arduino at all, it just has inputs that coud be arduino controlled to select a track.

I think you could use my concept tho, pull the SD/uSD signals off the card, and mux between the PC accessing the SD/uSD card, and the sparkfun board accessing the card. Put a toggle switch on and manually select who gets the card.

Very difficult. The SD card has a very simple SPI interface, USB is complicated.

Well, in Sparkfun's product, the SD card doesn't use the SPI interface. It uses a SDIO interface instead, as SPI wouldn't be fast enough.

Why can you physically remove the USB stick but not the SD card? That's not fair!

I know about the adapters, but it seems more accessible to people with less technical skills if there's an actual USB stick to be swapped. It would be more elegant, too.

That sparkfun card is not arduino at all, it just has inputs that coud be arduino controlled to select a track.

I realized indeed that I might not have asked my question at the right forum. As you say, my AVR is only used to control the sparkfun board, while my question is not in that. :slight_smile:

I think you could use my concept tho, pull the SD/uSD signals off the card, and mux between the PC accessing the SD/uSD card, and the sparkfun board accessing the card. Put a toggle switch on and manually select who gets the card.

That seems like a reasonable approach. I'm not sure about how the multiplexing should work. (Never done it before) Could you point me to a tutorial or anything that would be applicable? I'd like to readup on that.

Regarding the toggle switch, what dataline do you have to switch then? Or are there multiple contacts that need to be toggled?

jensvanhoof:

Very difficult. The SD card has a very simple SPI interface, USB is complicated.

Well, in Sparkfun's product, the SD card doesn't use the SPI interface. It uses a SDIO interface instead, as SPI wouldn't be fast enough.

OK, but the point stands: SD cards have very simple interfaces, USB sticks do not.

The two things aren't interchangeable just because they both store data and they both use flash memory.

The two things aren't interchangeable just because they both store data and they both use flash memory.

I thought the VUB300 was designed to do just that, but it seems it's more complicated than that :slight_smile:

The muxing is simple. The 74HC125 has 4 gates, each has an output enable line.
So have a simple switch that either enables one set of gates, or the other, by connecting the enable pins to Gnd. The ones not connected just get pulled high with a pullup resistor.

There might be a hex or octal version of the chip with a single enable line that work just as well, I haven't looked.

The sparkfun board is not a USB Host controller and can't be made to be, so let's just drop the USB stick idea from the discussion going forward if you are planning to use that board.

jensvanhoof:

The two things aren't interchangeable just because they both store data and they both use flash memory.

I thought the VUB300 was designed to do just that

Looks like it, but it hardly seems a simple solution.

The sparkfun board is not a USB Host controller and can't be made to be, so let's just drop the USB stick idea from the discussion going forward if you are planning to use that board.

Understood! 8)

So, the SN74HC125 approach then. Forgive me if I'm asking stupid question, I'm still well on the elektronics learning curve.

For what I understood about the 4 gates in the chip, they simply offer the means to put 4 certain contacts into a high-impedance mode (so..off? :)). In this setup, I'd have to tie all the enable pins together so that they all get disabled/enabled at the same time.
So, using this setup I'd connect the SD card either to the PC (through the VUB300), or to the Sparkfun board.

So far so good? :slight_smile:

What isn't clear to me at the moment, are which lines need to go over the gates.

need 2 for the VUB300 since it access the card with 4-bit interface. Need 1 for the SPI interface (SCK, MISO, MOSI, SS) since it uses serial interface.

So, on the VUB300 I'm guessing pins SD_D0, SD_D1, SD_D2 and SD_D3? So that could be done by a single SN74HC125 then?
On the Sparkfun board the SD is not accessed through the SPI interface but over the SDIO interface. What would that mean?

I'm sorry, obviously I'm a electronics beginner. :slight_smile:

Jens

I hadn't looked that close at the sparkfun schematic (too small). The VUB300 shows 6 or may 8 control lines - all would need to be muxed.
Some are output only - card detect, write protect - so just pass those along. The other 6 - 4 data lines, command, clock - would all need muxing.
https://www.sdcard.org/downloads/pls/simplified_specs/archive/partE1_100.pdf
Hmm, 5 of the 6 lines look to be 2-way signals. So maybe simple Mux is not the correct part, perhaps a low Rds analog switch that looks like a transparent connection would be better.
Ooh - two of these per master would be good.
http://www.intersil.com/content/dam/Intersil/documents/isl8/isl8499.pdf

(I'd say a quad and a dual, for 6 total, but the duals don't seem to be available).

Ooh - two of these per master would be good.

What do you mean by 'master'? PC and 'Sparkfun'?

VUB300 and sparkfun, the guys that actually interface with the card.

VUB300 and sparkfun, the guys that actually interface with the card.

Excellent. Well understood!

So, I'd need two ISL8499 chips for each master, and then connect
VUB300_D0, VUB300_D1, VUB300_D2, VUB300_D3 to ISL8499#1
VUB300_CMD, VUB300_CLK to ISL8499#2
spark_D0, spark_D1, spark_D2, spark_D3 to ISL8499#3
spark_CMD, spark_CLK to ISL8499#4.

On which pins would I have to connect them on the ISL8499's? I suppose either the NO or NC contacts?
Which pins would have to go the SD socket?

A little messy, but you get the idea?

Got it!

Ooh - two of these per master would be good.

Confused me a bit, I understood I'd need 2x2 chips, but got it now'.

How would you switch between the 2 masters in this configuration? As I don't see enable contacts on the chip as suggested with the previous suggestion? :slight_smile: