Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 4698|回復: 2
打印 上一主題 下一主題

關於Basic Stamp 與相關產品GPS的程式問題,請求解答!!

[複製鏈接]
跳轉到指定樓層
1#
發表於 2010-6-3 21:57:56 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
以下是完整程式範例,

我的問題是,要如何刪除簡化這些指令
因為我只想要接收$GPGGA,xxxx,x0xx,E,x.xx,N,.......的這種資料
想請各位懂BASIC STAMP的高手幫我解答。
' -----[ I/O Definitions ]-------------------------------------------------

Sio             PIN     15     ' connects to GPS Module SIO pin


' -----[ Constants ]-------------------------------------------------------

T4800           CON     188
Open            CON     $8000

Baud            CON     Open | T4800    ' Open mode to allow daisy chaining

MoveTo          CON     2     ' DEBUG positioning command
ClrRt           CON     11    ' clear line right of cursor
FieldLen        CON     22    ' length of debug text

EST             CON     -5    ' Eastern Standard Time
CST             CON     -6    ' Central Standard Time
MST             CON     -7    ' Mountain Standard Time
PST             CON     -8    ' Pacific Standard Time

EDT             CON     -4    ' Eastern Daylight Time
CDT             CON     -5    ' Central Daylight Time
MDT             CON     -6    ' Mountain Daylight Time
PDT             CON     -7    ' Pacific Daylight Time

UTCfix          CON     PST   ' for San Diego, California

DegSym          CON     176   ' degrees symbol for report
MinSym          CON     39    ' minutes symbol
SecSym          CON     34    ' seconds symbol

' GPS Module Commands
GetInfo         CON     $00
GetValid        CON     $01
GetSats         CON     $02
GetTime         CON     $03
GetDate         CON     $04
GetLat          CON     $05
GetLong         CON     $06
GetAlt          CON     $07
GetSpeed        CON     $08
GetHead         CON     $09

' -----[ Variables ]-------------------------------------------------------

char      VAR      Byte
workVal   VAR      Word     ' for numeric conversions
eeAddr    VAR      workVal  ' pointer to EE data

ver_hw    VAR      Byte
ver_fw    VAR      Byte

valid     VAR      Byte     ' signal valid? 0 = not valid, 1 = valid
sats      VAR      Byte     ' number of satellites used in positioning calculations

tmHrs     VAR      Byte     ' time fields
tmMins    VAR      Byte
tmSecs    VAR      Byte

day       VAR      Byte     ' day of month, 1-31
month     VAR      Byte     ' month, 1-12
year      VAR      Byte     ' year, 00-99

degrees   VAR      Byte     ' latitude/longitude degrees
minutes   VAR      Byte     ' latitude/longitude minutes
minutesD  VAR      Word     ' latitude/longitude decimal minutes
dir       VAR      Byte     ' direction (latitude: 0 = N, 1 = S, longitude: 0 = E, 1 = W)

heading   VAR      Word     ' heading in 0.1 degrees
alt       VAR      Word     ' altitude in 0.1 meters
speed     VAR      Word     ' speed in 0.1 knots


' -----[ EEPROM Data ]-----------------------------------------------------

NotValid        DATA    "No", 0
IsValid         DATA    "Yes", 0
DaysInMon       DATA    31,28,31,30,31,30,31,31,30,31,30,31
MonNames        DATA    "JAN",0,"FEB",0,"MAR",0,"APR",0,"MAY",0,"JUN",0
                DATA    "JUL",0,"AUG",0,"SEP",0,"OCT",0,"NOV",0,"DEC",0


' -----[ Initialization ]--------------------------------------------------

Initialize:
  PAUSE 250  ' let DEBUG open
  DEBUG CLS  ' clear the screen
  DEBUG "Parallax GPS Receiver Module Test Application", CR,
        "---------------------------------------------"

Draw_Data_Labels:
  DEBUG MoveTo, 0, 3,  "    Hardware Version: "
  DEBUG MoveTo, 0, 4,  "    Firmware Version: "
  DEBUG MoveTo, 0, 6,  "        Signal Valid: "
  DEBUG MoveTo, 0, 7,  " Acquired Satellites: "
  DEBUG MoveTo, 0, 9,  "          Local Time: "
  DEBUG MoveTo, 0, 10, "          Local Date: "
  DEBUG MoveTo, 0, 12, "            Latitude: "
  DEBUG MoveTo, 0, 13, "           Longitude: "
  DEBUG MoveTo, 0, 14, "            Altitude: "
  DEBUG MoveTo, 0, 15, "               Speed: "
  DEBUG MoveTo, 0, 16, " Direction of Travel: "
' -----[ Program Code ]----------------------------------------------------

Main:
  GOSUB Get_Info
  GOSUB Get_Valid
  GOSUB Get_Sats
  GOSUB Get_TimeDate
  GOSUB Get_Lat
  GOSUB Get_Long
  GOSUB Get_Alt
  GOSUB Get_Speed
  GOSUB Get_Head
  GOTO Main
---------------------------------------------------------------
Get_Lat:
  SEROUT Sio, Baud, ["!GPS", GetLat]
  SERIN  Sio, Baud, 3000, No_Response, [degrees, minutes, minutesD.HIGHBYTE, minutesD.LOWBYTE, dir]

  ' convert decimal minutes to tenths of seconds
  workVal = minutesD ** $0F5C  ' minutesD * 0.06

  DEBUG MoveTo, FieldLen, 12, DEC3 degrees, DegSym, " ", DEC2 minutes, MinSym, " "
  DEBUG DEC2 (workVal / 10), ".", DEC1 (workVal // 10), SecSym, " "
  DEBUG "N" + (dir * 5)

  ' convert to decimal format, too
  workVal = (minutes * 1000 / 6) + (minutesD / 60)
  DEBUG " (", " " + (dir * 13), DEC degrees, ".", DEC4 workVal, " )   "
  RETURN

' ----------------------------從這裡開始副程式------------------------

Get_Long:
  SEROUT Sio, Baud, ["!GPS", GetLong]
  SERIN  Sio, Baud, 3000, No_Response, [degrees, minutes, minutesD.HIGHBYTE, minutesD.LOWBYTE, dir]

  ' convert decimal minutes to tenths of seconds
  workVal = minutesD ** $0F5C  ' minutesD * 0.06

  DEBUG MoveTo, FieldLen, 13, DEC3 degrees, DegSym, " ", DEC2 minutes, MinSym, " "
  DEBUG DEC2 (workVal / 10), ".", DEC1 (workVal // 10), SecSym, " "
  DEBUG "E" + (dir * 18)

  ' convert to decimal format, too
  workVal = (minutes * 1000 / 6) + (minutesD / 60)
  DEBUG " (", " " + (dir * 13), DEC degrees, ".", DEC4 workVal, " ) "
  RETURN

以上我要如何刪除運算子運算??
這個問題希望各位能幫我解答,緊急需求,謝謝!!
2#
發表於 2010-6-4 19:59:12 | 只看該作者
以下是完整程式範例,
我的問題是,要如何刪除簡化這些指令,
因為我只想要接收$GPGGA,xxxx,x0xx,E,x.xx,N,.......的這種資料
想請各位懂BASIC STAMP的高手幫我解答。
log4518 發表於 2010-6-3 21:57


你是用Parallax GPS嗎?如果是的話,還是用簡化指令比較方便,如果直接解NMEA訊息的話,你大概會想寫到撞牆。XD
如果只想收到NMEA的話,把Parallax GPS的/raw 接low即可。

cdata VAR Byte
SERIN  Sio, Baud, [STR cdata\1]
DEBUG STR cdata\1

這樣你應該就能看到NMEA訊息了....
3#
 樓主| 發表於 2010-6-9 20:48:43 | 只看該作者
回復 2# g921002

謝謝你的解答,不過我試出來是很多小數字跟一些亂碼字,
然後我試著把
data VAR Byte
SERIN  Sio, Baud, [STR cdata\1]
DEBUG STR cdata\1
改成
SERIN  Sio, Baud, [cdata]
DEBUG cdata
結果出現這個


跟我原來想要抓到的$GPGGA的資料有出入,
所以向各位高手請求解答求救!!!謝謝~

另外
STR 這個指令是什麼意思 是轉成字串顯示的嗎?
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-4-20 18:42 , Processed in 0.099631 second(s), 10 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表