Temperature control between two points in single chip microcomputer test

Publisher:快乐的小鸟Latest update time:2013-04-02 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Experimental tasks

The voltage value is adjusted by an adjustable resistor as the input of the simulated temperature. When the temperature is lower than 30℃, a long beep and light alarm sound, and when the temperature is higher than 60℃, a short beep and light alarm sound. The measured temperature range is 0-99℃.

2. Circuit diagram

Click to browse the next page

Figure 4.29.1

3. Hardware connection on the system board

a) 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.

b) Connect P2.0-P2.7 in the "MCU System" area and S1S2S3S4S5S6S7S8 ports in the "Dynamic Digital Display" area using an 8-core cable.

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

d) Connect P3.1 in the “MCU System” area and the OE terminal in the “Analog-to-Digital Conversion Module” area with a wire.

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

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

g) Connect the A2A1A0 terminals in the "Analog-to-digital conversion module" area to the GND terminal in the "Power module" area with a wire.

h) Connect the IN0 terminal in the "Analog-to-digital conversion module" area to the VR1 terminal in the "Three-way adjustable voltage module" area with a wire.

i) 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.

j) Use wires to connect P3.6 and P3.7 in the "MCU System" area to L1 and L2 in the "Eight-way LED Indicator Module" area respectively.

k) Connect P3.5 in the "MCU System" area to the SPK IN port in the "Audio Amplifier Module" area with a wire.

l) Plug the SPK OUT in the “Audio Amplifier Module” area into the audio speaker.

4. Assembly source program

(Omitted) [page]

5. C language source program

#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};

unsigned char dispbuf[8]={10,10,10,10,10,10,0,0};

unsigned char dispcount;

unsigned char getdata;

unsigned int temp;

unsigned char i;

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;

bit lowflag;

bit highflag;

unsigned int cnta;

unsigned int cntb;

bit alarmflag;

void main(void)

{

  ST=0;

  OE=0;

  TMOD=0x12;

  TH0=0x216;

  TL0=0x216;

  TH1=(65536-500)/256;

  TL1=(65536-500)%256;

  TR1=1;

  TR0=1;

  ET0=1;

  ET1=1;

  EA=1;

  ST=1;

  ST=0;

  while(1)

    {

      if((lowflag==1) &&(highflag==0))

        {

          LED1=0;

          LED2=1;

        }

        else if((highflag==1) && (lowflag==0))

          {

            LED1=1;

            LED2=0;

          }

          else

            {

              LED1=1;

              LED2=1;

            }

    }

}

void t0(void) interrupt 1 using 0

{

  CLK=~CLK;

}

void t1(void) interrupt 3 using 0

{

  TH1=(65536-500)/256;

  TL1=(65536-500)%256;

       if(EOC==1)

         {

           OE=1;

           getdata=P0;

           OE=0;

           temp=getdata*25;

           temp=temp/64;

           i=6;

           dispbuf[0]=10;

           dispbuf[1]=10;

           dispbuf[2]=10;

           dispbuf[3]=10;

           dispbuf[4]=10;

           dispbuf[5]=10;

           dispbuf[6]=0;

           dispbuf[7]=0;

          while(temp/10)

            {

              dispbuf[i]=temp%10;

              temp=temp/10;

              i++;

            } [page]

          dispbuf[i]=temp;         

           if(getdata<77)

             {

               lowflag=1;

               highflag=0;

             }

             else if(getdata>153)

               {

                 lowflag=0;

                 highflag=1;

               }

               else

                 {

                   lowflag=0;

                   highflag=0;

                 }

           ST=1;

           ST=0;

         }

  P1=dispcode[dispbuf[dispcount]];

  P2=dispbitcode[dispcount];

  dispcount++;

  if(dispcount==8)

    {

      dispcount=0;

    }

  if((lowflag==1) && (highflag==0))

    {

      cnta++;

      if(cnta==800)

        {

          cnta=0;

          alarmflag=~alarmflag;

        }

      if(alarmflag==1)

        {

          SPK=~SPK;

        }

    }

    else if((lowflag==0) && (highflag==1))

      {

      cntb++;

      if(cntb==400)

        {

          cntb=0;

          alarmflag=~alarmflag;

        }

      if(alarmflag==1)

        {

          SPK=~SPK;

        }       

      }

      else

        {

          alarmflag=0;

          cnta=0;

          cntb=0;

        }

Reference address:Temperature control between two points in single chip microcomputer test

Previous article:Design of Single Chip Microcomputer Digital Frequency Counter
Next article:Design of Bus Intelligent Instrument Temperature Control System

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号