LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying string arrays

Solved!
Go to solution

Hello experts,

  I'm a labview newbie, but I haven't found anything that's quite like this in the knowledge base: Below is a simplified version of a data collection vi I built.

 

The vi in the screenshot uses a random number generator, but my real vi polls data from a magnetic susceptibility meter. The for loop iterates for however many times are needed for my test, which is dictated by the length of the sample I am measuring and the desired resolution, which is set before the test sequence begins. In the real vi, the for loop builds the array into a table (string format) in real time, so that the values can be seen in the front panel while it runs. The real vi converts decimals to string format in engineering notation, for the table to display. Now here's what I'm after:

 

If "apply" is selected, I want to be able to apply a linear correction to one of the columns in my table and spit out a new column. This has to be done after all of the measurements have already been made. The reason for this is that my sensor requires a "drift correction", wherein a blank measurement is made at the end of the sample, and all the values in between are adjusted linearly at each increment to make up for drift as the coil warms up during use. This is sort of like making sure a scale reads zero after something has been weighed, just to make sure the scale was working right, and then adjusting the measurement after the fact.

 

My question is, what would I put inside the case structure to accomplish this? In the simplified version depicted, I want to pass the array out of the shift register and into the next frame of my flat sequence. From there, I have already learned how to use the "index array" function to extract a column, and the "Replace array subset" function, to inject a new column into my old array (in the picture, I'll just be using a new table to show the modified data). I ran into trouble when I tried to apply mathematical functions to the elements, which are already in string format for the table. I tried using the "decimal string to number" function to bring the string data into numerical format so that I could say, multiply it by two. The problem there was that the function stops converting when it hits a decimal point, and all of my values are extremely small, between 0 and 1. Can anyone think of any way to take the string data and apply arithmetical operators to them, and then replace the subset of my original array with the new column?

 

Thank you for your insight!

0 Kudos
Message 1 of 5
(2,950 Views)
Solution
Accepted by topic author corelogger

Hello corelogger

 

If the problem lies in failure  of arthmetic operation  of a number with decimal point, then try converting the decimnal string to number and back .Its a kinda a lengthy way but if i have understoofd it correctly , if u split it then u can get the result-. See the snippet

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
Message 2 of 5
(2,916 Views)

You are initially dealing with numerics, right?  Why do you convert everything to string before doing the linear correction?  Keep everything numeric until you need to display it.  You don't even need a loop to do so.  Most functions in LabVIEW are polymorphic and are more than happy to handle arrays or any dimension.  For instance the Numer to Fractional String will do the job just before putting the results to the table.

 

Also, you need to learn about data flow.  Forget what you learned as a text based programmer.  You do not normally need to force sequencial steps by using those horrible sequence structures.  And learn to stay away from Local Variables.  They are FAR from what people think of when writing a text-based language.

 

To improve your program based on operator interaction, I would recommend a producer / consumer approach.  You can use the template from the File menu under > New > From Template > Frameworks > Design Patterns > Producer / Consumer Design Pattern (Events). 

 

Keep it simple.  Look at the example below.  I must caution that having the Apply button in the same loop as where the data is acquired is a bad approach as it may sample new data before you select the apply button.  Change the architecture.  You have to figure that one out 😉

 

 

Message 3 of 5
(2,894 Views)

Ray.R,

   Thanks for the reply! The reason I have it this way is because I need to be able to see the data in the table as it is populated. (the test sequence takes a long time, and the user comments on measurements while it is running.) This is also the reason I used the local variable, as this seems to be the only way to get data out of the for loop while it it running. My table needs to be outside of the for loop so that I can operate with it when my test loop is not in progress. Tables only accept string data, so I think this is what Im stuck with.

  The apply button can only be selected in my vi before the test sequence has begun. Also, The flat sequence here needs to be used to de-initialize my measurement drivers and then stop the testing while loop. Thanks for your input. I'm definitely studying it again.

0 Kudos
Message 4 of 5
(2,843 Views)

That was it, Nghtcrwlr.  Fract/decimal string to number was the function I was looking for. Thanks!

0 Kudos
Message 5 of 5
(2,841 Views)