Hi folks,
I'm building up a logging solution for the CAN-Bus and i want to capture all sent messages in a raw format to an SD Card.
I'm using the sparkfun CAN shield and an Arduino UNO (but I also ordered a Mega)
The logger works great BUT I can't handle CAN messages during the write process, because the CAN receiver and the SD card communicate over Hardware SPI and interrupting the SD card write to receive a new message messes up the write process. So i have to disable Interrupts (over which the CAN messages are received and put into a buffer) and lose a few messages, resulting in an incomplete Log.
Fat16Lib has already been extremely helpful and constructive towards my problem, but it really looks like doing the write with the current setup won't work. Hooking up a different sd shield, that interfaces over software spi would allow interrupts while writing, but will very likely not be fast enough to keep up with the 500kbit CAN-Bus.
So i went back to the drawing board and tryied to come up with new ideas/work arounds, but maybe my incomplete knowledge doesn't generate all possible solutions, so I was hoping you could throw in some ideas to do the write process in parallel to the CAN receive process.
This is what i've come up with so far:
- find an SD logger, that doesn't block the ATmel while writing (possibly with an extra IC that writes the data to the SD)
- connect an SD logger over I²C, so that it doesn't use the Hardware SPI (has anyone done this before? It should be almost as fast as hardware SPI, wouldn't it?!?!)
- Buffer all data into an external RAM and write the captured data to the SD after finishing the log (problem: 50 seconds of log need 1 MB of raw data - I haven't even seen a RAM for arduino that surpasses 256 Kbit...)
- USE TWO ARDUINOS - This is the solution that I think about the most at the moment!
There have already been several ideas concerning co-processors
( http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237871297 , hobby-roboter.de - This website is for sale! - hobby roboter Resources and Information. , Coprocessor )
and I know the basics of multiprocessor scheduling and resource handling, so I think it should definately be possible, to have one Arduino read the Data over his hardware SPI from the CAN controller, put it into a shared RAM buffer (of course using correct lock-outs) and then let the other Arduino fetch that buffer to write it to an SD card.
( sth. like: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293464810/all )
These are the ideas I have come up, but as i've already mentioned, my "knowledge tool-Box" is limited and I bet you have way better ideas or know instantly, that what I'm considering is complete BS
I would appreciate any insight/link/idea that you are willing to share with me, because I've already exceeded my capabilities.
Thanks in Advance, Keija