12-12-2008 04:13 PM
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?
Solved! Go to Solution.
12-12-2008 04:19 PM
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
12-12-2008 04:27 PM - edited 12-12-2008 04:31 PM
You need to keep your array in a shift register. (see attached).
Also:
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.
12-12-2008 04:28 PM - edited 12-12-2008 04:29 PM
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.
12-12-2008 06:47 PM
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?
12-12-2008 07:58 PM
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. 😄