51 single-chip microcomputer simple clock alarm eight-digit digital tube display simulation (proteus simulation + program + schematic diagram + report + explanation video)

51 single-chip microcomputer simple clock alarm eight-digit digital tube display simulation (proteus simulation + program + schematic diagram + report + explanation video)


51 single-chip microcomputer simple clock alarm eight-digit digital tube display simulation (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: S0046

1. Main functions:

This design aims to design a multifunctional digital clock alarm clock proteus simulation design based on 51 microcontroller, which can display hours, minutes and seconds, and can set the time and alarm clock.

1. Use the internal timer of the microcontroller to realize timing;

2. Use eight-digit digital tube to display hours, minutes and seconds;

3. The hours, minutes and seconds can be added and subtracted respectively, and the corresponding digital tube flashes during setting;

4. The alarm clock can be set, and after the time is up, the buzzer will sound every 1 second for 6 seconds;

5. When the alarm clock sounds, you can manually cancel the alarm clock.

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, the digital tube displays the time 00:00:00. The time increases by seconds.

img

When the time is displayed, press the setting button to enter the setting mode. The clock flashes to indicate that the clock is currently being set. Press the setting button again to enter the minute setting mode, and the minutes flash. Press the setting button again to enter the seconds setting mode, and the seconds flash. After setting the seconds, press Set again to exit the setting mode, and the digital tube will display normally.

Press the function switch button to display the alarm time. When the alarm time is displayed, press the setting button to enter the alarm setting mode. The clock flashes to indicate that the alarm clock is currently being set. Press the setting button again to enter the alarm minute setting mode. The alarm minutes flashing. Press the setting button again to enter the alarm seconds setting mode. The alarm clock The seconds flash. After setting the seconds, press Set again to exit the setting mode, and the digital tube will display the alarm time normally.

When the alarm time is up, the buzzer will sound. The buzzer will sound every 1 second for 6 seconds. The alarm can be turned off by pressing the button.

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
* 函数功能		 : 主函数
* 输    入       : 无
* 输    出    	 : 无
*******************************************************************************/
void main()
{
    
    	
	Timer0Init();  //定时器0初始化
		xian1[0]=shi/10;//计算到显存   时钟的十位
		xian1[1]=shi%10;// 时钟的个位
		xian1[3]=fen/10;// 分钟的十位
		xian1[4]=fen%10;// 分钟的个位
		xian1[6]=miao/10;  // 秒钟的十位
		xian1[7]=miao%10;  // 秒钟的个位
		xian2[0]=shi0/10;
		xian2[1]=shi0%10;
		xian2[3]=fen0/10;
		xian2[4]=fen0%10;
		xian2[6]=miao0/10;
		xian2[7]=miao0%10;
	while(1)
	{
    
    
	  if(mode)
	  	display2();//显示闹钟
	  else
		display1();//显示时间
	  if(!key1 &&(cixu==0))	//功能切换
	  {
    
    
	  	mode=!mode;
		while(!key1);
	  }
	  if(!key2)//选择
	  {
    
    
	  	if(cixu<3)
			cixu++;
		else
			cixu=0;
	  	while(!key2);
	  }
	  if(!key3)		//加
	  {
    
    
	  	if(mode==0)
		{
    
    
		  switch(cixu)
		  {
    
    
		  case 1:
		  	if(shi<23)
				shi++; //时钟+
				break;
		  case 2:
		  	if(fen<59)
				fen++;  //分钟+
				break;
		  case 3:
		  	if(miao<59)
				miao++;	    //秒钟+
		  }
		}
		else
		{
    
    
		  switch(cixu)
		  {
    
    
		  case 1:
		  	if(shi0<23)
				shi0++;	   //闹钟时钟+
				break;
		  case 2:
		  	if(fen<59)
				fen0++;		//闹钟分钟+
				break;
		  case 3:
		  	if(miao0<59)
				miao0++;	  //秒钟分钟+
		  }
		}
		xian1[0]=shi/10;//计算到显存
		xian1[1]=shi%10;
		xian1[3]=fen/10;
		xian1[4]=fen%10;
		xian1[6]=miao/10;
		xian1[7]=miao%10;
		xian2[0]=shi0/10;
		xian2[1]=shi0%10;
		xian2[3]=fen0/10;
		xian2[4]=fen0%10;
		xian2[6]=miao0/10;
		xian2[7]=miao0%10;
	  	while(!key3);
	  }
	  if(!key4)		//减
	  {
    
    
	  	if(mode==0)
		{
    
    
		  switch(cixu)
		  {
    
    
		  case 1:
		  	if(shi>0)
				shi--;
				break;
		  case 2:
		  	if(fen>0)
				fen--;
				break;
		  case 3:
		  	if(miao>0)
				miao--;
		  }
		}
		else
		{
    
    
		  switch(cixu)
		  {
    
    
		  case 1:
		  	if(shi0>0)
				shi0--;
				break;
		  case 2:
		  	if(fen0>0)
				fen0--;
				break;
		  case 3:
		  	if(miao0>0)
				miao0--;
		  }
		}
		xian1[0]=shi/10;//计算到显存
		xian1[1]=shi%10;
		xian1[3]=fen/10;
		xian1[4]=fen%10;
		xian1[6]=miao/10;
		xian1[7]=miao%10;
		xian2[0]=shi0/10;
		xian2[1]=shi0%10;
		xian2[3]=fen0/10;
		xian2[4]=fen0%10;
		xian2[6]=miao0/10;
		xian2[7]=miao0%10;
	  	while(!key4);
	  }
	  if(!key5)	//停止响铃
	   {
    
    
		beep_flag=0;
		beep=1;
	   while(!key5);
	   }

	  if((shi==shi0)&&(fen==fen0)&&(miao==miao0))//判断响铃
	  {
    
    
	  	 beep_flag=1;
		 beep=0;
	  }
	}		
}

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.

Parts list

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

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

5. Design report

6600+ words 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/132699492