Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

vehicle tracking system

Status
Not open for further replies.

hm1622

Junior Member level 1
Joined
Feb 9, 2011
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
surat
Activity points
1,481
my final year project is vehicle tracking system using gsm and gps module.
in which the tracking device is fixed on car and the device continuously(1 hour interval) send Google map link on cell phone.so guys please help me to complete this project.i need a program for this.i have already design the circuit but can't get the codes for this application.
i have design the program for manually sending the link.which is as below.so please guys modified this codes for my desire application.circuit diagram is also attached.


#include<reg51.h>
#include<string.h>

#define ldata P0

sbit rs = P2^7;
sbit rw = P2^6;
sbit e = P2^5;
sbit strobe = P1^6;
sbit LED1=P1^0;
sbit LED2=P1^1;

char info[70];
char info1[5];
char test[6]={"$GPRMC"};
char comma_position[13];
unsigned char message[25];
unsigned char code password1[4]="link";
unsigned char count, r;

unsigned int check=0,i;
unsigned char a, csms=0;

void receive_data();
void lcd_time();
void lcd_latitude();
void lcd_longitude();
void lcd_speed();
void lcd_date();


void delay(unsigned int msec)
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void Ascii(unsigned char d)
{
SBUF=d;
while(TI==0);
TI=0;
}

void AT_command(unsigned char f[])
{
for(r=0;f[r]!='\0';r++)
{
SBUF=f[r];
while(TI==0);
TI=0;
}
}


void receive_data() interrupt 4
{
if (strobe==1)
{
info[check++]=SBUF; //Read SBUF
if(check<7)
{
if(info[check-1]!=test[check-1])
check=0;
}
}

if (strobe==0)
{
info1[check++]=SBUF; //Read SBUF
if(info1[check-1] == "+"){csms=1; delay(1000);}
else {csms=0;}
ES=0;
}

LED2=0;
RI=0;
}

void sms_rr() //sms read request
{
AT_command("AT");

Ascii(0x0d);
delay(200);

AT_command("AT+CMGF=1");

Ascii(0x0d);
delay(200);
AT_command("AT+CMGR=1");
Ascii(0x0d);

}
void send()
{

AT_command("AT");

Ascii(0x0d);
delay(200);

AT_command("AT+CMGF=1");

Ascii(0x0d);
delay(200);

AT_command("AT+CMGS=");

Ascii(0x22);
AT_command("+919726562440");
Ascii(0x22);

Ascii(0x0d);
delay(200);
}
void Tx (unsigned char x)
{
SBUF=x;
while (TI==0);
TI=0;
}

void lcd_cmd(unsigned char item)
{
ldata = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
return;
}


void lcd_data(unsigned char item)
{
ldata = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
return;
}


void lcd_string(unsigned char *str)
{
int i=0;
while(str!='\0')
{
lcd_data(str);
i++;
// delay(1);
}
return;
}


void serial()
{
TMOD=0x20; //MODE=2
TH1=0xfd; // 9600 BAUD
SCON=0x50 ; // SERIAL MODE 1 ,8- BIT DATA ,1 STOP BIT ,1 START BIT , RECEIVING ON
EX0=1;
TR1=1; //TIMER START

}


void find_comma()
{
unsigned int i,count=0;
for(i=0;i<70;i++)
{
if(info==',')
{
comma_position[count++]=i;
}
}
}


void GPScompare()
{
EA=0;
find_comma();
lcd_time();
lcd_date();
lcd_latitude();
lcd_longitude();
lcd_speed();
check=0;
EA=1;
ES=1;
EX0=1;
}

unsigned char Rx_data(void)
{
RI=0;
while(RI==0);
return(SBUF);
}
void send_link()
{
unsigned int c3=comma_position[2];
unsigned int c5=comma_position[4];
send();
AT_command("http://maps.google.com/maps?q=");
Tx(info[c3+1]);
Tx(info[c3+2]);
Tx('.');
Tx(info[c3+3]);
Tx(info[c3+4]);
Tx(info[c3+5]);
Tx(info[c3+6]);
Tx(info[c3+7]);
Tx(info[c3+8]);
Tx(info[c3+9]);
Tx(',');
Tx(info[c5+1]);
Tx(info[c5+2]);
Tx(info[c5+3]);
Tx('.');
Tx(info[c5+4]);
Tx(info[c5+5]);
Tx(info[c5+6]);
Tx(info[c5+7]);
Tx(info[c5+8]);
Tx(info[c5+9]);
Tx(info[c5+10]);
Ascii(0x1a);
delay(200);

}

void em_send_link()
{
unsigned int c3=comma_position[2];
unsigned int c5=comma_position[4];
send();
AT_command("Emergency Help request");
Ascii(0x0d);
AT_command("http://maps.google.com/maps?q=");
Tx(info[c3+1]);
Tx(info[c3+2]);
Tx('.');
Tx(info[c3+3]);
Tx(info[c3+4]);
//Tx(info[c3+5]);
Tx(info[c3+6]);
Tx(info[c3+7]);
Tx(info[c3+8]);
Tx(info[c3+9]);
Tx(',');
Tx(info[c5+1]);
Tx(info[c5+2]);
Tx(info[c5+3]);
Tx('.');
Tx(info[c5+4]);
Tx(info[c5+5]);
//Tx(info[c5+6]);
Tx(info[c5+7]);
Tx(info[c5+8]);
Tx(info[c5+9]);
Tx(info[c5+10]);
Ascii(0x0d);
delay(200);
Ascii(0x1a);
delay(200);
}
void external(void) interrupt 0
{
EA=0;
LED1=0; LED2=0;
em_send_link();
LED1=1; LED2=1;
delay (100);
EA=1;
ES=1;
EX0=1;
return;
}
void sms_read_send() //To read SMS from GSM sim inbox, comparing sms and sending location link
{
EA=0;
sms_rr(); //sms read request
while(Rx_data()!='+' | Rx_data()!='O'); // chacking message format

while(Rx_data()!='C');
while(Rx_data()!='M');
while(Rx_data()!='G');
while(Rx_data()!='R');
while(Rx_data()!=':');
while(Rx_data()!='"');
while(Rx_data()!='\n');

for(count=0;count<5;count++) // storing msg in a buffer
{
message[count]=Rx_data();
if(message[count]=='\r')
break;
}
message[count]='\0';


if(strncmp(message,password1,4)==0) // comapring message with passward to make a action on device
{
send_link();
delay(250);
}

AT_command("AT+CMGDA=");
Ascii(0x22);
AT_command("DEL INBOX");
Ascii(0x22);
Ascii(0x0d);
delay(200);
EA=1;
ES=1;
EX0=1;
}

void lcd_time()
{
unsigned int c1=comma_position[0];
lcd_cmd(0x01); //Clear LCD display
delay(50);
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x86); //Move cursor to position 6 of line 1
lcd_string("TIME"); //Showing time
lcd_cmd(0xC2); //Begining of second line
lcd_data(info[c1+1]); //Displaying hours
lcd_data(info[c1+2]);
lcd_string(":");
lcd_data(info[c1+3]); //Displaying minutes
lcd_data(info[c1+4]);
lcd_string(":");
lcd_data(info[c1+5]); //Displaying seconds
lcd_data(info[c1+6]);
lcd_data(info[c1+8]);
lcd_data(info[c1+9]);
lcd_data(info[c1+10]);
delay(250); //Delay, so one can see time
}


void lcd_shape() //Shape of degree symbol
{
lcd_cmd(64);
lcd_data(10);
lcd_data(17);
lcd_data(17);
lcd_data(10);
lcd_data(0);
lcd_data(0);
lcd_data(0);
lcd_data(0);
}


void lcd_latitude()
{
unsigned int c3=comma_position[2];
lcd_shape();
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x84); //Move cursor to position 6 of line 1
lcd_string("LATITUDE"); //Showing latitude
lcd_cmd(0xC1); //Begining of second line
lcd_data(info[c3+1]);
lcd_data(info[c3+2]);
lcd_data(0);
lcd_data(info[c3+3]);
lcd_data(info[c3+4]);
lcd_data(info[c3+5]);
lcd_data(info[c3+6]);
lcd_data(info[c3+7]);
lcd_data(info[c3+8]);
lcd_data(info[c3+9]);
lcd_data(0x27); //ASCII of minute sign(')
lcd_data(info[c3+10]);
lcd_data(info[c3+11]);
delay(250);
}


void lcd_longitude()
{
unsigned int c5=comma_position[4];
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x84); //Move cursor to position 4 of line 1
lcd_string("LONGITUDE"); //Showing longitude
lcd_cmd(0xC1); //Begining of second line
lcd_data(info[c5+1]);
lcd_data(info[c5+2]);
lcd_data(info[c5+3]);
lcd_data(0);
lcd_data(info[c5+4]);
lcd_data(info[c5+5]);
lcd_data(info[c5+6]);
lcd_data(info[c5+7]);
lcd_data(info[c5+8]);
lcd_data(info[c5+9]);
lcd_data(info[c5+10]);
lcd_data(0x27); //ASCII of minute sign(')
lcd_data(info[c5+11]);
lcd_data(info[c5+12]);
delay(250);
}

void lcd_speed()
{
unsigned int c6=comma_position[6], c7=comma_position[7];
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x81); //Move cursor to position 5 of line 1
lcd_string("SPEED(inKNOTS)"); //Showing longitude
lcd_cmd(0xC3); //Begining of second line
for(i=c6+1;i<c7;i++)
{
lcd_data(info);
}
lcd_string(" KNOTS");
delay(250);
}

void lcd_date()
{
unsigned int c9=comma_position[8];
lcd_cmd(0x01); //Clear LCD display
lcd_cmd(0x86); //Move cursor to position 5 of line 1
lcd_string("DATE");
lcd_cmd(0xC4);
lcd_data(info[c9+1]);
lcd_data(info[c9+2]);
lcd_data('-');
lcd_data(info[c9+3]);
lcd_data(info[c9+4]);
lcd_data('-');
lcd_data(info[c9+5]);
lcd_data(info[c9+6]);
delay(250);
}




void gsm_init() //GSM Initialisation
{
AT_command("AT");
Ascii(0x0d);
delay(200);

AT_command("AT+CMGF=1");
Ascii(0x0d);
delay(200);

/* AT_command("AT+CMGDA=");
Ascii(0x22);
AT_command("DEL INBOX");
Ascii(0x22);
Ascii(0x0d);
delay(200);*/
}

void main()
{
serial();
lcd_cmd(0x38); //2 LINE, 5X7 MATRIX
lcd_cmd(0x0e); //DISPLAY ON, CURSOR BLINKING
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
gsm_init();
EA=1;
ES=1;
EX0=1;

LED1=LED2=1;
strobe=1;

while(1)
{
if (check==69)
{
GPScompare();
strobe=0;
}
if(strobe==1)
{
LED1=0;
LED2=1;
}
if(strobe==0)
{
LED1=1;
LED2=0;
sms_rr();
delay(100);
delay(100);
delay(100);
delay(100);
delay(100);
delay(100);
delay(100);
Tx('A');
if (csms==1)
{
sms_read_send();
Tx('R');
}
strobe=1;
ES=1;

}
}
}
 

Attachments

  • CKT_orig.bmp
    866.3 KB · Views: 101

Here is few thing for you check before asking someone else to finish your project.

Can you send data via the USART? Have you tested it? Have you read the manual for the AT command? Can you connect the GSM modem to your PC and test it via a terminal program - Tereterm or hyperterminal or realterm? Test if you can send AT command for SMS, signal strength, cell ID etc.. If so have you test your output of your micro to the PC and check you are sending the same AT commands in the terminal? Have you tried AT query to the GSM modem to check if you get a response in your micro?

The main thing is to get the basics working.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top