Coder Social home page Coder Social logo

Comments (6)

greiman avatar greiman commented on July 22, 2024

You will never log to an SD at 1,000 Hz with this simple approach.

The long write times are when an actual SD block is written.

SD cards have 512 byte blocks and can take a very long time to write. Often it will be much longer. If a cluster must be added to the file, the FAT must be read and a cluster found. Two copies of the FAT must be updated.

The SD card can have occasional long write latency. It must erase large blocks of flash. It may pause to move data and remap flash for wear leveling. This will take many ms.

Here is a program, LowLatencyLoggerADXL345 that logs data from an ADXL345 at 500 Hz. It requires shared SPI and a high quality SD.

LowLatencyLoggerADXL345 appears to work at 1,000 Hz but may be marginal.

You could use software SPI on the ADXL345 and buffer data for writing in loop. You would need to buffer about 100 ms of data which would require 600 bytes.

from sdfat.

JavernRey avatar JavernRey commented on July 22, 2024

Hey!

Thank you very much for your help!

I will try this example. But I have one question. I also need to use a nRF24L01+ module to transmit data, which is working fine with ADXL345 using hardware SPI. Is it possible to use software SPI on the microSD module with this example? Or is it better to use hardware SPI on the microSD and software SPI on the ADXL345 and nRF24L01+?

Thank you very much!

from sdfat.

greiman avatar greiman commented on July 22, 2024

I can't help you. The nRF24L01+ will fail if a TimerOne interrupt occurs while the nRF24L01+ is active.

I don't think you should try the LowLatencyLogger example if you want to add access to the nRF24L01+ while logging.

You are on your own. I don't want to waste my time trying to solve this problem using Arduino.

I would use an STM32 board with the ChibiOS/RT RTOS, not Arduino. Even low cost STM32 boards have two or three hardware SPI ports. The priority based preemptive scheduling of threads in ChibiOS/RT makse it easy to solve problems like this.

Good luck.

from sdfat.

JavernRey avatar JavernRey commented on July 22, 2024

Hey!

Just a short question, I don´t want you to waste your time.

I´m looking for a microSD module compatible with other SPI devices, i.e. which doesn´t hold the MISO line hostage. Could you tell me wich microSD module did you use for testing LowLatencyLoggerADXL345 or any other that I can use?

Thank you very much.

from sdfat.

greiman avatar greiman commented on July 22, 2024

I used an old Adafruit microsSD module. I have some older ebay modules that are OK.

Now most ebay modules are clones of the flawed Catalex MicroSD Card Adapter or the LC studio module without level shifters

The Adafruit module is more expensive, $7.50.

You may be interested in a test I did with an old TimerOne based program.

I use software SPI with an ADXL345. See my ADXL345 driver in UserFunctions.cpp to define pins.

I have logged data directly to a csv file at 2,000 Hz with SdFat and at 4,000 with SdFatEX.

I have attached the program. It is not polished since it is my test program. It uses the current version of SdFat-beta.

logger.zip

from sdfat.

JavernRey avatar JavernRey commented on July 22, 2024

Hey!

Thank you for your answer. Now I´m not using TimerOne library. I have followed your program LowLatencyLoggerADXL345 and I have edited it, so now I can log data during the time that I set into a variable and then I can send it to a raspberry using nRF24L01+. It´s working fine, the problem is that I´m using software SPI on the microSD and I can only get a frecuency of 200 Hz because if I try with higher frequency it says "Rate too fast". For this reason I´m going to buy the Adafruit microsSD module so I can use the hardware SPI on the three modules and I can get a frequency of 1000 Hz. I hope it will work.

Thank you very much!

from sdfat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.