[Puzhong Development Board] Design of temperature alarm based on 51 microcontroller (proteus simulation + program + physical demonstration + explanation video)


[Puzhong Development Board] Design of temperature alarm based on 51 microcontroller (proteus simulation + program + physical demonstration + explanation video)

Proteus emulation: Proteus 8.16

Program compiler: keil 4/keil 5

Programming language: C language

Design number: P01

1. Main functions:

Puzhong development board experimental design

1. Real-time DS18B20 temperature measurement and display, buzzer alarm when temperature exceeds range, temperature alarm value can be set by button;

2. Temperature measurement range -55 to 128 degrees Celsius;

3. The alarm temperature can be set, with the default exceeding 30°C (the default alarm value can be changed through the program);

4. Press the button setting to enter the alarm value setting mode, press the button to increase the value, and press the button to decrease the value.

5. The effect can be achieved on the Puzhong development board, both for simulation and development boards.

(Currently only fully compatible with Puzhong development board A234, other Puzhong development board models may require code modification or wiring)

It should be noted that the 51 microcontroller chips in the simulation are compatible. AT89C51 and AT89C52 are the specific models of the 51 microcontroller, and the cores are the same. In the same schematic diagram, both stc and at are the same, the pin functions are the same, the programs are compatible, and the chip can be replaced with 51 microcontroller chips such as STC89C52/STC89C51/AT89C52/AT89C51.

2. Explanation video:

The explanation video includes simulation operation explanation and physical operation explanation.

[Puzhong Development Board] Temperature alarm design based on 51 microcontroller (proteus simulation + code)

3. Simulation

Open the simulation project, double-click the microcontroller in proteus, select the hex file path, and then start simulation.

img

4. Physical recording and phenomena

img

Software preparation:

Be sure to install the CH340 driver before using it for the first time.

Double-click to open STC-ISP.exe.

Download steps:

0. Power on the board first and connect the power cord to the USB port of the computer. If you do not power on the board first, there will be no light on the board.

1. Select the microcontroller model

2. Select the serial port of the downloader

3. Open the HEX file generated by compilation

4. Click download, press the power button of the microcontroller board to turn on the power, and wait for the download completion prompt.

5. Program code

Compile using keil4 or keil5, and the code has comments.

img

main function

/*******************************************************
函数功能:主函数
********************************************************/
 void main(void)
 {
    uchar cont;
	TMOD=0x01;					   //定时器0的方式1
	TH0=(65536-1000)/256;		   //装初值		
	TL0=(65536-1000)%256;
	EA=1;						   //开总中断
	ET0=1;						   //打开定时器0
	TR0=0;						   //启动定时器0 
	 while(1)                 //无限循环
	  {
		 key();
		 cont++;
		 if(cont>100)
		 {
		 DS_temp=Ds18b20ReadTemp(); 
         if(DS_temp<0)				
  	     {
	  		Dsflag=0;
			DS_temp=DS_temp-1;
			DS_temp=~DS_temp;
			tp=DS_temp;
			DS_temp=tp*0.0625*10+0.5;	
		}
		else
		{	
			Dsflag=1;
			tp=DS_temp;
		    DS_temp=tp*0.0625*10+0.5;	//温度在寄存器中12位,分辨率:0.0625
	    }									 //加0.5是四舍五入

		cont=0;								
	}		
			
		if(number==0)			   //选择按键切换标志,显示当前温度
		{
			Led(DS_temp);
		}
		if(number==1)			   //选择按键切换标志,显示设置温度
		{
			Led(MAX);
		}
		if(DS_temp>=MAX)			  //超过温度报警
		{							  //定时器打开
		   TR0=1;
		}
		else
		TR0=0;
    }			
}

Key scan function

void key()						//按键函数
{
	
 if(key1==0)					 //选择按键
	{
		delay(2);
		if(key1==0)
		{
			while(!key1);
	    number++;				  //选择按键切换标志位,温度设置与温度显示
			if(number>1)
				number=0;
					
		
     }
	 }	
  if(key2==0)						  //加号按键
	{
		delay(2);
		if(key2==0)
		{
			while(!key2);
	    if(number==1)				  //温度设置状态
			{
			   MAX=MAX+10;
				 if(MAX==850)
					MAX=0;
			}
		}
	}	
	  if(key3==0)					   //减号按键
	{
		delay(2);
		if(key3==0)
		{
			while(!key3);
			if(number==1)				//温度设置状态
			{
			   MAX=MAX-10;
				 if(MAX==0)
					MAX=850;
			}
	  
		}
	}	
	 
	
}

6. Design information content list&&download link

Material design materials include simulation, program code, explanation videos, functional requirements, design reports, software and hardware design block diagrams, etc.

0. Common usage problems and solutions – a must-read! ! ! !

1. Simulation diagram

2. Program source code

3. Functional requirements

4. Explanation video

5. Burning tools

Altium Designer installation crack

KEIL+proteus microcontroller simulation design tutorial

KEIL installation crack

Proteus component search

Proteus installation

Proteus simple use tutorial

Microcontroller learning materials

Puzhong-2&Puzhong-3&Puzhong-4 development board schematic diagram.pdf

Related data sheets

Defense skills

Common descriptions for design reports

Double-click the mouse to open the search for Jiasheng MCU 51 STM32 MCU course graduation project.url

img

Data download link:

https://docs.qq.com/doc/DS2pPenNRaHB6SlR1

Guess you like

Origin blog.csdn.net/weixin_52733843/article/details/134835655