FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Development - selectively building an array

Here's the situation.   I have an array of, say 25 elements (for example, representing possible positions of the trailers.)   I have a FOR loop that goes through each one and applies a test, say coming up with 3 valid results (again, for example, where the right color is over the other color.)   I would like to build an array of just those three results.   Okay?

Right now, I feel that I have to build an array of 25 on the output side to match the input side.   If something is good, I set a boolean to true - if it isn't good, I set that boolean to false.   I then do a subsequent WHILE loop that does a DELETE FROM ARRAY - so I end up with a list of 3 good elements.

There must be a better way...    Any hints or thoughts?

(Although it may not seem like it - I am starting to get the hang of this approach...)

0 Kudos
Message 1 of 4
(6,610 Views)

I'm not sure I completely understand what you are trying to do; so, if I'm off base, let me know.  My recommendation is to output these three values on their own rather than as elements in an array.  If you need to propagate these three values from one iteration of the loop to the next, you can use shift registers to do so (right-click where the wire leaves the loop).

Also, feel free to post a small example of what you are doing which may make it easier for other to offer suggestions.

Hope this helps,

Geoff Schmit

Sponsor/Mentor Team 3061

Naperville North High School

--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 2 of 4
(2,832 Views)

You need to use a shift register to build an array dynamically.

See the example located at: c:\Program Files\National Instruments\LabVIEW 8.5\examples\general\arrays.llb\Separate Array Values.vi

OR see the attached VI.

These topics can be reviewed here: http://zone.ni.com/devzone/cda/tut/p/id/7466

CLA, CTA
0 Kudos
Message 3 of 4
(2,832 Views)

Perfect - thanks.   I had taken the tutorials - but I hadn't grasped this aspect (subtlety?) of shift registers around FOR loops.   It's actually very neat - but for us old timers a little unsettling...

0 Kudos
Message 4 of 4
(2,832 Views)