Hi, I've got a sketch logging CSV data from an Arduino, sent via the serial port, to a text file and also plotting it.The data indicates the state of a 3-way solenoid valve switching between two streams of milk flowing through a bioreactor. A pair of thermocouples measure the inflow and outflow temperature. The data is seconds run for, temp A, temp B and valve state. The sketch runs for days and data is sent at 0.2Hz so there's a fair amount of data there. What I'd like to do is adapt this sketch to logging data from HPLC detectors. These transmit analogue data as 0-1V, which I intend to process with an 18-bit ADC breakout for my Arduino.
My problem is that I like logging CSV to text files with a new line for every data point but I want to exploit the subset() function for array data, inconjunction with click-and drag, to zoom in on areas of the plot. This data will only be logged for an hour or so but at 10Hz so still tens of thousands of data. I have worked out how to import CSV data into an array with loadStrings() and then parse it into individual arrays for each column of values plot it but I want to know if there's an easier way of doing this than reading in and processing the array data every SerialEvent()?
~ <BRAINWAVE!> ~
The solution is obvious, now I write it down! Instead of working from a single repository, in the text file, and wasting processor time reading it in and out I just maintain parallel data streams, logging new data to a new line in the text file and appending it to an array in memory. I can maintain a second subset array of data to be plotted whose contents will be dictated by the region of the plot selected for display- zoomed or otherwise.
Simples!
Now I've written it I'll leave this here in case anyone else faces the same issue.
1