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, 1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F0h, 78h, 3Bh,0B9h
db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 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模塊上電就可以解決你的問題。