LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inconsistent data during VISA Serial Read

Hi,

 

I have a device that is outputting a stream of serial data every second with "\r\n" as termination character. Problem I am seeing is I am not getting the consitent stream of data from each read. In the following image, ones with red arrow is when I am getting too many or too few data. Rest of the data is how I am expected to get. First data in serial data stream is the number of seconds and such events are happening after about 8000 seconds. 

I logged the serial data from device using HyperTerminal overnight and inspected the data and everything on data log was fine. This verified the device is outputing the data correctly. 

 

I am configuring serial port with '10' or '\n' as termination character since that is the last character in the data stream. And, I am extracting the 10th byte of the data from the serial data stream therefore I am not worried about having '\r'. And, I am using default timeout of 10 seconds,and passing 500 as byte count to VISA READ. Therefore this setting along with termination character of 10 should be sufficient to read serial data stream efficiently every second. But, I am not able to consistently read them correctly. 

 

Any suggestion is highly appreciated. I have attached VI along with this post. Please refer to the while loop at the bottom of the VI. I am reading three of them so there are three blocks of similar code.  The following image was obtained as a troubleshooting step logging the data from one of the VISA READ in while loop.

 

I am using LabVIEW 2015, and NI-VISA 15.5. 

 

 Serial_Logged_Data.JPG

0 Kudos
Message 1 of 5
(3,141 Views)

Can't rule out a coding error on your part.  What you posted doesn't show how you did file logging or where you tapped into a string to do it.  Also, your main vi calls processing functions that weren't included and can't be examined.

 

That said, you'd be doing yourself a favor to:

- use 3 separate reading loops for the 3 instruments.  Then the timing won't be co-dependent.

- pay attention to the errors in the reading loop(s).  You've been ignoring any helpful clues they might have given you

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 5
(3,116 Views)

@Kevin_Price wrote:

- use 3 separate reading loops for the 3 instruments.  Then the timing won't be co-dependent.


Speaking of timing, there is actually no need for the wait in the loop either.

 

I would actually go so far as to make a reentrant VI to handle one of the instruments, and just reuse it for all 3 (call the VI 3 times in parallel, each having a different VISA Reference).  I would also change to using Notifiers for passing the data around instead of relying on the Local Variables.  You could also use Tag Channel Wires for passing the data.



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
(3,095 Views)

@Kevin_Price

Thank you for your feedback. I will run a test with three separate reading loops. Since the data I am logging is from VISA Read in the loop and that is where I am getting error, I will delete rest of the code (state machine) and run test with reading loops only. I will update on my findings.

 

In regards to "- pay attention to the errors in the reading loop(s).  You've been ignoring any helpful clues they might have given you", did you mean monitoring the error cluster in the loop?

0 Kudos
Message 4 of 5
(3,071 Views)

@crossrulz

Thank you for your feedback. I will implement your recommendations.

0 Kudos
Message 5 of 5
(3,067 Views)