Design of 4-digit digital thermometer based on 51 single chip microcomputer

Publisher:BlissfulMoonLatest update time:2021-05-25 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Basic knowledge of temperature sensor AD590


The current generated by AD590 is proportional to the absolute temperature. It can accept an operating voltage of 4V-30V and a detection temperature range of -55℃-+150℃. It has very good linear output performance. For every 1℃ increase in temperature, its current increases by 1uA.


The relationship between AD590 temperature and current is shown in the following table



2. Circuit diagram



Figure 4.30.1


3. Hardware connections on the system board


(1) Connect P1.0-P1.7 in the "MCU System" area to the ABCDEFGH ports in the "Dynamic Digital Display" area using an 8-core cable.


(2) Connect P2.0-P2.7 in the "MCU System" area and S1S2S3S4S5S6S7S8 in the "Dynamic Digital Display" area with an 8-core cable.


(3) Connect P3.0 in the "MCU System" area to the ST terminal in the "Analog-to-Digital Conversion Module" area with a wire.


(4) Connect P3.1 in the "MCU System" area to the OE terminal in the "Analog-to-Digital Conversion Module" area with a wire.


(5) Connect P3.2 in the "MCU System" area to the EOC terminal in the "Analog-to-Digital Conversion Module" area with a wire.


(6) Connect P3.3 in the "MCU System" area to the CLK terminal in the "Analog-to-Digital Conversion Module" area with a wire.


(7) Connect the A2A1A0 terminals in the "Analog-to-Digital Conversion Module" area to the GND terminals in the "Power Module" area with wires.


(8) Connect the IN0 terminal in the “Analog-to-Digital Conversion Module” area to the self-made AD590 circuit with a wire.


(9) Connect P0.0-P0.7 in the "MCU System" area to the D0D1D2D3D4D5D6D7 terminals in the "Analog-to-Digital Conversion Module" area using an 8-core cable.


4. Programming content


(1) The CLK signal of ADC0809 is provided by the P3.3 pin of the microcontroller.


(2) Since the temperature range of AD590 is between -55℃ and +150℃, the voltage sampled after passing through 10KΩ varies between 2.182V and 4.232V, which does not exceed the range represented by the 5V voltage. Therefore, the reference voltage is the power supply voltage VCC (measured VCC = 4.70V). From this, the Celsius temperature display data after A/D conversion can be calculated as:


If (D*2350/128) < 2732, the displayed temperature value is - (2732 - (D*2350/128))


If (D*2350/128)≥2732, the displayed temperature value is +((D*2350/128)-2732)


5. C language source program

#include

#include


unsignedcharcodedispbitcode[]={0xfe,0xfd,0xfb,0xf7,

0xef,0xdf,0xbf,0x7f};

unsignedcharcodedispcode[]={0x3f,0x06,0x5b,0x4f,0x66,

0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40};

unsignedchardispbuf[8]={10,10,10,10,10,10,0,0};

unsignedchardispcount;

unsignedchargetdata;

unsignedlongtemp;

unsignedchari;

bitsflag;


sbitST=P3^0;

sbitOE=P3^1;

sbitEOC=P3^2;

sbitCLK=P3^3;

sbitLED1=P3^6;

sbitLED2=P3^7;

sbitSPK=P3^5;



voidmain(void)

{

ST=0;

OE=0;

TMOD=0x12;

TH0=0x216;

TL0=0x216;

TH1=(65536-4000)/256;

TL1=(65536-4000)%256;

TR1=1;

TR0=1;

ET0=1;

ET1=1;

EA=1;

ST=1;

ST=0;

getdata=148;

while(1)

{

;

}

}


voidt0(void)interrupt1using0

{

CLK=~CLK;

}


voidt1(void)interrupt3using0

{


TH1=(65536-4000)/256;

TL1=(65536-4000)%256;


if(EOC==1)

{

YOU=1;

getdata=P0;

OE=0;

temp=(getdata*2350);

temp=temp/128;

if(temp<2732)

{

temp=2732-temp;

sflag=1;

}

else

{

temp=temp-2732;

sflag=0;

}

i=3;

dispbuf[0]=10;

dispbuf[1]=10;

dispbuf[2]=10;

if(sflag==1)

{

dispbuf[7]=11;

}

else

{

dispbuf[7]=10;

}

dispbuf[3]=0;

dispbuf[4]=0;

dispbuf[5]=0;

dispbuf[6]=0;

while(temp/10)

{

dispbuf[i]=temp%10;

temp=temp/10;

i++;

}

dispbuf[i]=temp;

ST=1;

ST=0;

}


P1=dispcode[dispbuf[dispcount]];

P2=dispbitcode[dispcount];

dispcount++;

if(dispcount==8)

{

dispcount=0;

}

}


Reference address:Design of 4-digit digital thermometer based on 51 single chip microcomputer

Previous article:Circuit structure of P0 port of 51 single chip microcomputer
Next article:Wireless apnea monitoring system based on nRF4O1

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号