LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a For loop to call one array element at a time

I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there.  My question pertains to the number of desired locations I can input right now.  I need to be able to input a predtermined number of locations (not just the one that I can input right now).  I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen.  Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission?  I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW.  Any help would be appreciated.

Adam
0 Kudos
Message 1 of 10
(3,634 Views)
It would be much easier for us of you would show us your code (or a small picture of it).
 
Do you have two arrays, one for longitude and one for latitude? I assume both are of the same lenght.
 
Simply wire both into a FOR loop and the input tunnel will switch to autoindexing. This means that the loop will run for as many elements you have and for each iteration it will operate in element [i].
0 Kudos
Message 2 of 10
(3,619 Views)

If I understand you correctly, the following might be helpful: It demonstartes how to perform an operation on elements of an array one at a time.

 

---God's Templar---

 

0 Kudos
Message 3 of 10
(3,615 Views)
Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.
0 Kudos
Message 4 of 10
(3,610 Views)
God's Templar,

Can you post an image of the VI.  I can't open anything later than LabVIEW 7.0. 
0 Kudos
Message 5 of 10
(3,606 Views)
God's Templar: I don't quite understand how this answers the question, and besides it is also incorrect coding.

What you coded:


The proper code:


Message Edited by smercurio_fc on 08-02-2007 09:04 AM

Download All
Message 6 of 10
(3,609 Views)
Adam,

A clarification question: You compare the current lat/long against a desired location, which is specified in the code with the "Desired Lat" and "Desired Long" controls. You then say you want to input an array of desired locations. The code you have determines a heading based on the difference between the current location and the desired one. Is it also supposed to output an array of headings, or are you supposed to find the minimum delta between your current location and the array of desired locations?

Also, do the lat/long need to be EXT? It would seem to me that DBL would be adequate.
0 Kudos
Message 7 of 10
(3,593 Views)


@adamoutlaw wrote:
Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.

I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.

Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!

Message Edited by altenbach on 08-02-2007 07:14 AM

Message 8 of 10
(3,593 Views)
Right now I am only comparing one desired location to the one current location.  I would like to be able to compare one desired location to one current location (perform other tasks not shown) and then compare the next desired location to the current location.  I am sure DBL would be plenty but I am still in the developing stages so the type of values aren't important at this time.  I'm still tinkering with the values that are output from the GPS unit.

Thanks for all the help so far.

0 Kudos
Message 9 of 10
(3,584 Views)
Thanks to everyone for their input.  I've got the system working now.  Now it's time to test and see if actually works in real time on a real system.

Adam
0 Kudos
Message 10 of 10
(3,567 Views)