LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to edit elements in a 2 d array while it is running

I am trying to edit elements in a 2 d array while it is running.  The array is going to be passing data to do a set of measurements, so the idea is that if I wanted to change the amount of measurements that I wanted to do, I would be able to change it.  I thought putting it into a while loop would allow it to update, but it is not.  any suggestion

 

 

Thanks,

 

Akshay

0 Kudos
Message 1 of 10
(3,603 Views)

When you're passing a wire to a subVI, labview passes a copy of your initial array, not the array itself.

 

If you want a subVI to modify an array from a calling VI, you might need to pass the reference to your array, then your subVI can change its value and the change will be available in the calling VI.

 

Without reference you can use your subVI to take an array input and an output, so the calling VI will replace its copy from the subVI output.

 

Does it answer your question? If not please give more details on what your trying to do.

0 Kudos
Message 2 of 10
(3,598 Views)

@fghfghgfhfhg wrote:

I thought putting it into a while loop would allow it to update, but it is not.  any suggestion


This sounds like you need to learn how to use a shift register.  If you just use tunnels, then once a value goes into the input tunnel, it cannot be edited.  By using a shift register, the new values are updated each iteration of your loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 10
(3,432 Views)

thanks

0 Kudos
Message 4 of 10
(3,373 Views)

Here is my code.  What I am trying to do is get the B setpoints array to update while the program is running.  I put in the shift registers, but it has not seemed to have worked the way I intended it to.  Where am I going wrong?  Running the code might not work, so I have included a screenshot

Download All
0 Kudos
Message 5 of 10
(3,338 Views)

Ok, we need to talk through your requirements.  You whole stop routine just seems outrageous.  You also need to work on understanding data flow.  So give us detailed description of exactly what you are trying to do.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 10
(3,320 Views)

Yeah I am working on my stop routine.  What I am trying to do is create an array of current and magnetic field setpoints, and then use it to run a measurement.  The program is supposed to take those setpoints and run the measurement, but also be able to update the array of magnetic field and current setpoints , just in case if wether or not an element was added to an array.  After all the magnetic field setpoints have been meausered, including any extra setpoints that were added in while the program was running, it is suppossed to stop the while loop, and then initialize the instruments, and end the program.

0 Kudos
Message 7 of 10
(3,315 Views)

What are the functions of the two sub VI's on left of your program that are unlabeled? I'm still a little confused as to what your end goal is. Are you trying to insert elements into the current and magnetic field arrays based on the output of the sub VI's inside your nested loops? The logic on your stop buttons for the three loops can be cleaned up which will help improve the VI's readability. 

 

Regards,

 

Kevin

National Instruments

Applications Engineer

0 Kudos
Message 8 of 10
(3,261 Views)

@fghfghgfhfhg wrote:

The program is supposed to take those setpoints and run the measurement, but also be able to update the array of magnetic field and current setpoints , just in case if wether or not an element was added to an array.  After all the magnetic field setpoints have been meausered, including any extra setpoints that were added in while the program was running, it is suppossed to stop the while loop, and then initialize the instruments, and end the program.


Honestly, that is a horrible work flow.  Anybody running the test should be able to set up the test (put in all set points) and then tell it to run.  From there, you just use a FOR loop to go through all of the set points, show the results, and then quit.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 10
(3,245 Views)

@fghfghgfhfhg wrote:

Yeah I am working on my stop routine.  What I am trying to do is create an array of current and magnetic field setpoints, and then use it to run a measurement.  The program is supposed to take those setpoints and run the measurement, but also be able to update the array of magnetic field and current setpoints , just in case if wether or not an element was added to an array.  After all the magnetic field setpoints have been meausered, including any extra setpoints that were added in while the program was running, it is suppossed to stop the while loop, and then initialize the instruments, and end the program.


It seems pretty pointless to try to fix your code. I would recommend to start from scratch after doing some LabVIEW tutorial.

 

  • What is the purpose of the event structure in the lower left? You already reset in the last frame, so what's the point?
  • LabVIEW will stop automatically once all code has finished, so the stop primitive is not needed.
  • What is the purpose of the first sequence frame? Execution order is already determined by dataflow alone.
  • You form a 2D array with two columns (You did not attach the subVI, but column number 2 does not exist, only 0 and 1. Do you do some math on the index?)
  • Your stop button should be latch action, no need for local variables and resetting to defaults.
  • The terminal of your stop button belongs in the innermost loop. Currently it's value does not get read while the code is inside the inner loops. Wiring across a loop boundary as you currently do is incorrect. All you ever get from the tunnel is the stale value from the time the loop started.
  • Your inner while loop should be a FOR loop, because you know the index of the max element, and thus the number of iterations needed. (You can still use the conditional terminal if desired).
  • Why is "sample name" using a local variable? Is it expected to change during a random iteration of the inner loops? Just branch the wire from the control?
  • Why is "Current Gauss" using a local variable? It is an indicator written once! Just branch the wire from the source! Do you even need that indicator?
  • Why does your diagram contain about 20 different font sizes? Keep it consistent!
  • Wiring from left to right and keeping related operations horizontally aligned works wonders for code readability. You should try it sometime.

 

 

0 Kudos
Message 10 of 10
(3,238 Views)