Richard Lin // // No Comments

The Data Logger Board does not actually use BRAIN as its central processing unit.

Everyone’s heard of black boxes – they are devices that record data in the event that something happens to assist in determining why something happened. Did you know that we have a similar device too – the Datalogger board!

You may be wondering where the BRAIN is, and the answer is, we didn’t use one. Initial testing with SD libraries available on the Internet showed insufficient performance. Additionally, there were concerns about overflowing the MCP2515’s 3-level deep receive buffer while the processor is busy doing SD Card writes. So, we chose the dsPIC33FJ128MC802 chip, which has a higher clock speed, integrated CAN module (with a 32-level deep buffer), and direct memory access to allow SPI transfers in the background. However, a future project would be to try the optimized code on a BRAIN and see if it will yield the necessary performance.

Of course, ours isn’t made to the same rigorous standards as aviation black boxes. Then again, we’re hoping we will never have to put their survivability to the test. Hopefully it will mainly be used for debugging in the debugging phase.

One of the major functions of the board is to log all relevant data (currently, anything flowing on the CANbus network) to a suitable medium (an SD card). Since it needs to do so at a reasonable pace, we need an optimized library.

Simple math shows that in the worst case scenario: for a 500kbit/s (which is what our CANbus will run at) input we need at least 62.5 kByte/s write speed. However, to be able to output in hex ASCII, the speed would need to be doubled, since one byte takes two characters, which gives us a minimum 125kByte/s. One available library on the Internet achieve 117kByte/s (– benchmarked on 14MHz Arduino), however, those are all operations performed on the processor, which leaves little processor time for anything else. Another library, written for the multicore Propeller chip, achieves a whopping 1MByte/s – but programming the Propeller is a pain, having to learn the non-portable and relatively uncommon SPIN language. And we spent an entire day banging our head against a wall trying to debug a CANbus library for Propeller, which certainly left quite a sour taste. With those options gone, we chose to write our own library.

And we have progress! After spending 4 hours implementing the SD Card block write function, a quick round of benchmarks showed that it achieves a raw write speed of ~600kByte/s! Nice!


Device under Test. Many thanks to Ryan for the logic analyzer!

What did we do to get that kind of performance?

Optimistically, we hope to push performance up to 1MByte/s and have most of the work done by the DMA module so the main processor is free to do whatever processing work is necessary. We may even be able to implement a CVR (Cockpit Voice Recorder – the other “black box” device)!

Then, possible future work includes:

Here is the testing methodology and setup:

← Back to Blog

Comments are closed.