LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extract numbers

Hello..

I'm using serial port to interface between my hardware and my PC...According to the hyper terminal or ASCII, all the values will be shown like this:

V = 0.00                                            Then, I convert this value into labview using Instrument I/O Assistant.And it's done with string format.Next,
V = 23.96                                           I try to program it with try to convert this string into number using Fract/Exp String To Number and extract all the
V = 47.68                                           numbers.But when I'll try to run the prog, nothing happen.It seems like it can't read n match with the data from the string.
                                                         Here I attach the 
vi. file and image below.Maybe the error occurs in my program.So, I hope u guys will fix
V = 70.92                                             it and tell me where I'm wrong. Thank u very much....Smiley Happy
V = 93.46                                           
V = 115.06         
V = 135.51         
V = 154.61         
V = 172.17         
V = 188.00         
V = 201.95         
V = 213.89         
V = 223.69         
V = 231.25         
V = 236.51         
V = 239.40         
V = 239.90         
V = 238.00         
V = 233.72         
V = 227.11         
V = 218.23         
V = 207.17         
V = 194.04         
V = 178.97         
V = 16   
V = 143.63         
V = 123.72         
V = 102.57         
V = 80.40        
V = 57.42        
V = 33.87        
V = 9.98       
V = -14.01         
V = -37.86         
V = -61.33         
V = -84.19         
V = -106.20          
V = -127.16          
V = -146.85          
V = -165.06          
V = -181.63          
V = -196.39          
V = -209.18          
V = -219.88          
V = -228.38          
V = -234.61          
V = -238.49          
V = -239.98          
V = -239.08          
V = -235.79          
V = -230.14          
V = -222.20          
V = -212.03          
V = -199.74          
V = -185.46          
V = -169.33          
V = -151.50          
V = -132.17          
V = -111.51          
V = -89.73         
V = -67.06         
V = -43.72         
V = -19.94         
V = 0.00       


Download All
0 Kudos
Message 1 of 29
(5,074 Views)
Hi takimi,

what about using "Scan from string" with format string "V = %f" in the loop? See attachment!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 29
(5,063 Views)
Hi GerdW...

Thank u very much for ur reply...U give me a very simplify prog...thank u again.....but I have 1 another prob. after i followed ur instruction to modify the prog using scan from string fuction.1stly, the value from string can be convert into numeric number or array...n then i'll try to link it with graph indicator..after I run the prog...It seems like a little bit confuse..The graph have shown  refer the all data values from string.but it is not run continuosly...refer to the image sine wave3.PNG below...for example...I take 3 values from string something like that :

V = 239.90         
V = 238.00         
V = 233.72

when the prog is running...suddenly the value from graph will be shown :

V = 239.90
V = 0        
V = 238.00         
V = 0
V = 233.72
V = 0             So, it means every each data will plot in the graph, n it return to zero after plot it. n it's continuing with the next data and turn to zero after that.and it repeat again n again...For the real result..I think, it will plot continously with the other values and not remain to the zero n plot it again...So, do u have any idea about this...coz..I have tried many ways..but nothing changes happen..thank U...Smiley Happy

Download All
0 Kudos
Message 3 of 29
(5,026 Views)
What is very unclear is exactly what the Instrument I/O Assistant is returning. Is it a single string like V=1.2 or do you actually get multiple results. If you could run the VI once so that there is data in the voltage indicator. Then go to Edit>Make Current Values Default and save the VI. Post that. What you are doing with the while loop and using a graph doesn't make much sense if you are getting a single result from the I/O Assistant.
Message 4 of 29
(5,011 Views)
Can you place an indicator on your string as it exits the IO assistant and then run your loop once to get valid data into the indicator. (Right-click on the wire and "create indicator".
 
Now delete the instrument assistant and right-click on the string indicator and select "change to constant". Save and attach the modified VI.
 
Now we have some real data to play with! 🙂
0 Kudos
Message 5 of 29
(4,985 Views)
I think your problem MAY be that you are looking for new data before it is available.  So, you get a blank or partial string whch doesn't scan correctly.  When you get an error, you still take the value (which would be 0) and add it to your array and plot.  When you get an error on your scan from string, you need to drop that data point.

Something along the lines of the attached VI.
0 Kudos
Message 6 of 29
(4,984 Views)
Hii Matthew...

Thank U very much for ur help.After I follow ur example...the graph have shown like it should be.Thank u very much...Thank u guys!!!Smiley Happy
0 Kudos
Message 7 of 29
(4,937 Views)
Hello...

Hi everyone.1stly, I almost forgot one thing..
How to create a start button instead of clicking on Run? right now I have all my VIs within a for loop and when clicked on the Run button it operates well but I want to create a start button in my front panel so that I don't have to click on Run everytime, is there a way I can do this? All I know is we should build a case structure  and put the start button at the case selector..So...in my vi above, I'm only using while loop to function it...Is there any other way...Thank U...Smiley Happy
0 Kudos
Message 8 of 29
(4,934 Views)
Putting a "Start" button on your main VI doesn't buy you anything as you'd still have to hit "Run" to get the VI going.

Set the "Run when opened" option under VI Properties:



When your main VI is opened, it will start without hitting "Run"

Message Edited by Bill@NGC on 09-15-2007 10:49 PM

0 Kudos
Message 9 of 29
(4,932 Views)
Hello Bill...
 
Thanks 4 ur reply....1stly, I can't catch ur words...U said that
it will start without hitting "Run"...But all i want to do is to start manually using push button...I mean when I click the run button...it didn't run 1st, but then...until we hit the push button ...so, the prog will be running...that's what I mean...thank U..Smiley Happy
0 Kudos
Message 10 of 29
(4,922 Views)