LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with shift register or other solution

I'm calling this vi based on the number of data points entered in the main vi. The data points can change each time the main program is run. I am trying to enter concentration data and create an array. The problem is the shift register holds the value I enter until the next time the vi is called. How can I have the array updated before leaving this vi.
0 Kudos
Message 1 of 12
(4,101 Views)
You probably should built your array in the calling program instead of the subVI.
 
In any case, you could make your subVI into a state machine, with one state clearing the shift register. Overall, you code is not clean because they array is appended at the end, which would create a mess unless you are calling this with points in increasing order starting with zero.
 
Can you also show us your calling program? I am pretty sure there is a much simpler solution. 😉
0 Kudos
Message 2 of 12
(4,087 Views)
If you think that code was bad, wait till you see the rest. I'm sure there is a better way to choose my channels and create names for them that can be saved to a file and passed to my graph. Such is the life of someone who is a novice. I am trying to calibrate data based on the number of channels the user chooses. Each channel has a different instrument connected to it. Once the user chooses the channels and the number of data points they are asked to enter the first concentration. They start the calibration and the program figures the average value for that concentration for each channel. They are then instructed to enter the next concentration. and so on. Once I have the averages I will plot the data against the concentration values and calculate best fit curves. Part of the best fit piece is done, but I need to get the concentration data saved into an array first. I was trying to accomplish the concentration array outside the concentration vi, but I was unsuccessful there also. The main program is calibration. Many of the indicators are there for my programming.
 
Thanks for your help,
Eric
0 Kudos
Message 3 of 12
(4,068 Views)

Altenbach,

Looked at your post on how to clear a shift register and came up with this. It works, but I don't understand why the 0 isn't added into my array. Thanks for your suggestion. To answer your question on adding the data to the bottom of the array: I'm entering concentrations in ascending order. I could add the data to the top, but then I would have to rearrange my array when complete.

Thanks,

Eric

0 Kudos
Message 4 of 12
(4,024 Views)

I'm not sure what you want to do, but did you intend NOT to wire the array through the FALSE case?  The blue wire between the shift registers.

Oops... there's more..  you are adding one single element of 0 to the array..  so now I'm even more confused.. 

What is the TRUE case supposed to do?  Why the ENTER button to stop the loop?  Are you trying to initialize an array?

As I continue to look at the code, I get even more confused.  It starts by comparing iteration 0 equal to 0 so it goes ito the True statement, runs a while loop that does nothing but wait for the ENTER button to be pressed.  Returns zero to an uninitialized array.  Offers the value 1 to the outer loop which stops because it is equal to 1.  So why do you have a FALSE case?  It will never go there..  So your array will always be 1 element 0.

RayR




Message Edited by JoeLabView on 06-24-2008 12:13 PM
0 Kudos
Message 5 of 12
(4,017 Views)
I'm building an array. This is a sub vi. Each time it is called the user enters a new concentration which is appened to the bottom of the array. In the outer while loop it sends a true to the case where the concentration is entered. On the next iteration of the while loop it sends a false and the shift register is cleared and the array is updated. I don't know why the shift register is cleared and the 0 is not added to my data, but it works. The first program I wrote "enter concentration" didn't update the array unless I ran the vi again.
0 Kudos
Message 6 of 12
(4,001 Views)


Knoebel wrote:
The first program I wrote "enter concentration" didn't update the array unless I ran the vi again.

 
That's because you "kind-of" created a Functional GLobal Variable.. Well...  not really..
 
You see, with the unitialized shift register, it will remember the last value entered the next time you run it.  That means every time you close the vi (or close Labview) to remove it from memory, it will reset itself completely.  However, for the time that it remains open, it will remember the value from the last time it ran.
 
However, I'm not sure this is how you should implement your solution.
 
Let me read your last reply again to better understand what you are attempting to do..  It still wasn't clear..
 
RayR

0 Kudos
Message 7 of 12
(3,995 Views)
I've created an example which adds a new button to clear the array.
 
I think this is what you want to do.  If you need to clear everytime you strat the program, then simply move the array constant out of the ResetArray Event and wire it to the left shift register.  Then delete the clear button and that event.
 
RayR
 
0 Kudos
Message 8 of 12
(3,989 Views)
0 Kudos
Message 9 of 12
(3,988 Views)

Joel and Altenbach,

Thanks for helping me out with this. It seems my solution is a combination of both your solutions. I'm building an array by running this vi multiple times. Each time a concentration is entered I leave this vi and start a calibration. Joel gives me the option to stop, but in my case that is accomplished by just entering the concentration and pressing enter or done. Altenbach's solution does this, but appending to the array isn't working. The data is overwritten and sometimes not written until the next time I run the vi. Probably a simple fix. I would not have come up with either of these solutions on my own so thank-you.

Eric

0 Kudos
Message 10 of 12
(3,973 Views)