08-23-2019 04:45 AM
So I have been trying to output my logging data from DAQ system into a csv file.
For some reason, Labview put all data into 1 column instead of 3. Any idea where I went wrong?
Also, you can see from the VI that I'm trying to log the time stamp, but to be honest I'm not sure how to do so. Any suggestion?
Solved! Go to Solution.
08-23-2019 05:30 AM
08-23-2019 06:53 AM
So I figured out where I was wrong (I transposed the array!). But now I also want to get the time data from the waveform.
With the setup below, after getting the dynamic data, I converted it into 2d array. By doing so, I get the analog value of my 2 signal. However, I did not get the time data. My sampling rate is 20k.
Is there any way to add the time into my csv file? I would like the time reference to the start of the sampling, not the global time.
08-23-2019 07:06 AM
Hi Anh,
Is there any way to add the time into my csv file?
Yes, sure.
(Most often things get clearer and easier once you get rid of ExpressVIs…)
I would like the time reference to the start of the sampling, not the global time.
Add two more items to your "header": start time and samplerate…
Add one more column to your data: sample index divided by samplerate…
08-23-2019 07:31 AM - last edited on 08-23-2019 12:42 PM by pcerda
Thanks for the code, now we can see what you did and make some possibly-helpful suggestions.
Here is a Snippet generating 2 small (20-sample) Waveforms, concatenating them (or not -- do test the more-natural "Build Array without Concatenation") that can easily be written and tested. Note the use of a Shift register to (correctly) call Write Delimited Spreadsheet, specifying the File Name only on the First Call.
Bob Schor
08-23-2019 07:32 AM
Hm.
So how accurate is that if I just assume that with 20kSample/s, the relative time stamp of those data sampled in 1 second is map out evenly throughout that 1 second period?
With the time stamp coming from the Labview express VI, is that the same way to get the time, or is the time stamp something sent along with the analog reading from the DAQ device?
08-23-2019 07:35 AM
Hi Anh,
So how accurate is that if I just assume that with 20kSample/s, the relative time stamp of those data sampled in 1 second is map out evenly throughout that 1 second period?
As long as you use the sample clock of your DAQ device (which you should for a samplerate of 20kS/s) it is accurate as the specsheet of that DAQ device promises. (Atleast it is much more accurate than any timing provided by WindowsOS.)
08-23-2019 07:37 AM
Does that mean I can just add my own timing data, without getting the actual timing data of DAQ?
08-23-2019 07:43 AM - edited 08-23-2019 07:43 AM
Hi Anh,
for "short" measurements it is safe to assume an accurate sample rate. For "longer" measurements you might use an external (even more accurate) timing source (depending on your requirements!).
As said before: read the specs of your DAQ device to learn about its capabilities regarding sample clock accuracy…
08-23-2019 07:53 AM - last edited on 08-23-2019 12:42 PM by pcerda
That's a really nice reply, Bob!
For some reason, I didn't see yours until now.
I see that you have found my mistake, which I ultimately found it through exactly what you suggested too.
So here's how I want to represent my data:
3 columns: Time, Voltage1, Voltage2
The time column is the relative time, which means it should be 0 at the first time interval. The unit of time should be us because I'm sampling at 20kHz.
And you are right about all data in 1 column, that's not what I want! But I have no idea how to, after converting the dynamic data to 2D array, to add time as another column to my spreadsheet. I find this is extremely difficult because I think the data I get from DAQ Assistant is 2 array of data in one time loop, while dt is a single data point. So I guess I'm not sure how to get another time column that supposedly comes with the data from the DAQ device. Any advice Bob?
Thanks again.