51 single chip microcomputer + max6675 to collect thermocouple temperature

Publisher:MysticalDreamerLatest update time:2020-02-24 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

51 MCU uses max6675 to collect thermocouple temperature and has been debugged successfully with circuit


The microcontroller source program is as follows:


#include "include.h"

#include "12864.h"

unsigned int i,j; 

unsigned char Flag_connect;

unsigned int MAX6675_Temp;

/********************************************************************     

/********************************************************************

                            Main function

*********************************************************************/

int max6675();

void InitTimer0(void);

void main()                                                                                                                                                                                            

        unsigned int t;

    InitTimer0();

         Ini_Lcd(); //Initialize LCD

          Write_Str ( 0, 0, "温度:    " );        

        //        unsigned char cnt = 11;


while(1)

             t=MAX6675_ReadReg();

                  Flag_connect=t&0x04; //The D2 bit of the read data is the thermocouple disconnection flag bit. If it is 1, it is disconnected, and if it is 0, it is connected.

                  Flag_connect=Flag_connect>>2; //Is MAX6675 online?


                t = t<<1; //D3~D14 of the read data are temperature values

                t = t>>4;

                MAX6675_Temp = t/4; //The measured temperature unit is 0.25, so you need to multiply by 0.25 (i.e. divide by 4) to get the temperature value in degrees

                

                for(t=0; t<200; t++) //Display temperature

                {  

                if(Flag_connect==0)

                LCD_DispDec ( 4, 0,MAX6675_Temp, 3, 0 );

                }




        

}

}



void Timer0Interrupt(void) interrupt 1

{        

        TF0=0;

  TH0=0xfc;

  TL0=0x18;

        i++;

         if(i==500)

        {  i=0;

      Key_Flag = 1;

         }

}




void InitTimer0(void)

{

    TMOD = 0x01;

    TH0 = 0xfc;

    TL0 = 0x18;

    

    ET0 = 1;

    TR0 = 1; 

         EA = 1;

……………………15:24 2020-2-24


Reference address:51 single chip microcomputer + max6675 to collect thermocouple temperature

Previous article:Design of temperature-controlled fan based on 51 single-chip microcomputer
Next article:Microcontroller serial communication notes (interrupt review)

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号