11-19-2013 12:45 PM
Hello NI community.
I am having an issue with a system I am trying to develop. I have gotten it 95% but just cant push it over the finish line. The end goal is to output 5 measurements into an excel spreadsheet directly from lab view at the press of an external switch. Then repeat the process for ever time the switch is closed.
The issue is that I am unable to input data into an aray below the previous line (switch closure). I am trying to use shift registers right now, but cant seem to get only one value in the aray once the switch is pressed.
Thank you in advance for your help,
Andrew
11-19-2013 12:50 PM - edited 11-19-2013 04:16 PM
I assume you are talking about the small while loop in the upper right corner. Since it only iterates once and the shift register gets initialized with every execution of the FOR loop, the shift register makes no difference. Maybe you should place the shift register in the outer loop instead.
Instead of writing to excel, I would write to a plain tab delimited text file. If you just want to append the new data, you don't need a shift register at all, because the history is already in the file.
(... And please don't use creative colors on the diagram. The grey background makes boolean wired hard to see.)
You might also consider simplifying the code. You could use an array of tanks, for example. Having the extra indicator for each tank is also no needed. Simply right-click the tank and select "visible items..digital display". Move the digital display to the desired place and set the formatting if needed.
11-19-2013 04:00 PM
Thank you altenbach,Very helpful
.
This is my first experience with LabVIEW, I have slowly went back and updated my completely inefficient code as I learn more. Thanks for the advice.
Im still not sure how to assemble the data into a file in the following way. I need to write a one dimentional(1x4 array) into a two dimentional (nx4 array) where n can be anything from one to inf. The 1x4 array is going to be the first set of data taken from the first first part. It will then be stored into the nx4 array. The next line that will be written will be a different part, activated by an external switch. This process will repeat for n number of parts. I have been incapable of producing anything that will accomplish this.
Any other comments would be greatly appreciated.
Andrew
11-19-2013 04:27 PM
If you want to add a new row of four every time, you need to place the shift register in the outer loop and add the new to the 2D array using "build array". If you use a case structure, wire the array across the other case unchanged if nothing should be added there.
Here's a simple example.
11-26-2013 09:53 AM
The sample provided was helpful.
I understand how to create an arbitrary array, but i need to be able to write to the next line at the press of a switch. (each switch press must create a new line.)
I tried using a case statement but it didnt seem to work as I had hoped.
Thank you!
Andrew Gascon
11-26-2013 09:55 AM
Sorry. Here is a copy of what I am working on.
11-27-2013 08:54 AM
I've taken the example previously posted and added an event structure to monitor a new button and the stop button. When either of them are pressed, the event fires and a new row is added to the array. You could also do this without an event structure, by wiring the "Add Row" switch into a case structure and building the array in the true case, and simply wiring the 2D array straight through the false case.
11-27-2013 10:27 AM
@gascon26 wrote:
Sorry. Here is a copy of what I am working on.
This is still pointless. the shift register needs to sit on the big (outermost) while loop.
12-19-2013 08:20 AM
Your attached code was very useful I was unaware of the power of a state structures. The problem that I am having now is passing the values of an array between two while loops. The problem is that a changing array is created in while loop 1 while while loop two is to write the sampled data when button is pressed.
Attempted Solutions:
12-19-2013 09:33 AM
What you are looking for is a "Master-Slave design pattern" Read up on them from the example finder.