LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert string to number

Solved!
Go to solution

Hi everyone , I'm new to labview and I want to show a number ( temp. ) on a diagram. I receive data from COM port as string.. how to convert this to number in order to use it in diagram or for comparison reasons.. Could you help ??

 

this is my block diagram : 

 

srial1.jpg

0 Kudos
Message 1 of 35
(4,959 Views)

Hi Eric,

 

I hope this can help you. You can delete the number to boolean array part if you don't need it, of course.

 

Kevin

Message 2 of 35
(4,942 Views)
Solution
Accepted by topic author eric_s88

Fract/Exp String To Number Function

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 35
(4,929 Views)

It really depends on what the format of the data from the serial port is.

 

Is it ASCII data?  Then just use the Fract/Exp String to Number (for floats) or Decimal String to Number (for integers).

Is is raw binary data?  Then we need to know a few more details on the format.  Little Endian?  Big Endian?  Convertion factor?


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 35
(4,922 Views)

Your question and your image doesn't mateches..If you are reading inside while loop with no delay, you will never get any data i.e. after it receives it will be overwriten with next empty string.. Use  string to number conversion in string paltte

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Message 5 of 35
(4,913 Views)

@Ranjeet_Singh wrote:

If you are reading inside while loop with no delay, you will never get any data i.e. after it receives it will be overwriten with next empty string.



Not true at all.  You won't get an empty string unless the VISA Read timeout passes without any new data coming in.  The timeout on the VISA is set for 10 seconds, so the loop will not iterate that fast.  It will only iterate as fast as it takes for 4 bytes to arrive.

0 Kudos
Message 6 of 35
(4,893 Views)

@RavensFan wrote:

@Ranjeet_Singh wrote:

If you are reading inside while loop with no delay, you will never get any data i.e. after it receives it will be overwriten with next empty string.



Not true at all.  You won't get an empty string unless the VISA Read timeout passes without any new data coming in.  The timeout on the VISA is set for 10 seconds, so the loop will not iterate that fast.  It will only iterate as fast as it takes for 4 bytes to arrive.

What will happen after 10 sec if no data arrived?

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 35
(4,889 Views)

Then you will get the string overwritten with an empty string.

 

But 10 seconds is a long time away, and it is a delay.

0 Kudos
Message 8 of 35
(4,887 Views)

Its not delay if you are using inside while loop. Inside while loop if you see next read operation will start immediately after 10sec. This is little hazard. Little delay is always recommend. Delay between two consecutive VISA read.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 9 of 35
(4,881 Views)

@Ranjeet_Singh wrote:

Its not delay if you are using inside while loop. Inside while loop if you see next read operation will start immediately after 10sec. This is little hazard. Little delay is always recommend. Delay between two consecutive VISA read.



It is NOT necessary to add an additional delay in this while loop.  The VISA Read will pace itself.  You will have 10 seconds between VISA reads if no data comes in.  You'll have some unknown amount of time between VISA reads if data is comiing in.  That delay will be a function of how frequently the other device is sending data.

0 Kudos
Message 10 of 35
(4,875 Views)