Forum Replies Created
-
AuthorPosts
-
SagarParticipant
unsigned int a;
a=TH0;
a<<=8; //left shift higher byte by 8 bits
a|=TL0; //merge lower bytes using OR
SagarParticipantplease post your source code and schematic.
SagarParticipantare you using the same schematic as mentioned there ?
the method implemented there is called as persistence of vision. so your project might be working and 7 segment leds are glowing with very less intensity. (although transistors are used there to increase source current this shouldn’t be happening). try using red gelatin or glass type material to overlay 7 segment.
SagarParticipantno you won’t find null character at the end.
if u study the formatted data you are receiving from gsm modem u will find that for every command executed successfully, the last few data bytes are OKrn and for those having errors like say i am reading message from sim memory location 1 and message does not exist there
AT+CMGR=1
+CMS ERROR: 517rnthats what you have to wait for (OKrn or error messages depending on AT commands u used).
you may need to manually put the null character for string comparision. (depends on your programming)
Happy Programming
May 28, 2013 at 8:58 pm in reply to: problem with program of ATmega16 for sms based device control #9850SagarParticipanthi shashank.
i think you moved from your previous thread to hear.
any how.
the function prototype for compr_strng() function your wrote is
void compr_strng();
however your function defination is
/**********************************************/
int compr_strng() // Function to string comparison.
{
char on[10],off[10], msg[10], result,fresult;
result = compare_string1(on, msg);
if(result==0)
{
fresult=1;
return fresult;
}
result = compare_string2(off,msg);
if ( result == 0 )
{
fresult=0;
return fresult;
}/************************************************/
“void” and “int” return type.
i went through code and found you are using multiple function for string comparision compare_string1 and compare_string2 (also finction prototype for these function is not defined), i don’t know for what reason you are doing so. both functions looks similar. i don’t think you wrote this code.
in function main you are calling undefined function uart_init. may be u miss typed it.(usart_init()).
you are passing pointer to string to function usart_putch() which accepts single charecter. so bascically you are passing address which then turns character (maps between 0 to 255).
i think first you need to study on some terminal how formatted data is received from GSM modem.
May 28, 2013 at 1:44 pm in reply to: how to show longtitude & latitude from gps to lcd 16×2 with atmega 128 #9849SagarParticipantSubmit your error logs along with C source code.
May 27, 2013 at 1:53 pm in reply to: problem with flash magic/interfacing DTMF 9170 with microcontroller #9835SagarParticipantwhich variant of 8051 you are using ?
SagarParticipanti don’t have a program for atmega16. actually i wrote one for RD2 uC and it worked great for me. the logic remains same.
set up usart (check atmeg16 usart tutorial) with 9600 baud rate.
write serial send and serial receive function.
the next thing is to set your modem in text mode format.
the command to do so is AT+CMGF=1
now whenever a new sms is received u’ll recv this string
+CMTI: “SM”,1
where SM indicates sim card and 1 is the memory location.
you have to collect these bytes in charecter array one by one.
then to read sms send this command AT+CMGR=1
after executing this command you will get your sms charecters 1 by 1.
study the message format in some terminals (like senders no and newline blah blah). i used putty. extract the string and then write/use function strcmp function.
Hope you are good at writing c codes. check out ur modem datasheet.
all the best.
April 26, 2012 at 8:13 pm in reply to: How to Load program on 89c51 using only tx/rx of rs232 .? help and give software to load file. #7550SagarParticipanthi paras. i think bootcode of at89c51 does not support program uploading via rs232 protocol. unlike p89v51rd2, AT89c51 lacks with ISP feature.
SagarParticipantproteus is pcb layout designing software. isn’t it ? what ur looking 4 ?
SagarParticipantya it is same. In Keil use sbit to define port pins instead of macros.
December 6, 2011 at 1:34 pm in reply to: problem regarding interfacing LCD using ATMEGA16 code by CHINMAY CHINARA #6913SagarParticipanthey guys solved my problem…. !
this is wat i did.
added little delay betwn two instruction of enable pin.
@query : add _delay_ms(1); after each high to low pulse for enable pin.
surely this will work for you.
December 6, 2011 at 9:40 am in reply to: problem regarding interfacing LCD using ATMEGA16 code by CHINMAY CHINARA #6912SagarParticipantm having same problem with JHD162A ATmega16
heres the code…
//#define F_CPU 16000000
#include <avr/io.h>
//#include <util/delay.h>#define lcd_data PORTB
/*
PD.0=rs
PD.1=rw
PD.2=en*/
void lcdbusy() //function to monitor d7th bit (busy flag)
{
DDRB=0x7f;// this will make msb of portb to inputPORTD=0xfe;// rs=0 rw=1 en=1, rw=1->read from lcd
while(PINB>>7) //move the msb to lsb
{PORTD |=0x04; //en-> from low to high
PORTD &=0xfb; //en-> from high to low
}DDRB=0xff;//make PORTB for output
}
void initlcd()
{
DDRD=0xff; //PORTD as output
DDRB=0xff; //portb as output
lcd_data=0x38; //8 bit,5×7 dots
PORTD=0xfc; //rs=0 rw=0 en=1, 0xfc where c=1100
PORTD=0xf8; //rs=0 rw=0 en=0, 0xf8 where 8=1000, frm en->high to lowlcdbusy(); // w8 b4 executing next command
lcd_data=0x0f; //cursor blinking display on
PORTD=0xfc;
PORTD=0xf8;lcd_data=0x01; // clear lcd
PORTD=0xfc;
PORTD=0xf8;lcdbusy();
lcd_data=0x06; //entry mode
PORTD=0xfc;
PORTD=0xf8;lcdbusy();
}void lcdcmd(unsigned char ch)
{
lcd_data=ch;
PORTD=0xfc;
PORTD=0xf8;lcdbusy();
}void lcdchar(unsigned char ch)
{
lcd_data=ch;
PORTD=0xfd; // 0xfd where d=1101 rs=w rw=0 en=1
PORTD=0xf9; //9=1001 rs=1 rw=0 en=0, en-> from high to low
lcdbusy();
}void lcdstring(char *str)
{
while(*str)
{
lcdchar(*str);
str++;
}
}int main()
{
initlcd();
lcdcmd(0x80);// move cursor to 1st line 1st column
lcdstring(“Welcome ATmega16 !”);while(1);
return 0;
}
m i missing something ?
-
AuthorPosts