LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Loss in VISA

Hi,

 

I just want read the data from serial port of Arduino by using the NI VISA. When I read the data from the serial Monitor, the data is like this:

T

1022

1023

987

885

854

T

1022

1024

988

885

854

But when I read these data in LabVIEW, some data is lost, like the text file, which I attaches. Could someone explain the reason?

 

Best regard

Download All
0 Kudos
Message 1 of 4
(3,194 Views)

If only I had a penny for every time this error came up on the forums...DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!! (enough emphasis?)

 

The Bytes At Port causes weird race conditions like what you are seeing.  Since you have the termination character enabled, use it.  Just tell the VISA Read to read more bytes than you ever expect in a message.  The read will stop when it reads 1) the number of bytes you told it to or 2) the termination character.  So by telling the VISA Read to read more bytes than a message should ever be, you are essentially ending your read with the termination character.  This ensures you got a full message.


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 2 of 4
(3,174 Views)

Also besides what Crossrulz said you might find it easier to send your data all at once instead of one at a time.

 

Instead of sending 

T

1022

1023

987

885

854

T

1022

1024

988

885

854

 

Just send it all in one line separated by commas;

T,1022,1023,987,885,854

T,1022,1024,988,885,854

 

Then you can use the "Spreadsheet String to Array" vi by setting the delimiter to a comma and Generate your Dataarray for every measurement in one simple step.

========================
=== Engineer Ambiguously ===
========================
Message 3 of 4
(3,148 Views)

@RTSLVU wrote:

Also besides what Crossrulz said you might find it easier to send your data all at once instead of one at a time.


That advice sounds familiar...https://forums.ni.com/t5/LabVIEW/String-Comparison/m-p/3671469#M1031920


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 4 of 4
(3,140 Views)