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
Highlighted

Hi Rob/Tamanna,

 

I have this small project. I am trying to read a single NMEA (GGA) string from Trimble GPS and putting it in a buffer. The buffer is then read in the host program and looks for the $GPGGA match. If its there it takes out GPS time and Latitude at 1 Hz.

 

I am not able to read the complete string, some where time out occurs and the data is lost. Do I need to adjust the timeout or ? I am attaching my project for reference.

 

I would appreciate any help.

 

Ajay 

0 Kudos
Message 31 of 52
(1,910 Views)
Highlighted

Ajay,

 

What you have is very tricky, putting a 1 second loop timer for a loop with a while loop that has its own time restrictions.  This could cause some problems, depending on when the FPGA starts in comparison to when the GPS starts.

 

What behavior are you seeing? Always missing values, sometimes missing values, always the same part of the sentence, random parts of the sentence missing? Does it run for some amount of time just fine and then start skipping? Have you put an iteration count on the while loop and keep checking it to see if it read the expected amount (is # of iterations = to number of characters you read?)  Some debugging here is required, as it is hard to see what may be happening.

 

As for the Host VI, the string parsing functions are relatively slow compared to others.  You also have some read/write controls that configure EOS and other things that should only be set once, not every iteration.  Also, put an iteration counter on elements remaining. Is it a large number? Is it growing over time and eventually overflowing?  Efficiency is the name of the game, and making your FIFO a U8 datatype instead of a U32 may help as well.

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 32 of 52
(1,894 Views)
Highlighted

Hello All,

 

I am currently trying to utilize a Novatel ProPak-LB Plus GPS to read data into a cRIO-9074. I am doing this as a part of my senior design project, in which my team is building a Ground Autonomous Vehicle so that it can traverse through a location utilizing this particular GPS. What we eventually would like to do, is read data from the GPS and tell the motor controllers where to go. If there is an obstacle in the way, then it will commence an obstacle avoidance algortithm. After avoiding the obstacle, the robot is to get "back on track", finding itself on the GPS, and proceeding to the next way point. We have ordered the 9870, but from what I saw from the earlier comments, this is unnecessary when trying to read data from the GPS. I believe the type of data that the GPS sends out is NEMA. At the current moment, I would just like to read in data from this GPS. Would you all have any suggestions in getting started? Any particular virtual instruments to get me on my way?

 

Thanks for the help

 

-Daniel

0 Kudos
Message 33 of 52
(1,312 Views)
Highlighted

Hey Daniel,

 

As you noticed, you can read in serial data either through the built in serial port on the controller or through a module.

 

9870 Module - Must program with FPGA, you deal with raw U8 values(strings are not available on FPGA, so get out your ASCII table!), but you have more than one channel available

Built-In Port - Read through RT program, data is easily converted to strings and manipulated/parsed, only one channel available, can readily write to disk

 

Anytime I have dealt with the 9870 module, I try to get the raw U8 values to the RT target to do my parsing, logging, etc. This involves the use of read/write controls or DMA FIFOS. Some people desire to use ONLY the FPGA in their applications. To those brave enough to parse out raw U8 values and make decisions based on them in FPGA, kudos to you.

 

For a senior design project and its time limitations(we've all been there...) your life will be substantially easier the more you can accomplish on the RT target. The RT target is also going to give you your user interface and any logging to file you need to do. Many people go the scan engine route, where you will not directly do any FPGA programming, however this module is not supported by the scan engine so you are forced to use FPGA. If you only need one serial channel and your other modules support scan engine (most new motion control modules do, I believe, check documentation) I would suggest returning the 9870 and going that route.

 

As for getting started, plug the GPS into your computer's COM port and open hyperterminal (Feeling old here, some new PC's do not have COM ports and hyperterminal is no longer provided in Windows 7 - find a freeware version somewhere) and start planning how to parse out the immense amount of data that is spewed forth. Your first goal with this should be 'Can my GAV determine it's current location' and then you can move into increasingly harder questions such as 'Where am I headed' and the hardest question 'What should I tell my motor controller to do'

 

Good Luck!

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 34 of 52
(1,304 Views)
Highlighted

Hi Rob,

 

This update came, and suddenly thought of asking a question.

 

We can shift it into completely new string here.

 

I am doing another project in which i am reading analog data using cRio 9014, may be frequency and some other things, but based on analog signals (temperature in this case) I have to control a digital output signal or inother words turn ON or OFF a heating source. I have done lots of acquiring stuff but have not done the control element. We have digitial output 9476 module we can use. Can you please show me some place to look for an example to build such a program using FPGA?

 

I will appreciate a lot.

 

Ajay

 

P.S. For reading the data you can use 9870, try the example program and then there is parsing exmaples too available to use. I have implemented a project for my research, if you decide to use these components, I can help you in case you are struck.

 

 

 

 

0 Kudos
Message 35 of 52
(1,296 Views)
Highlighted

Hey Ajay,

 

Might be best to open a new thread on this unrelated topic, but you have a pretty straightforward control need. You could do something as simple as:

 

while loop(

(read analog temperature = temp)

if(temp < setpoint)

    dig channel 0 = TRUE

else

    do nothing

)

 

I know this is text pseudocode, but with your experience you should be able to convert that pretty easy to G with a while loop, less than symbol, and a case structure. The control gets more complicated if you want to add PID control, hysteresis(would be a good idea), or pulse width modulation of the heater element, but those topics are very specific to application needs and cannot easily be answered on forums.

 

 

To bring this back around to the GPS question, one will be starting out with something simple such as

while loop(

read current position(x, y)

compare (x,y) to (desired x, desired y)

Turn motors on or off as needed at calculated power and direction (ie, if we only have to go a short distance, no need to turn motor to 100% power or you will overshoot)

 

This is greatly simplified since it assumes a cartesian coordinate system with a motor for X and a motor for Y, however we all know most robots do not have that, they have a direction they are pointing and it takes a certain distance to get to the correct facing direction. For example, if I have to drive straight north, and I am facing West, I am going to have to move a little west as I turn before I am facing north. Most robotics also integrate encoders on the wheels to approximate distance travelled and to make a better closed-loop control system. I say approximate because there is always minor slip in wheels.

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 36 of 52
(1,290 Views)
Highlighted

Rob,

 

Thank you very much, its always a pleasure taking to you.

 

I believe this while loop sits in the host.vi and then pass this true or False back to FPGA part of the program? is that right.

 

Appreciate your help.

 

Ajay

 

I will start a new thread and if you would like post your answer there please.

0 Kudos
Message 37 of 52
(1,275 Views)
Highlighted

Hey Rob,

 

Just had a quick question. In my status window for my source, it is generating the message, 'The generated code could not consume the un-parsed data before the token. Try defining the un-parsed data before the token in Instrument I/O Assistant". Would have any suggestions on how to fix this? Thanks Rob!

 

-Dan

0 Kudos
Message 38 of 52
(1,261 Views)
Highlighted

Hi Rob,

 

Sorry to disturb you. Now I want to use the GPS to synchronize multiple CRIO (9074)  measurements. The GPS receivers generate PPS signal and I want to make use of the PPS signal to achieve the synchronization. At the very beginning, I think I can use the SMD connector in the CRIO to do that, but later I found it is designed for drift correction. So if I use the GPS to correction the clock drift in the CRIO, how accuracy of sync. can I achieve in that way?

 

And is there any other way to make the sync with the help of PPS generated by GPS receivers? The GPS I am using is GMR 18 LVC. I am wondering if it is OK to plug the PPS output of GPS receiver to be the trigger?

 

Thanks for your help!

 

Regards,

Henry

0 Kudos
Message 39 of 52
(1,031 Views)
Highlighted

Hello Henry,

 

This is Andrew Brown, an Applications Engineer from National Instruments. A good resource on using your GPS device with your cRIO via the SMB port is Using the SMB Connector for Digital I/O or Drift Compensation on cRIO-901x and 9074 Controllers. In order to initially set the system time, a useful article is How Do I Set the Date and Time on My Real-Time Controller?.

 

To answer your question about accuracy, the GPS data should be accurate between 10 - 100 ns. Also, I definitely recommend using the SMB connector instead of triggerin off the PPS output of the GPS receiver.

 

Regards,

 

Andrew Brown

Software Engineer
National Instruments
0 Kudos
Message 40 of 52
(1,019 Views)