LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert string into number and put the data in different array

Solved!
Go to solution

Hello,

 

I am a beginner of labview. The function I want to realize is very simple:

Reading data from serial port, if the first bit is 1, remove the first bit, put the data in array 1.

                                                if the first bit is not 1, remove the first bit, put the data in array 2.

 

However, when I run the VI, what happens is: if the first bit is 1, remove the first bit, put the data in array 1, put zero in array 2

                                                              if the first bit is not 1, remove the first bit, put the data in array 2, put zero in array 1.

And the data is like this. I think the problem is caused by the unwired tunnel in case structure, but I don't know how to solve it.

Could anyone give me some suggestions?

result.PNG

 

0 Kudos
Message 1 of 8
(2,894 Views)

In your VI, you aren't putting any data into arrays.  You are just writing numbers to the measurmenet file.

 

If you want to create arrays, then start off with two empty arrays going into shift registers, then build the data into one array or the other wihtin a case structure.

 

But since you are just writing to the measurement file, and it looks like it alternates between the two types of data, just read the serial port twice in the loop.  Figure out which piece of data is which, then merge them into the single signal file and write to the measurement file.

0 Kudos
Message 2 of 8
(2,884 Views)

Hi Ravens,

 

Actually I don't need to creat arrays, I just want to write two types of data to the measurement file, but the case structure always put 0 in the data

0 Kudos
Message 3 of 8
(2,869 Views)

Is there any methods to remove those 0?

0 Kudos
Message 4 of 8
(2,866 Views)

Don't put the zeroes in.  That is why I said to take both VISA reads in one iteration, then combine the two in that same iteration.  You'll read X.  You'll read Y.  Convert to numbers.  Combine them.  Write them out.

0 Kudos
Message 5 of 8
(2,857 Views)
Solution
Accepted by topic author Big_man

Build up your two arrays first and then write to the file after the loop.

 

UWB_PLV.png

 

You can replace the FOR structure with a WHILE and perform your VISA reads in each iteration. If you want to append to the arrays only at a specific time window per your example, you can perform an AND on the conditional Booleans at the output tunnels.

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
Message 6 of 8
(2,826 Views)

Hi pangvady,

 

Thank you very much! I can understand your code, but how could you use boolean to control the array? My labview version is 12.0, do I have this function?Capture.PNG

0 Kudos
Message 7 of 8
(2,815 Views)

I find the solution, just change tunnel mode to conditional. I will try this method!

0 Kudos
Message 8 of 8
(2,812 Views)