Home > other >  Adc0809 and lcd12864 temperature measurement
Adc0809 and lcd12864 temperature measurement

Time:10-03

Why I use pt100 and adc0809 and 12864 measuring temperature, which cannot be updated in real time and the temperature
Below is the code # include & lt; Reg51. H>
# include & lt; Intrins. H>
# define uint unsigned int
# define uchar unsigned char
Uint volt, vtime dianya, wd;//voltage measurements
Uint sx, xx, SXGW, SXSW, XXGW, XXSW, SJSW, SJGW, SJXS;//upper and lower temperature
Uchar wendu;
# define the volt P1//ADC0809 module D0 - D7 respectively by P3.0 - P3.7
/* TS12864A - 3 port definitions */
# define LCD_data P0/mouth/data
Sbit LCD_RS=P3 ^ 5;//register select input
Sbit LCD_RW=P3 ^ 6;//LCD read/write control
Sbit LCD_EN=P3 ^ 4;//LCD that can control the
Sbit LCD_PSB=P3 ^ 7;//string and the method of controlling the
Sbit wela=P2 ^ 6;
Sbit dula=P2 ^ 7;
Sbit CLK=P2 ^ 4;//the clock signal
Sbit START=P2 ^ 5;//conversion start switch
Sbit EOC=P2 ^ 1;//conversion end mark
Sbit OE=P2 ^ 2;//define ADC0809 feet
Sbit S3=P3 ^ 0;
Sbit S5=P3 ^ 1;
Sbit kc=P2 ^ 0;
Sbit gc=P3 ^ 3;

Uchar code dis1 []={" 0123456789 V "};
Uchar code dis2 []={" 0123456789 V "};
Uchar code dis3 []={" 0123456789 V "};
# define delayNOP (); {_nop_ (); _nop_(); _nop_(); _nop_(); };
Uchar IRDIS [2].
Uchar IRCOM [4].
Void delay0 (uchar x);//* 0.14 MS x
Void beep ();
Void dataconv ();
Void lcd_pos (uchar X, uchar Y);//determine the display position
Void the timer ();
Void the display (uchar WD);
Void display1 (uint sx);
Void display2 (uint xx);
Void keyscan ();
Void wdscan ();

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* */delay function
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void delay (int ms)
{
While (ms -)
{
Uchar I;
for(i=0; i<250; I++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//the function name: ADC ()
//function: d/a conversion program
//the function:
//input parameters:
//output parameters:
//description: the converted measurement values stored in the variable volt
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
ADC (void)
{
OE=0;
START=0;
Delay (20);

START=1;
Delay (20);

START=0;//AD began to convert
Delay (20);
While (0==EOC);//wait for conversion end
{

}
OE=1;//output data flag is true
EA=0;//off interrupt
The volt=P1;//get conversion is stored into the volt, (P1) for the transformed data
Dianya=volt;//conversion value processing (example, the full range of 5 v conversion resolution for eight maximum is 255, 5/255=19.6 mV, namely 1 represents 19.6 mV)
OE=0;//output end of conversion (to get) after conversion value
EOC=~ EOC.//I
Wendu=dianya;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* check LCD busy state */
/* lcd_busy to 1, busy, waiting, 0 for LCD - busy, idle, can be written instructions and data, */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Bit lcd_busy ()
{
Bit result;
LCD_RS=0;
LCD_RW=1;
LCD_EN=1;
DelayNOP ();
Result=(bit) (P0 & amp; 0 x80);
LCD_EN=0;
Return (result);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* writing instruction data to the LCD */
/* RS=L, RW=L, E=high pulse, D0 - D7=order code, */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void lcd_wcmd (uchar CMD)
{
While (lcd_busy ());
LCD_RS=0;
LCD_RW=0;
LCD_EN=0;
_nop_();
_nop_();
P0=CMD;
DelayNOP ();
LCD_EN=1;
DelayNOP ();
LCD_EN=0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* write data to the LCD */
/* RS=H, RW=L, E=high pulse, D0 - D7=data, */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void lcd_wdat (uint dat)
{
While (lcd_busy ());
LCD_RS=1;
LCD_RW=0;
LCD_EN=0;
P0=dat;
DelayNOP ();
LCD_EN=1;
DelayNOP ();
LCD_EN=0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* LCD initialization setting */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void lcd_init ()
{

LCD_PSB=1;//parallel way

Lcd_wcmd (0 x34);//expanded instruction
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related