LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

changing single elements in a 1D array

Solved!
Go to solution

Firstly, forgive me as I am very new to Labview (8.5 full). I am still reading Labview for Everyone but I am trying to start building subVI's for a DA program I need to write. The attached code is for a (simple) routine that allows the user to manually load values into 1D arrays. These arrays are used for a poly curve fit (already written) to generate coefficients that will calibrate a nonlinear optical diplacement sensor.

 

What I have tried to do is initialize an array upon entry to he subVI then wait for the user to enter a new value into the entry box, select the cell to be changed and hit the "LOAD" button to write that value into the array cell. What happens is that the entire array sems to initialize every time the load button is clicked. I have intentionally kept the  initialize routine outside the "LOAD" loop but i doesn't seem to matter.

 

This is my first time with  graphics based programming and I am unsure that I even have an array. Where is it? In the wire? I formed it and display it but I don't see an array like in Visual Studio, Pascal, etc.

 

Am I even close to being on the right track or have I missed an importan point in my efforts?

Labview 8.5
Meas Studio 2008
0 Kudos
Message 1 of 6
(4,011 Views)

Walter

 

I cannot open your code on this computer

 

however, my guess is that you have not used a shift register.

 

Right-click on the loop tunnel and select 'replace with shift register'

 

Use the Replace Array Subset function - that should do it

 

 

-Scott
Message 2 of 6
(4,007 Views)
Solution
Accepted by topic author walter-donovan

You need to keep your array in a shift register. (see attached).

 

Also:

  • Your flat sequence has no purpose because execution order is fully determined by dataflow
  • Use proper datatypes. If you want DBL, initialize the array as DBL. If you want integer, use integer controls and indicators.
  • Your inner loops use 100%CPU doing nothing most of the time, You don't need it at all.
  • Your outer loop also consumes 100% cpu. Use an event structure instead.

 

You should also familiarze yourself with dataflow, because most of your code is highly flawed. For example your controls would need to be in the innermost loop in order for them to be read while the inner loop is executing.

Use my example: One loop, One event structure.

Message Edited by altenbach on 12-12-2008 02:31 PM
Message 3 of 6
(4,003 Views)

Scott is correct.  On your while loop, you need to create a shift register.  If you right-click on the wire as it intersects your while loop, you can replace it with a shift register.  You will need to wire the output of your replace array that you are currently wiring to the indicator into the shift register on the right-hand side of the while loop.

 

The data is in the wire.  You can tell by the thickness and color of the wires what the data type is.

 

 

Message Edited by Matthew Kelton on 12-12-2008 05:29 PM
Message 4 of 6
(4,002 Views)

Thanks all for your (collectively) lightning fast responses. Guess I have more learning in front of me than behind. I don't really understand shift registers. From my (only one) Labview book I thought they were only for moving iteration counts between segments of code. I did change the tunnels in the innermost loop to shift registers and the code still behaved the same. There must be more that I did wrong.

 

Alten's code worked as I envisioned the sub working. The stern warnings will be taken  seriously as I will also study the things he mentioned about efficiency, structure, etc. He actually sounded like my Mom (and I appreciate it). I know I trashed this code with overlooping but it was an attempt to isolate the initialization which I thought was causing the problem. The event loop is probably the way I'll go with this sub because I need the code to take input from three different inputs; reading a .cal file, manual user input, and the "CAPTURE" which will read voltage from the DA board and assign it to a cell. 

 

 Am I correct in thinking that the event loop is a correct way of executing these three different input options?

 

 

Labview 8.5
Meas Studio 2008
0 Kudos
Message 5 of 6
(3,968 Views)

walter-donovan wrote:

I did change the tunnels in the innermost loop to shift registers and the code still behaved the same. There must be more that I did wrong.


You would also need a shift register in the outer while loop.

 

You can easily see what's happening if you use execution highlighting. Try it!

 

You can think of a pair of shift registers as a single memory location that you can access in each iteration.

 


walter-donovan wrote:

The event loop is probably the way I'll go with this sub because I need the code to take input from three different inputs; reading a .cal file, manual user input, and the "CAPTURE" which will read voltage from the DA board and assign it to a cell. 


 

 Yes, an event structure is often the best solution. Add event cases as needed and make sure to wire the array across all releveant event cases.


walter-donovan wrote:

He actually sounded like my Mom (and I appreciate it).


Now eat you veggies and go clean your room. 😄

0 Kudos
Message 6 of 6
(3,951 Views)