LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lost data in the first data in table communication serial arduino with labview

Solved!
Go to solution

hello everyone, i have some question for all. i want to make a communication with Arduino with visa. the data from the detection i want to display in LabVIEW in the numeric and table. but i have some problem in the table data in the first in always lost data. i check in serial monitor in Arduino the data is fine not loss. Why did it happen ? thanks in advance

 

mamprat_0-1649062090967.pngmamprat_1-1649062098233.png

 

Download All
0 Kudos
Message 1 of 7
(1,815 Views)

From your screenshots it seems to me you're not loosing the first data, but it seems additional data is added...

 

Don't use bytes at port, at least not like that!

 

You have a termination character set up, so simply read enough bytes (e.g. 200).

 

What probably happens is that Bytes at Port is smaller then the complete message first time, and you don't get a complete message. The 2nd iteration will return the rest of the message.

 

Also, wire left to right. Your code would be near perfect if you did.

0 Kudos
Message 2 of 7
(1,808 Views)

can you point out what to fix from my vi ? I still don't understand what changes to make. thank in advance

0 Kudos
Message 3 of 7
(1,800 Views)
Solution
Accepted by topic author mamprat

@mamprat wrote:

can you point out what to fix from my vi ? I still don't understand what changes to make. thank in advance


Delete the Bytes at Port.

 

Use a constant (e.g. 200) to the nr. of bytes to read in stead.

 

If your data is really \n terminated, that will work a lot better. As it is, the \n termination and bytes at port are to conflicting ways to get your data. The two methods won't play nice together.

wiebeCARYA_0-1649065663415.png

 

 

To debug, add the string output of read to the loop. Make it autoindexing. You'll get an array once you stop the loop. Examine this data. You might see where it goes wrong...

 

And move some code (horizontally) so the wires go from left to right.

0 Kudos
Message 4 of 7
(1,792 Views)

mamprat_0-1649065863899.png

do you mean make like this sir ?

I found that the first time the data entered the visa read data there was an error

0 Kudos
Message 5 of 7
(1,775 Views)

@mamprat wrote:

mamprat_0-1649065863899.png

do you mean make like this sir ?

I found that the first time the data entered the visa read data there was an error


Yes, that is an improvement.

 

If the Arduino is running when you start the VI, you might simply start reading halfway in a message. The first data you read is only the last part of a message. (You can test this. Start your VI, then the Arduino. See if the behavior changes.)

 

So, discard the first read. You can do so by doing 1 read before the loop, after the init.

0 Kudos
Message 6 of 7
(1,764 Views)

I'm starting to understand a bit about the point of the communication problem. I will try to analyze the point of the problem. Thank you for the help sir

Message 7 of 7
(1,751 Views)