51 single-chip electronic clock six-digit digital tube display hourly reminder simulation design (proteus simulation + program + schematic diagram + report + explanation video)

51 single-chip electronic clock six-digit digital tube display hourly reminder simulation design (proteus simulation + program + schematic diagram + report + explanation video)

51 single-chip electronic clock six-digit digital tube display hourly reminder 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: S0047

1. Main functions:

This design aims to design an electronic clock proteus simulation design based on 51 microcontroller

1. Set up a power-on control display button, an hour/minute switching button, and a plus 1 button;

2. The buzzer sounds every hour

3. Use a 6-digit integrated digital tube to display hours, minutes and seconds, and display 12:00:00 when turned on.

The given microcontroller frequency is 12MHz. Design the hardware circuit diagram and use drawings to draw the circuit diagram, write code in keil and simulate it on Proteus, and write course design instructions.

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. When the schematic diagram is the same, this design is compatible with both stc and 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, the digital tube does not display, and you need to press the power-on display button.

img

After pressing the power-on display button, the digital tube displays the time 12.00.00, which is exactly the hour. The buzzer prompts the standby mode after 2 seconds, and the time increases second by second.

img

When the time is displayed, press the hour and minute adjustment button to enter the setting mode. The clock flashes to indicate that the clock is currently being set. Press the plus button to increase the clock by 1. After it reaches 23, it increases to 0 again. Press the hour and minute adjustment key again to enter the minute setting mode, and the minutes will flash. Press the hour and minute adjustment key again to enter the setting mode, and the digital tube will display normally.

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

//主函数
void main()
{
    
    
	uchar k=0;
	TMOD|=0X01;
	TH0=0X3C;
	TL0=0XB0;	
	ET0=1;//打开定时器0中断允许
	EA=1;//打开总中断
	TR0=1;//打开定时器
	while(1)
	{
    
    
		//按键检测
		if(!k1 &&(k!=1))//时分
		{
    
    
			k=1;
			if(mode<2)
				mode++;	   //设置模式变化
			else
				mode=0;
		} 
		if(!k2 &&(k!=2))//加按键
		{
    
    
			k=2;
			if(mode==1)//设置时间
			{
    
    
				if(shi<23)//时间+1
					shi++;
				else
					shi=0;//时间从0开始加
			}
			if(mode==2)//设置分钟
			{
    
    
				if(fen<59)//分钟+1
					fen++;
				else
					fen=0;//分钟从0开始加
			}
		}
		if(k1 && k2)
			k=0;
		if(!k3)//软件复位,时间回复到默认时间
		{
    
    
			shi=SETSHI;
			fen=SETFEN;
			miao=SETMIAO;
			mode=0;
		}
		//显示
		if(mode==0)
		{
    
    
			P0=smgduan0[shi/10];smg1=0;delay(100);smg1=1;
			//P0先给数据,位选给0,选中数据位,数据稳定后,位选给1取消位选
			P0=smgduan1[shi%10];smg2=0;delay(100);smg2=1;
			P0=smgduan0[fen/10];smg3=0;delay(100);smg3=1;
			P0=smgduan1[fen%10];smg4=0;delay(100);smg4=1;
			P0=smgduan0[miao/10];smg5=0;delay(100);smg5=1;
			P0=smgduan0[miao%10];smg6=0;delay(100);smg6=1;
		}
		if(mode==1)
		{
    
    
			if(time<11)//做闪烁效果,如果time小于11,显示时钟,否则时钟不显示
			{
    
    
			P0=smgduan0[shi/10];smg1=0;delay(100);smg1=1;
			P0=smgduan1[shi%10];smg2=0;delay(100);smg2=1;
			}
			P0=smgduan0[fen/10];smg3=0;delay(100);smg3=1;
			P0=smgduan1[fen%10];smg4=0;delay(100);smg4=1;
			P0=smgduan0[miao/10];smg5=0;delay(100);smg5=1;
			P0=smgduan0[miao%10];smg6=0;delay(100);smg6=1;
		}
		if(mode==2)
		{
    
    
			P0=smgduan0[shi/10];smg1=0;delay(100);smg1=1;
			P0=smgduan1[shi%10];smg2=0;delay(100);smg2=1;
			if(time<11)//做闪烁效果,如果time小于11,显示分钟,否则分钟不显示
			{
    
    
			P0=smgduan0[fen/10];smg3=0;delay(100);smg3=1;
			P0=smgduan1[fen%10];smg4=0;delay(100);smg4=1;
			}
			P0=smgduan0[miao/10];smg5=0;delay(100);smg5=1;
			P0=smgduan0[miao%10];smg6=0;delay(100);smg6=1;
		}
		//整点
		if(mode<3)
		{
    
    
		if((fen==0)&&(miao<1))//整点判断
			beep=0;
		else
			beep=1;
		}
	}
}

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.

Reference parts list

Number of component models Microcontroller
AT89C51 1
capacitor 10uf 1
capacitor 30pf 2
crystal oscillator 12MHZ 1
resistor 10k 1
button 3
resistor 1k 1
transistor PNP 1
buzzer active 1
digital tube 6-bit common cathode 1 row
resistor 10k 1

Power supply part
Pin header 2P 1
Capacitor 0.1uf 2
Capacitor 100uf 2
Voltage regulator 7805 1

5. Design report

7000+ words design report, including design block diagram, introduction, hardware design introduction, software design introduction, simulation debugging, summary and references.

img

6. List of design information contents

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/132700640