Custom ring buffer written from scratch to allow data collection at a rigid rate, while allowing writing that data to either serial or an SD card whenever time allows.

Dependents:   SpindleBot_1_5b

Files at this revision

API Documentation at this revision

Comitter:
labmrd
Date:
Wed Apr 29 21:52:23 2015 +0000
Parent:
1:f109687a28fe
Commit message:
Collaborating!!!!

Changed in this revision

ServoRingBuffer.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f109687a28fe -r da00ed8a1cd5 ServoRingBuffer.cpp
--- a/ServoRingBuffer.cpp	Mon Apr 06 21:10:08 2015 +0000
+++ b/ServoRingBuffer.cpp	Wed Apr 29 21:52:23 2015 +0000
@@ -97,12 +97,12 @@
     static unsigned int currentReadIdx;
     for (ii = 0; ii < readsRemaining(); ii ++) {
         currentReadIdx = (lastRead + 1) % BUFFER_SIZE;
+        fprintf(txtFile,"%d,", ringBuffer[currentReadIdx].time);
         for(jj=0;jj<NUMBER_OF_SPINDLES;jj++)
         {
             fprintf(txtFile,"%d,%d,", ringBuffer[currentReadIdx].myServoData[jj].pos,
                                           ringBuffer[currentReadIdx].myServoData[jj].force);
         }
-        fprintf(txtFile,"%d,", ringBuffer[currentReadIdx].time);
         fprintf(txtFile,"%d,", ringBuffer[currentReadIdx].direction);
         fprintf(txtFile,"%d\n", ringBuffer[currentReadIdx].cycle);
         lastRead = currentReadIdx;