You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • That looks pretty good.

    I'm not sure what the fastest speed you can get is with C code, but I bet the vast majority of time in your code right now is spent in fID.write(data);, which is all C code.

    SD card IO is a bit tricky because it often has to load up a 512 byte sector before it can write it, but you're off to a pretty good start by batching samples in RAM and writing them out in one chunk.

    Some things that would help you though:

    • Try Puck.on('accel', storeMyData.bind(null,fID, start)); instead of what you have - it'll call the function directly rather than having the function inbetween
    • Turn on minification in the IDE
    • Try writing in smaller batches (20?)

    Also worth noting that the way storeMyData is, it'll lose 1 in 100 readings (the one where you write the file).

    I think one issue you might be hitting is that the data is read direct from the accelerometer data registers, but only in the idle loop. It means that if your code is spending a long time doing something (like writing to an SD card!) then you'll end up missing accelerometer data.

    Puck.js wasn't really designed for this kind of high speed data acquisition so it wasn't implemented, but the LSM6DS3TR-C actually contains a pretty big FIFO, which means it could be configured pretty easily such that it doesn't lose data.

    Either that'd require some firmware changes, or potentially it would be possible to access the LSM6DS3TR-C directly from JS and read the data out that way. If you just grabbed the binary data and wrote it straight to the file (without turning it into CSV) then you should be able to get a pretty decent data rate out of it.

About

Avatar for Gordon @Gordon started