LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Stamps in Producer/Consumer Setup

I am trying to acquire signal from a Gas Analyzer, Flow Meter, and 3 RTDs.  My hardware is a NI 9215 and NI 9217.  I need to write the data to a file with a time stamp at which the sample was read.  The program is written in a producer/consumer setup in which the data is being acquired in the prodcuer loop and sent to the consumer loop to be written.  I can get the samples written to the file okay. However, I have not figured out how to put the time stamp in the data file correctly. I thought the time stamp was created with the corressponding measurement at the Data Acquisition VI. However, whenever I open the data file, there are only 0s in the time column.  So, I've tried to use Format/Date String to add the time stamp. I can get it to work if I place it in the consumer loop. However, the time stamp is not accurate.  It puts the same time stamp up to six digits of precision for two consecutive samples. I've tried to figure out how to add it to the producer  loop, but I don't know how to add it and the measurements to the queue at the same time. Please tell me the best way to acquire signals with the exact time stamp and write them to a file using a producer/consumer design.

 

 Example:

 

Date             Time               RTD1     RTD2      RTD3     CO2      Flow

5/26/07      5:20:01.25       57         56         56.5      100       0.5

5/26/07      5:20:01.30       57         56         56.5      100       0.5

5/26/07      5:20:01.35       57         56         56.5      100       0.5

0 Kudos
Message 1 of 11
(3,463 Views)

You need to change the data type of the queue to hold the timestamp (use a cluster for this or use array of waveforms), then you could add it in the producer queue. Also your DAQmx ReadVIs are set to 2D Double, try use Waveform array.

 

Felix

0 Kudos
Message 2 of 11
(3,462 Views)
Thanks for the reply. I've tried that, but there is not time stamp in the file, only the measurments.
0 Kudos
Message 3 of 11
(3,457 Views)
I've also tried using the Format Date/Time String in the Producer loop, and I successfully added it to the queue, but I cannot figure out how to connect the Dequeue to a data file/spreadsheet, etc.. file. I've tried connecting it directly, unbundling the cluster. It just doesn't work
0 Kudos
Message 4 of 11
(3,442 Views)

Almost done. Your waveform data is already a cluster containing the timestamp(s). Take a look at your waveform palette to extract t0 and Y for each waveform (they are in an array, so you might need a for loop). The timestamp you can format with the same way as before (use the input of the function) and the Y data as you 2D-double.

 

Felix

0 Kudos
Message 5 of 11
(3,435 Views)
Thanks for the reply. I'm not sure I follow you on how to use a For Loop to extract the time stamp.  All of this data type business is really confusing.  I've tried connecting the waveform signal to the "Get Waveform Components" vi and it doesn't like anything I connect to it. I've tried connecting them when both signals are together and after I have split the signals. Could you please show me how to do this. It doesn't seem like it should be this difficult just to put the time stamp with the measured data.
0 Kudos
Message 6 of 11
(3,426 Views)

Just draw a for loop around your Get Waveform Components.vi.

 

Felix

0 Kudos
Message 7 of 11
(3,423 Views)
Okay, I've put it in a For Loop and it will connect now. However, whenever it runs the time stamp increments for a couple seconds and then it just repeats. How do I correct this?
Download All
0 Kudos
Message 8 of 11
(3,414 Views)

I don't understand your problem this time. Your txt file shows correct readings.

 

I'm of for at least two days, someone else needs to keep up this community support. Sorry.

 

Felix

 

0 Kudos
Message 9 of 11
(3,406 Views)

If you look at the time stamps closely it repeats the range at 16:24 seconds multiple times and then at 16:25. I'm not sure why it does this.

 

Thanks for the help

0 Kudos
Message 10 of 11
(3,404 Views)