Jump to content
bhills

SD card reader Sleep

Recommended Posts

Hello,

 

I am working on a project in which we are using the MSP4305969 to measure temperatures and write data to an SD card. The datalogger is in a remote location, so the system needs to conserve enough power to log for a full year. In order to do this we are logging only every 15 minutes and powering everything down to a sleep mode between measurements. We use a transistor as a switch to take power away from the line of temperature sensors while the board is sleeping. That all works fine, my issue is with the SD card reader. We are using the "slot socket" for arduino

 

https://www.amazon.com/Card-Reader-Module-Socket-Arduino/dp/B008B52QQC

 

and the Petit FatFS library for writing to the card. 

 

http://elm-chan.org/fsw/ff/00index_p.html

 

When the SD card reader is wired directly to the board the system works fine and it writes exactly how I want it to. However, it draws too much power. I tried wiring the SD card reader through the transistor so that it will have its power taken away when the board is asleep. This creates an issue in writing to the card. It seems as if the SD card reader needs some startup initialization time before it can properly write. I have also tried having the logger pause between waking up and writing, that didn't help either. 

 

If anyone has any advice it would be greatly appreciated.

Share this post


Link to post
Share on other sites

Everytime you power cycle the card you will need to perform the initialization sequence again.

 

Something like this

SD_PWR_ON();
FATFS fs;

disk_initialize(0); // Re-initialize the SD card

pf_mount(&fs); // mount Fat FS
pf_open("logfile.txt"); // re-open file

pf_lseek(fs.fsize); // seek to end of file
pf_write(...); // Write block of data

Note that if the disk is re-initialized then you really should be performing pf_mount and pf_open again.

 

Also be aware of the limitations when using PetietFS for writing to files.

  • Cannot create file. Only existing file can be written.
  • Cannot expand file size.
  • Cannot update time stamp of the file.
  • Write operation can start/stop on the sector boundary.
  • Read-only attribute of the file cannot block write operation.

 

Particularly "Write operation can start/stop on the sector boundary." This requires that you write your data logs in multiples of 512 bytes.

Share this post


Link to post
Share on other sites

Is this somehow different from your initialization procedure?

This is written into the loop so it should initialize the card every loop.

  FatFs.begin(CS_PIN);             // initialize FatFS library calls
  rc = FatFs.open("LOG.TXT");      // Specify file
  FatFs.lseek(file_byte);         // Move forward to current location in file.

Commands are the same as that in the PFatFsFileTest.ino example file.  The SD card reader is supplied with power before the above commands, then instructed to write, then power is removed.

 

Thanks

Share this post


Link to post
Share on other sites

@@bhills

 

That fr5969 has 64KB of *FRAM* on board. You could use that to your advantage.

 

Why not do periodic writes to the FRAM? Then, at some power budget friendly interval (say one day), power up that SD Card and dump the FRAM buffer contents to it.

 

What do you think?

Share this post


Link to post
Share on other sites

That is a good idea. Thanks zeke, I will give that a try.

 

I figured out the initial issue. It was mostly a hardware problem. The SD card reader was not getting the voltage that it needed to write. I rewired it, gave it ~0.1 sec startup time between when power is turned on and when I start the initialization. It seems to be working well now. 

 

Thanks for your help

Share this post


Link to post
Share on other sites

An SD card once initialized will automatically go into sleep mode when there is no activity on the clock line. In sleep mode a SD card will draw between 100 and 200 microamps. Depending on the interval of your powerup/initialize/log sequence, you may be wasting more power re-initializing the card on every power-up than you would be to just let it sleep and not having to initialize it each time you write.

 

It's always good to have the FET control of the SD card power, because that's the only way to reset it if it somehow locks up, but you need to do a careful analysis of power use to find out the best way to save over time.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...