简体   繁体   English

用于将 GPS 坐标转换为 NMEA 格式的 AVR 代码

[英]AVR code for converting GPS coordinates to NMEA format

I made an Android application that takes data from the GPS and sends it.我制作了一个从 GPS 获取数据并发送它的 Android 应用程序。 It's picked up by aPC, and sent over USB to an AVR kit, which needs to convert the longitude, latitude format to NMEA format and return it back to USB.它由 aPC 接收,并通过 USB 发送到 AVR 套件,该套件需要将经度、纬度格式转换为 NMEA 格式并将其返回到 USB。 The message format is:消息格式为:

latitude='23.353434333' and longitude='45.34333345'纬度='23.353434333'和经度='45.34333345'

I need to convert the above message using an ATmega32 to NMEA GPS format, but since I don't know AVR programming, can somebody suggest how I can do it or the code for above?我需要使用 ATmega32 将上述消息转换为 NMEA GPS 格式,但由于我不知道 AVR 编程,有人可以建议我如何做或上面的代码吗?

That you have no experience with AVR programming has nothing to do with implementing NMEA.您没有 AVR 编程经验与实施 NMEA 无关。 Knowing C however would help ;)但是,了解 C 会有所帮助;)

Your given representation latitude='23.353434333' and longitude='45.34333345' is called decimal degrees (your example is missing the N/S and E/W indication).您给定的表示latitude='23.353434333' 和 longitude='45.34333345'称为十进制度数(您的示例缺少 N/S 和 E/W 指示)。

I assume you are aware that NMEA is a protocol specification, not just a coordinate format.我假设您知道 NMEA 是一种协议规范,而不仅仅是一种坐标格式。 The NMEA standard uses the following coordinate notation in the datasets: NMEA 标准在数据集中使用以下坐标表示法:

XXYY.ZZZZ XXYY.ZZZZ

This can be directly represented in the degrees minutes seconds format like this:这可以直接以度分秒格式表示,如下所示:

XX°YY'(0.ZZZZ * 60)" XX°YY'(0.ZZZZ * 60)"

So the conversion between the two is trivial, as well as the conversion from degrees minutes seconds to decimal degrees :所以两者之间的转换是微不足道的,以及从度分秒十进制度数的转换:

decimal degrees = degrees + minutes/60 + seconds/3600十进制度数 = 度数 + 分/60 + 秒/3600

So in essence you just have to perform the given conversions in reverse and you get your NMEA coordinate format.所以本质上你只需要反向执行给定的转换,你就会得到你的 NMEA 坐标格式。

A NMEA dataset looks like this: NMEA 数据集如下所示:

$GPRMC,162614,A, 5230.5900,N,01322.3900,E ,10.0,90.0,131006,1.2,E,A*13 $ GPRMC,162614,A, 5230.5900,N,01322.3900,E ,10.0,90.0,131006,1.2,E,A*13

I highlighted the coordinate information in bold.我用粗体突出显示了坐标信息。 Implementing the conversion is nothing special, while implementing the NMEA protocol requires some additional reading about the implementation details.实现转换没什么特别的,而实现 NMEA 协议需要一些关于实现细节的额外阅读。

Convert a NMEA decimal-decimal degree value into degrees/minutes/seconds First.首先将 NMEA 十进制-十进制值转换为度/分/秒。 convert the decimal-decimal value to a decimal: 5144.3855 (ddmm.mmmm) = 51 44.3855 = 51 + 44.3855/60 = 51.7397583 degrees将十进制值转换为十进制数:5144.3855 (ddmm.mmmm) = 51 44.3855 = 51 + 44.3855/60 = 51.7397583 度

Then convert the decimal to degrees, minutes seconds: 51 degress + .7397583 * 60 = 44.385498 = 44 minutes .385498 = 23.1 seconds Result: 51 44' 23.1"然后将十进制转换为度,分秒:51 度 + .7397583 * 60 = 44.385498 = 44 分钟 .385498 = 23.1 秒 结果:51 44' 23.1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM