51 single chip water heater temperature control system simulation design (proteus simulation + program + schematic diagram + report + explanation video)


51 single chip water heater temperature control system simulation design (proteus simulation + program + schematic diagram + report + explanation video)

Simulation diagram proteus7.8 and above

Program compiler: keil 4/keil 5

Programming language: C language

Design number: S0045

1. Main functions:

This design aims to realize a simple kettle water heater control simulation proteus simulation design based on 51 microcontroller, which has the following functions:

1. Use temperature sensor DS18B20 to monitor the water temperature, and use LCD1602 to display the water temperature, water temperature alarm threshold, and set heating temperature value;

2. Heating temperature and over-temperature alarm threshold can be adjusted through buttons;

3. Press the button to control the start and stop of the heating process. When the temperature exceeds the set value, the heating will stop;

4. When the alarm value is exceeded, the buzzer alarm is activated.

It should be noted that the 51 microcontroller chip in the simulation is universal. AT89C51 and AT89C52 are specific models of the 51 microcontroller, and the cores are compatible. 原理图一样的情况下。Regardless of stc or at, the pin functions are the same and the program is the same. The chip can be replaced with 51 microcontroller chips such as STC89C52/STC89C51/AT89C52/AT89C51.

The following is a display diagram of this design information:

2. Simulation

Start simulation

Open the simulation project, double-click the microcontroller in proteus, select the hex file path, and then start simulation. After starting the simulation, LCD1602 displays the current temperature value, heating status, set target temperature value, and temperature alarm value.

img

During the simulation, adjust the value of the DS18B20 temperature and humidity module by pressing the buttons to change the displayed value.

imgThe up and down arrows are used to change the temperature value. The down arrow decreases the value, and the up arrow increases the value. imgChange the icon to display the temperature value

After starting the simulation, the default alarm temperature is 100°C. When the temperature exceeds, the buzzer will alarm.

img

After starting the simulation, click the button to start heating, LCD1602 displays start, and the heating pin outputs a PWM signal. The greater the difference between the current temperature and the set temperature, the greater the output duty cycle.

img

After the adjusted temperature exceeds the set temperature, the system automatically stops heating and LCD1602 displays stop.

img

3. Program code

Use keil4 or keil5 to compile, the code has comments, and you can understand the meaning of the code in conjunction with the report.

img

main function code

#include "reg51.h"
#include"Ds18b20.h"
#include "lcd1602.h"
#define uchar unsigned char
#define uint unsigned int
sbit beep=P2^7;//蜂鸣器
sbit out=P2^6;//加热器
sbit k1=P1^0;//按钮
sbit k2=P1^1;
sbit k3=P1^2;
sbit k4=P1^3;
sbit k5=P1^4;
sbit k6=P1^5;

uchar time=0,mode=0;//系统变量
uchar wendu=0;//温度
uchar lim1=90,lim2=100;//阀值
uchar disp1[]="Temp:000C";
uchar disp2[]="Set:000 Lim:000";
uchar start=0;

void main()//主函数
{
    
    
	uchar i=0;
	init_1602();	//初始化LCD
	TMOD|=0X01;
	TH0=0X3C;
	TL0=0XB0;	
	ET0=1;//打开定时器0中断允许
	EA=1;//打开总中断
	TR0=1;//打开定时器
	while(1)
	{
    
    
		if(!k1)//启动
			start=1;
		if(!k2)//停止
			start=0;
		if(!k3)//设置加
		{
    
    
			if(lim1<130)
				lim1++;
			while(!k3);
		}
		if(!k4)//设置减
		{
    
    
			if(lim1>0)
				lim1--;
			while(!k4);
		} 
		if(!k5)//阀值加
		{
    
    
			if(lim2<130)
				lim2++;
			while(!k5);
		}
		if(!k6)//阀值减
		{
    
    
			if(lim2>0)
				lim2--;
			while(!k6);
		}
		//输出占空比,加热控制
		if(start)
		{
    
    
			if(wendu<lim1)
			{
    
    
			if(i<99)
				i++;
			else
				i=0;
			if(i<(lim1-wendu)*2)//设置温度和当前温度相差50以内,温差越小,PWM占空比越小
				out=0;
			else
				out=1; 
			}
			else
				out=1;
		}
		else
			out=1;
		
	}
}
//定时器中断
void Timer0() interrupt 1
{
    
    
	if(time<10)//0.5s
		time++;
	else
	{
    
    
		time=0;
		Ds18b20ReadTemp();//读取温度
		wendu=ds18b20_temp;
		//显示
		disp1[5]=wendu/100+0x30;
		disp1[6]=wendu%100/10+0x30;
		disp1[7]=wendu%10+0x30;
		disp2[4]=lim1/100+0x30;
		disp2[5]=lim1%100/10+0x30;
		disp2[6]=lim1%10+0x30;
		disp2[12]=lim2/100+0x30;
		disp2[13]=lim2%100/10+0x30;
		disp2[14]=lim2%10+0x30;
		write_string(1,0,disp1);
		write_string(2,0,disp2);
		
		//报警控制
		if(wendu>lim2)
		{
    
    
			start=0;
			beep=0;
		}
		else
			beep=1;
		if(start)
			write_string(1,10,"start");
		else
			write_string(1,10,"stop ");
	}
	TH0=0X3C;
	TL0=0XB0;
}

4. Schematic diagram

The schematic diagram is drawn with AD, which can be used as a reference for the real thing. The simulation is different from the real thing. If you are inexperienced, don't make it easy.

img

The difference between Proteus simulation and physical works:

1. Running environment: Proteus simulation runs on the computer, while the real thing runs on the hardware circuit board.

2. Debugging method: In Proteus simulation, you can easily perform single-step debugging and observe changes in variable values, while in real objects, you need to debug through a debugger or serial port output.

Circuit connection method: In Proteus simulation, the circuit connection can be modified through software settings, but in the real thing, it needs to be modified through the hardware circuit board and connecting wires.

3. Running speed: Proteus simulation usually runs faster than the real thing, because the simulation is based on computer operation, while the real thing needs to consider factors such as the physical limitations of the circuit board and the response time of the device.

4. Function realization: In Proteus simulation, different functions can be realized through software settings, but in real objects, they need to be realized according to the circuit design and device performance.

5. Design report

6605-word design report, including design block diagram, introduction, hardware design introduction, software design introduction, simulation debugging, summary and references.

img

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. Proposal report

4. Schematic diagram

5. Functional requirements

6. Components list

7. Design report

8. Software and hardware flow chart

9. Explanation video

Altium Designer Software Information

KEIL software information

Proteus software information

Microcontroller learning materials

Defense skills

Common descriptions for design reports

Double-click the mouse to open and find more 51 STM32 Microcontroller Course Graduation Project.url

img

Data download link (clickable):

Guess you like

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