Ano Ano Posted March 16, 2017 Report Share Posted March 16, 2017 Hello, In the the attached vi there is the followiing operation: When the boolean (Acquire) turns on, an array starts to fill with data, when that boolean turns off the user can decide to "keep" that 1D data by pressing a boolean button (Keep) and thus incerting that 1D array into a 2D array. When the user repeats the process the 2D array should populate accordingly; one row of 1D data each time the keep is pressed. As you can see from the attached vi, when the user presses the keep button, the 2D array continuously fills with the acquired array. I "prevented" this by adding a 1sec timer but its a bit unstable. Is there another way of doing this? Thank you in advance 2D array filling.vi Quote Link to comment
eberaud Posted March 16, 2017 Report Share Posted March 16, 2017 I'd suggest modifying the mechanical action of the Keep button to "Latch when released" (or "Latch when pressed", doesn't matter). This will reset the button to FALSE as soon as LabVIEW detects that it was set to TRUE by the user. So this will execute the code that populates the 2D array only once each time the user presses the Keep button. Additional comment: don't you want to restart populating the 1D array from scratch each time the Acquire button switches from FALSE to TRUE? Right now you keep appending and never discard the old elements. Quote Link to comment
smarlow Posted March 16, 2017 Report Share Posted March 16, 2017 (edited) Manudelavega has a good point that you are appending new data to old with each cycle of the Acquire button, so that the data just keeps growing. When you save each row to the 2D array, it will be mixing the runs on each line, and also padding previously save 1D rows with zeros. LabVIEW expands 2D arrays to accommodate the largest row, and pads all other smaller rows with zeros. If you expect each test run to have different lengths, then a 2D array is not a good choice for saving the data. Why not save the test runs you want to keep to a file? Isn't that the objective anyway, to permanently save your valuable data? If you want to save to memory, and test runs are different lengths, you should bundle each run into a cluster and store the data as a 1D arrays of clusters of 1D data arrays. Take Manudelvegas advice and change your save boolean to a latch type. Also add some code to reset your acquired data to empty. An event structure, rather than multiple case structures, would probably serve you well in this regard. Edited March 16, 2017 by smarlow Quote Link to comment
smarlow Posted March 16, 2017 Report Share Posted March 16, 2017 (edited) Reset boolean is Latch type: Edited March 16, 2017 by smarlow Quote Link to comment
Ano Ano Posted March 20, 2017 Author Report Share Posted March 20, 2017 Thank you!!!!! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.