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?
Solved! Go to Solution.
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.
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
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.
Build up your two arrays first and then write to the file after the loop.
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.
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?