electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

writing code for mobile interfacing


Goto page 1, 2  Next
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> writing code for mobile interfacing
Author Message
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post28 Jul 2007 5:07   

writing code for mobile interfacing


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.
Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post28 Jul 2007 14:11   

Re: writing code for mobile interfacing


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;
}Very Happy
Back to top
aandavan



Joined: 31 Aug 2006
Posts: 88
Helped: 1
Location: india


Post01 Aug 2007 10:15   

Re: writing code for mobile interfacing


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??
Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post01 Aug 2007 15:20   

Re: writing code for mobile interfacing


i used ericsson T29 . but u can modify it according to your requirement!!
Back to top
Google
AdSense
Google Adsense




Post01 Aug 2007 15:20   

Ads




Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post03 Aug 2007 6:58   

writing code for mobile interfacing


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.
Back to top
aandavan



Joined: 31 Aug 2006
Posts: 88
Helped: 1
Location: india


Post04 Aug 2007 6:15   

Re: writing code for mobile interfacing


#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;
Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post04 Aug 2007 7:28   

Re: writing code for mobile interfacing


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
Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post04 Aug 2007 14:36   

Re: writing code for mobile interfacing


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 http://www.dreamfabric.com/sms/
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!
Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post06 Aug 2007 4:59   

writing code for mobile interfacing


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.
Back to top
aandavan



Joined: 31 Aug 2006
Posts: 88
Helped: 1
Location: india


Post06 Aug 2007 12:00   

Re: writing code for mobile interfacing


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
Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post06 Aug 2007 17:00   

Re: writing code for mobile interfacing


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..Very Happy



Sorry, but you need login in to view this attachment

Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post08 Aug 2007 5:41   

writing code for mobile interfacing


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.
Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post08 Aug 2007 15:00   

Re: writing code for mobile interfacing


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)



Sorry, but you need login in to view this attachment

Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post08 Aug 2007 16:13   

Re: writing code for mobile interfacing


brother check your coding

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

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



Sorry, but you need login in to view this attachment

Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post09 Aug 2007 6:10   

Re: writing code for mobile interfacing


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...



Sorry, but you need login in to view this attachment

Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post09 Aug 2007 10:57   

Re: writing code for mobile interfacing


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

Neutral and 0x0D is same as 0x0d
Back to top
itsfanidotcom



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post10 Aug 2007 4:34   

Re: writing code for mobile interfacing


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..
Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post10 Aug 2007 10:46   

Re: writing code for mobile interfacing


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



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post11 Aug 2007 5:02   

writing code for mobile interfacing


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



Joined: 09 Mar 2007
Posts: 98
Helped: 3


Post17 Aug 2007 13:42   

writing code for mobile interfacing


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
Back to top
MAfrooz



Joined: 25 Jun 2007
Posts: 6


Post20 Aug 2007 20:38   

Re: writing code for mobile interfacing


hi my friends
i have a problem
i not understand your language
i speaking persian
please put the shematic of board
tanks for it
Back to top
glide_07



Joined: 30 Jun 2007
Posts: 8
Helped: 1


Post11 Sep 2007 5:37   

Re: writing code for mobile interfacing


Hi itsfanidotcom i have the same project as yours but i will be using PIC16F84a or PIC16F628. I have downloaded a code for sms controller but its written in assembly so i find it hard to understand. My question is did you successfully program your project using c language? if so, Please help i want to code in c also for my project.. Thanks...hope to hear from you.
Back to top
neoaspilet11



Joined: 29 Sep 2005
Posts: 276
Helped: 21
Location: Cebu, Philippines


Post11 Sep 2007 6:40   

Re: writing code for mobile interfacing


Hey friends, Anybody who knew what command to read automatically long SMS message more than 160 characters SMS. Currently my method is to look into the PDU frame and determine if teh message is part of a long message or not then integrate the broken short messages into a single message. Any shortcut of this?
Back to top
sohail_akram



Joined: 26 Feb 2006
Posts: 50


Post13 Sep 2007 13:20   

Re: writing code for mobile interfacing


Here i make to try gsm engine in Proteus for tesing

mcu codes.but it is still progress ,

http://rapidshare.com/files/55353408/Emu-Gsm.zip
Back to top
junaidali



Joined: 29 Oct 2007
Posts: 11


Post29 Oct 2007 21:07   

Re: writing code for mobile interfacing


@ abbas
Dear abbas

i have samsung x700 and when i write AT+CMGS command it donot show double quotes (") after = and nothing write till five characters after that it write any thing i cant understand this pls help
Back to top
abbas1707



Joined: 03 May 2007
Posts: 230
Helped: 11


Post31 Oct 2007 13:46   

Re: writing code for mobile interfacing


@junaid
u r testing it at hyper terminal????
plz attach the output u r getting from mobile.
Back to top
junaidali



Joined: 29 Oct 2007
Posts: 11


Post31 Oct 2007 19:28   

Re: writing code for mobile interfacing


i copy paste this thing from notepad to hyperterminal

AT+CMGS="+923225387571"

and it become like this in hyper terminal

AT+CMGS=25387571

it works and give me prompt > to write my message when i write my message it appears like that

> loo (i write heloo it eats h and e )

ok i write my message and press ctrl+z nothing happens no message send and no response from mobile

i cant understand plz help thanks
Back to top
necolei



Joined: 26 Oct 2007
Posts: 25
Helped: 1


Post01 Nov 2007 12:06   

Re: writing code for mobile interfacing


abbas1707 wrote:
here is sample code...... u can get idea from it

d transmit(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;
while(TI==0);
TI=0;
a++;
}
}



I am using a Zilog Microcontroller can you explain this part so that I can convert it for my micro controller. Thank you


Necolei
Back to top
junaidali



Joined: 29 Oct 2007
Posts: 11


Post01 Nov 2007 17:37   

writing code for mobile interfacing


@ necolei
transmit(unsigned char *a) is a function which is called from main program and *a shows the pointer which points the array which is send from main program.
while(*a!='\0') shows that loop till the last character of array will not be null.
SBUF=*a; it shows that transmit character of array at microcontroller TX pin SBUF is internal register of 8051 microcontroller.
while(TI==0); means stay here till charater which is in SBUF not transmitted when it is transmitted it interupts and TI=1.
TI=0; means ready to transmit next character.
a++; increment in array.

hope u will understand.
GoodLuck
Back to top
necolei



Joined: 26 Oct 2007
Posts: 25
Helped: 1


Post03 Nov 2007 9:02   

Re: writing code for mobile interfacing


abbas1707 wrote:
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;
}Very Happy


Hi

I can't understand SBUF what is it used for because I'm uisng a different microcontroller and I also need this code.

Regards,

Necolei
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> writing code for mobile interfacing
Page 1 of 2 All times are GMT + 1 Hour
Goto page 1, 2  Next
Similar topics:
writing C code for 8051 (2)
Writing Optimized C Code for Microcontroller Applications (2)
Problem with writing C code for handling interrupt (1)
verilog code for reading and writing a textfile (1)
stuck writing code for pic side of usb project (10)
Help needed for PIC18f4520 in writing switches programe code (1)
Writing code for different bit rates in one of application (2)
FREE, EASY CODE WRITING For MPLAB Users.(New Ver.) (6)
i need help writing c code for ccs c compiler usig pic16f877 (3)
FREE, EASY CODE WRITING For MPLAB Users.(Source View Helper) (23)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS