04-04-2022 03:51 AM
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
Solved! Go to Solution.
04-04-2022 04:17 AM
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.
04-04-2022 04:31 AM
can you point out what to fix from my vi ? I still don't understand what changes to make. thank in advance
04-04-2022 04:43 AM - edited 04-04-2022 04:47 AM
@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.
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.
04-04-2022 04:52 AM
do you mean make like this sir ?
I found that the first time the data entered the visa read data there was an error
04-04-2022 04:57 AM - edited 04-04-2022 04:59 AM
@mamprat wrote:
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.
04-04-2022 05:02 AM
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