3

I am on a project that requires data logging and I am using an STM32F1 MCU. The amount of data is around 400 bytes per log entry. One of the environmental conditions of the deployment is vibration. It will be on a car with a stiff suspension setup.

I can either implement an SD card with SPI or full-speed USB OTG. My goal is to have an easy access - considering current laptops' lack of an SD card slot - to the recorded data.

I cannot be sure which one to use: I think an SD card with SPI, 1 bit recording capability might result in high latency. Therefore, may be using USB full speed is a better way to go. But on the other hand, because of the vibrations, a USB connection might not be stable.

My question is: which method is the preferable choice?

ocrdu
  • 8,705
  • 21
  • 30
  • 42
squieler
  • 31
  • 2
  • 1
    Note that (consumer-grade) SD cards / slots are also sensitive to shocks and vibration. – ocrdu Jan 25 '22 at 08:43
  • 3
    Some quibbles with your question: 1) "considering current laptops' lack of an SD card slot" -- SD to USB adapters are trivially easy to get and dirt cheap; this should not be a consideration. 2) "SD card with SPI, 1 bit recording capability" -- yes but 4-bit SDIO is a thing too; 3) in a vibration-prone environment, the overall mechanical design of your system is about 100x more important than the vibration performance of your recording solution (SD versus USB). I'd say choose the solution that is easiest to implement, then just give it some vibration isolation. – Mr. Snrub Jan 25 '22 at 08:47
  • 2
    how often do you need to log? Once per second? Minute? Millisecond? no point worrying about latency or speed of the interface until you define this. – danmcb Jan 25 '22 at 09:02
  • 2
    Which exact STM32F1 model? Some have USB, some don't. Some have SD controller, some don't. – Justme Jan 25 '22 at 09:04
  • Thank you for your questions and suggestions. It gave me a wider perspective of the problem. The MCU is STM32F103. It has no SDIO but has USB peripheral. Because of that SPI is my only alternative for SD card. The interval for logging, ideally for every update of the variables. But practically 100 ms would be enough for analysing the data. – squieler Jan 25 '22 at 09:37
  • Your STM32F103's USB peripheral only supports acting in the USB *Device* role. You cannot use it in OTG mode it to hook up a USB flash drive. So you either need to change your micro, or consider this question moot since your only option with an F103 is to use an SD card. – brhans Jan 25 '22 at 13:00
  • 1
    4 kB/s should be no problem in SPI mode. But beware of variable latency when writing to the card, you might need threads / interrupts and some buffering or a preallocated file. – DamienD Jan 25 '22 at 15:03

0 Answers0