SD card and max write current - when is it safe to say that it will not bite?

sicco

Well-known member
For a project I started to use SanDisk Ultra 512GB cards. My T41 power supply, 5V, comes from initially a 10..36V DC-DC converter, then an isolated DC-DC converter, NTE0506MC that gets me 6VDC, then a LDL1117S50R low dropout to make 5V that cannot exceed 5.5V ever, and then wired OR with diode for either USB or this 5V source.

The problem I face is that after running and logging for some time, the Teensy reboots. With some SD cards it does that. With Samsung 128GB card it seems ok. But not with SanDisk Ultra U1 512GB. I suspect it reboots following a dip in my VIN 5V rail when I write a lot to the card. Because when assisting with 5V power via USB, it keeps running fine.

Reducing Teensy CPU speed from 600 to 151 MHz avoids the reboots it seems. So that's another hint that with a power hungry SD card, I do get dips that make T41 reboot.

OK, my isolated power supply is a bit weak. 167 mA max out of the NTE0506 according to its data sheet.

Started to also use secure T41 recently... More current consumed now, so more likely that it fails?

But now my question: how strong must my VIN power supply be so that I will not get bitten again by this? 200 mA? 500 mA? When will I be sure that things will never fail when units are far away in the field?? Had I not spotted this issue with SanDisk 512GB just now, then I could have ended up in deep trouble... What safety margin would be right? Is there any way that a SD card can tell what its max current consumption can be? And can we read that, and reject a card if that would be more than what we can give on the T41 3V3 rail?
 
If you have a current limiting power supply, you could do some imperial testing to see at what current limit setting the issue is resolved to get a feel for what kind of baseline you may need to set.

This guy put a lot of work into doing some testing of SD cards including power consumption. It's a long read and I just skimmed it, but looks like he was measuring 25mA on average with peaks of 100mA on a 16GB Sandisk with a few peaks of up to 180mA under high stress testing.

The Teensy wants up to about 100mA itself, so your 167mA isolated supply may well be on the weak side and you may need something up around 250-300mA or so. Since the SD current draw comes in spikes, it might be worthwhile adding some bulk capacitance to the current power setup to help smooth out the current spikes to see if that helps.
 
What safety margin would be right? Is there any way that a SD card can tell what its max current consumption can be? And can we read that, and reject a card if that would be more than what we can give on the T41 3V3 rail?
A factor of two? I don't know of any way to pre-determine the max power required for a particular SD card.
 
Probably a case of the fingers typing a similar word all by themselves, I've done that especially with words I frequently type...
 
You need to read the SD specification as it has quite a bit to say about power limits. For example:

"CMD6 mode 0 is used to query which functions the card supports, and to identify the maximum
current/power consumption of the card under the selected functions."

200mA seems to be the limit for vanilla modes but more in the UHS modes.
 
Thanks for this. But is any of that low level card diagnostics info accessible through the SD card drivers / libraries that we use in T4 by default? SDFat etc.
What i would like to build in my application is something that checks the max current before any attempt to write to the card. Just so that the system will never crash. In this application failing to write to the logfiles is tolerable, but crash / reboot is not.
 
CMD6 is included in the libraries. It is used to query the card before switching the clock speed above 25MHz.
 
What I found so far is that in SdCardInfo.h there's the CSD specification. If you have a 'v1' CSD card then there are various 3 bit values that indicate max current. The actual limits in mA is via a lookup table that is not in SdCardInfo.h, but can be found in the SD card spec as below. Note min is not a minimum, but a maximum current when the supply voltage is at its minimum...

Code:
  Serial.printf("vdd_r_curr_max:%d ", (int)m_csd.v1.vdd_r_curr_max);
  Serial.printf("vdd_r_curr_min:%d\n", (int)m_csd.v1.vdd_r_curr_min);
  Serial.printf("vdd_w_cur_max:%d ", (int)m_csd.v1.vdd_w_cur_max);
  Serial.printf("vdd_w_curr_min:%d\n", (int)m_csd.v1.vdd_w_curr_min);
Ugly typo in vdd_w_cur_max that has only one r, but ok.

All in all, 200 mA seems to be the absolute maximum ever. So now I know what a T41 power supply must be capable of, without knowing upfront what uSD card will be plugged in: 200 mA on top of what the bare T41 needs at the CPU clock that it runs at. ~100 mA @600MHz default. So 300 mA seems a bare minimum. That's 2x more as what I had designed for initially.

1722092635481.png
 
Back
Top