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
Previous article:Design of temperature-controlled fan based on 51 single-chip microcomputer
Next article:Microcontroller serial communication notes (interrupt review)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Transfer: Deep digging into the IAR startup function process and its underlying initialization design
- TMS320C6000 Basic Learning (6) - gel file
- [National Technology M4 core hot-selling N32G45XVL evaluation] Part 3 DAC output dual-channel triangle wave signal
- Doubts about LDO power supply power and output current.
- How to Select a Digital Isolator
- Can you tell what is different about 5G?
- [Open Source] Development Board Power-On Tutorial - Crazy Shell Development Board Series
- Problems with freewheeling diodes in MOS drive motors
- How to solve the problem of abnormal heating of op amp THS4052ID
- [Home Smart Lighting Control and Indoor Environment Monitoring System]--5. [RSL10] Bluetooth BLE Host Computer Development 1