embedded control and monitoring temperature

Status
Not open for further replies.

zarin

Newbie level 1
Joined
May 1, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
hello..
i'm a final year student and doing embedded system.

overview of my project:
-lcd display instuction for user key-in temperature
-4x4 numeric keypad is used
-thenthe data send to microcontroller. i use microcontroller AT89s51
-then the output from AT89s51 send to DAC and DAC will activate power stage
-power stage will active the room heater.


my problem is:
-i already design the shematic but have some doubt about the connection. i design in proteus but in designation i use at89c51.
-also,i learn the programming of lcd and try to run the simulation as suggested but the problem is the lcd do not display the character.

here i attached my schematic and lcd simulation.

#include<AT89X51.H>
#include<intrins.h>
#include<string.h>
#include<stdio.h>
#define lcd_port P0
#define lcd_busy_flag P0_7
#define RS P0_0
#define RW P0_1
#define EN P0_2
#define RS_LOW 0x00
#define RS_HIGH 0x01
#define RW_LOW 0x00
#define RW_HIGH 0x02
#define EN_LOW 0x00
#define EN_HIGH 0x04

void delay_100us();
void delay_x100us(unsigned int);
void delay_1ms();
void delay_ms(unsigned int);
void delay();


void write_data(unsigned char nilai);
void write_command(unsigned char nilai);
void write_pesan(unsigned char *value);
void write_pesan_dengan_delay(unsigned char *value);
void initialization();

void key_init(void);


void write_data(unsigned char nilai)
{
unsigned char hasil;
hasil = nilai & 0xF0;
lcd_port = (hasil | RS_HIGH | RW_LOW | EN_HIGH );
delay();
lcd_port = (hasil| RS_HIGH | RW_LOW | EN_LOW );
delay();
hasil = ((nilai<<4) & 0xF0);
lcd_port = (hasil | RS_HIGH | RW_LOW | EN_HIGH );
delay();
lcd_port = (hasil | RS_HIGH | RW_LOW | EN_LOW );
delay();
delay_x100us(6);

}
void write_command(unsigned char nilai)
{
unsigned char hasil;
hasil = nilai & 0xF0;
lcd_port = (hasil | RS_LOW | RW_LOW | EN_HIGH );
delay();
lcd_port = (hasil | RS_LOW | RW_LOW | EN_LOW );
delay();
hasil = ((nilai<<4) & 0xF0);
lcd_port = (hasil| RS_LOW | RW_LOW | EN_HIGH );
delay();
lcd_port = (hasil | RS_LOW | RW_LOW | EN_LOW );
delay();
delay_x100us(6);

}

void write_pesan(unsigned char *value)
{
unsigned char k,i;
k=strlen(value);
for(i=0;i<k;i++)
{
write_data(*value);
value++;
}
}

void write_pesan_with_delay(unsigned char *value)
{
unsigned char k,i;
k=strlen(value);
for(i=0;i<k;i++)
{
write_data(*value);
delay_ms(10);
value++;
}
}


void initialization()
{

delay_ms(15);
write_command(0x30); //step startup
delay_ms(10);
write_command(0x30); //step startup
delay_ms(5);
write_command(0x30); //step startup
delay_ms(5);
write_command(0x20);
delay_ms(5);
write_command(0x28); // 4 bit, 2 line, 5x7 dot
delay_ms(5);
write_command(0x0c);
delay_ms(1);
write_command(0x06);
delay_ms(1);


}



void delay_1ms()
{
TMOD=0;
TH0=0x1C;
TL0=0x17;
TR0=1;
while(!TF0);
TF0=0;
TR0=0;
}

void delay_ms(unsigned int x)
{
unsigned int i;
for(i=0;i<x;i++)
{
delay_1ms();
}
}



void delay_100us()
{
TMOD=0x02;
TH0=0x9B;
TR0=1;
while(!TF0);
TF0=0;
TR0=0;
}

void delay_x100us(unsigned int x)
{
unsigned int i;
for(i=0;i<x;i++)
{
delay_100us();
}
}

void delay()
{
_nop_(); _nop_(); _nop_();//_nop_(); _nop_(); _nop_();
//_nop_(); _nop_(); _nop_();_nop_(); _nop_(); _nop_();
}
main()
{
unsigned int i;
delay_1ms();
initialization();
write_command(0x01);
delay_1ms();
while(1)
{
write_command(0x81);
delay_1ms();
write_pesan("hello enter") ;
delay_1ms();
write_command(0xC3);
delay_1ms();
write_pesan("temperature:") ;
delay_1ms();
write_command(0x0C);
delay_ms(500);
write_command(0x01);
delay_1ms();
//display one by one
write_command(0x81);
delay_1ms();
write_pesan_with_delay("hello enter") ;
delay_1ms();
write_command(0xC3);
delay_1ms();
write_pesan_with_delay("temperature:") ;
delay_1ms();
write_command(0x0C);
delay_1ms();
delay_ms(500);
write_command(0x01);
delay_ms(100);
for(i=0;i<5;i++)
{
write_command(0x81);
delay_1ms();
write_pesan("hello enter") ;
delay_1ms();
write_command(0xC3);
delay_1ms();
write_pesan("temperature:") ;
delay_1ms();
write_command(0x0C);
delay_ms(20);
write_command(0x01);
delay_ms(20);
}

write_command(0x01);
delay_1ms();

}

}


 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…