基于51单片机的GPS定位系统
(仿真+程序+PCB+原理图+设计报告)
功能介绍
具体功能:
1.UBLOX-NEO-6M GPS模块采集信息;
2.LED作指示灯;
3.LCD12864显示数据信息,时间、经纬度、方向速度、海拔;
演示视频:
基于51单片机的GPS定位系统设计
#include "display.h"GPS_INFO GPS; //GPS信息结构体uchar code beiwei[] = "北纬";
uchar code nanwei[] = "南纬";
uchar code dongjing[] = "东经";
uchar code xijing[] = "西经";
uchar code sudu[] = "速度: ";
uchar code hangxiang[] = "航向: ";
uchar code gaodu[] = "高度: ";
uchar code jiaodu[] = "角度: ";
uchar code haiba[] = "海拔: ";
uchar code du[] = "度";
uchar code meter[] = "米";
uchar code kmperhour[] = "km/h";
uchar code date[] = " 年 月 日 ";void Show_Float(float fla, uchar x, uchar y);void GPS_DispTime(void)
{uchar i = 0;uchar ch;//char * yearp;//char year[5];//char month[3];//char day[3];//char hour[3];//char minu[3];//char seco[3];//yearp=year;char time[5];Lcd_DispLine(0, 0, date); //年月日//yearp=" ";Int_To_Str(GPS.D.year,time); //将年转换成字符串,存在time中Lcd_SetPos(0, 0); //设置显示地址if(strlen(time)==4) //判断接收数据是否有效,有效则显示{i = 0;while(time[i] != '\0'){ch = time[i++];Lcd_WriteDat(ch); //显示年}}Int_To_Str(GPS.D.month,time);Lcd_SetPos(0, 3);if(strlen(time)==2){i = 0;while(time[i] != '\0'){ch =time[i++];Lcd_WriteDat(ch); }}Int_To_Str(GPS.D.day,time);Lcd_SetPos(0, 5);if(strlen(time)==2){i = 0;while(time[i] != '\0'){ch =time[i++];Lcd_WriteDat(ch); }}Int_To_Str(GPS.D.hour,time);Lcd_SetPos(1, 1);if(strlen(time)==2){i = 0;while(time[i] != '\0'){ch =time[i++];Lcd_WriteDat(ch); }}Lcd_WriteDat(' ');Lcd_WriteDat(':');Int_To_Str(GPS.D.minute,time);Lcd_SetPos(1, 3);if(strlen(time)==2){i = 0;while(time[i] != '\0'){ch =time[i++];Lcd_WriteDat(ch); }}Lcd_WriteDat(' ');Lcd_WriteDat(':');Int_To_Str(GPS.D.second,time);Lcd_SetPos(1, 5);if(strlen(time)==2){i = 0;while(time[i] != '\0'){ch =time[i++];Lcd_WriteDat(ch); }}
}void GPS_DisplayOne(void)
{uchar ch, i;char info[10];ET0=0;clr_screen();//Lcd_WriteCmd(0x01); //清屏/* Lcd_SetPos(3, 4);Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE3);Lcd_SetPos(3, 6);Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE4); Lcd_SetPos(2, 4);Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE3);Lcd_SetPos(2, 6);Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE4); */GPS_DispTime(); //显示日期,时间if (GPS.NS == 'N') //判断是北纬还是南纬Lcd_DispLine(2, 0, beiwei);else if (GPS.NS == 'S')Lcd_DispLine(2, 0, nanwei);if (GPS.EW == 'E') //判断是东经还是西经Lcd_DispLine(3, 0, dongjing);else if (GPS.EW == 'W')Lcd_DispLine(3, 0, xijing);//Lcd_DispLine(2, 2, info);//Int_To_Str(GPS.latitude_Cent,info); //纬分//Lcd_DispLine(2, 5, info);//Int_To_Str(GPS.latitude_Second,info); //纬秒//Lcd_DispLine(2, 7, info);Int_To_Str(GPS.latitude_Degree,info); //纬度Lcd_SetPos(2, 2);if(strlen(info)==2){ //只有正常显示纬度,才显示纬分i = 0;while(info[i] != '\0'){ch = info[i++];Lcd_WriteDat(ch);}Lcd_WriteDat(' ');Lcd_WriteDat(' ');Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE3); Int_To_Str(GPS.latitude_Cent,info); //纬分if(strlen(info)==2){ //只有正常显示纬分,才显示纬秒i = 0;while(info[i] != '\0'){ch = info[i++];Lcd_WriteDat(ch);}Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE4);Int_To_Str(GPS.latitude_Second,info); //纬秒if(strlen(info)==2){i = 0;while(info[i] != '\0'){ch = info[i++];Lcd_WriteDat(ch);}}} } //Int_To_Str(GPS.longitude_Degree,info); //经度//Lcd_SetPos(3, 2);//Lcd_WriteDat(' ');//Lcd_DispLine(3, 2, info);//Int_To_Str(GPS.longitude_Cent,info); //经分//Lcd_DispLine(3, 5, info);//Int_To_Str(GPS.longitude_Second,info); //经秒//Lcd_DispLine(3, 7, info);Int_To_Str(GPS.longitude_Degree,info); //经度if(strlen(info)==3){//Lcd_SetPos(3, 2);//i = 0;//while(info[i] != '\0')//{// ch = info[i++];// Lcd_WriteDat(ch);//}Lcd_DispLine(3, 2, info);Lcd_WriteDat(' ');Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE3);Int_To_Str(GPS.longitude_Cent,info); //经分if(strlen(info)==2){//i = 0;//while(info[i] != '\0') //{// ch = info[i++];// Lcd_WriteDat(ch);//}Lcd_DispLine(3, 5, info);Lcd_WriteDat(0xA1);Lcd_WriteDat(0xE4);Int_To_Str(GPS.longitude_Second,info); //经秒if(strlen(info)==2){//i = 0;//while(info[i] != '\0') //{// ch = info[i++];// Lcd_WriteDat(ch);//} Lcd_DispLine(3, 7, info);}}} ET0=1;
}void GPS_DisplayTwo(void)
{clr_screen();//Lcd_WriteCmd(0x01); //清屏ET0=0;Lcd_DispLine(0, 0, sudu);Lcd_DispLine(1, 0, hangxiang);Lcd_DispLine(2, 0, gaodu);Lcd_DispLine(3, 0, haiba);Show_Float(GPS.speed, 0, 3);Lcd_DispLine(0, 6, kmperhour);Show_Float(GPS.direction, 1, 3);Lcd_DispLine(1, 6, du);Show_Float(GPS.height_ground, 2, 3);Lcd_DispLine(2, 6, meter);Show_Float(GPS.height_sea, 3, 3);Lcd_DispLine(3, 6, meter);ET0=1;
}
硬件设计
使用元器件:
单片机:STC89C52;
(注意:单片机是通用的,无论51还是52、无论stc还是at都一样,引脚功能都一样。程序也是一样的。)
12864液晶显示屏;
UBLOX-NEO-6M GPS模块;
LED灯(红、绿、黄);
1K电阻;10K滑动变阻;
30pf电容;10K电阻;
按键;AMS1117稳压器;
DC电源插口;
导线:若干;
流程图:
设计资料
01 仿真图
本设计使用proteus8.9版本设计,资料里有安装教程,无需担心!具体如图!
02 原理图
本系统原理图采用Altium Designer19设计,具体如图!
03 程序
本设计使用软件keil5版本编程设计,资料里有安装教程,无需担心!具体如图!
04 设计报告
六千字设计报告,具体如下!
05 设计资料
资料获取请关注同名公众号,全部资料包括仿真源文件 、程序(含注释)、PCB电路图、AD原理图、设计报告、任务书、流程图、结构图、元件清单、仿真视频等。具体内容如下,全网最全! !
资料获取请观看前面演示视频!
点赞分享一起学习成长。