02-18-2020 10:21 AM
Hi all,
attached is an example I obtained from another thread and tried modifying to my needs.
Right now it works but I'm having problems extracting the values I need. It a state machine and when the use clicks Next the state goes to the next process in the predefined array. If each Process needed to be executed only once each time I would have no problem 'freezing' the mean value while the state enters the next step.
However, here the user can define how many times a certain process step is repeated and each time the mean value needs to be recorded when the Next button is clicked.
I've inserted a rudimentary case structure in the case structure of Process 1 in the Main VI to illustrate what I mean. Process 2 and 3 differs from 1 just to show the ways I tried (but ultimately they should be similar to what I'm trying to achieve). For example, for the Array on the front panel you can fill in Process 1, Process 1, Process 2... That means Process 1 is repeated and each time the mean value should be obtained. However it is not know how many time the user might repeat a particular step, hence the case structure is unsuitable though I'm able to separate the corresponding mean values. I'm thinking of a FOR loop with indexing into an array to collect each step but the way the data flows in my Vi it doesn't work because the the latest mean value just replaces every index in the array (observe Array2). Then I tried insert and replacing into an array (as shown in Process 3) but it didn't work either.
I feel this is basic dataflow but I'm missing the logical link at the moment.
Thanks in advance!
02-18-2020 11:04 AM
Where are you trying to save all of these values? Seems like you just need another Shift Register to hold the means from all of the processes and use Build Array to add on the new means each time any process is done. However, you might want to be storing this as a cluster with a String and a Numeric so you can state what process the mean came from in your array.
02-19-2020 12:32 AM - edited 02-19-2020 01:10 AM
I'm trying to hold the means to be displayed to the user at the very end after the last process is done as a pop up window so I'll have to feed them into a Subvi and in the background it should be saved to a text file without further user input.
I tried as you suggested but the newest mean values of each process keep replacing the old one. For example if Process 1 is run twice, it should give me two mean values but here it just replaces the first one. Also should I use Build Array, Bundle and Build Cluster Array? Build Array just seems to replace every value in the array with the latest one
02-19-2020 02:49 AM
@nikvl wrote:
I tried as you suggested but the newest mean values of each process keep replacing the old one. For example if Process 1 is run twice, it should give me two mean values but here it just replaces the first one. Also should I use Build Array, Bundle and Build Cluster Array? Build Array just seems to replace every value in the array with the latest one
Ok I figured what was wrong due to wires jungle, I connected the wrong wire into the shift register.
02-19-2020 09:33 AM
@nikvl wrote:
@nikvl wrote:
I tried as you suggested but the newest mean values of each process keep replacing the old one. For example if Process 1 is run twice, it should give me two mean values but here it just replaces the first one. Also should I use Build Array, Bundle and Build Cluster Array? Build Array just seems to replace every value in the array with the latest one
Ok I figured what was wrong due to wires jungle, I connected the wrong wire into the shift register.
Your mixing up cause and effect. The "wires jungle" is what is wrong. The bug is the effect. 😋