30. Four-digit digital thermometer

Publisher:梦想学院Latest update time:2016-09-22 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 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 the temperature and current of AD590 is shown in the following table Celsius 
temperature 
AD590 Current 
through 10KΩ Voltage 
0℃ 
273.2 uA 
2.732V 
10℃ 
283.2 uA  2.832
V  20
℃ 
293.2 uA 
2.932 V 
30℃ 
303.2 uA 
3.032 V 
40℃ 
313.2  uA 3.132  V 50℃  323.2 uA 
3.232  V 60℃  333.2 uA  3.332 V  100℃  373.2 uA  3.732 V  AD590 pin diagram  2.  Experimental task  Use the AD590 temperature sensor to complete the temperature measurement, send the converted temperature value to one of the channels of ADC0809 for A/D conversion, and convert the conversion result into temperature value and send it to the digital tube for display.  3.  Circuit schematic diagram 










   



 
Figure 4.30.1
4.  Hardware connection 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 with an 8-core cable. 
(2). Connect P2.0-P2.7 in the "MCU system" area to the S1S2S3S4S5S6S7S8 ports 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 terminal in the "Power module" area with a wire. 
(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 with an 8-core cable. 
5.  Program design content 
(1) The CLK signal of ADC0809 is provided by the P3.3 pin of the MCU 
(2). Since the temperature range of AD590 is between -55℃ and +150℃, the voltage sampled after 10KΩ varies between 2.182V and 4.232V, which does not exceed the range represented by 5V voltage. Therefore, the reference voltage is the power supply voltage VCC (measured VCC = 4.70V). It can be calculated that the Celsius temperature display data after A/D conversion is: 
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) 
6.  Assembly source program 
(omitted) 
7. C language source program 
#include  
#include  
unsigned char code dispbitcode[]={0xfe,0xfd,0xfb,0xf7, 
                                  0xef,0xdf,0xbf,0x7f}; 
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66, 
                               0x6d ,0x7d,0x07,0x7f,0x6f,0x00,0x40}; 
unsigned char dispbuf[8]={10,10,10,10,10,10,0,0}; 
unsigned char dispcount; 
unsigned char getdata; 
unsigned long temp; 
unsigned char i; 
bit sflag; 
sbit ST=P3^0; 
sbit OE=P3^1; 
sbit EOC=P3^2; 
sbit CLK=P3^3; 
sbit LED1=P3^6; 
sbit LED2=P3^7; 
sbit SPK=P3^5; 
void main(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      ;    TH1=(65536-4000)/256;    TL1=(65536-4000)%256;      if(EOC==1)     {       OE=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=temp%10; 
        temp=temp/10; 
        i++; 
      } 
    dispbuf=temp;           
     ST=1; 
     ST=0; 
   } 
  P1=dispcode[dispbuf[dispcount]]; 
  P2=dispbitcode[dispcount]; 
  dispcount++; 
  if(dispcount==8) 
    { 
      dispcount=0; 
    } 
}
Reference address:30. Four-digit digital thermometer

Previous article:26. Dot matrix LED simple graphic display technology
Next article:29. Temperature control between two points

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号