1. 求GPS模块与51单片机之间通信的c程序
$GPRMC、 <1>、<2>、<3>、<4>、<5>、<6>、<7>、<8>、<9>、<10>、<11>、*hh<CR><LF>
<1>定位时UTC时间hhmmss 格式
<2>状态A=定位V=导航
<3>经度ddmm.mmm 格式
<4>经度方向N 或S
<5>纬度dddmm.mmmm
<6>纬度方向E或W
<7>速率
<8>方位(二维方向指向,相当于二维罗盘)
<9>当前UTC日期ddmmyy 格式
<10>太阳方位
<11>太阳方向
2. 请问如何用单片机实现GPS功能
GPS是用到三个卫星的时间 计算出 到三个卫星的距离。这样就计算出一个绝对的点。同是如果有到更多卫星的距离,就可以修正数据,使位置更精确。
一般有三个星就能定位。四个 到五个精度会很高。一般不会超过六个。因为地球是圆的,你不可能接收到地球北面等的卫星信号。
3. 什么单片机可以实现gps定位两个东西之间的距离
只要有GPS模块,一般单片机都可以,GPS解析出经纬度信息,通过串口发送给单片机,单片机计算当前点和预定点的距离,计算任务量稍大一些,8位机运算慢一些,32位机则几十ms就可以完成,网上搜一下,有两点间距离计算公式,GPS信息解码也有C语言程序
卖GPS模块的一般都提供51或STM32的例程(其实解码经纬度的程序和单片机种类没有关系).
4. 如何通过51单片机实现GPS定位功能
GPS不需要驱动程序,只需要单片机用串口不停的接收程序并且解包就可以了。
5. 基于51单片机的GPS定位 程序
额····跟我毕业设计正在做的一样啊。我给你资料,不过我也看不大懂啊。
;12864(带字库汉字显示演示程序)
;***************************************************************************
;* [email protected] (51c51 test web) www.8951.com *
;* Create by :石学军 www.51c51.com 更多例程请登陆网站 *
;***************************************************************************
RS EQU P2.0
RW EQU P2.1
E EQU P2.2
PSB EQU P2.3
RST EQU P2.5
;-----------------------------------------------
LCD_X EQU 30H
LCD_Y EQU 31H
COUNT EQU 32H
COUNT1 EQU 33H
COUNT2 EQU 34H
COUNT3 EQU 35H
;-----------------------------------------------
LCD_DATA EQU 36H
LCD_DATA1 EQU 37H
LCD_DATA2 EQU 38H
STORE EQU 39H
;-----------------------------------------------
ORG 0000H
LJMP MAIN
ORG 0100H
;-----------------------------------------------
MAIN:
MOV SP,#5FH
CLR RST ;复位
LCALL DELAY4
SETB RST
NOP
SETB PSB ;通讯方式为8位数据并口
;********************初始化**********************
LGS0: MOV A,#34H ;34H--扩充指令操作
LCALL SEND_I
MOV A,#30H ;30H--基本指令操作
LCALL SEND_I
MOV A,#01H ;清除显示
LCALL SEND_I
MOV A,#06H ;指定在资料写入或读取时,光标的移动方向
LCALL SEND_I ;DDRAM 的地址计数器(AC)加1
MOV A,#0CH ;开显示,关光标,不闪烁
LCALL SEND_I
;===============================================
TU_PLAY1:
MOV DPTR,#TU_TAB1 ;显示图形
LCALL PHO_DISP
LCALL DELAY3
;=================================================
;;显示汉字和字符
;加入80ms的延时,使你能够看清楚显示的过程
;根据汉字显示坐标分段写入(顺序写入)
;=================================================
HAN_WR2:
LCALL CLEAR_P
HAN_WR2A:
MOV DPTR,#TAB1A ;显示汉字和字符
MOV COUNT,#10H ;地址计数器设为16。
MOV A,#80H ;第一行起始地址
LCALL SEND_I
LCALL QUSHU
HAN_WR2B:
MOV DPTR,#TAB1B ;显示汉字和字符
MOV COUNT,#10H ;地址计数器设为16。
MOV A,#90H ;第二行起始地址
LCALL SEND_I
LCALL QUSHU
HAN_WR2C:
MOV DPTR,#TAB1C ;显示汉字和字符
MOV COUNT,#10H ;地址计数器设为16。
MOV A,#88H ;第三行起始地址
LCALL SEND_I
LCALL QUSHU
HAN_WR2D:
MOV DPTR,#TAB1D ;显示汉字和字符
MOV COUNT,#10H ;地址计数器设为16。
MOV A,#98H ;第四行起始地址
LCALL SEND_I
LCALL QUSHU
LCALL DELAY3
LCALL FLASH
LCALL CLEAR_P
JMP TU_PLAY2
;----------------------------------------------
;TU_PLAY1:
MOV DPTR,#TU_TAB1 ;显示图形
LCALL PHO_DISP
LCALL DELAY3
;----------------------------------------------
TU_PLAY2:
MOV DPTR,#TU_TAB2 ;显示图形
LCALL PHO_DISP
LCALL DELAY3
;----------------------------------------------
TU_PLAY3:
MOV DPTR,#TU_TAB4 ;显示图形
LCALL PHO_DISP
LCALL DELAY3
;-----------------------------------------------
;显示点阵
;-----------------------------------------------
LATPLAY1:
MOV A,#01H ;清屏
LCALL SEND_I
MOV LCD_DATA1,#0CCH ;显示点阵
MOV LCD_DATA2,#0CCH
LCALL LAT_DISP
LCALL DELAY3
LCALL CLEAR_P
KU_PLAY2:
LJMP TU_PLAY1
;===============================================
;全屏显示图形子程序
;===============================================
PHO_DISP:
MOV COUNT3,#02H
MOV LCD_X,#80H
PHO_DISP1:
MOV LCD_Y,#80H
MOV COUNT2,#20H
PHO_DISP2:
MOV COUNT1,#10H
LCALL WR_ZB
PHO_DISP3:
CLR A
MOVC A,@A+DPTR
LCALL SEND_D
INC DPTR
DJNZ COUNT1,PHO_DISP3
INC LCD_Y
DJNZ COUNT2,PHO_DISP2
MOV LCD_X,#88H
DJNZ COUNT3,PHO_DISP1
MOV A,#36H
LCALL SEND_I
MOV A,#30H
LCALL SEND_I
RET
;----------------------------------------------
CLRRAM:
MOV LCD_DATA1,#00H ;GDRAM写0子程序
MOV LCD_DATA2,#00H
LCALL LAT_DISP
RET
;==============================================
;显示点阵子程序
;==============================================
LAT_DISP:
MOV COUNT3,#02H
MOV LCD_X,#80H
LAT_DISP1:
MOV LCD_Y,#80H
CLR F0
MOV COUNT2,#20H
LAT_DISP2:
MOV COUNT1,#10H
LCALL WR_ZB
LAT_DISP3:
JB F0,LAT_DISP32
MOV LCD_DATA,LCD_DATA1
AJMP LAT_DISP31
LAT_DISP32:
MOV LCD_DATA,LCD_DATA2
LAT_DISP31:
MOV A,LCD_DATA
LCALL SEND_D
DJNZ COUNT1,LAT_DISP31
INC LCD_Y
CPL F0
DJNZ COUNT2,LAT_DISP2
MOV LCD_X,#88H
DJNZ COUNT3,LAT_DISP1
MOV A,#36H
LCALL SEND_I
MOV A,#30H
LCALL SEND_I
RET
;---------------------------------------------
WR_ZB:
MOV A,#34H
LCALL SEND_I
MOV A,LCD_Y
LCALL SEND_I
MOV A,LCD_X
LCALL SEND_I
MOV A,#30H
LCALL SEND_I
RET
;===============================================
FLASH:
MOV A,#08H ;关闭显示
LCALL SEND_I
LCALL DELAY5
MOV A,#0CH ;开显示,关光标,不闪烁
LCALL SEND_I
LCALL DELAY5
MOV A,#08H ;关闭显示
LCALL SEND_I
LCALL DELAY5
MOV A,#0CH ;开显示,关光标,不闪烁
LCALL SEND_I
LCALL DELAY5
MOV A,#08H ;关闭显示
LCALL SEND_I
LCALL DELAY5
RET
;==================================================
;清屏
;==================================================
CLEAR_P:
MOV A,#01H ;清屏
LCALL SEND_I
MOV A,#34H
LCALL SEND_I
MOV A,#30H
LCALL SEND_I
RET
;==================================================
;查表取数据送显示
;==================================================
QUSHU:
CLR A
MOVC A,@A+DPTR ;查表取数据
LCALL SEND_D ;送显示
INC DPTR
LCALL DELAY4 ;延时80ms,
DJNZ COUNT,QUSHU
RET
;===============================================
;写数据子程序
;RS=1,RW=0,E=高脉冲,D0-D7=数据
;===============================================
SEND_D:
LCALL CHK_BUSY ;写数据子程序
SETB RS
CLR RW
MOV P0,A
SETB E
NOP
NOP
CLR E
RET
;===============================================
;写指令子程序
;RS=0,RW=0,E=高脉冲,D0-D7=指令码
;===============================================
SEND_I:
LCALL CHK_BUSY
CLR RS
CLR RW
MOV P0,A
SETB E
NOP
NOP
CLR E
RET
;================================================
;读数据子程序
;RS=1,RW=1,E=H,D0-D7=数据
;================================================
READ_D:
LCALL CHK_BUSY ;读数据子程序
SETB RS
SETB RW
SETB E
NOP
MOV A,P0
CLR E
MOV STORE,A
RET
;================================================
;;测忙碌子程序
;RS=0,RW=1,E=H,D0-D7=状态字
;================================================
CHK_BUSY:
MOV P0,#0FFH ;测忙碌子程序
CLR RS
SETB RW
SETB E
JB P0.7,$
CLR E
RET
;================================================
;延时子程序
DELAY3:
MOV R5,#16H
DEL31: MOV R6,#100
DEL32: MOV R7,#0FFH
DEL33: DJNZ R7,DEL33
DJNZ R6,DEL32
DJNZ R5,DEL31
RET
DELAY2:
MOV R6,#0CH
DEL21: MOV R7,#18H
DEL22: DJNZ R7,DEL22
DJNZ R6,DEL21
RET
DELAY1:
MOV R6,#06H
DEL11: MOV R7,#08H
DEL12: DJNZ R7,DEL12
DJNZ R6,DEL11
RET
DELAY4:
MOV R6,#100
DEL41: MOV R7,#200
DEL42: DJNZ R7,DEL42
DJNZ R6,DEL41
RET
DELAY5:
MOV R5,#05H
DEL51: MOV R6,#100
DEL52: MOV R7,#0FFH
DEL53: DJNZ R7,DEL53
DJNZ R6,DEL52
DJNZ R5,DEL51
RET
;***********************************************
TAB1:
TAB1A: DB ' 51测试网 ' ;显示在第一行
TAB1C: DB '自学单片机第一站' ;显示在第三行
TAB1B: DB ' www.8951.COM ' ;显示在第二行
TAB1D: DB 'TEL 755-89956892' ;显示在第四行
;*-------------------------------------------------------------------- *
;* Bitmap点阵数据表 *
;* 图片: E:\图形8.bmp,横向取模左高位,数据排列:从左到右从上到下 *
;* 图片尺寸: 128 * 64 *
;*-------------------------------------------------------------------- *
TU_TAB1: ; 数据表
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 3Ch, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 7Fh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h,0FFh,0C0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 01h,0BFh,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 01h,0FFh,0DCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 01h, 1Fh,0FEh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 01h,0DFh,0FFh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h,0FFh,0FFh, 19h, 8Ch, 03h, 06h, 00h, 18h, 00h,0FFh,0E1h
db 80h, 00h, 00h, 00h, 00h, 3Fh,0FFh, 0Ch,0CCh, 03h, 06h, 00h, 18h, 00h,0FFh,0E1h
db 80h, 00h, 00h, 00h, 00h, 7Fh,0FFh, 04h, 58h, 03h, 06h, 01h,0FFh,0C0h, 00h,0C1h
db 80h, 00h, 00h, 00h, 00h, 7Fh,0DAh, 3Fh,0FEh, 0Fh,0DFh,0C1h,0FFh,0C0h, 01h, 81h
db 80h, 00h, 00h, 00h, 00h, 7Fh, 8Ch, 3Fh,0FEh, 0Fh,0DFh,0C1h, 98h,0C0h, 07h, 01h
db 80h, 00h, 00h, 00h, 00h, 7Fh,0B8h, 30h, 06h, 03h, 06h, 01h, 98h,0C0h, 06h, 01h
db 80h, 00h, 00h, 00h, 00h,0FEh,0C0h, 0Fh,0F8h, 03h, 8Eh, 01h,0FFh,0C3h,0FFh,0F9h
db 80h, 00h, 00h, 00h, 00h, 7Eh, 00h, 0Fh,0F8h, 07h,0CFh, 01h, 98h,0C3h,0FFh,0F9h
db 80h, 00h, 00h, 00h, 00h, 7Fh, 00h, 00h, 60h, 07h, 5Fh, 81h, 98h,0C0h, 06h, 01h
db 80h, 00h, 00h, 00h, 00h, 7Fh, 80h, 3Fh,0FEh, 0Fh, 36h,0C1h,0FFh,0C0h, 06h, 01h
db 80h, 00h, 00h, 00h, 00h, 1Fh, 80h,0BFh,0FEh, 0Bh, 36h, 61h,0FFh,0C0h, 06h, 01h
db 80h, 00h, 00h, 00h, 00h, 1Fh,0C7h, 00h,0C0h, 03h, 66h, 21h, 98h, 30h, 06h, 01h
db 80h, 00h, 00h, 00h, 15h, 5Fh,0C7h, 00h,0C0h, 03h, 06h, 00h, 18h, 30h, 06h, 01h
db 80h, 00h, 02h,0E0h, 06h, 7Fh,0CEh, 03h,0C0h, 03h, 06h, 00h, 1Fh,0F0h, 1Eh, 01h
db 80h, 00h, 04h, 54h, 4Fh,0FFh,0FCh, 01h, 80h, 03h, 06h, 00h, 0Fh,0E0h, 0Ch, 01h
db 80h, 00h, 03h,0FDh, 3Fh,0FFh,0D9h,0C0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 1Dh,0FFh,0FFh,0FFh, 87h, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 2Bh,0FFh,0F8h, 7Fh, 06h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 3Fh,0BFh,0F8h, 09h, 0Fh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 1Fh, 9Fh,0F0h, 00h,0BCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 9Dh,0FEh, 1Fh, 8Fh,0F0h, 00h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 9Fh,0FCh, 17h, 8Fh,0F0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 81h,0FFh,0CFh, 9Fh,0E0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 82h,0FFh,0FFh, 9Ch, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 81h, 7Fh,0FFh,0FCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 6Fh,0FEh, 30h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 03h,0FCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 34h, 14h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 0Eh, 18h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 02h, 30h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 01h,0E0h, 00h, 00h, 7Fh, 04h, 00h, 3Fh, 82h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 7Fh, 0Ch, 00h, 3Fh, 86h, 00h, 00h, 00h, 00h, 01h
db 80h, 00h, 00h, 00h, 00h, 00h, 7Fh, 1Ch, 00h, 3Fh, 8Eh, 00h, 00h, 00h, 00h, 01h
db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 70h, 7Ch, 38h, 38h, 3Eh, 00h,0E0h, 38h, 3Bh, 31h
db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 70h, 7Ch, 3Ch, 38h, 3Eh, 00h,0F0h, 7Ch, 3Fh,0F9h
db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 76h, 1Ch, 7Eh, 3Bh, 0Eh, 01h,0F8h,0FEh, 3Fh,0F9h
db 83h,0BBh, 9Dh,0DCh,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, 00h, 00h, 00h, 01h
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
;*-------------------------------------------------------------------- *
;* Bitmap点阵数据表 *
;* 图片: E:\图形12.bmp,横向取模左高位,数据排列:从左到右从上到下 *
;* 图片尺寸: 128 * 64 *
;*-------------------------------------------------------------------- *
TU_TAB2: ; 数据表
db 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 03h, 65h,0E8h, 80h, 00h, 01h
·········
·········
end
6. 单片机连接gps模块后无法烧写程序
单片机只有一个串口,程序的下载就是用这个串口进行的,你使用的GPS模块和单片机的通信方式也是串口,所以当你全部上电后,GPS是有数据发出的,你在下载程序那样单片机就会收到GPS的数据,把他当成错误的指令。
在下载的程序的时候不要给GPS模块上电就可以解决你的问题。