LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading/displaying from multiple sensors

Solved!
Go to solution

Hi GerdW


@GerdW wrote:

Hi sr,

 

you can "split" the string at each "\r\n" delimiter: use SpreadsheetStringToArray with a LF as delimiter.

Now you can convert each separated string element to numeric. When an error occurs while conversion you have a found a letter, use it to put the next numeric value in the right place!

Remove already converted string subsets from your concatenated string to avoid conversion of the very same values again and again…


Thanks GerdW for the response. That would be true if it was a single string comprising all the sensors readings with their respective alphabets. Actually, i am receiving one reading at one time. that is; A , then line feed then the floating point number; then line feed , then B , line feed , and a floating point number and so on. So what would be the solution in this case?

Thanks

0 Kudos
Message 11 of 25
(1,448 Views)

@crossrulz wrote:

@sr_murd wrote:

Why do you put a linefeed (LF, or CR, or both) between your values? Why not use a space or tab char and only ONE linefeed after the E value?

This is because the measurements are coming from another device in this manner.


Since you can change what is being sent over this serial port, you can remove those extra characters.  Personally, I would get rid of the A, B, C, etc.  Just have your values with a tab between them and end the message with a Line Feed (\n).  This will make things, by far, the simplest to handle.


The reason for having the alphabets is to differentiate the sensors readings at the receiving end, otherwise there is no way to tell which floating point number corresponds to which sensor and the order gets changed depending on the start of the labview program.

0 Kudos
Message 12 of 25
(1,446 Views)

Hi sr,

 

So what would be the solution in this case?

See message #9.

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 25
(1,440 Views)

@sr_murd wrote:

@crossrulz wrote:

@sr_murd wrote:

Why do you put a linefeed (LF, or CR, or both) between your values? Why not use a space or tab char and only ONE linefeed after the E value?

This is because the measurements are coming from another device in this manner.


Since you can change what is being sent over this serial port, you can remove those extra characters.  Personally, I would get rid of the A, B, C, etc.  Just have your values with a tab between them and end the message with a Line Feed (\n).  This will make things, by far, the simplest to handle.


The reason for having the alphabets is to differentiate the sensors readings at the receiving end, otherwise there is no way to tell which floating point number corresponds to which sensor and the order gets changed depending on the start of the labview program.


Again, not if you format your data correctly.  If you have just your values delimited by a tab and you have the line feeds removed, you get all of your data in a single read and it is fairly safe to assume from there the order of the data is constant.



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 14 of 25
(1,433 Views)

Hi GerdW

I am sorry to bother you again, but as you said using Spreadsheet stringto array , and using linefeed as delimiter, i could not get an output of that block in the array indicator. pls check the my read loop and suggest, thank you very much

Download All
0 Kudos
Message 15 of 25
(1,419 Views)

You keep forcing your code to have \r\n between every value and every set of values and are not following the advice you are given.  What instrument is sending the data?  It seems to be something you are able to control.

 

Put a tab between the individual values in the group.  Put a linefeed at the end of each group.  Then Write to Spreadsheet Array will work exactly like you need it to.

0 Kudos
Message 16 of 25
(1,428 Views)

@RavensFan wrote:

You keep forcing your code to have \r\n between every value and every set of values and are not following the advice you are given.  What instrument is sending the data?  It seems to be something you are able to control.

 

Put a tab between the individual values in the group.  Put a linefeed at the end of each group.  Then Write to Spreadsheet Array will work exactly like you need it to.


Sir,

these are Udp.write() messages sent from remote device (Arduino wireless device) and being displayed in serial port on local computer. they are being sent in this way as one by one sensor readings which have \r\n between them; (im trying to pack them and send them all in one string as you mentioned) ; but is there anyway to get these values segregated ?

0 Kudos
Message 17 of 25
(1,426 Views)

Rewrite the Arduino.  If the text language is like other text languages such as BASIC,  there is a Print and a PrintLN.  When you to a print to the serial port, it sends out that data,  if you do a PrintLN, it sends out the data and ends it with a linefeed.

 

So you could do a

Print (val A)

Print chr$(9)    '  tab character

Print (val B)

Print chr$(9)   ' tab

......

PrintLN (val E)

 

You put a tab between values and a linefeed at the end.  Don't put linefeeds between every value.

0 Kudos
Message 18 of 25
(1,416 Views)

@RavensFan wrote:

Rewrite the Arduino.  If the text language is like other text languages such as BASIC,  there is a Print and a PrintLN.  When you to a print to the serial port, it sends out that data,  if you do a PrintLN, it sends out the data and ends it with a linefeed.

 

So you could do a

Print (val A)

Print chr$(9)    '  tab character

Print (val B)

Print chr$(9)   ' tab

......

PrintLN (val E)

 

You put a tab between values and a linefeed at the end.  Don't put linefeeds between every value.


Thanks dear, im nearly there. i have concatenated on the sending side with tab delimted values and receiving as one string as attached in image of read buffer; trying to separate them, if you can please advise on that

Download All
0 Kudos
Message 19 of 25
(1,412 Views)

Hi sr,

 

oh boy: did you take the basic LabVIEW lessons? They are offered for free!

 

Why do you think you need an array constant for a five-dimensional array? You surely need a one-dimensional array holding 5 values/elements after string conversion…

 

Solution:

- set the array constant to just 1D!

- change the format string to "%f"!

- Delete the delimiter char constant: SpreadsheetStringToArray already uses the Tab by default!

(Reading the help for LabVIEW functions might be a good idea, don't you think?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 20 of 25
(1,404 Views)