MAX6675 thermocouple temperature data acquisition based on 51 single-chip microcomputer (Proteus simulation) (serial port print data)

tags: Proteus simulation  Using 51 single chip microcomputer to drive MAX6675 thermocouple  Temperature data collection, serial port print data

1. Introduction to MAX6675 Thermocouple

See this article
MAX6675

Second, the program source code

#include "reg51.h"
#include "intrins.h"	
#include "stdio.h"
#define uchar unsigned char
#define uint  unsigned int				
#define DISPLAYLED  P1			
sbit CS  =P2^5; 
sbit SCK =P2^6;
sbit SO  =P2^7;  
typedef struct __MAX6675
{
	uint temperature;
	float finallyDat;
	uchar displaydat[4];
	uchar flag;
}MAX6675;
MAX6675 max6675={0,0.0,0};
uchar code str[]="max6675:  ";
void delay_ms(uint cnt);
void MAX6675_ReadData(void);
void Send_Char(uchar chr);
void Send_Str(uchar *str);
void displayData(void);
void UartInit(void);
//The time delays in the sequence are as follows: (according to the official manual)
/*
	fSCL <= 4.3MHz
	tCH  >= 100ns
	tCL  >= 100ns
	tCSS >= 100ns
	tDV  <= 100ns
	tTR  <= 100ns
	tDO  <= 100ns 
*/
void MAX6675_ReadData(void)
{ 
	uchar i=0;   
	uint dat=0;	   
	CS=0; 
	SCK=0;     
	for(i=0;i<16;i++)		//get D15-D0 from 6675  
	{      
		SCK = 1; 
		_nop_();    
		dat=dat<<1;    
		if(SO)   
			dat=dat|0x01;   
		SCK=0;
		_nop_();     
	} 
	CS=1;   
	max6675.temperature=dat;
	max6675.temperature>>=3;//D3~D14 of the read data is the temperature value
	max6675.temperature&=~(0xf<<12);
	max6675.finallyDat=max6675.temperature*0.25;	   
} 
void delay_ms(uint cnt)	
{
	uint j,k;
	for(j=0;j<cnt;j++)
		for(k=0;k<114;k++);
}
void displayData(void)
{
	uint temp=max6675.finallyDat;
	DISPLAYLED=temp;
	Send_Str(str);
	max6675.displaydat[0]=temp/100+'0';
	max6675.displaydat[1]=temp%100/10+'0';
	max6675.displaydat[2]=temp%10+'0';
	Send_Char(max6675.displaydat[0]);
	Send_Char(max6675.displaydat[1]);
	Send_Char(max6675.displaydat[2]);
	SBUF=0x0A;
	SBUF=0X0D;
	while(!TI);
	SCON&=~(1<<1); 
}
void UartInit(void)
{
   TMOD = 0x20;    
   PCON = 0x00;       
   SCON = 0x50;//0101 0000
   TH1=0XF3;
   TL1=0XF3;	     
   TR1=1;	          							  
}
void Send_Char(uchar chr)
{
	SBUF=chr; 
	while(!TI);
	SCON&=~(1<<1);          
}

void Send_Str(uchar *str)
{
	while(*str!='\0')
	{
		SBUF=*str; 
		while(!TI);      
		TI=0;            
		str++;
	}
	SCON&=~(1<<1); 
}

int main(void)
{
	SCK=CS=1;
	UartInit();	
	while(1)
	{
		MAX6675_ReadData();
		displayData();		
		//delay_ms(10);
	}
	return 0;
}

Three, simulation diagram:

Four, simulation video

MAX6675 data acquisition based on 51 single chip microcomputer (Proteus simulation) (serial port print data)

Intelligent Recommendation

Program realization and Proteus simulation of 51 single chip microcomputer serial communication

1. Serial communication of 51 single chip microcomputer There are many blogs explaining the serial communication of 51 single-chip microcomputer, so I won't explain it in detail here. The program is g...

51 single-chip microcomputer simulation examples based on proteus 69, serial-to-parallel device 74HC164 application examples

1. 74HC164 is an 8-bit edge-triggered shift register, serial input data, and parallel output. Data is serially input through one of the two input terminals (DSA or DSB); either input terminal can be u...

Simulation of temperature alarm system proteus based on single chip microcomputer

The temperature monitoring simulation circuit based on single chip microcomputer mainly includes DS18B20 temperature acquisition circuit, LCD temperature display circuit, buzzer LED lamp alarm circuit...

Based on 51 single -chip microcomputer+ DS1302+ LCD1602 Show PROTEUS simulation

Based on 51 single -chip microcomputer+ DS1302+ LCD1602 Show PROTEUS simulation AT89C52、LCD1602、 DS1302、 ProteusSimulation device Instance code...

51 single-chip computer simulation examples based on proteus 20. Use the single-chip port to demonstrate the result of data division

1. When performing division in the microcontroller, try to avoid using real variables directly, because real variables take up a lot of bytes and consume CPU time, so try to use plastic data instead ,...

More Recommendation

"Single-chip Microcomputer Practice Project" "Electronics DIY" PWM experiment based on 51 single-chip ADC0808, Proteus simulation, voltage acquisition

"Single Chip Microcomputer Practice Project" "Electronic DIY" PWM experiment based on 51 single chip microcomputer ADC0808, Proteus simulation ADC0808 It is a CMOS component with 8...

A simulation example of 51 single-chip microcomputer based on Proteus 17. Use different data types to control the blinking frequency of LED lights

The program design of the single-chip microcomputer is inseparable from the processing of various data, and the storage of data in the single-chip memory is determined by the data structure. The data ...

Proteus Simulation II. Virtual Serial Port Communication is achieved by 51 single-chip microcons, based on Modbus_RTU protocol (1)

Proteus Simulation II. Virtual Serial Port Communication is achieved by 51 single-chip microcons, based on Modbus_RTU protocol (1) This chapter mainly introduces the receipt of a frame of packets, the...

Proteus simulation 51 single -chip microcomputer notes

The problems and solutions encountered 1. LCD1602 is bright and does not display data Solution 1. If the data bus is connected to the P0 port, the pull -off resistance is connected to the P0 port 2. C...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top