Y l d z 8 8 8 @ y a h o . c o m . c n
基于 51 单片机解析
GPS
数据的实验程序
(附有效果图)
作者:朱亚龙
亚龙电子工作室
1
基于 51 单片机解析 GPS 数据的实验程序
亚龙电子工作室
E-mail:yldz888@yahoo.com.cn
QQ:369485483
//***用 51 单片机解析 GPS 数据并在 12864 液晶显示经纬度、时钟以及高度的源代码程序
//***邮箱: yldz888@yahoo.com.cn
//***作者: zhuyalong
//***时间: 2010/6/16
//【声明】此程序仅用于学习与参考,引用请注明版权和作者信息!
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit duan=P2^6;
sbit wei=P2^7;
sbit lcd_en=P3^4;
sbit lcd_rs=P3^5;
sbit lcd_rw=P3^6;
sbit lcd_psb=P3^7;
uchar a,b,c,d,i,flag;
uchar table0[62];
void delay(uint z);
void write_com(uchar com);
void write_date(uchar date);
void init();
void main()
{
init();
write_com(0x90);
for(a=0;a<17;a++)//局部定义数组并写入液晶(局部定义极大的节省 RAM)
{
uchar table[]="亚龙电子欢迎您!";
write_date(table[a]);
}
delay(5000);
write_com(0x01);//清屏
write_com(0x90);//局部定义数组并写入液晶
for(a=0;a<16;a++)
{
uchar table1[]="GPS 信号接收中";
write_date(table1[a]);
}
write_com(0x8b);//局部定义数组并写入液晶
2
基于 51 单片机解析 GPS 数据的实验程序
亚龙电子工作室
E-mail:yldz888@yahoo.com.cn
QQ:369485483
for(a=0;a<10;a++)
{
uchar table2[]={"请稍后…………"};
write_date(table2[a]);
}
delay(6000);
ES=1;
while(1)
{
if(flag==1)
{
if(table0[4]=='G')//确定是否收到"GPGGA"这一帧数据
{
d++;
if((d>=0)&&(d<=15))//前 15 秒显示经纬度
{
//以下给液晶写经纬度内容
uchar table3[]="纬度:";
uchar table4[]="经度:";
if(d==1)
write_com(0x01);//显示之前清屏
write_com(0x80);
for(a=0;a<7;a++)
write_date(table3[a]);
write_com(0x88);
for(a=0;a<7;a++)
write_date(table4[a]);
write_com(0x92);
for(a=0;a<11;a++)
write_date(table0[a+18]);
write_com(0x9a);
for(a=0;a<12;a++)
write_date(table0[a+30]);
ES=1;
flag=0;
}
if((d>=16)&&(d<=30))//后 15 秒显示时间和高度
{
uchar temp1,temp2,shi_1,shi_2;
uchar code sj[]="0123456789";
3
基于 51 单片机解析 GPS 数据的实验程序
亚龙电子工作室
E-mail:yldz888@yahoo.com.cn
QQ:369485483
uchar table5[]="时间:";
uchar table6[]="高度:";
uchar GD[8];
a=0;
for(b=0;b<62;b++)//这里完成高度数据分离
{
if(table0[b]==',')
{
a++;
if(a==9)
{
for(c=0;c<8;c++)
{
GD[c]=table0[b+c+1];// 将 分 离 的 高
度内容写入高度数组
}
}
}
}
if(d==30)
d=0;
if(d==16)
write_com(0x01);//显示之前清屏
//以下给液晶写高度内容
write_com(0x80);
for(a=0;a<6;a++)
write_date(table5[a]);
write_com(0x88);
for(a=0;a<6;a++)
write_date(table6[a]);
write_com(0x98+2);
for(a=0;a<9;a++)
{
if(GD[a]==',')
{
a=9;
write_date('M');//无数据提前退出写入同时结尾补写单
位'M'
}
- 1
- 2
前往页