LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to clear an array inside a case structure

Good morning all.  I am trying (unsuccessfully, obviously) to clear an array inside a case structure.  (See case structure at right side of vi, I colored it green to make it easy to find).  Here's (briefly) what I'm trying to do.  I have 6 test probes in the process.  All six probes are connected to the Alcatel Detector through a 6-solenoid manifold.  As I run the test, I want to sample 1/second, for let's say 3 minutes.  For the first 30 seconds, I want to pull a sample from from probe 1, so I turn on solenoid one and leave it open for 30 seconds.  Now all 30 values are tagged as having come from Probe 1, and they're stored in array 1.  I can now compute an average value for probe 1. Then I close solenoid 1 and open solenoid 2, saving the next 30 values to array 2.  (and so-on, until I have measured all 6 probes for 30 seconds each).  Then I wait a pre-determined amount of time and repeat the process.  Here's my problem.  I want to clear out each array as I begin the second iteration, so that I can easily compute the average of the last 30 values.  If I initialize the array by connecting a constant 0 to the shift register on the for loop insid ethe case structure, it does not work, nor does it work to place the 0 outide the overall for loop (the next for loop going out, NOT the OVERALL for loop).  I know my programming skills are still crude, but I'm putting everything into this.  Anyone have any suggestions? 
0 Kudos
Message 1 of 11
(3,484 Views)
Since the shift registrer contains an array, you need to initialize it with an empty array, not with zero.
 
Simply right-click on the left shift register terminal and select "Create constant". That should do it. 🙂
 
(In any case, your code does not make much sense. I think the shift register should be on the big loop).
 
I doubt you even need a shift register, simply feed the scalar to the right edge of the FOR loop and use autoindexing to brate an array. Then take the mean after the loop.

Message Edited by altenbach on 04-25-2006 07:19 AM

0 Kudos
Message 2 of 11
(3,483 Views)
Altenbach, sorry for not having described my initialization effort more clearly. I did try initializing using the empty array (right click, create, constant), and NO it does not work.  Instead of building an array, you get one value, whose value simply changes each iteration.  It dumps the n-1 value for the n value. 
0 Kudos
Message 3 of 11
(3,466 Views)
Also, the reason for my arranging it the way I did was to split the data into 6 different arrays.  I want the first x number of points (depending on dwell time at each probe) to go into one array.  Then I want the next x number of points to go the the second array, then the third group to go the 3rd array and so on.  If you have some suggestions on a more straightfprward approach, I'm all ears. (and mouse).  Thanks for the feedback so far.
0 Kudos
Message 4 of 11
(3,460 Views)
OK, I am still not quite clear, but you just need to only empty the shift register "on demand". One possibility would be to clear it only whenver the selector changes.
 
Attached is a simple example using only two cases.
0 Kudos
Message 5 of 11
(3,449 Views)
Altenbach, I definately understand your approach, and I like it much better than my own.  But I still have no luck making it work. Smiley Mad  I get the same result as before (my original attempt).  Value 0 of the array simply changes each iteration, with nothing "saved".  Each new value simply overwrites the last value.  Can you take a look at my new vi, with changes, and see if you can find the error of my ways.  I am but a rookie Jedi in the vast reaches of LabVIEW Space, and you are no doubt a Jedi MASTER Smiley Wink
0 Kudos
Message 6 of 11
(3,437 Views)
Change the "equal" to "not equal". Check my example above. 😉
0 Kudos
Message 7 of 11
(3,434 Views)
Lord Vader...You ARE my father!!!  Wait'll we tell the Princess...she's gonna CRAP!!!  Thanks so much for the help!  Works like a charm!  I also have most of my sloppy timing issues (that you were kind enough not to point out) resolved.  I'm off to conquer the nest solar system. 
0 Kudos
Message 8 of 11
(3,427 Views)
OK, so here I am again.  I have almost finished this beast.  I have 6 good averages (one for each probe).  Now I need to figure out how to obtain an average of the first three, and an average of the second three.  As you can see, my first SWAG was definately a no-go.  The zeros I have to plug in really foul it up.  I also have to make sure I find a way to send the two final averages out as analog voltages.  As always, ANY input is GREATLY appreciated.  Translated...PLEASE HELP!
0 Kudos
Message 9 of 11
(3,410 Views)
It is difficult to follow your large diagram but I think a shift register is what you need. Or perhaps 6 shift registers, one for each probe average. In the cases where you now have zeros, just pass the data through. In the non-zero cases connect the new data to the shift register.

Also, it looks like you have the potential to have timing problems with the two for loops.

Lynn
Message 10 of 11
(3,404 Views)