04-06-2019 06:47 PM
Hi,
I am a beginner in labview. I want to split the values stored inside a string and display each value on an indicator. The values are acquired from an arduino through serial communication created into a string.
Note: i have tried using the scan string function but it didn't work so i don't know if i am using it in a wrong way or if there's another function i should use.
Thanks.
Solved! Go to Solution.
04-06-2019 07:18 PM
First I would pull the VISA Configure serial port vi outside the loop. No need to keep configuring the port over and over. Secondly we have no idea what your string looks like so I couldn't help with that. Third you said you tried but you are not showing that attempt. Finally you are concatenating your array with a feedback node but you say you want it separated?
04-06-2019 08:35 PM
Sorry i am new to labview i don't know if the feedback node is causing a problem. i used the feedback node with the concatenation function because i saw this method done in the examples and i have tried displaying the string directly without them but the indicator shows nothing. i am trying to send the numbers 26 and 19 (just as an example) through serial communication with arduino. The second picture attached is simulation without using the scan string function.
04-06-2019 10:04 PM
Several comments:
This is a Snippet, which I'll attach as a PNG and as the underlying LabVIEW (saved with LabVIEW 2016, so you should be able to open it with LabVIEW 2016, 2017, or 2018). You'll need to set the VISA Resource Name control to match your VI (so it will read from your Arduino) then run the VI. The VISA Configure Serial Port using the same default Baud Rate (9600) as yours and also uses the default Enable Termination Character (T). Note the VISA Read command that says "Read 1024 characters". Because we enabled <LF> as a Termination Character, we will read a string from the Arduino until it sends a New Line (probably 10-20 characters). When you run this, let us know the string that Arduino returns, and how you want to parse it (is it a single number, several numbers, or what, and what variables do you want to assign to them?).
Bob Schor
04-06-2019 11:43 PM
My purpose is to display values received from multiple sensors (most likely 3) ,stored in arduino, and display the value of each sensor on an indicator (indicator for temperature, indicator for humidity,.....). The arduino sends the data as an array (as i understand labview reads data as a string) through serial communication by a usb cable. I want to separate the values of each sensor from the array (each value will not exceed 1 byte in length) and to display each value (some have several numbers) separately, also it doesn't matter to me if the values are stored in new variables or displayed on indicators directly .
This is the result i got by trying to run your VI:
I have made some modifications to my VI. I removed the feedback node and concatenation functions and the VI ran without them successfully (most likely i had a problem with the usb cable) but there was a bit of a delay in displaying the data. I tried using the scan string function to separate the values but it gave me an error.
This is a snippet of my diagram:
And this is the error i got:
I also attached my VI.
Thanks for the help.
04-07-2019 03:21 AM
Your read buffer starts with some unprintable byte (which displays as a space before 2619). You need to better understand the format your device is sending.
Note: if you right-click on your string indicator, you can change its display format to show unprintable bytes as hex codes, so you can better see what you are reading.
04-07-2019 03:15 PM
@drjdpowell wrote:
Your read buffer starts with some unprintable byte (which displays as a space before 2619). You need to better understand the format your device is sending.
Note: if you right-click on your string indicator, you can change its display format to show unprintable bytes as hex codes, so you can better see what you are reading.
I displayed the output as hexadecimal numbers and this is the result i got:
Sometimes the reading appears with the extra byte and sometimes not. I have no clue why it appears like that. Also, the reading appears for a short time and disappears.
Note: my main problem is separating the values (26 and 19 in this case).
04-07-2019 04:48 PM
If random, odd unprintable characters are showing up, then something is wrong with your Arduino code. The problem starts there.
If you want the 26 and 19 to be separated, why is your Arduino sending them jammed together? They should be separated with some other character. A common choice is a comma.
04-07-2019 05:36 PM
@RavensFan wrote:
If random, odd unprintable characters are showing up, then something is wrong with your Arduino code. The problem starts there.
If you want the 26 and 19 to be separated, why is your Arduino sending them jammed together? They should be separated with some other character. A common choice is a comma.
I modified the arduino code and put the variables inside the loop and this seems to have solved the problem of the odd byte at the beginning. Putting a coma is a good solution for separation in the code but how do i separate them inside labview if i use a special character like a comma?
Note: i attached the arduino code i'm using.
04-07-2019 09:49 PM
Spreadsheet String to Array.
Or
Scan from String with a format string of %d,%d