Forum Replies Created
-
AuthorPosts
-
RUBEN KURIAKOSEParticipant
Check it one by one. First check the LCD-microcontroller interfacing. Before that you can check the working of microcontroller and your programmer by a sample LED blinking program. Then interface GSM modem to mc and if all works properly burn the full program to IC and check output.
RUBEN KURIAKOSEParticipantCan you show me the circuit diagram used. I come with a similar problem.
April 20, 2013 at 4:59 am in reply to: how to convert the program to generate sound using micro controller 8051 into hex code?? #9537RUBEN KURIAKOSEParticipanthi;
In Keil u-vision,right click on ‘Target’ and options for target will allow you to create a .hex file in the output window.
You should use a programmer or a burner to burn this hex code into the microcontroller.
RUBEN KURIAKOSEParticipantThe LCD interfacing program is also available on engineers garage.
eg :
//Program to test LCD. Display single character "A"
#include<reg51.h>
#define cmdport P3
#define dataport P2
#define q 100
sbit rs = cmdport^0; //register select pin
sbit rw = cmdport^1; // read write pin
sbit e = cmdport^6; //enable pin
void delay(unsigned int msec) // Function to provide time delay in msec.
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char item) //Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
}
void lcddata(unsigned char item) //Function to send data to LCD
{
dataport = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
}
void main()
{
lcdcmd(0x38); // for using 8-bit 2 row mode of LCD
delay(100);
lcdcmd(0x0E); // turn display ON for cursor blinking
delay(100);
lcdcmd(0x01); //clear screen
delay(100);
lcdcmd(0x06); //display ON
delay(100);
lcdcmd(0x86); // bring cursor to position 6 of line 1
delay(100);
lcddata('A');
}
RUBEN KURIAKOSEParticipantHi;
You will get the code from engineers garage site that might help you for the project.
GSM interfacing.
// Program to interface GSM Module with 8051 microcontroller (AT89C51) using PC and LCD
#include<reg51.h>
#define port P1
#define dataport P2 // Data port for LCD
sbit rs = port^0;
sbit rw = port^1;
sbit en = port^2;
int count,i;
unsigned char check,str[15];
bit check_space ;
void init_serial() // Initialize serial port
{
TMOD=0x20; // Mode=2
TH1=0xfd; // 9600 baud
SCON=0x50; // Serial mode=1, 8-Bit data, 1 Stop bit, 1 Start bit, Receiving on
TR1=1; // Start timer
}
void delay(unsigned int msec ) // Function for delay
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0; j<1275; j++);
}
void lcd_cmd(unsigned char item) // Function to send command on LCD
{
dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void lcd_data(unsigned char item) // Function to display character on LCD
{
dataport = item;
rs= 1;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void lcd_data_string(unsigned char *str) // Function to display string on LCD
{
int i=0;
while(str!=' ')
{
lcd_data(str);
i++;
delay(10);
}
return;
}
void lcd()
{
lcd_cmd(0x38); // For using 8-bit 2 row LCD
delay(5);
lcd_cmd(0x0F); // For display on, cursor blinking
delay(5);
lcd_cmd(0x80); // Set the cursor on first position of lcd
delay(5);
}
void receive_data() interrupt 4 // Function to recieve data serialy from RS232 into microcontroller
{
str[++count]=SBUF; //Read SBUF
RI=0;
}
unsigned char byte_check() //Function to check carraige return and new line character
{
switch(str[0])
{
case 0x0a:
{ // Return 0x00 for new line
return 0x00;
break ;
}
case 0x0d:
{ // Return 0x01 for carriage return
return 0x1;
break ;
}
default:return 0x02 ; // Return 0x02 for characters except new line and carriage return
}
}
void main()
{
lcd(); // Initialize LCD
init_serial(); // Initialize serial port
count=(-1);
lcd_data_string("Ready");
delay(10);
lcd_cmd(0x01);
IE=0x94;
while(1)
{
if(count>=0)
{
check=byte_check(); //Check the character
if(check!=0x00)
{
if(check==0x01)
{
if(check_space==1) //Check previous character
{
lcd_data(0x20);
check_space=0;
}
}
else
{
lcd_data(str[0]);
check_space=1;
}
}
count--;
for(i=0;i<count;i++) // Shift the whole array to one left
{
str=str[i+1];
}
}
}
}
RUBEN KURIAKOSEParticipantDid you check it any compiler.(Kiel u-vision).
RUBEN KURIAKOSEParticipantThe c program i used is given below. But while compiling it there shows an error ‘DATA SEGMENT EXEEDS’. When i decrease the size of array a[161] it shows no error. But the loop works on 161.
#include <REGX51.H>
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
void lcd_command(unsigned char);
void lcd_data(unsigned char);
void string(unsigned char *disp);
void delay(unsigned int);
void read(char*);
void newline();
void display (char);
void send();
void serial();
void nextline(unsigned char);
void nextline1(unsigned char);
void nextline2(unsigned char);
sfr chdata=0xA0;
void lcdnewline();
char a[161];
char b[13];
int i,j,z,k,l,f=0;
void main()
{
P0=0x00;
P1=0x00;
P2=0xFF;
delay(100);
lcd_command(0x38);
delay(100);
lcd_command(0x80);
delay(100);
lcd_command(0xc0);
delay(100);
lcd_command(0x0e);
delay(100);
lcdnewline();
serial();
read(“AT”);
newline();
read(“AT+CMGF=1”);
newline();
lcdnewline();
read(“AT+CMGD=1”);
newline();
lcdnewline();
while(1)
{
lcd_command(0x83);
string(“NOTICE BOARD”);
for(i=0;i<=13;i++)
{
while(RI==0);
b=SBUF;
RI=0;
}
lcdnewline();
string(“Command Signal”);
if((b[2]==’+’)||(b[3])==’+’)
{
if((b[3]==’C’)||(b[4])==’C’)
{
if((b[4]==’M’)||(b[5]==’M’))
{
if((b[5]==’T’)||(b[6])==’T’)
{
if((b[6]==’I’)||(b[7])==’I’)
{
lcd_command(0xC4);
string(“received”);
lcdnewline();
//delay(300);
read(“AT+CMGF=1”);
newline();
read(“AT+CMGR=1”);
newline();
newline();
//newline();
//newline();
for(l=0;l<=161;l++)
{
while(RI==0);
a[l]=SBUF;
RI=0;
}
for(l=60;l<=161;l++)
{
f=1;
if(a[l]==’a’)
{
k=0;
do
{
k++;
l++;
if(k<=20)
{
lcd_data(a[l]);
}
if((k>20) && (k<=40))
{
nextline(f);
lcd_data(a[l]);
f++;
}
if((k>40) && (k<=60))
{
nextline1(f);
lcd_data(a[l]);
f++;
}
if((k>60) && (k<=80))
{
nextline2(f);
lcd_data(a[l]);
f++;
}
} while(a[l]!=’$’);
l=162;
break;
}
//break;
}
delay(65000);
}
}
}
}
}
} /* while end here*/
} /* MAIN ends here*/
/* PROTOTYPE FUNCTIONS */
void lcd_command(unsigned char value)
{
chdata=value;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}
void lcd_data(unsigned char value)
{
chdata=value;
rs=1;
rw=0;
en=1;
delay(150);
en=0;
}
void read(char *ch)
{
int i;
for(i=0;ch!=’