Adopting avr series ATMEGA8A microcontroller, digital tube adopts 74hc595 static drive, reads MAX6675 chip and performs temperature conversion.
Cold junction compensation potassium thermocouple digital converter (0℃ to +1024℃)
MAX6675 performs cold junction compensation and digitizes the signal of K-type thermocouple. The data is output in 12-bit resolution, SPI compatible, read-only format. The converter can resolve the temperature to 0.25°C, the reading can reach up to +1024°C, and the thermocouple accuracy is 8 LSb in the range of 0°C to +700°C. MAX 6675 adopts small 8-pin SO4 package. Application ● Industry ● Home appliances ● HVAC
Features ● Direct digital conversion of K-type thermocouple output ● Cold junction compensation ● Simple SPI compatible serial interface ● 12 bits, 0.25°C resolution ● Open thermocouple detection
Simply put, read 16 binary, only the middle 3 to 14 are valid, take them out, and then multiply by the resolution 0.25 to get how many degrees Celsius.
The microcontroller source program is as follows:
#include
#include
#include
#define Date16 PORTD.5
#define CLK PORTD.7
#define RCLK PORTD.6
#define DateIN PINB.0
#define MCLK PORTB.1
#define CS PORTB.2
const unsigned char Dis_Code[] = {0xFC, 0x60, 0xDA, 0xF2, 0x66, 0XB6, 0xBE, 0xE0, 0XFE, 0xF6};
unsigned char Blk_Flg,Blk_Bit;
unsigned char Disp_Timer, Dis_Buffer[8];
unsigned int wendu,T_Timer;
unsigned int Read6675(void)
{
unsigned int date6675=0;
unsigned char i;
CS=0;
delay_us(15);
MCLK=0;
delay_us(15);
for(i=0;i<16;i++)
{
date6675<<=1;
delay_us(15);
MCLK=1;
delay_us(15);
if(DateIN==1) date6675|=0X01;
delay_us(15);
MCLK=0;
delay_us(15);
}
CS=1;
delay_us(15);
// MCLK=1;
if((date6675&0X0004)!=0) date6675=4095;
else date6675>>=3;
return date6675;
}
void T_zhuanhuan(void)
{
float temp;
temp=Read6675();
temp*=2.5;
wendu=(unsigned int)temp;
}
int EEPROMwrite( int location, unsigned char byte)
{
unsigned char oldSREG;
while (EECR & 0x02);
EEAR = location;
EEDR = byte;
oldSREG = SREG;
SREG &= ~0x80;
EECR |= 0x04;
EECR |= 0x02;
SREG = oldSREG;
return 0;
}
unsigned char EEPROMread( int location)
{
while (EECR & 0x02);
EEAR = location;
EECR |= 0x01;
return (EEDR);
}
void Disp_Led(void)
{
unsigned char Dis_Temp_B1,Dis_Temp_B2,Dis_Temp_B3 ;
RCLK=1 ;
for(Dis_Temp_B1=0;Dis_Temp_B1<5;Dis_Temp_B1++)
{
Dis_Temp_B3=1 ;
for(Dis_Temp_B2=0;Dis_Temp_B2<8;Dis_Temp_B2++)
{
if((Dis_Buffer[Dis_Temp_B1]&Dis_Temp_B3)!=0)
Date16=1 ;
else
Date16=0 ;
CLK=0 ;
CLK=1 ;
Dis_Temp_B3*=2 ;
}
}
RCLK=0 ;
RCLK=1 ;
}
void Dex_To_Bcd(int Dis_Value,unsigned char Blk_En,unsigned char Bcd_T_B1)
{
Dis_Buffer[4]=Dis_Code[Dis_Value/10000];
Dis_Value%=10000 ;
Dis_Buffer[3]=Dis_Code[Dis_Value/1000];
Dis_Value%=1000 ;
Dis_Buffer[2]=Dis_Code[Dis_Value/100];
Dis_Value%=100 ;
Dis_Buffer[1]=Dis_Code[Dis_Value/10];
Dis_Value%=10 ;
Dis_Buffer[0]=Dis_Code[Dis_Value];
if((Blk_Flg==1)&&(Blk_En!=0))
{
switch(Blk_Bit)
{
/*0*/
case 0 :
break ;
/*1*/
case 1 :
if(Bcd_T_B1==4)Bcd_T_B1=3 ;
break ;
/*2*/
case 2 :
if(Bcd_T_B1==3||Bcd_T_B1==4)Bcd_T_B1=2 ;
break ;
/*3*/
case 3 :
if(Bcd_T_B1==2||Bcd_T_B1==3||Bcd_T_B1==4)Bcd_T_B1=1 ;
break ;
/*4*/
case 4 :
Bcd_T_B1=0 ;
break ;
default :
break ;
}
}
if(Bcd_T_B1==1&&Dis_Buffer[4]==0xFC)Dis_Buffer[4]=0x00 ;
if(Bcd_T_B1==2&&Dis_Buffer[4]==0xFC)
{
Dis_Buffer[4]=0x00 ;
if(Dis_Buffer[3]==0xFC)
……………………
Previous article:AVR MCU fuse configuration and related solutions
Next article:ICCV7 For AVR Tutorial Atmega16 MCU
- 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
- HuaDa HC32F003 / HC32F005 project template
- RTT & Renesas high-performance CPK-RA6M4 development board evaluation - PWM breathing light and output square wave
- IL0389 Electronic Paper (Ink Screen) Driver
- Please advise: What is the impact of wireless modules working in a wide voltage range?
- [Perf-V Review] + First Look at Pengfeng Artix 7 FPGA Development Kit
- Can a 0805 SMD LED be lit with a current of 1.25mA?
- EEWORLD University Hall----Live Replay: Microchip Security Series 17 - Pre-configured Wi-Fi? MCUs accelerate time to market and simplify production
- [National Technology N32 MCU Development Package] --N32G030 Series
- Domestic MCU manufacturers are also starting to roll
- The problem of being unable to sample data when using the 28335 ADC module to sample current