Jump to content

2D Array Filling by Boolean


Recommended Posts

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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 by smarlow
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.