Pages: [1]   Go Down
Author Topic: How to power-up SD Card manually with digital pins to control its power consump.  (Read 1294 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having a problem powering up my sd card manually. I have a data-logger circuit that logs the temperature and humidity. It will soon run on batteries (3 AAA's - 4.5V) so i need my circuit to be power efficient enough. Furthermore, I used voltage divider resistors to lower down the voltage supply of the SD card. I did it also to MISO, MOSI, CS, etc pins. I believe that using voltage divider connected directly to battery and sd card consumed a lot of power already so i want power up my card when it is only needed. I will also use SLEEP stuffs to my arduino to reduce the consumption of power but i have to settle this thing first.

I used the sketch of SD in arduino's samples

SCENARIO 1.
I connected my MISO, MOSI, CS, etc of the SD card to their proper pins.
I connected the SD Card's GND and VCC to Arduino's GND and +5v respectively
------- AND IT WORKED------- without any issues.

SCENARIO 2
I connected my MISO, MOSI, CS, etc of the SD card to their proper pins.
I connected the SD Card's GND and VCC to Arduino's GND and Digital Pin 7  respectively
In the Sketch, I also added some lines.

  pinMode(10, OUTPUT);     // change this to 53 on a mega
  pinMode(7,OUTPUT);
  delay(1000);
  digitalWrite(7,HIGH);
  delay(2000);



------- IT DIDN'T WORKED AT ALL------




PLEASE HELP. Advance Thank you anyway..



PS: I am having a problem purchasing an SD card shield or module here in the small mountainous province here in the Philippines. That's why i used voltage dividers   smiley

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having a problem powering up my sd card manually. I have a data-logger circuit that logs the temperature and humidity. It will soon run on batteries (3 AAA's - 4.5V) so i need my circuit to be power efficient enough. Furthermore, I used voltage divider resistors to lower down the voltage supply of the SD card. I did it also to MISO, MOSI, CS, etc pins. I believe that using voltage divider connected directly to battery and sd card consumed a lot of power already so i want power up my card when it is only needed. I will also use SLEEP stuffs to my arduino to reduce the consumption of power but i have to settle this thing first.

I used the sketch of SD in arduino's samples

SCENARIO 1.
I connected my MISO, MOSI, CS, etc of the SD card to their proper pins.
I connected the SD Card's GND and VCC to Arduino's GND and +5v respectively
------- AND IT WORKED------- without any issues.

SCENARIO 2
I connected my MISO, MOSI, CS, etc of the SD card to their proper pins.
I connected the SD Card's GND and VCC to Arduino's GND and Digital Pin 7  respectively
In the Sketch, I also added some lines.

  pinMode(10, OUTPUT);     // change this to 53 on a mega
  pinMode(7,OUTPUT);
  delay(1000);
  digitalWrite(7,HIGH);
  delay(2000);


------- IT DIDN'T WORKED AT ALL------




PLEASE HELP. Advance Thank you anyway..



PS: I am having a problem purchasing an SD card shield or module here in the small mountainous province here in the Philippines. That's why i used voltage dividers   smiley



========================================================================
This is just a report of my problem. Hope you'll forgive me for that. smiley
Original Post: http://forum.arduino.cc/index.php?topic=214859.0
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 614
Posts: 49384
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What, specifically, is connected to pin 7? If its the power pin for the SD card, it's no wonder the 40 mA supplied by the pin didn't power the card.

If it's a transistor gate, you need to define the rest of the circuit. And the rest of the code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks PaulS for the idea. I see, 40mA of current is not enough to power up the card. This is what I did then; I set the pinModes of D2,3,4,5,6 to output and turn them to HIGH. I connected all these pins to +v of the card. (Crazy stuff) And it worked!

I am very carefull with my code because all D2,3,4,5,6 pins are directly connected to each other.

Thanks again paul!
Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1637
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You may have problems if you power the card off with the Arduino SD.h library.  You will need to reinitialize the card when you restore power.  SD.h has a bug that only allows begin() to be called once.  There is a fix for this bug.

SD.h also has a bug that often prevents an SD card from sleeping in low power mode.

SD.h is based on a very old version of SdFat that I wrote four years ago.

I did tests with an Adafruit microSD module http://www.adafruit.com/products/254.

I used a SanDisk 8 GB card www.amazon.com/Sandisk-MicroSDHC-Memory-Card-Adapter/dp/B000WH6H1M.

I used the latest version of SdFat https://code.google.com/p/sdfatlib/downloads/list.

With sdfatlib20131225, the Adafruit module and SanDisk card draw 0.44 ma when idle.

With SD.h the idle current is often 26.4 ma.

Modern SD cards are very power efficient when idle so there is little point in powering the card off.

Your voltage divider may draw more current if one of the SPI pins is high.  The Adafruit card has an IC level shifter that is more efficient than a resistor voltage divider
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, as of now, I am working with this kind of problem regarding sd cards. I've been reading your posts a while ago, but hey! here you are helping me smiley

I see,  SD.begin() can only be called once. I've downloaded your sdfat library and I noticed you have a lots of samples that I can referred to. Thank you. About the Adafruit's module for SD, I've been trying to find a store for that here in the Philippines but unfortunately, you know.. smiley-sad

Another question please. Since I have a datalogger here and I will put all the readings in a single file, e.g. logs.txt, will the sdfat continue appending new data to that file even if the file is already 1MB or bigger? And also, my idea of downloading the readings is through Serial. Will it still read the logs.txt even if it's already 1MB or bigger? I will create a VB program to read and download the measurements/data from the logger without removing the card.

Any idea please. smiley
Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1637
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
will the sdfat continue appending new data to that file even if the file is already 1MB or bigger?

The maximum file size for FAT16/FAT32 files is 4 GB so 1MB is no problem.
 
If you close the file and power off the card, you will need to reopen the file with an option to position the file at the end.

Here is an example:

Code:

  if (!file.open("FILENAME.TXT", O_WRITE | O_CREAT | O_APPEND)) {
    // handle open error here
 }

You can also position the file to the end with seekEnd() like this.
Code:
  file.seekEnd();

The SD.h wrapper always positions files opened for write at the end.  SdFat follows Linux and the open group standard of opening files at the beginning unless an option is specified to position the file.

If possible avoid opening and closing large files, the overhead can become large.  You can use the SdFat sync() call to insure no data will be lost if the program terminates before closing the file.

Code:
  // write data here
  file.print(firstItem);
  // ...
  // force cached data to file
  if (!file.sync()) {
    // handle write error here
  }
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This helps a LOT!!!

Thank you very much!  smiley-lol
Logged

Pages: [1]   Go Up
Jump to: