Hi,
After some investigations I saw SD initialization for fast data logging looks like:
// initialize the SD card at SPI_FULL_SPEED for best performance.
// try SPI_HALF_SPEED if bus errors occur.
if (!sd.begin(chipSelect, SPI_FULL_SPEED)) {
sd.initErrorHalt();
}
// delete possible existing file
sd.remove("RawWrite.txt");
// create a contiguous file
if (!file.createContiguous(sd.vwd(), "RawWrite.txt", 512UL*BLOCK_COUNT)) {
error("createContiguous failed");
}
// get the location of the file's blocks
if (!file.contiguousRange(&bgnBlock, &endBlock)) {
error("contiguousRange failed");
}
According to my SD storage experience I have some difficulties to integrate it.
Thanks to a moderator who makes my sketches usable without all the sensors, hence you can find it attached with the associated library. You just need a SD board.
I am actually using a 16 Gb SanDisk Extreme Plus whose the bench.ino test gives:
Type any character to start
FreeStack: 6699
Type is FAT32
Card size: 15.93 GB (GB = 1E9 bytes)
Manufacturer ID: 0X3
OEM ID: SD
Product: SP16G
Version: 8.0
Serial number: 0XD46709D8
Manufacturing date: 8/2015
File size 5 MB
Buffer size 512 bytes
Starting write test, please wait.
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
262.80,120024,1484,1941
259.44,192484,1488,1966
Starting read test, please wait.
read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
484.56,2040,996,1050
483.90,2040,1000,1051
The attached sketch perfectly illustrates the timing problem when the recording file is extended leading inevitably to missing writings.
With the real sketch I get:
With the "sensor simulated" sketch which is attached I obtain:
Press 1 to start logging, 0 to stop
Initializing SD card...
SD card initialized.
Writing to data_03.txt
W5330396=5
S5330828=5
I5331352=6
W18860092=2
S18860568=2
I18867564=2
W18946268=2
S18946744=2
I18947312=2
I18974124=3
W26022492=2
S26022976=2
I26033992=4
W47646692=2
S47647176=2
I47652068=3
I47670404=2
W69255272=2
S69255752=2
I69259712=3
I75820696=2
W101575040=2
S101575568=2
I101577560=3
W101595128=2
S101595660=2
I101599992=3
I102401784=2
I102488544=2
W102568180=2
S102568704=2
I102569336=2
W102641836=2
S102642356=2
I102648856=3
.....
Each line is a missing writing. The letter corresponds to the sensor's name (I=IMU, S=Steering sensor, W=Wheel speed sensor) and then the time in micros when it happens.
I would be grateful if someone could help me. It's the last part of a 2-month project.
Thank you very much,
Pm
simple.zip (157 KB)