LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Number conversion problem

Solved!
Go to solution

I have a VI that pulls in data from a device using VISA, and I had it working on another computer a few weeks back. I had to transfer the VI to a laptop in order to perform some testing, and now I can't get it to work. I am unable to post my VI because the laptop it's on is unable to access the companies network, I will do my best to explain everything, I apologize for the annoyance! My problem is not with VISA however, it is with a string to number conversion from VISA's output.

 

I have attached a paint drawing of the VI to better explain it.

 

I use the Visa serial block, match baud rate and all that good stuff to that of the device and the device managers serial port settings. Then, a while loop is entered. The loop will run until the "stop" button is pressed. The next visa block is the write block, it request one reading from the device. The next visa block is the first read block, it returns the reading in the form "NA-XXX.X" where the X's are numbers. The next visa block is the second read block, this block just echoes back the command sent to the device. The reading from the first visa read block, "NA-XXX.X" goes to a fractional/exponential string to numeric converter.

 

When doing a highlight execution/debug run, the visa output reports the correct value, the value the device is reading - however the string to number converter outputs a 0.000, regardless of what the string number is. I'm at a loss as to what may be wrong because this is the EXACT set up that I had working just fine a few weeks ago!

 

I'm using Labview 10 on the laptop, the old computer had labview 7. I'm guessing this may be where the problem lies... I remade the VI from scratch though, I did not open the old VI in labview 10.

 

Any help would be appreciated. Again, sorry I am unable to attach the VI.

0 Kudos
Message 1 of 13
(3,804 Views)

If you are using the standard LV num to string conversion, it cannot handle leading characters in the string.  You need to strip them off using a split string, string subset, match pattern, etc. so the result has the "NA-" removed from the repsonse.

0 Kudos
Message 2 of 13
(3,776 Views)

Thanks I'll try that...

 

Any idea why it worked that way before?

0 Kudos
Message 3 of 13
(3,774 Views)

None.  I tried to look in LV2010 tro see if it was more forgiving, but it also cannot handle the leading characters, so I have no idea how you got it to work.

0 Kudos
Message 4 of 13
(3,771 Views)
Solution
Accepted by topic author DARB

 


DARB wrote: 

I have attached a paint drawing of the VI to better explain it.


Would it not have been easier to just post a screenshot? Smiley Surprised You could also have used the Code Capture Tool.(Which reminds me that I need to install it for my earlier LabVIEW versions, as evidenced by the screenshot I took. Smiley Very Happy)

 

As for the question: you probably either:

  • used Scan From String originally and when you rewrote the VI you used the regular string to conversion functions. 
  • wired an offset value into the string to number function.

Message 5 of 13
(3,758 Views)

awesome thanks guys.

0 Kudos
Message 6 of 13
(3,754 Views)

oh also, I cant connect that computer to anything, thats why I didnt post a SS or VI...

 

Now for some reason the return value is switching between the two VISA read blocks... ugh...

0 Kudos
Message 7 of 13
(3,740 Views)

I love that Paint VI - it should be a graphical style option in LV! 😄

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 13
(3,711 Views)

I can't get Paint VI to work...

National Instruments - Tech Support
0 Kudos
Message 9 of 13
(3,684 Views)

^^^^ Me either, I guess labview isnt jpeg friendly...

 

The VI works just fine in the debug mode, but wont run otherwise, not sure why.

 

I stopped caring, I'm just doing an analog output now, and trying to use DAQ assist instead.

0 Kudos
Message 10 of 13
(3,670 Views)