09-05-2013 04:32 AM - edited 09-05-2013 04:35 AM
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 :
Solved! Go to Solution.
09-05-2013 04:54 AM
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
09-05-2013 05:36 AM
09-05-2013 06:21 AM
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?
09-05-2013 07:06 AM
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
09-05-2013 08:42 AM
@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.
09-05-2013 08:43 AM
@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?
09-05-2013 08:46 AM
Then you will get the string overwritten with an empty string.
But 10 seconds is a long time away, and it is a delay.
09-05-2013 08:50 AM
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.
09-05-2013 08:57 AM
@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.