05-04-2021 11:47 AM
I know I don't understand something here but I'm trying to figure out what piece I'm missing. Im writing a producer/consumer loop to log thermocouple measurements from an NI9210/compact DAQ. I want to read data as fast as it's available from the hardware (2 samples/sec IIRC) and write it to a spreadsheet.
My VI is as pictured, but whenever I set the "Samples to Read" on the DAQmx read to -1 (read whatever is in the buffer, not a specific number, correct?) and I run the VI for 10-15 seconds I only get 1 sample logged. If I set "Samples to Read" to 1 or 2, then I get approximately 15 data points, which is what I would expect for how long I run it.
Obviously setting to 1 or 2 works, but I don't understand what's wrong with setting it to -1, as that is the default that should do what I want, right?
05-04-2021 01:14 PM
I would advise against using the Write To Delimited File. It is constantly opening and closing the file. Instead, use the File I/O API to create the file before the loop, write your header (still before the loop), write the data inside of the loop, and close the file after the loop.
I am also suspicious because your file header is showing 2 channels, but you are only reading 1 channel (1Chan NSamp). How many channels should you be reading from?
Finally, with the rate you are reading data (500ms per sample is extremely slow to a computer), I would not use a Producer/Consumer here. It can all be in 1 loop. This will make things a lot simpler for you. I would also just read 1 sample at a time using the NChan 1Samp (assuming you have multiple channels) option for the DAQmx Read.