LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

splitting serial data from multiple sensors recieved from arduino in Labview?

Hi, I have 3 sensors measuring, humidity,temperature,lightintensity and soli moisture that I need to represent in different Numeric Indicators on the front panel. I want to represent the measurements in a PI&D that I drwa on the front panel.

I have built a simple labview program that recieves the Serial data from Labview by using VISA Serial and VISA Read Blocks.My problem is that the data comes as a stream of numbers , somtehing like this:

Time_Temperature_Himidity_Moisture_Light intensity

1s           20                   20          4                3

2s           20                   20          4                3

.

.

.

.

. etc

I just dont know how to split this String into several strings and show them in separate Numeric Indicators so that I have overview of the measurements from each of the instruments?

I tried String Split/Search Block, but didnt manage to achieve it.

Need some tips here.

0 Kudos
Message 1 of 13
(6,440 Views)

Assuming you are using the PrintLn() command, you can just use the Spreadsheet String To Array to parse the string.  You can then use Index Array to get your individual measurements.


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 13
(6,426 Views)

I tried your tips but not getting there Smiley Sad

 

This is my code from arudino sketch that generates the serial data measurements:

Serial.println(String(hours) +" " + String(moistureValue) +
" " + String(pResistorValue) + " " + String(humidity) +
" " + String(temperature));

I have attached the blockdiagram and frontpanel.

I am not completely certain how this Spreadsheet String To Array works? I am getting only one value, the value showing elapsed time.The sensor value I am not able to see Smiley Frustrated

What is this delimiter tab and Array type. I dont know how I can change or expand the array size?

Download All
0 Kudos
Message 3 of 13
(6,390 Views)

The delimiter is the character that separates the values in your data string. The default is tab, but in your case it appears to be a space, so you need to wire a single space character to that input so Spreadsheet String to Array knows how to break your string apart.

0 Kudos
Message 4 of 13
(6,382 Views)

1. It looks like your delimiter (the character you use to separate your measurements) is a space.  So use the Space Constant and wire that up to the Delimiter input.

2. Since you are processing a single line, change that array type to a 1D array (shrink the array index to 1 item).


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 5 of 13
(6,377 Views)

I have tried as you suggested to add a space " " in the delimiter , but it hasnt changed anything.I am only getting one value after the Spreadsheet to Array function block and that is elapsed time. I dont know how to pull the others?

I need to get the front panel to something like the attached image of the frontpanel.

This is my goal.As you can see on the P%ID the indicated sensor values on the P%ID drawing are normal sensor values coming from arudino serial monitor and getting read in Labview.

Download All
0 Kudos
Message 6 of 13
(6,374 Views)

You need to attach your actual VI in order for us to help.  But my current thought is that you are not letting the termination character stop the read and you are therefore only getting part of the message.  But that is just a complete guess without seeing the code.


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 7 of 13
(6,354 Views)

I have managed to get the data from Serial measurements in Arduino in the individual indicators representing each sensor.Please view the attached JPG files. I have also added the VI file now.

What is bugging me now is that measurements are not updated continuously. It seems like I" lose" the measurement data , and the indicators show zero "0" even though the measurements are not suppose to change.

The Labview is not updating the measurement data every 0,5s as specified, but has a lag. 

I dont understand why Smiley Frustrated

 

0 Kudos
Message 8 of 13
(6,332 Views)

How often is your Arduino sending the data?  LabVIEW can only get the data at the rate it was sent.


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 13
(6,310 Views)

@crossrulz wrote:

How often is your Arduino sending the data?  LabVIEW can only get the data at the rate it was sent.


My arduino sketch sets the data to  Serial.begin(9600);, means 9600 bps for Serial communication between arduino and labview I guess.

0 Kudos
Message 10 of 13
(6,260 Views)