最新消息:

Arduino通讯模块-GPS接收器 5Hz刷新频率

Arduino 少儿编程 1705浏览 0评论
Arduino通信模块

外观

Arduino通讯模块-GPS接收器 5Hz刷新频率

简介

  • 相信你一定用过GPS设备,我们很容易在手机,平板,汽车里找到它的身影。它的用处就是帮助你在全球范围内定位自己。
  • 这款兼容Arduino平台的GPS模块将GPS芯片与天线集成在了一起,安装在一个小型的塑料盒内。通过TinyGPS库,就可以在Arduino上获取地理坐标(包括经纬度,海拔高度)、速度、航向、GMT时间信息。
  • 另外,刷新速率也是一款GPS模块重要的性能参数。大部分手机内的GPS使用的是1Hz的刷新速率,这就意味着这种GPS每秒只能获取一组数据。而我们的GPS模块拥有5Hz的刷新速率,信号间隔的大大降低使得它可以应付更严苛的使用条件。(例如:快速移动的车辆)

技术规格

  • 芯片方案: U-BLOX G6010
  • 刷新频率: 5Hz
  • TTL串口通信频率: 38400bps
  • 额定电压: 3.3V @ 41mA
  • 通信频道: 50
  • 灵敏度: -161dBm
  • 精确度: 2.5m (主动) / <2m[SBAS]
  • 工作温度: -40°C to 85°C
  • 热启动: 1s
  • 暖启动: 32s
  • 冷启动: 32s
  • 天线尺寸: 25252mm
  • 模块尺寸: 25287.5mm
  • 外壳尺寸: 40x30x10mm

管脚定义

  • 黑:RxD
  • 白:TxD
  • 红:VCC
  • 黑(粗):GND

教程

  • 使用时,首先创建一个对象的实例,如下:
#include "TinyGPS.h"
TinyGPS gps;
  • 通过调用 encode() 函数将一串NMEA标准数据数据一个接一个字符得发送到对象内(TinyGPS不能处理正在取回的来自GPS模块的数据串),如果encode()回复“true”,说明一个有效的句子已经保存在了tinygps对象的内部,例如:
void loop()
{
  while (Serial.available())
  {
    int c = Serial.read();
    if (gps.encode(c))
    {
      // process new gps info here
    }
  }
}
  • 之后你可以查询对象得到各种各样想要的信息。为了测试得到的数据是否已过期,可以检查参数“fix_age”(可选),该参数代表从编码结束到现在的时间,以毫秒为单位。
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;

// 获取经纬度值,单位为 十万分之一度
gps.get_position(&lat, &lon, &fix_age);
 
// 时间格式 hhmmsscc, 日期格式 ddmmyy
gps.get_datetime(&date, &time, &fix_age);
 
// 返回速度,单位为百分之一节
speed = gps.speed();
 
// 航向单位为百分之一度
course = gps.course();

GPS 与 LCD 模块结合样例代码

Arduino通讯模块-GPS接收器 5Hz刷新频率

GPS模块 ———— Arduino
VCC —————— VCC
GND —————— GND
RX —————— TX
TX —————— RX

库文件:TinyGPS V1.3

#include <TinyGPS.h>
#include <LiquidCrystal.h>

TinyGPS gps;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);              //LCD driver pins
int led = 13;

long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
//int year;
//byte month, day, hour, minute, second, hundredths;

int DEG;
int MIN1;
int MIN2;
 
void LAT(){                       //Latitude state
  DEG=lat/1000000;
  MIN1=(lat/10000)%100;
  MIN2=lat%10000;

  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("LAT:");              
  lcd.print(DEG);
  lcd.write(0xDF);
  lcd.print(MIN1);
  lcd.print(".");
  lcd.print(MIN2);
  lcd.print("'   ");
}
void LON(){                        //Longitude state
  DEG=lon/1000000;
  MIN1=(lon/10000)%100;
  MIN2=lon%10000;

  lcd.setCursor(0,1);              // set the LCD cursor   position 
  lcd.print("LON:");              
  lcd.print(DEG);
  lcd.write(0xDF);
  lcd.print(MIN1);
  lcd.print(".");
  lcd.print(MIN2);
  lcd.print("'   ");
}

void setup()
{
  Serial.begin(38400);            //Set the GPS baud rate.

  pinMode(led, OUTPUT);  

  lcd.begin(16, 2);               // start the library
  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("GPS test");          // print a simple message on the LCD 
  delay(2000);
}

void loop()
{
  while (Serial.available())
  {
    digitalWrite(led, HIGH);
    int c = Serial.read();                   // Read the GPS data
    if (gps.encode(c))                        // Check the GPS data
    {
      // process new gps info here
    }

  }
  digitalWrite(led, LOW);
  gps.get_position(&lat, &lon, &fix_age);     // retrieves +/- lat/long in 100000ths of a degree
  gps.get_datetime(&date, &time, &fix_age);   // time in hhmmsscc, date in ddmmyy

  //gps.crack_datetime(&year, &month, &day,    //Date/time cracking
  //&hour, &minute, &second, &hundredths, &fix_age);  

LAT();
LON();

}

相关文件
TinyGPS
U-Center Download

您必须 登录 才能发表评论!