LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read Losing Characters off the end of the output string

Solved!
Go to solution

Hi,

 

So I am writing a VI to take an output string of data from an ardunio Uno and parsing it. I am using the Read Visa vi to grab the string from output of the device. In the end I will be connecting a device that actually gives value in this type of string  format : (#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0*).

 

So after a large number of loops, the program starts to drop the last few characters of the string that it outputs. So the string output from Visa Read will read something like (#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,). The only way to fix this problem after it has occured is to completely close labview (all the way). Once I open it again and start running the program, all is fine in the world.

 

Anyone ever have this issue? I have been trying to debug this in different ways and the only weird symptom that I have other than the Visa Read function losing a few characters of the string is the fact that looking at the Bytes at Port after I Visa Read, is that it starts showing five bytes instead of zero. 

 

attached is my most recent attempt at solving this issue. 

 


Note:  The Ardunio outputs a string of this format every 2 seconds with the values being incrimental over a specified range.(#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0*) 

0 Kudos
Message 1 of 15
(5,061 Views)

Increase your number of bytes to read.  If you are using the termination character (usually a line feed), use that to stop the read.  You can set the bytes to read to something much larger just to make sure everything is being read.

 

My thought is that if your Arduino uses an extra character or two or five, then you will be missing data.


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
0 Kudos
Message 2 of 15
(5,048 Views)

I have tried that; 


When the error starts to occur I created a Variable Control for the Number of Bytes input. I expect 90bytes to be output, When the error starts to occur I  pushed that number up past 300 and the characters that are missing stay missing. 

 

 

 

0 Kudos
Message 3 of 15
(5,035 Views)

How do you have the serial port configured, especially the termination character? Does the Arduino always send the exact same number of characters or can some of the numeric values have fewer or more digits? Does the Arduino send the "(" and ")"  characters?  If so, matching "(#" and "*)" might be more reliable. Do you get a string with fewer numeric characters but the ) is present when the error occurs?  I do not see how your VI would ever show the ( and ) characters.  Why do you need to clear the buffers? The time delay should be unnecessary. VISA Read will wait for the termination character or byte count. There should probably be a VISA Close after the loop.

 

Lynn

0 Kudos
Message 4 of 15
(5,022 Views)

Serial is configured in Devices in windows - I don't see how clarifying it at the start would really help.

 

#80212164,2289,2292,2296,2300,2328,2289,2297,2290,2300,2308,2292,2295,2298,2289,22,24,0* is the exact format of the output string; The string values with vary but the string will always be that long (90 Bytes). 

   - There are no bracket characters, that was just my version of your quotes around an object.

 

Clear the Buffers - It helps with Buffer Buildup, when the program is not running and Labview is open it will build up all the values that are being streamed out of the Ardunio and when you start will start outputting those values before getting to the most recent output values. 

 

 

Time Delay - Helps with a TimeOut Error that the Read Visa has. 

 

0 Kudos
Message 5 of 15
(5,009 Views)
Serial is NOT configured in Windows device manager. Those settings are overridden by the settings in MAX which would be overridden by settings on your code. For clarity, always explicitly set the port in your code.

A flush should be done once and only once.

A delay is not necessary. Use a high byte count, a termination character that you specify in the code, and never use bytes at serial port.

Attach the code from the arduino, please.
0 Kudos
Message 6 of 15
(4,995 Views)

How do i Use the # and * as my start string and termination character?

0 Kudos
Message 7 of 15
(4,981 Views)
If your arduino code is appending a cr or lf, you set that with the VISA Configure Serial Port. You skip the start and end string characters that you have. They are just not required. After configuring and flushing the buffer, do a single read and discard the data. A read inside the loop is then synched.
0 Kudos
Message 8 of 15
(4,959 Views)
Solution
Accepted by topic author abirkel133

You could configure the * as your termination character if your Arduino is not sending out the Carriage Return or the Line Feed.  Use the Configure Serial Port to make sure all of your settings are correct.  You can also use that VI to increase your timeout so that you don't need your wait anymore.


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
0 Kudos
Message 9 of 15
(4,935 Views)

So i did a long data collect and It looks like ever 43minutes and 24 seconds the system goes from cutting off the last 5 characters to not cutting off the last 4 characters.

 

As I cant see how Labview would be causing that, I am going to try and dig into the Ardunio and solve that issue... hopefully when thats done I can simplfy my code like you guys pointed out.

 

Thanks!

 

 

Download All
0 Kudos
Message 10 of 15
(4,875 Views)