LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean Array Scanning

Solved!
Go to solution

I am trying to create a scanning GUI that scans through an array of buttons (Rows) and then when an Arduino switch is pressed, the button in the array (row) that is highlighted is recorded. After the row is selected, the same thing happens to the Columns Array.

I am having trouble reading the Arduino values at the same time as the buttons highlight.

 

CLD Certified 2014
0 Kudos
Message 1 of 20
(3,927 Views)

Is that DrexelDragon as in Drexel in Philly? So how is Drexel these days? Wonder if Moshe Kam is still teaching there.

 

As to your query: I haven't a clue what you're trying to do. I don't see any connection between the "pin" that you're reading and the array of LEDs. Why did you set up 2 loops? If you're just trying to update a Boolean array you should use a shift register in your single loop and simply perform a Replace Array Subset to update the array.

0 Kudos
Message 2 of 20
(3,923 Views)

Yes Drexel University. Moshe Kam is still here. Haha.

 

The value is 0 while the button is open. When I press the button, the value goes to 1. I was trying to stop the boolean array during its incrementing cycle, then record that index.

 

Overall, I am trying to pick a certain row and certain column when I press the button. The idea was to cycle through a boolean array until the row that I want is lit, I press the button and that stays lit. Then I move on to select a column in the same process.

 

I hope this is clearer.

CLD Certified 2014
0 Kudos
Message 3 of 20
(3,916 Views)

Your "Value" value change event will not fire. It will only fire if it is a control and a user changed the value. It will not work if you update the value of an indicator with a wire like that. What you can do is create a Value(Signaling) property node and write to that. But it is preferable to use a user event or send the data to another loop via a queue. But for a simple application the Value(Signaling) property method is probably ok.

 

(Right click on the indicator and select Create/Property Node/Value(Signaling)

=====================
LabVIEW 2012


0 Kudos
Message 4 of 20
(3,914 Views)

I tried to queue the data over but I get an error in the dequeue element in the Row selecting loop.

CLD Certified 2014
0 Kudos
Message 5 of 20
(3,907 Views)

The error is because a value other than zero causes the bottom loop to stop. Then the queue is released when that loop exits. When that happens the reference to the queue in the top loop becomes invalid throwing an error.

 

Do something similar to this to make sure the queue is only released after everyone is done with it.

 

Example_VI_BD.png

=====================
LabVIEW 2012


0 Kudos
Message 6 of 20
(3,899 Views)

Still no luck with sending the data. I replaced the value with a control so that I can troubleshoot w/out setting up the Arduino.

CLD Certified 2014
0 Kudos
Message 7 of 20
(3,890 Views)

As soon as you enqueue any number greater than zero the top loop will stop. Are you sure you don't want not equal to zero?

 

In any case that is a bad way to stop the loop unless you know there is one value that will never be part of your data. Some "sentinal" value.

 

I wrote a micronugget on stopping multi-loop applications. In your application you could just create a local variable from the stop button and read that in your upper loop. It means you have to change the mechanical action to switching.

=====================
LabVIEW 2012


0 Kudos
Message 8 of 20
(3,879 Views)

The Arduino will either read a 0 (off) or 1 (on) and is a push button so that it is always off unless pressed.

As long as the value is 0, the loop should keep cycling through the row array.

CLD Certified 2014
0 Kudos
Message 9 of 20
(3,871 Views)

A few things:

  • As it is, pressing the Stop button will only stop the bottom loop. The top loop could keep spinning since it only stops when it pulls out a value of 1 from the queue, and this value may never get added. E.g., you run the VI, but don't press the button on the Arduino, and then try to press the Stop button. A simple method it to enqueue a 1 to tell the upper loop to stop.
  • You do not want to enqueue all the time in the bottom loop. All you're doing is filling up the queue with 0. Since the upper loop has a 1 second timer, you're going to get a whole lot of zeros in the queue since the bottom loop spins so much faster. Thus, enqueue only when you see a 1. Consequently, you will need to wire a timeout value to the dequeue function so that it doesn't sit there forever waiting for a queue value. A small value of, say, 10 msec is more than adequate.
  • Instead of placing a numeric constant and then using a conversion function to change its datatype to U8, set the datatype of the constant to begin with.
  • There is a much simpler way to cycle through the array index in terms of moving the True. Hint: modulo function, or in LabVIEW speak, Quotient and Remainder.
0 Kudos
Message 10 of 20
(3,860 Views)