LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update GPS Sentences

Hi Experts,

currently I'm receiving GPS sentences in this form

$GPGGA,172012,0120.050,N,10356.393,E,1,03,3.8,54.6,M,5.2,M,,*43

and I had already managed to extract the Longtitude and Latitude which are 10356.393 and 0120.050 respectively. As my GPS receiver is always on the move, so the values of the latitude and longtitude are always varying. I've tired to use arrays to capture and update the values but I'm not too sure if I'm on the correct way.

Can someone pls give me so guidance or examples on how to go about solving this problem?

Thanks a million

From
Donny
0 Kudos
Message 1 of 21
(4,904 Views)
Donny,

This is a general pattern-matching problem. As such, you have a variety of options from the String function palette. I've attached an example with a good general method (Scan String from Tokens) and a good, simple one-VI method (Scan from String).

Hope it helps,
John
Message 2 of 21
(4,895 Views)
Hi John thanks for the help. But I think I've not make myself clear. I've written a program to get the GPS sentences. But how can i update the same strings into different rows and columns? I still want to view the previous Longtitude and Latitude values. So the new data coming in should not override the old data.

Do you think it is possible?


From
Donny

|---------------------------|
| Longtitude | Latitude |
|---------------------------|
| 10356.397 | 120.03400 | <--- I wish to keep the old GPS data
|---------------|-----------|
| 10345.356 | 123.45678 |
|---------------|-----------|
| 10403.873 | 125.86544 |
|---------------|-----------|
0 Kudos
Message 3 of 21
(4,887 Views)
I have done a lot of programming with GPS. If I understand you correctly: you have the code that is able to read the strings from the serial port. You also managed to parse LAT and LON from the string and that is the only data you want to keep..
If that is correct the question is: do you want to have the "history" of coordinates in memory? You would if, for instance, you want to plot your trail in an XY graph. If not, you should consider writing the coordinates to file as you acquire them (or every now and then). If you are using all the coordinates while the program is running I would recommend a 2D array with one LAT and LON coordinate per row. Only if you acquire LOTS of coordinates (say 2 days at 10 Hz) you might get memory problems.
To use the array correctly do initialize the array at the maximum size you plan to use it at such that Labview doesn't need to re-allocate memory and then use the replace element function to add coordinates as you parse them from the serial input.

Included simple example

have fun, Aartjan
Message 4 of 21
(4,881 Views)
Thanks for the example...I really appreciate your help. The example is a real good one where i can learn from. Thanks again!!

From
Donny
0 Kudos
Message 5 of 21
(4,846 Views)
Hi aartjan,

I've tried to implement the example you posted. I've replace the two random number generators by the LON and LAT coordinates as stated by you. But the LON and LAT only seem to re-update to only one row and one column.

But when running the example you had provided is perfectly fine. Could it be the delay which is affecting my program?

From
Donny
0 Kudos
Message 6 of 21
(4,822 Views)
Hum yes, The loop only simulates the coordinates coming in. In your case you only want the loop to execute when new coordinates are received. The wait can be disposed of and needs to be replaced with code that only executes when new coordinates come in. I attached an html file that shows one of the many ways you could do it. It assumes that you write TRUE to a boolean "coordinates changed" when you parse incoming coordinates.
Alternatively you could have the loop write zeros to lat and lon as soon as retrieved the coordinates. after that you can have it check whether lat and/or lon are not equal to zero.

I can highly recommend the book Labview for everyone. that will explain a lot.

aartjan
Message 7 of 21
(4,801 Views)
And here is the code for the folks running Labview 7.1
BTW. there is nothing GPS specific about this code. It is a genaral way of storing data inside an array. It really only stores it and doesn't even include retrieval, "replaying," deleting or anything.
You might want to consider making a subvi that includes additional functions like that.


Aart-Jan
Message 8 of 21
(4,801 Views)
Hi Aart-Jan,

I've to once again thank you for helping me out. I've tried to implement your sub module in my GPS program but after trying out for a few days I still can't manage to update the GPS sentences into their respective rows and columns. The LON and LAT data will only write to the first row and the next GPS data will then over write the previous one.

Please help me out again. Sorry for my ignorance.

From
Donny
0 Kudos
Message 9 of 21
(4,773 Views)
It works just fine for me..
Sounds to me that you are not increasing the index for the replace array element function after you have written coordinates to it. Did you use my example? Also, it only works if you would use this directly in your code and replaced the random functions with local varaiables (producer consumer would work, too).

I went ahead and made something more useful for you. see GPS.llb attached. requires LV7.1

Aart-Jan
Message 10 of 21
(4,749 Views)