Pages: 1 [2]   Go Down
Author Topic: SD Card - how to reduce the power consumption?  (Read 10537 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bingo!!!

I ported over my sketch last night to the SdFat library and hey presto the sd is now sleeping like a baby between read / write events. The current consumtion on the SD card has fallen into the circa 200uA region regardless of which card i use. That means the overall system is now running at only 13mA which is mainly the LCD screen. this will give me around 70 hours of run time from 4 AAA batteries - easily enough for the 24 hour race with practice and qualifying covered as well. smiley

It took me a few attemts to convert the code over but its all working fine and the examples in the SdFst library were a big help

Thanks for your help with this problem and keep up the good work - I'll only be using this library from now on for future SD projects
Logged

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

I added a simple change to the SD library to help with this issue.  I have not tested it fully yet but it may be of interest to know that the SD library has a begin() but no matching end().  I implemented:

void SDClass::end() {
       if (root.isOpen())
       {
          root.close();
       }
}

This allows you to close the SD library.  Also I am using an N-Channel FET in the ground of the SD card (BS170 Drain connected to SD card gnd, BS170 Gate connected to 10K to ground and Arduino digital IO pin, BS170 Source connected to ground).  When I wish to switch off the SD card I tristate all the SD card connections and then I tristate the FET Gate pin.  The 10K resistor forces the Gate to 0v and all the pins on the SD card float to Vcc.  Next step is to switch off the SPI module in the processor and take the power consumption down further.
Switching back on is easy but this time to switch on the power to the SD card put the FET Gate pin to HIGH.  This forces the FET full on and with its low Drain - Source resistance puts power back on to the SD card.  It all seems to work but I have not measured the off current and I still have to put the processor to sleep.
Logged

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

Your SDClass::end() may not always work.  You must make sure all files are closed before calling your end(). 

Your end() doesn't do the equivalent of an unmount for a file system.  I never added that to the underlying SdFat.  It really isn't possible since SdFat does not maintain a list of open files.  SdFat was written with RAM use as a top priority.

SD.h has a feature or bug that doesn't allow begin() to be called without closing root so this version of end() fixes that.  The underlying SdFat allows begin() to be called multiple times but once again you must close all open files before calling begin().

I would be interested in how much energy you can save with your power saving circuit.  SD.h has the bug that doesn't allow SD cards to sleep but SdFat allows cards to sleep.

Modern SD cards sleep at 100 - 200 micro-amps.  Many SD card take 500 ms to initialize and draw a lot of current during initialization.  A card may draw 50 - 100 ma during this time.

My guess is that several minutes of power off would be required before there was any advantage.

I will be interested in how you determine this and what the result is.
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2073
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Also I am using an N-Channel FET in the ground of the SD card
It may work fine, but usually such modules are always switched on/off by a high-side switch - ie a P-channel Fet in the VCC rail. Also mind the max drain current (up to 200mA for an SDcard). Switching complex modules low-side in the GND is quite rare.. (with the BS170 low-side you offset signal's log levels by +0.24V when Isd=200mA, probably not a big  issue here but not a good design practice, though..  smiley-wink)
« Last Edit: February 25, 2013, 08:57:07 am by pito » Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was thinking about switching the SD card with a FET (I even bought a BS170 for the job) but I would need to write data to the card every 40 - 80 seconds (dependant on the race track lap length) so I would loose too much power re initialising the card. After porting my sketch over to the SdFat library the SD card is nicely sleeping between write events at around 200uA. This is easily enough power saving for my project.

However, I am interested in how you get on with this and how much current is being used when off and for the initialising.
Logged

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

Made an account to say thank you to fat16lib.

You reduced the power consumption of my SD card from 22ma to ~0.03ma.

Thank you!
Logged

UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 278
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Evenin' all,

I'm just trying to do the same - that is get the power right down in between my data logs which occur every 5 mins.

The best I can do at the mo is about 500uA in sleep mode (the arduino bit accounts for 22uA) so I'm wondering if I need to do anything more than close the SD file to get the SD card to sleep?... or perhaps its my SD card - any recommendations for nice sleepy SD cards and any difference between micro SD and full size?

Any code snippets to illustrate would be great :-)
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2073
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

500uA might be ok - it depends on the actual card used. Check the sdcard's chipselect is high when idle.
You may disconnect the card fully with a high-side switch (ie. pmosfet).
Logged

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

Quote
The best I can do at the mo is about 500uA in sleep mode (the arduino bit accounts for 22uA) so I'm wondering if I need to do anything more than close the SD file to get the SD card to sleep?

Closing the file does nothing. 

The standard SD.h library is based on an old version of SdFat that does not put the SD in sleep mode.  New versions of SdFat enable sleep mode after every transfer and the card will go into low power mode when it becomes idle.

Almost all modern cards go into a very low power mode since this is important for battery powered devices.  The 30 uA achieved by user arduino_  above is typical.

The method of level shifting or not applying proper voltage to the SD can cause higher power drain.

Logged

Melbourne, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am unable to compile the sketch from fat16lib in Reply #12

I receive the following error:

Quote
In function 'void setup()':
'class SdFat' has no member named 'begin'
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2073
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It compiles fine here.. Do you have SdFat library installed?
Logged

Melbourne, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thankyou Pito for taking the time to read my post and test the short sketch posted in February by fat16lib to which I referred.

Yes I have the library installed and I can compile every one of the included example sketches ie AnalogLogger.

I raise this mainly in case other beginners are trying to leverage this useful example to create a periodic data logger using sync and are discouraged by being unable to get the sketch to compile in their environment.

I have downloaded and installed the latest build of the library from http://code.google.com/p/sdfatlib/downloads/list and the error has disappeared.

Have a great day,

Mike
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't see what the reason was for the problem. Apparently something was done differently in sdfat, but I didn't see an explanation of what it was.
Logged

Pages: 1 [2]   Go Up
Jump to: