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: 

case structure

Hello

 

I have a vi in which an array is initialized and in every iteration one row is added to it. At the same time a subarray is taken from this "growing" array.

It works fine.

 

I need to put a case structure in the while loop and the process I explained will happen in case nr. 3.

 

I have problem with initialization of the array. I guess there should be some extra connections to transfer initalized array to case nr 3.

 

The vi with and without case structure is attached.

 

Any suggestions?

 

Thanks

0 Kudos
Message 1 of 7
(2,607 Views)

Aside from the fact that you have a classic race condition with your abuse and misuse of local variables, using Insert Into Array is 99% of the time the wrong function to use. I don't understand what you are trying to do. Please describe more clearly what the objective is.

 

Also, your sequence structure is completely unnecessary. Remove it, and the code still runs as is. Broken as it is.

0 Kudos
Message 2 of 7
(2,599 Views)

 

 

 

 

0 Kudos
Message 3 of 7
(2,587 Views)

You still have a race condition with the terminal and the local variable of row number.  You have no control over which is read from or written to first.

Message 4 of 7
(2,582 Views)

Mittani HD wrote:

 

 


You are still making serious mistakes. It has been pointed out that "insert into array" is the wrong tool here, yet you still keep it.

As has been mentioned, you are still creating race conditions due to the abuse of local variables. The wire is right there, so why do you need to read the value from local variables?? (Most likely the local variables are read way before their indicator receives the updated value!). Your sequence structure serves no purpose. Why is is there? Why do you have two diagram constants with the value 20? One is enough! If you ever want to use a different value, you would need to make identical changes in multiple places. This can cause problems if you forget one.

 

  • You talk about images, yet you seem to be dealing with 1D array with each acquisition. Can you explain?
  • Your 2D array grows forever and you will run out of memory at one point. Guaranteed!
  • Initialize with an empty 2D array, not some weird array with zero in one dimension and 320 in the other.
  • Use the correct representation. For example "number of row from subarray" should be I32.

 

Attached is a very quick draft correcting some of your mistakes without changing functionality. I would recommend to rethink the entire algorithm and code architecture and start from scratch.

 

Please explain in more detail what the program actually should do and how long it should run. Are you ever making any use of the evergrowing 2D array? If you are only interested in the subset, you should think about an in-place solution.

Message 5 of 7
(2,555 Views)

I have to use "insert into array", because I have to show change in real time.

 

Each column in the picture below is coming from the row which is inserted into array.

The subarray is sent to IMAQ to create picture.

 

mass flow.JPG

 

I agree about the mismatch of the array sizes and I will fix the memory issue.

After spending a lot of time, I decided to keep the flat sequence.

 

Thanks

 

0 Kudos
Message 6 of 7
(2,515 Views)

@Mittani HD wrote:

I have to use "insert into array", because I have to show change in real time.


This makes absolutely no sense, regardless of programming language. I can't even think what rationale there might be for coupling "real time" with using Insert Into Array. It's like you blew up the universe and then put it back together in an absolutely random fashion.

 


After spending a lot of time, I decided to keep the flat sequence.

Clearly in this universe of yours you equate completely unnecessary steps or programming constructs with reasons for existence.

Message 7 of 7
(2,504 Views)