cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 DISCOVERY UART + GPS

John Doe_2
Associate
Posted on March 31, 2018 at 17:30

Hey guys.

I would like to receive NMEA lines from my GPS module with UART with STM32L476 DISCOVERY. Can you please help me how can I receive the full sentences? Because the length of the lines always differ, so with simple HAL_UART_Receive I am not able to get them.

#gps #stm32 #stm32l4 #discovery #uart #usart #nmea
7 REPLIES 7
Posted on April 01, 2018 at 00:56

https://community.st.com/0D70X000006SjgqSAC

 
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on April 01, 2018 at 14:37

The use of 32-bit floats in that code for latitude and longitude are likely to be problematic given the circumference of the Earth and that they only hold about 7 digits of precision. Towards the limits the resolution/granularity blows up to 1.7 metres, one should use 64-bit doubles.

Majerle.Tilen

Here is some code to crack $GPGLL

https://community.st.com/0D50X00009Xkh8gSAB

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
AvaTar
Lead
Posted on April 03, 2018 at 15:38

To recap for an easier start - receiving NMEA sentences is quite simple.

Sync onto the '$' character, and receive until '\r\n' (but expect corruption and drop-outs).

A 80 byte buffer used to work for me.

Don't do extensive parsing in the interrupt context, GPS receivers use to send in bursts.

I will confirm Clive's information. To be really precise (just like GPS marketing says), 10cm should be achievable, while in reality if we have 1.7m, we are good

AFAIK, about 1.5m is quite normal for a civilian receiver, which is usually arificially distorted.

And when the  c r e e p s  meet near to you, expect far less accuracy, or even drop-outs for days.

Posted on April 03, 2018 at 15:03

I will confirm Clive's information. To be really precise (just like GPS marketing says), 10cm should be achievable, while in reality if we have 1.7m, we are good

Please note that NMEA output is not ready for more than 7-digits precision.

Posted on April 03, 2018 at 17:10

>>

Please note that NMEA output is not ready for more than 7-digits precision.

That is nonsense, used GPS receivers for over a decade where we output to six decimal places, ie 12345.123456. Sure you can find NMEA receivers from the 1980's using 12345.1234 form but we're still talking >7 digits, and the float format doesn't care which side of the decimal point the digits are on, it starts counting from the left.

My point more specifically is the loss of least significant digits when using 32-bit floats. ie at close to 0.0 you have resolution to fractions of mm, and at 179.99999 degrees you have resolution steps of multiple metres. This will be compounded if you use any math with multiplication that explodes out the most significant digits and loses the the least. ARM floating point implementations don't hold intermediate values at higher precision.

>>AFAIK, about 1.5m is quite normal for a civilian receiver, which is usually artificially distorted.

Confusing accuracy with precision. 

The Selective Availability 100m dither was turned off in 2000 by the Clinton administration. Civilian L1 GPS can deliver cm level accuracy with established carrier phase methods (>25 years)

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on April 03, 2018 at 17:48

The Selective Availability 100m dither was turned off in 2000 by the Clinton administration. Civilian L1 GPS can deliver cm level accuracy with established carrier phase methods (>25 years)

I guess you mean A-GPS. I didn't tinker with GPS lately.

Confusing accuracy with precision. 

I intentionally not entered the 'precision' discussion. The LNG/LAT part of GPS sentences consists of degree, minute and second (or minute fractions) parts, which IMHO call for an integer representation ...