Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading GPS data from a cRIO

Solved!
Go to solution

HI everyone

 

I am using a ni 9870 serial module with cRIO 9014. I need to acquire analog data along with the GPS data and have lang+ long for every data point.

I am able to get the gps data to the host vi, but I am confused about the rate of acquisition. I was curious and put a front panel control to look at the gps data in my RT vi and i see lot of spaces in it.(pictures attached). I have looked at lot of good examples on gps with visa drives but since i am using a cRIO with a TCP connection, I am not sure how to deal with the seral data out of the controller.

 

Can anyone please help me with any ideas of using the serial module right.

 

Thank you

Tamanna

Download All
0 Kudos
Message 1 of 52
(8,736 Views)

Fot additional info on the timing, I am acquiring the analog data at 25 Hz, should i need to acquire the GPS data at that rate too(like make the acquisition loops event driven or something like that) so that I have correct location points or

is it fine if i run 2 separate loops in my fpga vi for analog data and GPS data at different speeds ?

 

I am using

Labview 8.5.1

RIO 3.0.1

 

Thank you

Tamanna

0 Kudos
Message 2 of 52
(8,735 Views)

The FPGA AI and Serial loops can be independent, I don't see that interfering with the acquisition.  How are you passing the data from FPGA to host?

 

Also, have you tried using the serial port on the 9014 with VISA commands to see if you can get that work?

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
Message 3 of 52
(8,694 Views)

 

I am not using visa drivers because, I am reading the data through the ethernet.

 

I am not sure how to acquire data continuously in the FPGA vi. Can i write a continuous while loop or do i need to write a for loop with definite number of points to be picked up to put into a FPGA ? the GPS receiver I am using updates every second. So anything more than 1Hz should be fine.

 

while sending through the TCP connection, I am kind of losing the data. Could that be because of the timing issues or the depth of the FIFO? Shared variables are being used to transfer data between the host and the FPGA.

 

Thanks

Tamanna 

0 Kudos
Message 4 of 52
(8,665 Views)
Solution
Accepted by topic author Gautam Dee

Since this is a serial connection, you need to be constantly reading the 9870 on the FPGA.  Even though your gps only updates once a second, that 'update' has strings of unsigned 8 bit integers representing all of your characters - each read will only grab one of those U8s, if you read at 1hz, you will NOT get correct data.

 

So...read on the FPGA continuously, the faster the better, and pass that into a FIFO to pass it off to the Host so that you can decode your data. You may have to adjust the timeouts on the I/O reads.  Definitely take a look at the examples in the example finder for Serial communication with this module.

 

And...as a diagnostic...you should be able to hook this up easily to the serial port on your controller, and use the VISA commands ON THE RT HOST - the ethernet connection has nothing to do with this.

 

For diagnostics, the more indicators the better. Let me know if you any more some specific questions.

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
Message 5 of 52
(8,642 Views)
  

You are the best !!! you solved my problem in a sec 🙂 I found this gps llb on the site(http://sine.ni.com/devzone/cda/epd/p/id/2197) and it was designed with the exact same gps receiver I am using.  So, thanks to you.

I wish the NI marketing guys were sweet enough to tell us not to buy the 9870 module and use the serial port of the crio instead. But yeah, it did help a new developer like me to learn some fpga coding

 

I have a question here, I am using NI 9239 4 channel analog module to acquire analog data at 50k samples/ sec. I need to log the data in a file, each data point should have a lat+lon point.  I am using 2 parallel loops in my host vi, one for the analog data and one for GPS data, I am not sure how to get the data from each loop to make a file entry. Can you suggest me on something.

 

Thanks a lot

Tamanna 

Message 6 of 52
(8,622 Views)

Glad to hear it worked out Smiley Happy

 

As for the analog input, it depends on a few factors.  Since you are reading the analog data much faster than the GPS data, you are going to have a lot of repeated points.  You are headed down the right track in using two parallel loops  The first loop to read and decode the GPS and put the lat/long into an indicators at 1h.

 

The other loop should read the 50,000hz data from the fifo, maybe at 10k samples each read(keep an eye on elements remaining to make sure you are not overflowing), and also reads a local variable that was created off the indicators.  Design your code to only read this shared variable once, not 10,000 times(this will slow down execution)! Pass this data to a file write(spreadsheet will work, but I can't recall the exact throughput  - if you find it is taking too long to write and getting a buffer overflow in your FIFO, then write to binary file is faster but it more difficult to open with standard programs)  This should read the analog data 5 times a second, which should put you close enough to your GPS data for reasonable measurements.

 

Let me know if you have any questions, it is not too difficult, just a little tricky when writing 150ksamples a second to the flash memory, execution time and speed become a factor

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
Message 7 of 52
(8,607 Views)
 Hey rob

 

Thanks for all the help. 🙂 actually I am done with reading from the FPGA, taking care of the elements remaining in the time critical loop and putting the data in a queue and dealing with the TCP connection. Right now I have 2 independent while loops in my host vi which give me analog data and GPS data. I was writing the analog data into an excel sheet before I had to integrate GPS into the project (I wont be using the binary file writing because the data needs statistical analysis later). Since they are 2 independent loops, the execution control kind of remains in the respective loops and data is not being available outside the loop to combine and write into a file. Its a little confusing to integrate 2 while loops which give data at different rates.

 

The attached file is my host vi, where I can see the analog and gps data independently.

 

Thank you

Tamanna 

0 Kudos
Message 8 of 52
(8,597 Views)

To add to it, 

I have my data being read at 25 hz(40ms), 8000 values in 40ms, 2000 per channel and the GPS data has a baud rate of 4800.

 

Thankyou

Tamanna 

0 Kudos
Message 9 of 52
(8,595 Views)

Wow, you have a lot going on here.  The easiest way to do this(not necessarily the fastest) is to put your lat and long data into an indicator, and creating local variables off of those indicators.  Then, before you write your 2D arrays to your write to spreadsheet, you would read these local variables and add this data as a new column in your 2D array.  Keep in mind that this value will be repeated a lot...your data may look like this:

 

AI0   Lat    Long

1.2      5        5

1.3      5        5

1 4      5        5

 

Since you are sampling your AI faster than your lat/long, you need to fill in all the empty spaces between samples.  You have so much going on here, several spreadsheet writes and reads, not sure how much more RT CPU space you have left to do large array operations and still not start missing data.

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
Message 10 of 52
(8,568 Views)