First of all many many thanks, because you have done so much work. Totally interesting data with the different processors and signal timings. I would not have thought that there are such differences. I will save the thread for me and if necessary edit the SdSpiLibDriver.
But these changes are very challenging even if it is, as you write, small adjustments.
However, I have here a new sd card reader (Amazon, 3 €
). I have now tested with the reader.
Interestingly, the SD library ONLY works with the internal card reader.
As already described, the SDfat library (by default) works only with the external card reader.
Thus I could not carry out my tests of the two libraries and class on the same hardware. But, the results are very interesting !!!
So I tested the different classes with the same data (381909 byte). Here are the results:
| Library/Class | File Reading | Performance | SD Card Reader |
|---|---|---|---|
| SD Bibliothek (File Class) | "while(file.available()){ file.read(); }" | 70.55kb/Sek | internal |
| SD Bibliothek (File Class) | "while(...){ file.read(byteBuffer, 1000); }" | 153.28kb/Sek | internal |
| SD Bibliothek (SdFile+Sd2Card+SdVolume) | "while(...){ file.read(byteBuffer, 1000); }" | 183.50kb/Sek | internal |
| SDfat Bibliothek (File Class) | "while(file.available()){ file.read(); }" | 86.78kb/Sek | external |
| SDfat Bibliothek (File Class) | "while(...){ file.read(byteBuffer, 1000); }" | 214.34kb/Sek | external |
| SDfat Bibliothek (SdFile Class) | "while(file.available()){ file.read(); }" | 90.21kb/Sek | external |
| SDfat Bibliothek (SdFile Class) | "while(...){ file.read(byteBuffer, 1000); }" | 214.11kb/Sek | external |
Thus, the decision falls on the following constellation: the SDfat library with the external (cheap) card reader and the blockwise reading into a buffer.
In my application the data should not be read completely to process them at the end. I need to load the data in small pieces to process them in real time. I have only max 45 microseconds to read and process.
Therefore, I have been testing reading small blocks. And that I would not have thought possible:
| Data Length | Duration | Performance |
|---|---|---|
| ----- | 2 Mikrosekunden | |
| 0 Byte | 4 Mikrosekunden | |
| 1 Byte | 8 Mikrosekunden | 122 kb/sec |
| 2 Byte | 8 Mikrosekunden | 244 kb/sec |
| 4 Byte | 9 Mikrosekunden | 434 kb/sec |
| 6 Byte | 9 Mikrosekunden | 651 kb/sec |
| 8 Byte | 9 Mikrosekunden | 868 kb/sec |
| 10 Byte | 10 Mikrosekunden | 977 kb/sec |
| 12 Byte | 10 Mikrosekunden | 1172 kb/sec |
| 14 Byte | 11 Mikrosekunden | 1243 kb/sec |
| 16 Byte | 11 Mikrosekunden | 1420 kb/sec |
| 18 Byte | 11 Mikrosekunden | 1598 kb/sec |
| 20 Byte | 12 Mikrosekunden | 1628 kb/sec |
| 30 Byte | 13 Mikrosekunden | 2254 kb/sec |
| 40 Byte | 16 Mikrosekunden | 2441 kb/sec |
| 50 Byte | 18 Mikrosekunden | 2713 kb/sec |
| 100 Byte | 27 Mikrosekunden | 3617 kb/sec |
| 300 Byte | 64 Mikrosekunden | 4578 kb/sec |
| 500 Byte | 102 Mikrosekunden | 4787 kb/sec |
| 512 Byte | 104 Mikrosekunden | 4808 kb/sec |
| 550 Byte | 2497 Mikrosekunden | 215 kb/sec |
| 600 Byte | 2511 Mikrosekunden | 233 kb/sec |
| 750 Byte | 2535 Mikrosekunden | 289 kb/sec |
| 1000 Byte | 2584 Mikrosekunden | 378 kb/sec |
Unbelievable that the performance with 512 byte or less is so high !!!
Why this is so, I can not understand. But I think there is an 512 byte buffer implemented somewhere (for example, on the sd card reader).
Because I only have a maximum of 45 microseconds to load min 2 byte + process, I will probably load about 20-50 byte as a block (12-18 micros.). So I have enough time in the next loops to take care of the bluetooth communication and the stepper motors, ....
Thanks again and Greetings, DrDooom. ![]()