I am reading a string from an arduino and I will develop an application to make data seems better to look.
1- I have some doubts how to reset the com port when the labview starts reading the com port that receives data from an arduino. I explain, in the past I was some experience that when the arduino stars working, starts sending data to the com port, but labview did not starts and I am not sure if the data stays waiting until labview "open" com port and data starts enter in order, so the data has a delay. I want to star reading the real data on time with arduino.
I now there is some configuration in the visa block to clear the buffer but I don't know how.
2- The string from arduino has a problem, the lenght is not the same between readings
RPMFreio: 0.00 S.R: 0.00 194 0.04 0.90 0.90 4
RPMFreio: 174.00 S.R: 363.56 0 0.48 10.74 20.94 10
If the values changes, the length changes, I was using the string subset, but the offset isn't the same. Only in the 2 first subsets I have letters and I could use the replace substring, but in others I only have 7 spaces between values....
Solved! Go to Solution.
1. Search for multiple instances of spaces and replace them with a single space. Then use spreadsheet string to array with a space as a delimiter. Now you will have an array of strings. The parts you care about should not be at known elements.
2. Fix the code on the arduino to be more consistent (such as commas between data elements) to make it easier on the LabVIEW side.
Thanks for the help.
Could be a solution.
About arduino code, I am not sure the correct version in my laptop.
This code and equipment was not developed by me.
No I would to get data into labview to build some graphs and saving some data.
Try Scan from String:
As for your first question, try calling "VISA Clear" or "VISA Flush I/O Buffer" at the start of your session. That should empty out all of the buffers. I seem to remember there can be some hardware differences that may make one or the other work for you but I think either would be fine.
Seems not working good when replace the input string (constant) for the input from arduino
I create a case and before starting, the case is true for enter a constant string, and after starting receive data from arduino i change for false and then works fine
It sounds to me like you are getting an incomplete string on your first read because the device is constantly sending data, so you are probably opening up the serial port in the middle of a message and getting an incomplete and of the message.
Do a VISA Read before the loop which will be just reading a message (complete or incomplete) and thus discarding it. Then in the loop, you'll be getting complete messages and you won't have to mess with a case structure.
You are reading 88 characters at a time, and your messages are not always 88 characters. You should be using a termination character to end your read, which will give you a full line's worth of data. https://www.ni.com/en-us/support/documentation/supplemental/06/termination-characters-in-ni-visa.htm...
I don't speak Arduino but I think a carriage return is added using the PrintLn() function.
A picture of your block diagram doesn't show us what data you are actually receiving and why it is causing an error when scanning from the string.
As Bert pointed out, are you sending data with a carriage return or line feed? Your VISA Configure is set up with a line feed as the termination character. So if you send your message so that it ends with the line feed, then what I told you should work.
Unless there are other problems with your data string that we don't see.