Shop OBEX P1 Docs P2 Docs Learn Events
GPS Tracker project ( BS2P + GPS module + JP Module + 16x2 LCD Display) — Parallax Forums

GPS Tracker project ( BS2P + GPS module + JP Module + 16x2 LCD Display)

OldSpringOldSpring Posts: 6
edited 2008-07-23 15:40 in Robotics
Hello all,
·
I just finished a summer project which is a GPS tracker demonstration program with data logging capacity. It uses BasicStamp 2P to interface with a GPS Module, JP Module and 16x2 LCD display. Code used is standard PBasic 2.5, it should work with most of the BasicStamp chips.
·
It can record GPS data to a MMC/SD card with latitude and longitude information. The data can be processed from Google Map at the website: http://www.gpsvisualizer.com. If you have Google Earth installed, the data also can be processed into a KML file (Google earth data file format) at the website: http://www.gpsvisualizer.com/map?form=googleearth
·
Main components:
(1) Basic Stamp 2P
Manufacturer:· www.parallax.com
Datasheet: http://www.parallax.com/tabid/440/Default.aspx
·
(2) GPS Module 40EBLS
Manufacturer:· www.mightygps.com
Datasheet: http://www.mightygps.com/oem/MightyGPS40EBLS.pdf
·
(3) JP Module·
Manufacturer: www.jianpingusa.com
····· ·Datasheet: http://www.jianpingusa.com/datasheet/JP%20Module%20Instruction.pdf
·
(4) 16x2 LCD Display
Manufacturer: http://www.femacorp.com/
Datasheet: http://www.femacorp.com/Products/LCD/Character%20Modules/Character%20Modules%20Index.htm
·
·
Attached files:
(1)·· Schematic
gpsschvz4.jpg
·
(2)·· Code
'======================================================
'   File...... GPS Tracking Data Logger Demo
'   Purpose... BS2P + JP Module + GPS Module + 16x2 LCD
'   Author.... OldSpring
'   Email..... [url=mailto:OldSprings@yahoo.com]OldSprings@yahoo.com[/url]
'   Started...
'   Updated... 18 July 2008
'
'   {$STAMP BS2p}
'   {$PBASIC 2.5}
'
'=======================================================
#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
  #CASE BS2PX
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
#ENDSELECT
'-------------------------------------------------------
'                 I/O Definitions
'-------------------------------------------------------
E               PIN     1       'LCD Enable Pin
SOUT            PIN     15      'Send command and data to JP Module
StatePin        PIN     14
ResetPin        PIN     13
GPS_In          PIN     12      'GPS Data in
RecIndicator    PIN     11      'GPS Data record Indicate
'-------------------------------------------------------
'                    Constants
'-------------------------------------------------------
'-------------------------------------------------------
'                    Variables
'-------------------------------------------------------
RecCount        VAR     Byte
x               VAR     Nib
GPSData         VAR     Byte(24)    'GPS Data from module
JP_Baud         CON     T19K2   ' 19200,8,N,1
GPS_Baud        CON     T4800   ' 4800,8,N,1
'--------------------------------------------------------
'                  LCD command
'--------------------------------------------------------
LcdCls          CON     $01     ' clear the LCD
LcdHome         CON     $02     ' move cursor to home
LcdLine1        CON     $80     ' Lcd address for line 1
LcdLine2        CON     $C0     ' Lcd address for line 2
Init_LCD:
  PAUSE 1000                    ' LCD self init
  LCDCMD E, %00110000           ' wakeup
  PAUSE 10
  LCDCMD E, %00100000           ' set data for 4 bits
  LCDCMD E, %00101000           ' set 2(4) line mode with 5x8 font
  LCDCMD E, %00001100           ' turn cursor off
  LCDCMD E, %00000110           ' auto increment cursor
'------------- First Screen ---------------
  LCDCMD E, LcdCls
  LCDOUT E, LcdLine1, [noparse][[/noparse]"  GPS Tracking  "]
  LCDOUT E, LcdLine2, [noparse][[/noparse]"  Data Logger   "]
  PAUSE 2000
'***********************************************************
'             Format MMC/SD Card with FAT16
'Warning: Format will erase ALL data on your MMC/SD card!!!!
'===========================================================
'  GOSUB Formatting            If formatting MMC/SD Card
'===========================================================
  GOSUB Init_JP_Module
' ----------------------------------------------------------
'                    Initialization
' ----------------------------------------------------------
Initialize:
  RecCount = 0
'  OUTPUT RecIndicator
  LCDCMD E, LcdCls
  LCDOUT E, LcdLine1, [noparse][[/noparse]"La:"]
  LCDOUT E, LcdLine2, [noparse][[/noparse]"Lo:"]
'-----------------------------------------------------------
'                     Main program
'-----------------------------------------------------------
HIGH RecIndicator                  'Turn LED ON
Main:
 GOSUB DisplayData                 'LCD Dispaly GPS Data
 GOSUB RecordData                  'Record Record Data
 PAUSE 5000                         'About per sample/per 5 sec.
 GOTO Main
END
' ----------------------------------------------------------
'                       Subroutines
'-----------------------------------------------------------
RecordData:
    GOSUB Rec_GPS_Data             'Get GPS Data for record
'***********************************************************
'      Change GPS Data format "xxxx.xxxx,N,xxxxx.xxxx,W"
'     to Google Earth Data format "xxxx.xxxx,-xxxxx.xxxx"
'***********************************************************
'DEBUG GPSData(11),CR
    IF GPSData(11) = "N" THEN
       GPSData(0) = " "
    ELSE
       GPSData(0) = "-"
    ENDIF
'DEBUG GPSData(24),CR
    IF GPSData(24) = "W" THEN
       GPSData(12) = "-"
    ELSE
       GPSData(12) = " "
    ENDIF
    GPSData(11)= " "
'DEBUG STR GPSData\23,CR
  SEROUT SOUT, JP_Baud, [noparse][[/noparse]STR GPSData\23, CR,"!!"]  'Data recording
RETURN
'-----------------------------------------------------
DisplayData:
 GOSUB LCD_GPS_Data
 LCDOUT E, LcdLine1 + 5, [noparse][[/noparse]STR GPSData\11]
 FOR x = 0 TO 12
  GPSData(x) = GPSData(x+12)
 NEXT
 LCDOUT E, LcdLine2 + 4, [noparse][[/noparse]STR GPSData\12]
RETURN
'-------------------------------------------------------
LCD_GPS_Time:
 GPSData(6) = 0
 SERIN GPS_In, GPS_Baud, [noparse][[/noparse]WAIT ("$GPRMC"), SKIP 1, STR GPSData\6]
RETURN
'-------------------------------------------------------
LCD_GPS_data:
 GPSData(24) = 0
 SERIN GPS_In, GPS_Baud, [noparse][[/noparse]WAIT ("$GPRMC"), SKIP 13, STR GPSData\24]
RETURN
'-------------------------------------------------------
Rec_GPS_data:
 GPSData(24) = 0
 SERIN GPS_In, GPS_Baud, [noparse][[/noparse]WAIT ("$GPRMC"), SKIP 12, STR GPSData\25]
RETURN
'-------------------------------------------------------
Formatting:
  LCDCMD E, LcdCls
  LCDOUT E, LcdLine1, [noparse][[/noparse]"  Formatting... "]
  SEROUT SOUT, JP_Baud, [noparse][[/noparse]"MF!"]                  'Format MMC/SD Card
  PAUSE 50
  SEROUT SOUT, JP_Baud, [noparse][[/noparse]"OldSpring!!"]           'Volume label
  PAUSE 1000
Waiting:
  IF StatePin = 1 THEN
  LCDOUT E, LcdLine1, [noparse][[/noparse]"  Finished!     "]
  ELSE
  PAUSE 1000
  GOTO  Waiting
  ENDIF
RETURN
'-----------------------------------------------------
Init_JP_Module:
  OUTPUT ResetPin
  ResetPin  = 0
  PAUSE 1000
  ResetPin  = 1
  PAUSE 1000
  SEROUT SOUT, JP_Baud, [noparse][[/noparse]"MA!"]                    'Open data file
  PAUSE 50
  SEROUT SOUT, JP_Baud, [noparse][[/noparse]"GPSTrack.CSV!!"]         'File Name
  PAUSE 1000
  IF StatePin = 0 THEN                          'If file not find, create a new file
    ResetPin  = 0
    PAUSE 1000
    ResetPin  = 1
    PAUSE 1000
    SEROUT SOUT, JP_Baud, [noparse][[/noparse]"MC!"]                  'Create a new file
    PAUSE 50
    SEROUT SOUT, JP_Baud, [noparse][[/noparse]"GPSTrack.CSV!!"]       'File Name
    PAUSE 1000
    SEROUT SOUT, JP_Baud, [noparse][[/noparse]"Latitude,Longitude", CR,"!!"]  'Data title
    PAUSE 1000
  ENDIF
RETURN

(3)·· Project photo
p1cl4.jpg

p2si1.jpg················ p3ij4.jpg

(4)·· Google Map
·
gpstrack0px1.jpg
(5)·· Google earth map
·
gpstrack1oh0.jpg··· gpstrack2ep1.jpg· gpstrack3jh2.jpg
·
·
Thanks to Parallax team and all forum users,
·
OldSpring (Author of the project)


Post Edited (OldSpring) : 7/23/2008 7:01:19 PM GMT
980 x 552 - 73K
620 x 617 - 145K
771 x 668 - 84K
771 x 668 - 54K
773 x 668 - 86K
Sign In or Register to comment.