LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run a for loop on a boolean latch

Hi,

 

Fairly simple question, but I seem to be stuck, frustratingly. I am trying to build a 2 dimensional array of data points gathered from 2-9 dial gauges being measured on a click from the user. I have attempted this with an event structure, but it did not record anything when I did it that way. I have attached a version of what I want to do with a second for loop in place of what I want to be a loop that will run the inner contents once and then reset, while compiling the data into an array. I hope this makes sense. Here is my VI in case my stellar explanation skills are lacking.

 

datacollector.png

0 Kudos
Message 1 of 18
(4,080 Views)

What do you want to do when the boolean button is off?

 

Generally, you put code you want to selectively run in a Case Structure.

0 Kudos
Message 2 of 18
(4,069 Views)

Nothing. The VI will be used to record dial gauge values periodically during engineering testing, so the click should record a row of data from each gauge, added on top or bottom of the array of previously recorded data points. 

 

Also, the case structure won't let me use an indexing tunnel to make the output array 2 dimensional.

0 Kudos
Message 3 of 18
(4,066 Views)

Wrap All of your code that is inside the while loop in the case structure.  (Be sure to put a wait value in the False case where you do nothing so you don't burn up the CPU doing nothing.)

0 Kudos
Message 4 of 18
(4,059 Views)

I only want to write the array to an excel file after the user is finished collecting data, though. And if I have that inside the true case, it doesn't give the user enough time to hit the record button. 

0 Kudos
Message 5 of 18
(4,055 Views)

You are writing out the to file on every iteration of your While Loop as it is now.  How is what I am proposing any different?

 

You may need to explain more exactly what you are trying to do in your application.  Your current VI is very simple right now, and it seems like your actual application is a bit more involved and your simple VI doesn't reflect that.

 

What you've stated and shown so far is a VI that reads some values and then writes them to a file every iteration.  You have a button that if you press it, you want that to happen.  If you don't press it, then you want absolutely nothing to happen.

0 Kudos
Message 6 of 18
(4,049 Views)

You are writing out the to file on every iteration of your While Loop as it is now.  How is what I am proposing any different?

In fact, I am only writing the data to a file when the Record Data button is pressed, which enables the Write to Measurement File express VI.

 

You may need to explain more exactly what you are trying to do in your application.

All I am doing is reading N dial gauges when the Take Data button is pressed, and putting the resulting 2 dimensional array (Gauges x Logging instance) into an excel spreadsheet when the user is finished collecting data points. 

 

Your current VI is very simple right now, and it seems like your actual application is a bit more involved and your simple VI doesn't reflect that.

My VI is simple because the actual reading of the gauges is being done in the CDI Dial Gauge subvi, which I did not include because it functions correctly. 

 

My question does not depend on the application, so I did not find it necessary to explain all of that. What I need is a way to take the double output of the Scan from String VI, which is being indexed into a 1 dimensional array by the inner for loop and stack it based on the data collection iteration. I want the output to look like the excel sheet attached. 

0 Kudos
Message 7 of 18
(4,040 Views)

Additionally, when a case structure is used for the boolean trigger, the "false" case resets my array to zeroes again, making the concatenation of the new data impossible. 

0 Kudos
Message 8 of 18
(4,035 Views)

Everything you describe you want will happen if you follow what I say and am showing below.

 

I would make sure your Write to File is set to Append data to the file.

 

I don't understand why you have an outer For Loop set to run 2 times and are creating a 2-D array.  Your Excel Files shows you logging a row of data at different times which would be a single capture of all gage data written out as a 1-D array.

 

 

There is one other thing that might be able to help you (although the way you've described and programmed things, I can't tell) is to use a Conditional Auto-indexing tunnel.  (right click option on the tunnel).  You wire a boolean in and if the value is True, it will put the new data into the array.  If it is false then it will not put it in. 

0 Kudos
Message 9 of 18
(4,026 Views)

The outer for loop was a placeholder, since I could not figure out which structure was supposed to go in its place. I said that in my initial post.


 

"I have attached a version of what I want to do with a second for loop in place of what I want to be a loop that will run the inner contents once and then reset, while compiling the data into an array."


 

What you  gave me takes two measurements from the same dial gage at the same time and then leaves it there. I need there to be one measurement taken when the take data button is pressed, adding onto the top or the bottom (it doesn't matter which) every time the user presses it. Then, the resulting array will record to an excel spreadsheet after the user is done collecting data.

0 Kudos
Message 10 of 18
(4,018 Views)