11-17-2014 05:41 PM
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*)
Solved! Go to Solution.
11-17-2014 06:17 PM
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.
11-17-2014 07:13 PM
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.
11-17-2014 07:36 PM
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
11-17-2014 07:52 PM
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,229
- 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.
11-17-2014 08:13 PM
11-17-2014 08:38 PM
How do i Use the # and * as my start string and termination character?
11-17-2014 10:18 PM
11-18-2014 07:41 AM
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.
11-19-2014 09:29 PM
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!