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.

AT89S52 and modem interfacing

Status
Not open for further replies.

9780id

Junior Member level 1
Junior Member level 1
Joined
May 8, 2013
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,386
hi friends,I made a project to turn on and off light using SMS.
So if I send LAMP ON the lamp will turn on and the circuit will send back LAMP IS ON.
I know there are many thread similar problem with mine,but I haven't found the thread that already discuss about it completely.
and I also want to ask about interfacing modem and microcontroller.
I use Wavecom 1306B, does anybody have the link for that?
your help is mean a lot for me.
thanks
 

hi anboli,thanks for the reply.
but that was for arduino and PIC.
i am new in programming here :(
do you have that using 8051 and in C language?
thanks a lot
 

while you posting the queries, you need to specify the controller and other details. then only we could help.

give any circuit or anything about your project, at where you having problem now?
 

hi friends,I used AT89S52,xtal 11,0592 MHz and max 232 for this project.I dont use any LCD
I just try a simple code but it not works :(
can you help me examine it?
 

Attachments

  • code.zip
    492 bytes · Views: 87

Hi friend,

I have seen your whole code, in your main loop you first init GSM and then serial communication. How it is possible that GSM AT command work without serial communication initialize,
So, first init serial communication then send AT command to you GSM module.

Best of Luck.

Regards,
 

    V

    Points: 2
    Helpful Answer Positive Rating
hi g_shyam1682,thanks a lot buddy..
i now can send sms :)
 

hi,I got another question.
now I am trying to read and sms,i found references code on the internet,but i dont get what does that mean.
can somebody help decode it?
Code:
void tx_data(unsigned char tdata)
	{
    	TI=0;
		SBUF=tdata;
		while(TI==0);
	}
/************************************************************************************/
void tx_string(unsigned char *tstring)
	{
		unsigned char i=0;
		while(tstring[i]!='\0')
		{
			tx_data(tstring[i]);
			i++;
		}
	}
/************************************************************************************/
unsigned char rx_data()
	{
		while(RI==0);
		RI=0;
		return(SBUF);

	}
/************************************************************************************/
void enter()
{
	tx_data(0x0d);       //  <CR>
	tx_data(0x0a);		// <LF>
}

- - - Updated - - -

hi,I got another question.
now I am trying to read and sms,i found references code on the internet,but i dont get what does that mean.
can somebody help decode it?
Code:
void tx_data(unsigned char tdata)
	{
    	TI=0;
		SBUF=tdata;
		while(TI==0);
	}
/************************************************************************************/
void tx_string(unsigned char *tstring)
	{
		unsigned char i=0;
		while(tstring[i]!='\0')
		{
			tx_data(tstring[i]);
			i++;
		}
	}
/************************************************************************************/
unsigned char rx_data()
	{
		while(RI==0);
		RI=0;
		return(SBUF);

	}
/************************************************************************************/
void enter()
{
	tx_data(0x0d);       //  <CR>
	tx_data(0x0a);		// <LF>
}
 

tx_data() is for transmitting single byte through uart and rx_data() is to receive single byte. tx_string() is to transmit a string. You have to use Serial interrupt for reading data. Whenever there is a serial interrupt you have to put the received data byte into an array and increment the array index and after all data is received terminate the array with a null string so that it becomes a string which can be displayed on Serial Terminal or LCD.
 
  • Like
Reactions: 9780id

    9780id

    Points: 2
    Helpful Answer Positive Rating
how can I activate serial interrupt?can you give a clear explanation of that?
and I'm also not unsure about this matter
Code:
void read_nd_check_password(unsigned char msg_array[])
{
if(Pass_array[0]==msg_array[59]&&
	Pass_array[1]== msg_array[60]&&
	Pass_array[2]==msg_array[61]&&
	Pass_array[3]== msg_array[62])
	{
		display_msg();
	}
	else
	{	
	SMSString("AT+CMGS=\"");
	SMSString(Mob_no);
	SMSString("\"\r");
	delay(1);
	SMSString("Password Incorrect!!");
	tx0(0x1A); // Ctrl+z
	delay(10);	
	}
the meaning of Pass_array[0]==msg_array[59] is if the pass_array contained in array number 0 is the same is with the msg_array number 59.Is that true?
 

If Pass_arry[0] element 0 matches with msg_array[59] element 59 and similar matches then display message else send SMS password is incorrect. Before that it is reading the SMS and msg_array[] contains the SMS. element 59 to 62 of msg_array[] contains the password. For serial interrupt refer to book "The 8051 Microcontroller and Embedded System Using Assembly and C" by Muhammed Ali Mazidi.

https://www.8051projects.info/resources/a-rewrite-of-the-serial-example-to-use-interrupts-in-c.60/
https://saeedsolutions.blogspot.in/2012/05/interfacing-with-uart-of-8051.html
 
  • Like
Reactions: anboli

    anboli

    Points: 2
    Helpful Answer Positive Rating
this sample program for the receiver serial interrupt..

void serial (void) interrupt 4 // giving the interrupt priority
{
static char temp = '\0';

if (RI == 1) // it was a receive interrupt
{
temp = SBUF;
RI = 0;
TI = 1;
}
}
 

Hi friend,

I read your whole thread, i think if you don't know how to interface on serial port, how to work RX, TX, then GSM communication or SMS is the far away from you.
I suggest you first study Serial interface over microcontroller, hands on serial interface then start work on SMS.
There is also "8051 Microcontroller by Ayala" book to study complete microcontroller. It is very easy to understand.

Regards,
 

If Pass_arry[0] element 0 matches with msg_array[59] element 59 and similar matches then display message else send SMS password is incorrect. Before that it is reading the SMS and msg_array[] contains the SMS. element 59 to 62 of msg_array[] contains the password. For serial interrupt refer to book "The 8051 Microcontroller and Embedded System Using Assembly and C" by Muhammed Ali Mazidi.

https://www.8051projects.info/resources/a-rewrite-of-the-serial-example-to-use-interrupts-in-c.60/
https://saeedsolutions.blogspot.in/2012/05/interfacing-with-uart-of-8051.html

thank you friend,but how can you save a data in a certain location of array?
i thought array will be saved randomly.
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
unsigned int i = 0;
 
void serial (void) interrupt 4 // giving the interrupt priority 
{   
 
i   f (RI == 1) // it was a receive interrupt 
    {
        msg_array[i++] = SBUF;
        msg_array[i] = '\0'; 
        RI = 0; 
        TI = 1; 
    }
}

 

still i can not get it :((
can you give me sample how to read sms?
 

yes,i know i should use AT+CMGR=index message.
but I can not program it to microcontroller,I really dont understand how it can be done.
 

I Suggest some time on following work which give u better understanding of Controller

1. How each pin work & how to assign to particular task.
2. How crystal block work what setting required for external & internal type required.
3. Use LED & timer to generate specific time say 100 ms 200 ms etc & blink LED in ISR or
Main loop
4. How serial Communication work what setting it required for B.R. generation according to
crystal value.
5. Then just Send few Character & similar for Reciving
6. After that just send AT command for SMS read. Check command on hyper terminal. Note: If same command is send by PC to GSM then SMS read action should occur. Else correct command used & then same command used in controller.

U may feel time consuming but if u know each step well then ur work easier for this project as well as future work also. U can ignore any step if u have expert it on the same
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top