Examples | Shop
 
Global Positioning System using the Basic Stamp 2p Microcontroller
 
This example application demonstrates how to read time and date from the Total Robots DS-GPM (Global Positioning System Module) and display the data on a debug window.

This application uses I2C communication to read the data registers. You can adapt this example to read Latitude, Longitude, Altitude, Heading, Speed and any other GPM registers you require very simply.


Connections are as follows:
(In this application, the GPMs enable jumpers are on. Address jumpers are default)
Download the code here.

 

'**************************************************************************
'**************************************************************************
'This program demonstrates how to communicate with the Total Robots DS-GPM
'Global positioning module via I2C using the BS2p micorcontroller.
'This example reads time and dat from the GPM and displays them on the debug screen.
'The same principle applies for reading all other data registers.
'Written by Total Robots Ltd
'Date: 16/12/03
'{$STAMP BS2p} 'STAMP directive (specifies a BS2p)
Reg VAR Byte 'Variable for register address
Time VAR Byte(7) 'Byte array for returned time value
Date VAR Byte(9) 'Byte array for returned date value
x VAR Byte 'Array byte control variable
READTime:
DEBUG "Read Time and Date from Total Robots GPM", CR,CR
PAUSE 4000 '4 second delay
x = 0
FOR Reg = 0 TO 5 'Read from register 0 to 5
I2CIN 0, $D1,Reg, [Time(x)] 'I2C read structure
x = x+1 'Increment array byte
NEXT
'Display the Time
DEBUG "Time ", DEC Time(0), DEC Time(1), ":", DEC Time(2), DEC Time(3), ":", DEC Time(4), DEC Time(5), CR
x = 0
FOR Reg = 6 TO 13 'Read from register 6 to 13
I2CIN 0, $D1,Reg, [Date(x)] 'I2C read structure
x = x+1 'Increment array byte
NEXT
'Display the Date
DEBUG "Date ", DEC Date(0), DEC Date(1), "/", DEC Date(2), DEC Date(3), "/", DEC Date(4), DEC Date(5), DEC Date(6), DEC Date(7),CR
STOP
'**************************************************************************
'**************************************************************************


Examples | Shop