LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I record data from 2 devices synchronously

Hi,

I've been working on this VI for some time now and I've already recieved some prior help from these forums, so I hope I can get this problem solved.

 

I have a DAQpad 6020e, a hot wire thermo anemometer, and Labview 7.1.  I need to take voltage measurements from the DAQpad at a scan rate I specify (I have it set to 1000 in the screenshot), while simultaneously taking readings from the anemometer.  However, the anemometer only takes readings every 1.6 seconds, which it sends to the serial port in ASCII.

 

I have tried many iterations of this vi to try to get the data to come out synchronously.  By synchronously, I just mean I want both measurements to START at the EXACT same time.  Obvisously the scan rates are drastically different so I will have far more measurements from the DAQpad, but that is ok so long as both measurements start at the same time.  I cannot control when the anemometer makes its reading, so what I have attempted to do is as follows:

 

1.  VI starts, both reads initialize, then DAQpad scan begins.

2.  If Scan Rate and "Scans to read" are equal, it takes one second for measurements to start being recorded from the DAQpad.

3.  In an attempt to synchronize the measurements, I attempted to tell the anemometer WHILE loop (serial) to wait until the first measurement has been recorded from the DAQpad.  (**Note, I have also tried using the "number read" lead off of the AI read command).

4.  Because I only get 1 reading from my anemometer per 1.6 seconds, I can't predict when the next reading will be.  But I want my measurements to be corrolated in time, so I have attempted to start the measurement file as soon as the case structure starts.  This way, even if the very first reading is invalid, the rest of the readings will be valid and will be taken at times that directly correlate with the DAQpad measurements.

 

 

I have run this vi many times, with different results.  I have gotten it to run sucessfully many times, meaning that both measurement files started recording data at the exact same instant, even if the anemometer reading wasn't available yet (I know this because the second measurement was taken at a time earlier than 1.6 seconds, meaning that the file did not wait for a measurement to be obtained in order to assign a value at 0 time).  HOWEVER, other times, this vi does not run correctly.  Sometimes the anemometer readings begin before the DAQpad readings, sometimes after.  In every case where the vi does not work, it appears that the anemometer measurement has waited for its first measurement to be recorded at time 0 instead of starting the measurement file when the DAQpad starts.

 

I need to know why this vi doesn't run consistently.  I can see it do what I want it to do over and over again, but I can't use this vi if it is not 100% consistent.

 

Thank you,

Jake

0 Kudos
Message 1 of 5
(2,874 Views)

Also, to clarify, I get very similar results when I connect the "numbers read" lead from the AI read function to a =/0? boolean operator and then to the boolean LED.

0 Kudos
Message 2 of 5
(2,866 Views)

For future reference, just post the actual VI.  It is easier to troubleshoot than a print as a PDF.

 

Given the software complexities of separate threads and serial bus versus PCI bus, I don't see how you can say that the measurements actually start at the same time.  The only way you can say that the measurements started together was if you were using a hardware trigger.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(2,865 Views)

The LabVIEW measurement file records the date and time that the file was created, as well as the date and time of the first measurement, up to a tenth of a second.  I was assuming that if both measurement files said they started recording their measurements at the same time up to the tenth of a second, the measurements would be synced, or at least you could correlate the times of the measurements.

 

Here is the actual vi that you requested, with a couple minor modifications I made as I am still trying to make it work on my end.

0 Kudos
Message 4 of 5
(2,863 Views)

As I said, it seems to work 50% of the time.  The recorded starting measurement time in each measurement file is the same down to the tenth of a second and the data from my serial measurement indicates that the file was created before the first measurement was available (which I want).

 

However, the other 50% of the time the start times are different and it does not appear that the serial while loop waited for the AI read while loop, or that it waited an extra length of time, and I can't determine why this occurs and why it seems to be random.

0 Kudos
Message 5 of 5
(2,856 Views)