From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array sizing

I need to create a loop somehow that waits till the array is a certain size then continues and processes the data after that.  Is there a way to do set this up, I have tried several methods including a timed sequence and looping but can't seem to get the correct data to result.  I am continually pulling data from a rs232 port and this is what is populating the array.
0 Kudos
Message 1 of 9
(3,160 Views)
Use the array size function in the Array palette.  When it is equal or greater than you value of interest, stop the while loop.
0 Kudos
Message 2 of 9
(3,156 Views)
I don't see how a timed sequence would do any good. You have the Array Size function. If you want to terminate a loop when the array is a certain size, it seems to me that this function would come in handy.Smiley Wink
0 Kudos
Message 3 of 9
(3,155 Views)

Is the target array size going to be a pre-determined constant or a variable controll?  Either way, use the Array Size function to return the size of your ever-growing array, then use the Greater? function to output a boolean true when the array size exceeds the value defined by your controll/constant. Connect this boolean output to the Stop If True of the loop (assuming you're using a While Loop to keep adding elements to the array).

 

Sorry i've not given you a block diagram, but i don't have LabVIEW on this computer. I hope you can still understand what i'm trying to say.

Message Edited by James Mamakos on 04-27-2009 12:38 PM


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 4 of 9
(3,152 Views)
OK I tried the above mentioned ideas and am still only getting the size out as 1 continuously even though elements are being added.  I am very new to labview and this is most likely why.  I am going to go ahead and attach the part of the VI I am having problems with, I do appreciate all the help, it is definately teaching me a lot about the labview software that I didn't know before.   I have multiple calculations afterword that I perform on this data coming in.  Once again thank you for the help!! 🙂
0 Kudos
Message 5 of 9
(3,110 Views)

HI cecb,

 

in your loop nothing gets added to the array... You simply check the array size again and again...

Maybe you should add some new data to the array in that loop???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(3,107 Views)

You aren't adding any elements to your array.  You are taking the last string value located in "Read Buffer" then converting that to a 2-D array a single time, nothing ever gets added.  Since we don't know what data is in that string, we can't determine what the 2-D array looks like.

 

Then you start a new loop where you index out row 0 and take the number of elements in that.  Apparently there is only 1 element since that is all you say you are getting.  Then you will continuously run that loop forever because there is no way for it to get to 1024 elements to stop the loop.   You are working on the same data array over and over again.

 

I am not sure you completely understand how data flows in a LabVIEW program.  I would recommend you learn more about LabVIEW from here. How to Learn LV

0 Kudos
Message 7 of 9
(3,104 Views)

You are going to want to build an array of the data you are reading in from the buffer.

The 'read' function assumes everything is of 'string' type, so convert as neccessary.

Then use an 'array size' to check how large the populated array is.

In my example, I chose to use 100 as the maximum array size.

Message Edited by Cory K on 04-28-2009 11:46 AM
Cory K
0 Kudos
Message 8 of 9
(3,091 Views)
Sorry I am still learning didn't realize my mistakes thanks for the help.
0 Kudos
Message 9 of 9
(3,083 Views)