LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

having problem in making iteration in grid.

Solved!
Go to solution

Hello, I want to make a grid in which when user clicks on the first element of each array a pattern evolves, as shown in the jpg attached. Till now i am able to draw take clicks from the user and change color. But when i try to do the iteration either my vi hangs or does not work out. The pattern which should evolve in real time should be for eg if i click on the first element of 7th array and make it red, then after that the 1st element of the 6 th array will become red, after that 2nd element of array 5 and so on. I have attached the snapshot to make it more clear. I know the algorithm  but the problem is I am very new to labview so I am not able to implement it. And I don't understand one thing, if I add one or more event structure in the same loop why my vi hangs.I am attaching my vi till point it is working perfectly. Thanks in advance.

Download All
0 Kudos
Message 1 of 18
(2,919 Views)

First of all, your are using way too much code for all this. Here's a quick implementation that modifies the visibility using an array of references (You are using a huge case structure with many cases, making the code very complicated and unmaintainable).

 

You should really change to arrays of picture rings or color boxes. (Using arrays of pictures seems a little bit weird). Once you do that, things will become much simpler and you can do all your "patternization" in a single additional event case. Try it.

Message 2 of 18
(2,896 Views)

Hey, I did all the changes you asked me to do. My program looks much simpler now, and I am using array of boxes. I wanted to know is their any property node through which I can get the index of the element on which the user clicked. I have already read this thread http://forums.ni.com/t5/LabVIEW/How-do-I-get-the-index-of-the-selected-array-element/td-p/474736  .I need to make some pattern so for that should I make 2 d array from these 1d arrays and make changes on that and than again convert it back to 2d arrays. But one problem in that would be I need to make it real time as if the pattern is evolving. Thanks for the help in making the code much simpler. I am attaching my new vi.

0 Kudos
Message 3 of 18
(2,864 Views)
Message 4 of 18
(2,844 Views)

Take a look at these two threads. I help two differnt peoplr achieve that same thing using two different methods. I suspect that this is homework.

 

http://forums.ni.com/t5/LabVIEW/Touch-screen-boolean-arra-with-changing-input/m-p/1619758#M585839

 

and

 

http://forums.ni.com/t5/LabVIEW/how-to-create-an-interactive-rectangular-grid-in-labview/m-p/1600750...

Tim
GHSP
0 Kudos
Message 5 of 18
(2,840 Views)

@altenbach wrote:

Maybe something like this?


The 2D array should be initialzed with 20 rows instead of 10, of course. Modify as needed.

0 Kudos
Message 6 of 18
(2,836 Views)

Hi, Tim the second link you have posted, It was me only who had questioned and you and altenbach had replied. And yes I did my home work before questioning. I just wanted to know is this way in which I am supposed to go forward. And Altenbach thanks for the help. I also made a 2d array that worked fine, in it I used build array and all the 1d array controls to build a 2d array. That looked more simpler. Thanks for the help guys.

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

Hi, I guess this would my last question regarding this topic. I am stuck on clearing the grid. If I make another event to clear grid, i need to fire the event having mouse up . But I couldn't find any way to do that. I also tried many other ways but the problem that occurs most of the time is that everything is grayed out after i press the clear button and if I try to use grid again it doesn't respond at all. It becomes black in color.

0 Kudos
Message 8 of 18
(2,775 Views)
Solution
Accepted by topic author GJAKLDFJG

@gj;AKLDFJG wrote:

 If I make another event to clear grid, i need to fire the event having mouse up .


What's wrong with "value changed" as you have now? Also make sure that the terminal is inside the event case so it correctly resets.

 


@gj;AKLDFJG wrote:

I also tried many other ways but the problem that occurs most of the time is that everything is grayed out after i press the clear button and if I try to use grid again it doesn't respond at all. It becomes black in color.


It is not sufficient to initialize the 2D array in the shift register, you also need to rewrite all the 1D arrays. You did not include the subVI, so I cannot run to see what you are seeing.

 

Why do you have these hidden stop buttons?

 

Remember that the "lock front panel" settings is per event, and not per event case. You only disabled it for "array 1", but not for the other arrays.

 

You also have race conditions due to overuse of local variables (Why do you write to (terminal or local var) and read from (local var) "output array"? Most likely, the read operation occurs before you write the new values to it, leading to unexpected results. Solution: delete the hidden controls and wire the 2D array (from the shift register) directly to the subVI input. There is no need for a front panel object. You can also delete the local variable "number of?": place the terminal inside the array case to replace the local and read the value from the "new value" event terminal in its event frame). You can change all the 1D arrays to indicators and eliminate the local variables, the mouse up will still work.

 

Your subVI has way too many connectors to be manageable. If you would feed it the array of references, it would not need any outputs at all (defer panel updates while writing the arrays). The outputs also have incorrect representation. They should NOT be orange!

 

Don't call the subVI with every iteration of the inner while loop, discarding the output values until the last iteration. Update the display once the loop has finished and after the case structure.

 

There should not be while loops inside event cases, unless they are not interactive and are guaranteed fo complete quickly.

 

Please attach the missing subVI.

Message 9 of 18
(2,771 Views)

Did whatever you said, vi works great now. Thanks for the help.

0 Kudos
Message 10 of 18
(2,736 Views)