Hi,
A few days ago I got my Teensy 3.6, and I'm now trying to make a dual channel CAN logger out of it.
Currently the aim is to be able to log two 500kbps channels, but 1Mbps would be even better.
Logging to serial port seems to be working well, but logging to an SD card might be problematic.
Below are output from Greimans SdFat-beta library with the card I am using.
1:
size,write,read
bytes,KB/sec,KB/sec
512,16039.19,18710.54
1024,17056.88,18889.52
2048,17123.70,19061.90
4096,17295.31,19191.60
8192,17312.16,19126.09
16384,17325.54,19266.40
32768,17304.02,19272.50
totalMicros 6522071
yieldMicros 186429
yieldCalls 176
yieldMaxUsec 1349
kHzSdClk 45000
Done
Type '1' for SdFatSdioEX or '2' for SdFatSdio
2:
size,write,read
bytes,KB/sec,KB/sec
512,415.15,2068.71
1024,561.05,2899.53
2048,1593.08,5062.67
4096,4137.94,9203.65
8192,5899.78,11952.82
16384,9984.05,16415.39
32768,10952.01,17668.97
totalMicros 56682983
yieldMicros 56134934
yieldCalls 81362
yieldMaxUsec 134753
kHzSdClk 45000
Done
The question is how much or little I can/have to write to avoid loosing any CAN frames.
I believe the CAN buffer is 6 frames long, and 6 full frames would take about 1.5ms to receive.
If the CAN frames contain less than 8 bytes of payload, the time to fill the buffer will be less.
Using DMA method, I was able to write a block of 512 bytes in about 2.5ms.
A 32 byte block was written in 0.19ms
I chose DMA method to have the most free CPU time, but that might not be required.
Is it OK to write in 32 byte blocks, or in general anything less than 512?
Will there be a longer delay when I reach 512 bytes in total?
I will try to perform some tests to check this, but if anyone can tell me to just forget it, that would save some time.
Thanks
View attachment canloggerserial.inoView attachment sdwrite32byte.ino
A few days ago I got my Teensy 3.6, and I'm now trying to make a dual channel CAN logger out of it.
Currently the aim is to be able to log two 500kbps channels, but 1Mbps would be even better.
Logging to serial port seems to be working well, but logging to an SD card might be problematic.
Below are output from Greimans SdFat-beta library with the card I am using.
1:
size,write,read
bytes,KB/sec,KB/sec
512,16039.19,18710.54
1024,17056.88,18889.52
2048,17123.70,19061.90
4096,17295.31,19191.60
8192,17312.16,19126.09
16384,17325.54,19266.40
32768,17304.02,19272.50
totalMicros 6522071
yieldMicros 186429
yieldCalls 176
yieldMaxUsec 1349
kHzSdClk 45000
Done
Type '1' for SdFatSdioEX or '2' for SdFatSdio
2:
size,write,read
bytes,KB/sec,KB/sec
512,415.15,2068.71
1024,561.05,2899.53
2048,1593.08,5062.67
4096,4137.94,9203.65
8192,5899.78,11952.82
16384,9984.05,16415.39
32768,10952.01,17668.97
totalMicros 56682983
yieldMicros 56134934
yieldCalls 81362
yieldMaxUsec 134753
kHzSdClk 45000
Done
The question is how much or little I can/have to write to avoid loosing any CAN frames.
I believe the CAN buffer is 6 frames long, and 6 full frames would take about 1.5ms to receive.
If the CAN frames contain less than 8 bytes of payload, the time to fill the buffer will be less.
Using DMA method, I was able to write a block of 512 bytes in about 2.5ms.
A 32 byte block was written in 0.19ms
I chose DMA method to have the most free CPU time, but that might not be required.
Is it OK to write in 32 byte blocks, or in general anything less than 512?
Will there be a longer delay when I reach 512 bytes in total?
I will try to perform some tests to check this, but if anyone can tell me to just forget it, that would save some time.
Thanks
View attachment canloggerserial.inoView attachment sdwrite32byte.ino