Connecting SD card to Leostick

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
Post Reply
leo_stuck
Posts: 26
Joined: Sun Jun 16, 2013 11:57 pm

Connecting SD card to Leostick

Post by leo_stuck » Sun Mar 02, 2014 10:54 pm

Hope you can help me with the last stage of my project. I have a couple of sensors attached to my leostick and I need to log the data to an SD card, for this I'm using an Adafruit sd module. I'm not able to "see" it and think the problem may lie in the way I have connected it,
could you answer the following questions?

1. When looking at the top of the leostick which is pin 1 of the ICSP header?

2. I am using a USBBOOST to power the SD module, should I also use it to power the leostick so that they share a common ground?

3. What is the max output current I can expect from the USBBOOST? (can't find it in the documentation anywhere)

4. The sd module calls for a connection to the SS pin, however the leostick has no external point where I can connect to it, can I use another pin?

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Connecting SD card to Leostick

Post by angusgr » Mon Mar 03, 2014 2:45 am

leo_stuck wrote: 1. When looking at the top of the leostick which is pin 1 of the ICSP header?
Pin 1 of the LeoStick ICSP is closest to LeoStick pin D3, there is a circular yellow dot on the LeoStick PCB to mark it as well.

Another way of seeing it, it's the top left pin in this image:
Image
2. I am using a USBBOOST to power the SD module, should I also use it to power the leostick so that they share a common ground?
You don't need to connect a common +5V from the same place, those can provide 5V separately. However you do need to run a ground wire between the USBBOOST/SD ground and the LeoStick ground to make sure the ground is common.
3. What is the max output current I can expect from the USBBOOST? (can't find it in the documentation anywhere)
500mA (it's listed on the product page.)
4. The sd module calls for a connection to the SS pin, however the leostick has no external point where I can connect to it, can I use another pin?
The SS (Slave Select) pin on the SD module is the same as the "CS" (Chip Select) pin assigned the LeoStick (the terms SS & CS are often used interchangeably.) You can assign any pin on the LeoStick, it's passed to the SD module when you start using the card in your sketch.

You will need CS/SS connected and assigned correctly for the SD module to work.

Hope these tips help you get up and running.

- Angus

LukeW
Posts: 91
Joined: Tue Nov 01, 2011 10:14 am

Re: Connecting SD card to Leostick

Post by LukeW » Mon Mar 03, 2014 3:48 am

Whatever you're using to power the LeoStick with can also be used to power the SD module, only one 5V supply is needed. But yes, they do need a common ground if two different power supplies are used.

So you're only using the USBBoost to power the SD module alone, not the whole system? To be honest I don't see the point of that, I don't understand what your overall system looks like, but you should already have 5V available from the LeoStick to power the SD board, so what's the point of the USBBoost?

Note that a 500mA load current from the USBBoost requires an input voltage of at least 2.4V. At very low input voltages (say a single AA battery) the USBBoost will provide a 5V output but it will only support quite small output currents. Consult the RT9276 datasheet for more details.

LukeW
Posts: 91
Joined: Tue Nov 01, 2011 10:14 am

Re: Connecting SD card to Leostick

Post by LukeW » Mon Mar 03, 2014 4:03 am

Let's try the following:

First column is the pins on the LeoStick ISP header, oriented as in the picture posted above.
Second column is the pins on the Adafruit MicroSD board.

Pin 1 (top left) = "DO"
Pin 2 (top right) = "5v"
Pin 3 (centre left) = "CLK"
Pin 4 (centre right) = "DI"
Pin 5 (bottom left) = Don't Connect
Pin 6 (bottom right) = "GND"

Don't connect the "CD" and "3v" pins on the Adafruit module.

(CD is Card Detect, which is a little metal "switch" inside the SD card socket which is normally floating but connected to ground when a card is inserted. You can connect it to a digital pin and read it to check for an empty card socket, but you'll need a pull-up resistor.)

Connect "CS" on the Adafruit module to D8 (or some spare pin) on the LeoStick.

For test purposes remove your other power supplies, we'll plug the LeoStick into the PC which will power everything together.

Now load an example SD card Arduino sketch, and ensure that you edit the code so that the nCS pin is defined as pin 8 or whatever you've wired it to. Insert your card, upload it, and that should work.

leo_stuck
Posts: 26
Joined: Sun Jun 16, 2013 11:57 pm

Re: Connecting SD card to Leostick

Post by leo_stuck » Tue Mar 04, 2014 10:55 pm

Thanks Angus & Luke for putting me on the right track. Will let you know how I go.

leo_stuck
Posts: 26
Joined: Sun Jun 16, 2013 11:57 pm

Re: Connecting SD card to Leostick

Post by leo_stuck » Fri Mar 14, 2014 2:14 am

Yes the common ground worked. The reason I used a separate supply for the card was that I understood that cards were rather hungry for power and I was doubtful that the leostick could cope with it, also at the time I was breadboarding the project and it was the quickest way of going about it. I have since tried powering the card from the 'stick and it seems to handle it without problems. The project is now up & running, thanks for the advice. I did have one strange problem with the sketch however - there are six lines of code, each line concanates a data value to a string before the whole string is written to the card, if I tried to upload the whole sketch to the 'stick it printed out a few lines of gibberish & then hung. The only way I could find to upload it was by adding one line of the offending code then uploading, adding next line & uploading & so on. Thanks again.
P.S Are you the same LukeW that designed the MobSenDat? if so , I've had fun partly reinventing the wheel!

Post Reply