pt100测温程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

下载后可显示仿真图片,网上观看可能不支持图片

#include"at89X52.h"

sbit LCD_RS =P2^0;

sbit LCD_RW =P2^1;

sbit LCD_E =P2^2;

sbit ADC_CS =P2^3;

sbit ADC_WR =P3^6;

sbit ADC_RD =P3^7;

#define LCD_DATA P0

unsigned char LcdBuf1[10]="";

unsigned char code Bmp001[][8]=

{

{0x06,0x09,0x09,0x06,0x00,0x00,0x00,0x00}, {0x06,0x09,0x10,0x10,0x10,0x09,0x06,0x00} };

void dellay(unsigned int h)

{

while(h--); //0.01MS

}

void WriteDataLcd(unsigned char wdata)

{

LCD_DATA=wdata;

LCD_RS=1;

LCD_RW=0;

LCD_E=0;

dellay(1000);

LCD_E=1;

}

void WriteCommandLcd(unsigned char wdata)

{

LCD_DATA=wdata;

LCD_RS=0;

LCD_RW=0;

LCD_E=0;

dellay(1000);

LCD_E=1;

}

void lcd_init(void)

{

LCD_DATA=0;

WriteCommandLcd(0x38);

dellay(1000);

WriteCommandLcd(0x38);

dellay(1000);

WriteCommandLcd(0x01);

WriteCommandLcd(0x0c);

}

void display_xy(unsigned char x,unsigned char y)

{

if(y==1)

x+=0x40;

x+=0x80;

WriteCommandLcd(x);

}

void display_string(unsigned char x,unsigned char y,unsigned char *s) {

display_xy(x,y);

while(*s)

{

WriteDataLcd(*s);

s++;

}

}

void Write_CGRAM(unsigned char add,unsigned char *char_num)

unsigned i;

add=add<<3;

WriteCommandLcd(0x40|add+8);

for(i=0;i<8;i++)

{

WriteDataLcd(*char_num++);

}

}

void delayms()

{

int i;

for(i=110;i>0;i--);

}

void delay1s()

{

int i,j;

for(i=1000;i>0;i--);

for(j=110;j>0;j--);

}

void convert()

{

unsigned long value;

char i;

unsigned long res;

int temp,temp2;

int w;

P1=0xff;

ADC_RD=0;

for(i=0;i<10;i++);

value=P1;

res=(float)(2550000+110000*value/30)/(2550-11*value/30); temp=(float)(res*10000-10000000)/3851-545;

temp2 = temp;

if(temp >= 0)

{

for(i=6;temp>0;i--)

{

LcdBuf1[i]=temp%10+48;

temp/=10;

}

}

if(temp < 0 )

{

w= -temp;

for(i=6;w>0;i--)

{

LcdBuf1[i]=w%10+48;

w/=10;

}

}

if(i>=0&&temp<0)

{

if(temp > -10)

{

LcdBuf1[i] = '0';

i--;

}

LcdBuf1[i] = '-';

i--;

/* if(i==5)

{

LcdBuf1[5] = '0';

i --;

}

LcdBuf1[4] = '-';

i--; */

}

for(;i>=0;i--)

LcdBuf1[i]=' ';

for(i=0;i<5;i++)

LcdBuf1[i]=LcdBuf1[i+1];

if(LcdBuf1[4]==' ')LcdBuf1[4]='0'; LcdBuf1[5]='.';

LcdBuf1[7]=1;

LcdBuf1[8]='C'; WriteCommandLcd(0x84); display_string(3,0,LcdBuf1); ADC_RD=1;

ADC_WR=0;

for(i=0;i<10;i++)

相关文档
最新文档