LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a grid with arrays and booleans?

Solved!
Go to solution

As part of a bigger project, I'm trying to create a sub-VI which will allow me to move a "cursor" in a 3x3 array.

There should be 2 boolean inputs, one for moving down in the array, and the other for moving to the right. Once the edge of the array has been reached, the "cursor" will start back from the beginning.

I have a vague idea of a 2 dimensional array with LED's. Once "down" has been pressed, the LED corresponding to (0,0) will turn off, turning (0,1) on. Same goes for the "right" button. When "down" is pressed at (0,2), the LED should turn off, and LED (0,0) should turn on.

I'm sure it has something to do with initializing arrays, but i can't seem to find the right way to do it.

Any kind of assistance is much appreciated. Thanks!

0 Kudos
Message 1 of 9
(4,835 Views)

It might help if you posted what you have tried so far.

 

I would probably use a shift register for the row index and another for the column index.  Increment or decrement the index values when the buttons are pushed.  Use the Quotient and Remainder function (divide by 3) to limit the index values to the {0, 1, 2} set.

 

Lynn 

0 Kudos
Message 2 of 9
(4,790 Views)

 

Maybe this will help.

 

grid1.png

 

true case.png

 

Oh, I just noticed that I could have done the "Clear True" outside of the inner case structure and some other things too, but oh well - it works.

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Message 3 of 9
(4,753 Views)

Hmmm....

 

Guess this project hasn't been finished yet by the groups. 

0 Kudos
Message 4 of 9
(4,742 Views)

I believe that members should post their real work before any help is done since these members will only depend on others(solving a project while creating another and a major problem [not knowing LabView])

These members are my classmates which I respect although some have cursed me with 1337-speech ; they should atleast think before consulting others.

In this project ,there is alot of competition which this project will be included on the C.V. Resumee,if experts help some sophomore students who have not postedtheir work this will cause an inequality and a fierce and unbalanced competition.

Please report any of those cheaters so that some actions can be taken.Smiley Mad

Thanks

Message 5 of 9
(4,717 Views)

I would just like to say that I wasn't asking for a solution to my homework, however, I was only asking about boolean arrays (which is a very small part of my project).

The thing is that I have reached a point where I cannot find anything wrong in my VI, yet it doesn't work properly, and so I will post what i have done so far so that anyone willing to help may TELL ME what I am doing WRONG, and not solve the homework for me.

I have posted the VI below, and if anyone can try to run it, and see why the LED's don't turn off after an increment, so that i may know how to solve not only this assignment, but others to come.

I would also like to clarify the fact that I am NOT cheating, and I am in NO WAY plagiarizing anyone's work. This is my own design, and everyone can see that is very amateurish, but it was the best I could come up with. 

Thank you. 

0 Kudos
Message 6 of 9
(4,711 Views)
Solution
Accepted by topic author Alf Lira

Your array is always empty.  Look at the detailed help page for the Replace Array Subset function.  It states that the function has no effect if the specified index refers to a location outside the array.

 

What you see on the panel is only a display and has nothing to do with what is in the array.

 

Lynn 

Message 7 of 9
(4,705 Views)

I just read the help file and found an example on Arrays.

It's working now, but i still need to solve the flickering of the light.

Thanks anyway! Much appreciated. 

0 Kudos
Message 8 of 9
(4,693 Views)

You should put a short delay in the while loop to prevent it from hogging all the CPU resources.  You may also have a race condition with the local variables.  Use shift registers.

 

You also do not need the sequence structures. 

 

One or both of those may contribute to the flickering.

 

Lynn 

Message 9 of 9
(4,689 Views)