Beruflich Dokumente
Kultur Dokumente
Advanced Mechatronics
What Is GPS?
A space-based satellite navigation system
developed by U.S. Department of Defense in 1973
Became fully operational in 1994
A constellation of 27 satellites (24 are active at a
How to locate?
The process is called Trilateration
Project Goals
Using GPS standard sentences : NMEA 0183
$GPRMC Sentence
$GPRMC Sentence:
$GPRMC,
204331,
V,
3630.0000,N,
09712.0000,W,
$Code
Latitude: DDMM, hemisphere
(GMT+0) HHMMSS
,,,
\r\n
End of sentence
Status: A or V
(Max length = 74 )
6
Programming Strategy
RS232 Initialization:
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,STREAM=pc)
#use rs232(baud=9600,parity=N,xmit=PIN_C0,INVERT,STREAM=lcd)
# use rs232(baud=4800,parity=N,INVERT,rcv=PIN_C3,STREAM=GPS,ERRORS)
RDA Interrupt:
Interrupt occurs when RS232 receive data available
For GPS, it should occur at PIN_C3
ERRORS:
Used to cause the compiler to keep receive errors in the
variable RS232_ERRORS and to reset errors when they
occur
7
}
void main ()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
}
8
External Interrupt
char store_data [MAX_BUFFER];
.
# INT_EXT // INT_RDA Replaced by INT_EXT
{
int i;
byte char;
char = fgetc (GPS);
.
If ()
{ store_data [ i ] = char;
}
}
void main ()
{
}
10
11
Maximum Characters
$PGRMT
50
$GPRMC
74
$GPGGA
82
$GPGSA
66
$GPGSV
70
4800 Baud =
480
Characters
per Second
12
13
Memory Management
If Carriage Return (\r) and Line Feed (\n) are removed, around 400
receivable characters per second
At least data for 2 seconds should be stored to get all these sentences
connected end-to-end
A buffer size of 600 should work
15
#int_EXT
void serial_isr() {
int t;
buffer[next_in]=fgetc(gps);
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t;
// Buffer
full !!
}
#define bkbhit (next_in!=next_out)
BYTE bgetc() {
BYTE c;
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;
return(c);
}
16
19
void gps_input(*checker)
{
char c;
char temp[7];
.
while(TRUE)
{
c=fgetc(gps);
if(c=='$')
state=1;
if(state)
{
store_data[i]=c;
if(i<6)
temp[i]=c;
++i;
20
$GPRMC Sentence:
$GPRMC,
204331,
V,
3630.0000,N,
09712.0000,W,
$Code
Latitude: DDMM, hemisphere
(GMT+0) HHMMSS
,,,
\r\n
End of sentence
Status: A or V
Comma Position = 4
Pointer
21
void sub_string_finder(void)
{
int i,j=0,count=0,store_data_length;
store_data_length=strlen(store_data);
if (comma_position==0)
{
strcpy(sub_string,"Not Available");
return;
}
for (i=0;i<store_data_length;++i)
{
if(store_data[i]==',')
++count;
if (count==comma_position)
{
++i;
.
}
sub_string[j]='\0';
break;
}
}
}
22
Only one function has been written to show all option in both menus
Parameters like 1 or A or C etc. are sent to this function to display
different options
A switch case function is used to store all the option strings
This makes the code concise and memory efficient
Invalid inputs can be handled
23
option=fgetc(pc);
.
fprintf(pc,"Wrong option! Please try
again....\r\n ");
fprintf(lcd,"Wrong option! Please try
again....");
24
Plan in progress!
25
Questions?
26