Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

sms based control of home appliances

Status
Not open for further replies.

erminesh11

Newbie level 4
Joined
Apr 16, 2011
Messages
6
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,316
im placing my code here that i used to communicate atmega16 with pc on hyperteminal. it is working fine. my concern is regarding using at commands in my code. how could i start...

Code:
#define F_CPU 16000000UL
 
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
 
#include<avr/io.h>
#include<util/delay.h>

void usart_init();
void usart_putch(unsigned char send);
unsigned int usart_getch();
 
int main()
{
	unsigned char value;
	DDRD=0xff;
	DDRA=0xff;		
	DDRB=0x07;		
	
	_delay_ms(50);		// delay of 50 mili seconds
	usart_init();		// initialization of USART
	while(1)
	{

	value=usart_getch();
	usart_putch(value);	
	}
	return 0;
}
 

 
void usart_init()
{
	UCSRB |= (1 << RXEN) | (1 << TXEN);   
					// Turn on the transmission and reception circuitry
	UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1); 
					// Use 8-bit character sizes
 
	UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value..
							// into the low byte of the UBRR register
	UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
									// into the high byte of the UBRR register
}
 
void usart_putch(unsigned char send)
{
	while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
							// for more data to be written to it
	UDR = send; // Send the byte 
}
 
unsigned int usart_getch()
{
	while ((UCSRA & (1 << RXC)) == 0);
				// Do nothing until data have been received and is ready to be read from UDR
	return(UDR); // return the byte
}
 

erminesh11

Newbie level 4
Joined
Apr 16, 2011
Messages
6
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,316
had a lot of search..... unable to find specific coding procedure for atmega16...

---------- Post added 17-04-11 at 00:39 ---------- Previous post was 16-04-11 at 23:16 ----------

can anyone provide me solution for this....????
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
there are many solutions for 8051... please dont tell you did not find it... from years i am giving solution for it... atmega is not much different from 8051... take the code and guidelines procedure and modify it for your controller....

refine your search and find a solution..... cant expect a readymade solution here....... post your code and circuit and tell what is your problem.. we may help you.........
 

sherazi

Banned
Joined
Feb 15, 2010
Messages
388
Helped
61
Reputation
126
Reaction score
61
Trophy points
1,318
Location
Muscat, Oman, Oman
Activity points
0
you should first mention which module u want to use , .. the first place is to look at the modules user manual ... it will show u what At cammands to use ...

sending an at command to a module is just like u send any data to serial port or hyperterminal as far as code is concerned ... search 8051projects.net for gsm and u will get lots of results ! if u still dont get started .... tell us what u dont understand and what u understood?
 

erminesh11

Newbie level 4
Joined
Apr 16, 2011
Messages
6
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,316
yes sir... i know that... if i get a readymade code then how will i learn to write it.... as you can see i had already posted the code. im not good in c programming. im having trouble in how to use the at commands in the code.. i had gone through a lot of posts..no doubt they are much helpful.. but still im facin prob...

---------- Post added at 19:15 ---------- Previous post was at 19:12 ----------

hello sherazi, thanx....im having problem in using the at commands in the code. im using sim300 gsm module. everything is working perfect... only concern is how i should program atmega16 to act like a hyperterminal...?
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
in a simple way , assuming that you know how to write serial communication program...

write a serial comm program, where you send AT in your program... then wait for serial data to be received... compare the incoming data with character 'K' (type OK from hyperterminal). if it is K then send next at command and again wait for response from hyperterminal.....

if you can write this program then there is nothing else to write for GSM......
 

[xx]eternal

Newbie level 1
Joined
Apr 6, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
Hi im also doing a similar project.Im using pic16f877a and a Sony Ericsson K750i phone as my receiver.I use the unused SE data cable DCU-60 and make some modification(I peel off the rubber exterrior)and had managed to determine all the pins connected with the wires inside.the pins for the data cable is as follow:
Sony Ericsson C702, C902, C905, F305, G502, G700, G705, G900, K205i, K310i, K320i, K330, K510i, K530i, K550i, K610i, K630i, K660i, K750i, K770i, K790i, K800i, K810i, K850i, M600i, P1i, P990i, R300, R306, S302, S500i, T303, T650i, T700, W200i, W300i,

my problem is to which pins should i connect in order to have serial communication with my MCU(is that DTMS/DFMS or CTMS/CFMS)??BTW i knew tat both CTMS and CFMS is used as DATA+/DATA- for USB protocols,since pic16f877a doesnt have USB module I assume i cannot connect CTMS/CFMS to my circuit.I had also tried DTMS/DFMS but stil cant managed to get any result.

my circuit is as follow:

pic(tx)------->k750(DTMS);
pic(rx)-------->k750(DFMS);

the following code is a first stage tester,which mean if i can get the message stored in my phone i am succeed.pls help......
void main()
{
unsigned char temp;
unsigned char a;
unsigned char b;
//set I/O input output
TRISB = 0b00000011; //configure PORTB I/O direction
TRISD = 0b00000000; //configure PORTD I/O direction


//Configure UART
SPBRG=129; //set baud rate as 9600 baud
BRGH=1; //baud rate high speed option
TXEN=1; //enable transmission
TX9 =0; //8-bit transmission
RX9 =0; //8-bit reception
CREN=1; //enable reception
SPEN=1; //enable serial port
temp=RCREG;
temp=RCREG;

while(1)
{
if(SW1==0)
{
delay(10000);
sync();
uart_str("AT+CMGW=24");

uart_send(0x0D);

uart_str("079106xxxxxxx11000A9xxxxxxxx000AA0CC8F71D14969741F977FD07");

uart_send(0x1A);
led1=!led1;
delay(5000);
}
}
}

======================================================
void sync(void)
{
unsigned char c;
c = 'u';
for( ;c>128;c--)
{
uart_send(c);
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top