LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to numeric array ?

Solved!
Go to solution

Hi 🙂

 

what am I doing wrong converting a string to a double array?
It works to convert the incoming string to a string-array but not to convert it to a doublearray.

 

Any ideas?

Cheers, Anna

Download All
0 Kudos
Message 1 of 9
(3,694 Views)
Solution
Accepted by labviewis3

Hi Anna,

 

set the regional settings of your computer to use the point as decimal separator!

 

Or use proper formatstrings like "%.;%f"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,691 Views)

Hi GerdW,

 

I guess, changing the regional settings is not the correct way 😉

Your formatstring is working, although I do not understand it 100% right now.

I have to work into these formatstrings.

 

Thanks 🙂
Anna

0 Kudos
Message 3 of 9
(3,642 Views)

@labviewis3 wrote:
Your formatstring is working, although I do not understand it 100% right now.

I have to work into these format strings.


The problem was that your regional settings use the comma as the decimal point while the data you read uses the period.  The "%.;" part of the format string tells the parser to use the period as the decimal point regardless of the regional settings (default to using the local regional setting).  The "%f" is telling the parser to parse a floating point number.


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
Message 4 of 9
(3,631 Views)

Hi again 🙂

there are 2 things I don't understand aswell.

 

1)

 

I do have those voltage values in a numeric array, perfect. Now I plot them in a diagramm.

How do I prevent the voltage going down to zero every loop? I thought to use shift registers? I tried to implement those structures in my vi but didn't succeed. Is this the right way?

2)

 

I want all 24 voltages out of my array simultaneously being plotted into my diagramm.

Old values are supposed to time out... lets say after 30 sec or so, is that possible in labview?

Thank you very much for your help 🙂

 

Anna

0 Kudos
Message 5 of 9
(3,629 Views)

Time to take a step back.  Where is this data coming from?  What is the exact format of the data?  How do you know you got all of your data?  Does the message end with a special character (termination character) so that you know you got all the scanned data?


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
Message 6 of 9
(3,617 Views)

hi crossrulz,

 

the data is the output of a voltage measuring device. In my VI, I ask the device to give me the latest voltages. The output of  the device comes via serial port, for example:

 

0.3353,0.3362,0.3369,0.3353,0.3350,0.3351,0.3366,0.3366,0.3380,0.3359,0.3363,0.3359,0.0006,0.0001,0.0000,0.0002,0.0001,0.0000,0.0000,0.0000,0.0001,0.0002,0.0001,0.0000

 

To ensure, I got all the data, I implemented a Delay Before Read (mS) procedure.

I don't have a special termination character. I just read all bytes that arrived at the serial port.

 

thanks and regards

 

anna

0 Kudos
Message 7 of 9
(3,605 Views)

ok, I now used a cluster to plot. should do the job! 🙂

Download All
0 Kudos
Message 8 of 9
(3,592 Views)

labviewis3 wrote:

To ensure, I got all the data, I implemented a Delay Before Read (mS) procedure.

I don't have a special termination character. I just read all bytes that arrived at the serial port.


That is typically a BAD way to do it.  What if the instrument happens to be a little slow?  Hint: you will lose data.  What happens if the instrument fast?  You wait unnecessarily.  Every single instrument I have ran into that transmits data as human readable text ends the transmission with a termination character, typically a Carriage Return or a Line Feed.  So it would be much better to use that by enabling the Termination Character on the VISA Configure Serial Port and just telling the VISA Read to read more bytes than you expect in a message.

 

So what is the make and model of the device sending this data to you?  Do you have a link to the manual?


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 9
(3,566 Views)