ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unwanted delay between channels

Hello LabVIEW community,

 

I have a strange delay (on the order of several seconds!) between several signals I am acquiring with my .vi. In summary, I am using a cDAQ chasis with AI and AO modules and am using two devices which transmit data using RS-232. In my vi I use the VISA functions to read the COM ports, parse the data strings and translate them to numbers, which I save to a measurement file. Additinally, I acquire analog voltage through the cDAQ using DAQ assistant and save that to the same measurement file. There are some calculations, plotting and analog voltage outputting going on as well.

 

The problem with the delay is seen in my measurement files. The RS-232 signals seem to arrive several seconds faster than the signals from the DAQ, even though their X_Values match pretty closely. To diagnose this problem further and to determine the exact delay, I've powered one of my analog voltage inputs and the RS-232 devices with the same voltage signal, which I could instantly kill with the same switch. That way I would know that I could provide a step change in both of the channels at the same exact time (well, not on the order of several seconds, anyway) and watch the response time between channels. To my dismay, the delay is not the same between several repeats of the same experiment (see attached excel spreadsheets - as a note, the gap in time between the first row of data (XValue=0) and the second row of data (XValue>>0) seems to correspond to the amount of time it takes me to type in the file name, and doesn't seem to correlate to the signal delay.... although I may be wrong).

 

I am hypothesizing that the problem lies in my rate of sampling of the DAQ somehow not alligning with the baud rate of the COM ports... I am uncertain, however, how to figure out what sampling rate I shold be using to allign the readings.

 

Another problem is that I already collected some data with the delay in it, and I'd like to back-calculate the delay to compensate. Is this possible?

 

PLEASE HELP! Thank you in advance!

Download All
0 Kudos
Message 1 of 2
(2,689 Views)

A small portion of your code showing 2 race condition caused by reading the local variable before writing the terminal.  you code is full of them

Untitled.png

 

Also read your note about match regular expression  Its pretty easy to match a NUL character (ASCII 00) but a space character is ASCII 0x20 NUL Never equals SPACE.

 

ADDITIONALLY: and why it takes the time to type to refresh! AHAA! the 0 ms Timeout on the event structure means that event case exited 0 ms after it entered and no reading was taken that iteration of the while loop when you pressed the button the event queued up waiting for the event loop to run again and when the while loop started over the measurement was made.  This is BAD.


"Should be" isn't "Is" -Jay
Message 2 of 2
(2,669 Views)