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.

writing code for mobile interfacing

Status
Not open for further replies.

itsfanidotcom

Member level 5
Joined
Mar 9, 2007
Messages
87
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Activity points
1,868
hi there, i need a a smal help,
i made a circuit for interfacing my mobile with the microcontroller to send message through the mobile, by using serial port.
i need to write code for that.
if i need to write code in c language for transmiting some data from a register of microcontroller AT89c51, how should i procede,
i mean any one can help me regarding a sample code to do that.
thanks.
 

here is sample code...... u can get idea from it


#include sbit led=P1^0;
void init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
void transmit(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;
while(TI==0);
TI=0;
a++;
}
}
unsigned char rcv()
{
while(RI==0);
return SBUF;
}
void main()
{
unsigned char ok[2];
unsigned char j;
led=0;
init();
transmit("AT");
transmit(0x0d);
for(j=0;j<2;j++)
ok[j]=rcv();
if(ok[0]=='O'&&ok[1]=='K')
led=1;
}:D
 

hi abbas1707,

You have written a c code for interfacing the mobile to the microcontroller. Which mobile u have used for interfacing to the microcontroller??
 

i used ericsson T29 . but u can modify it according to your requirement!!
 

i cannot understand the code completely ...if possible plz explain a little ,,, specially,
#include sbit led=P1^0;
while(*a!='\0')
ok[j]=rcv();
if(ok[0]=='O'&&ok[1]=='K')
led=1;

can u modify the code for t610... and also mention where we are giving the phone number of the person whom we want to send the message...
thanks in advance.
 

#include sbit led=P1^0; /* Here an led is connected to the Port1, 0th bit


while(*a!='\0') /*Here its meant for reading a character*/

ok[j]=rcv(); /*The received character is stored in an array */

if(ok[0]=='O'&&ok[1]=='K') /* if the received character is "ok" it will glow the led connected to the port*/

led=1;
 

thanks for replying...other commandds are ok, but i m a little confused in,
while(*a!='\0')
from where the microcontroller will read the character,,,
is this character given by the user...
if we want microcontrolller to read the numbers from any location of memory or from some register what will be the command.
and what the following command wil do
transmit("AT");
and the last thing from where we will give the mobile number of the person whoom we wanna transmit the message if the mobile is attached with microcontroller
 

hi itsfanidotcom:!:
as i said u that u can modify it as u need. have u succeeded in sending message from hyper terminal:?: if so then u can easily do that in this code.
for example i u want to delete a message from your mobile
for t29s the commands are
AT+CMGD=1 // command to delete the message which i have at first
//mermory location
OK // with this output the mesasge in my mobile at first location
// will be deleted

so in code u can do it as

transmit("AT+CMGD=1");
transmit(0x0d);
for(j=0;j<2;j++)
ok[j]=rcv();
if(ok[0]=='O'&&ok[1]=='K')
led=1; // if led glows then u have successfully deleted message from your mobile.


first u visit **broken link removed**
and understand how to send sms. and if u got it then try to write code for it or if u face any problem then show it in the forum we will try to solve it!!

best of luck!
 

thanks for ur reply,,,
yes i have transmitted the message successfuly through hyper terminal...and now i wanna implement the AT Commands through programing.
i have msged u in ur inbox... and i explained in detail.. i have a little concept of programing of AT commands. i have checked the site but it explains the concept of PDU mode...and i want to send message in text mode.
but first pl tell me whether i have to make the functions:
transmit();
rcv();
by my self or they are built in in the compiler....
and also plz specify if wanna send the message through some memory location then how should i write this in AT+CMGW,,, as in hyper terminal we got a '>' sign , how will we write this in C.
thanks again for reply.
 

U have to write a function for transmit and receive. It wonmt be predefined in the compiler.

For this ">" sign u have to use "0x1a" . Its the value for ctrl-Z

Added after 59 seconds:

U have to write a function for transmit and receive. It wonmt be predefined in the compiler.

For this ">" sign u have to use "0x1a" . Its the value for ctrl-Z
 

hi itsfanidotcom,
here is solution for ur problem..
here is program for 8051 in c for sending message also it is checked on proteus and working fine.
hope it will help u..:D
 
thanks alot abbas for ur reply... certainly it wil help me greatly... now i m going to check this code on microcontroller...plz pray for me.
 

hi abbas,
i m not able to compile the code which u gave.
i have C51 compiler and i m compiling the code, and want to generate the HEX file, but i m getting the following errors:
can u tel me what could be the problem
i m also attaching the code.if possible plz tel the problem ...
thanks for ur cooperation.(the code is in .doc extension change it to .c, the path of the included .h file is same as shown in the program)
 

brother check your coding

method is
void init()
not
void int()
plz correct it.and there will b no erreors.....
:D:D:D
also close the braces for if in main..

why .c file is not getting attached to my post.??? anyhow check the corrected doc file
 

hi abbas,
thaks for ur help,
the code u send after removing the error is now successfully compiled and .HEX file is generated.
but the problemis that when i try to run the hex file in proteus, i m able to see only OK in terminal screen, nothing after that, i think there is some problem with checkOK() function, because in the third line in the main function ofter sending the carriage return OxOD(i have used capital 'D'and smal 'd' both but nothing changes), the checkOK() function is not responding OK. first tel me in ur program u wrote 0X0d is it right or we use 0X0D for carriage return.
plz help me in this regard so that i m able to run it on the actual circuit....
thanks. i m also attaching the responce plz check...
thaks again for ur cooperation ...i know it takes ur time...
 

yaaaaar
hyperterminal acts as ur mobile.
1. controller send AT commnd with carriage return to ur cell (hyper terminal here)
2.cell has to reply OK(u will type OK in hyper terminal)
3.this OK is checked by checkOK() method and if OK received then
4.controller send AT+CMGF=1 + carriage return to ur cell
5.again ur cell must reply OK(u have to type OK again in terminal)
6.checkOK() will check this OK again and if it is received then
7.controller send command AT+CMGS="mobile number here" +carriage return to cell
8.mobile phone will send back a prompt formed by four characters. They are the carriage return character, the linefeed character, the ">" character and the space character
So, here is what you will actually see in a terminal program such as Hyper Terminal:
AT+CMGS="mobile num here"
>
but i have simplified it
because the controller have to send the message string when it gets space character so when u will type space on terminal in proteus controller will send the message string
and if it was a cell phone (not terminal) the message will be sent to the number u specified

dats the alogo behind program
i hope u will understand it and wil do according to the steps i explained above

:| and 0x0D is same as 0x0d
 
ohhhhh thaks buddy... i was expecting that the terminal program will respond the ok and other responses by it self...
well i have again run that in proteus and it is working fine.
but first tel me that i m not able to see the ok and the > sign ...but in the images u send earlier , there ok can be seen... is there any setting required for this..
 

when u run it on proteus then right click on virtual terminal and select "Echo typed characters" and dnt worry about > sign
ok
 

THANKS , U HELPED ME ALOT...i will implement it in hardware and finally i will update u abt the progress...
 

hi abbas, i send a message to u.. plz read it...
secondly i need to know that which pins of the DB9,,,which is attached to max232,,,, should be made short and which pins should be used as Tx and Rx when the DB9 connector is attached to t630 mobile... thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top