LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building array in a case structure

I am trying to build an array in a case structure that's nested in a while loop to enable shift registers. The false condition of the case selector reads from a configuration file and makes 1. a displayed array of NAMES   2. a display array of DESCRIPTIONS   3. an array of min values  and 4. an array of max values.

These min and max values will be passed onto the next case and checked with the voltages the user inputs in set voltages. After the voltages are checked in range I would like an array to be made so that I can send it off to an NI Voltage Out DAQ.

 

The problem is on the indicator for the array of in range voltages, it appears flickering constantly once I click the OK button to check the values. I cannot find a way to move it out of the loops and get it to just give me a made array without constantly updating and flickering the values.

 

Please help!!!!

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

If you attach the text file as well, we'd be able to run your code to see it in action.

 

A few things I noticed:

  1. Your Check Voltages button is set for Switch when Pressed,  (when Released is more typical of windows button behaviors)  But that button could be true for multiple iterations of the while loop until you manually press the switch to return it to false.  Do you really need to read that configuration file multiple times?  Once should be enough.  That  button should look like the OK button and have the mechanical action Latch when Released so it is only true for one loop iteration.
  2. In your inner For Loop, you are opening and closing the configuration file 16 times.  Why not open it once before the For Loop, and close it after.  The code that actually reads the 16 different sets of values should be the only functions in the For Loop.
  3. You don't have any timing functions in the while loop.  It is running as fast as the computer will allow.  Do you really need to update the indicators infinitely fast with the same data?  This behavior is worse when you combine it with #1 since you are rereading the same config file super fast.  Loops without some sort of wait function when needed are called "CPU burners".  The flickering may be an artifact of that.
0 Kudos
Message 2 of 7
(2,896 Views)

Here is the text configuration file. I also attached an updated version. It seems when I make the array a shift register I can pull it all the way out of the while loop and it will display without the constant flickering updating from the loop. However, I am not sure if this will be a solution as a whole because I want to add more cases.  As a whole I am making a test setup that uses both the NI Voltage IN and Out DAQs. I am not sure whether I can break these down into different files but have them all on one VI. Any other ideas or suggestions for making a big test setup?

Download All
0 Kudos
Message 3 of 7
(2,890 Views)

First take care of the 3 things I told you about in my previous post.

 

I think the flicker is being caused because of the Transpose Arrays you have in there that are constantly taking it from a 1 x 16 array to a 16 x 1 array and back again every other iteration of the while loop.  That along with the array manipulation in the inner For Loop where you index on 1 dimension of the  2D array and then take that back to a 2D array.  When you auto-index on a 1 x 16 array and a 16 x 1 array in the same For Loop, you'll wind up with a 1 x 1 array.  In the next iteration when you change the one back to a 1 x 16, you now auto-index on two 1 x 16 arrays, you can now get a 1 x 16 array again.  You flicker between a full array and a nearly empty single element array.

 

When you move the indicator out of the loop, you don't see the "flicker", but it is still happening.  But depending on exactly when you hit the stop button, your final result will either be 1 x 16 or a 1 x 1 array in that indicator.

0 Kudos
Message 4 of 7
(2,878 Views)

I took a look the the probe at before and after the MAX array. It seems like data comes out of the for loop in the false case value as an array, but I am putting this array into a Build Array Block, thus making it 2d. I am going to try to keep everything one dimensional and see what that does.

0 Kudos
Message 5 of 7
(2,853 Views)

I also took away the for loop that does the In Range and Coerce checking. With this the array is not constantly looping and the1.PNG2.PNG3.PNG flickering stopped. 

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

That's good to hear.

 

You still need to fix two of the other issues I brought up like the missing wait function and the mechanical action of the button should be Latched when Released and not Switch when Pressed.

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