51 single chip microcomputer music alarm clock stopwatch countdown hourly time chime multi-function electronic clock perpetual calendar digital tube display (proteus simulation + program + schematic + report + explanation video)

51 single chip microcomputer music alarm clock stopwatch countdown hourly time chime multi-function electronic clock perpetual calendar digital tube display (proteus simulation + program + schematic + report + explanation video)

51 single chip microcomputer music alarm clock stopwatch countdown hourly time chime multi-function electronic clock perpetual calendar digital tube display (proteus simulation + program + schematic + report + explanation video)

Simulation diagram proteus7.8 and above

Program compiler: keil 4/keil 5

Programming language: C language

Design number: S0053

Explainer video

51 single chip microcomputer music alarm clock stopwatch countdown hourly time chime multi-function electronic clock perpetual calendar digital tube display (proteus simulation + program + schematic + report + explanation video)

1. Main functions:

Simulation design of date and time alarm clock stopwatch countdown multifunctional electronic clock and perpetual calendar based on 51 microcontroller

1. The digital tube displays the current date and time, and the date and time can be modified by pressing the buttons;

2. Set the alarm time and play music when the time is up;

3. With stopwatch function;

4. With countdown function;

5. It has hourly time reporting function, and the buzzer will sound as many times as many times;

6. It has the leap year judgment function and follows the normal month and month rules when setting the date.

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. In the same schematic diagram, whether 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. When starting the simulation, it enters the time display mode by default and displays the current time of the computer.

img

When the time is displayed, press the setting key to enter the setting mode, and the time indicator light will light up. There will be a buzzer on the hour, which will sound as many times as the hour.

Press the setting button to set the clock, minutes and seconds respectively. The corresponding variables in the setting mode will flash to facilitate user settings. Set to seconds and press the setting button to exit setting mode. Use the plus and minus buttons to adjust the set hours, minutes and seconds.

img

Switch to the real date mode by pressing the date button, the digital tube displays the year, month and day, and the date indicator light turns on.

Press the setting button to enter the setting mode. Set the year first. The year will flash. Complete the setting of the year by pressing the plus and minus buttons. After setting the year, set the month. The operation is the same as the year adjustment. Then press the setting button to set the day. After setting the date, press the setting button to exit the setting.

img

Enter the alarm display mode by pressing the alarm button, and the alarm indicator light will turn on. Displays the default alarm time 16.30. If you need to modify the alarm time, press the setting button. The time flashes to indicate setting the clock. Pressing it again indicates setting the minutes. After setting the minutes, press the setting button to exit the alarm setting mode. When the alarm time comes, the alarm tone will be played through the buzzer. If you want to stop the alarm during this period, you can press the stop alarm button.

img

Enter the alarm display mode by pressing the alarm button, and the stopwatch indicator light turns on. Press the start button to start the stopwatch, and press the pause button to pause the current stopwatch and display the time. Press the reset button to reset the timer to 0.

img

Enter the countdown mode by pressing the countdown button, and the countdown indicator light will turn on. Press the start button to start the countdown, and press the pause button to pause the current countdown time and display it on the digital tube. Press the reset button to reset the timer to 0.

The above simulation results are in line with the design requirements.

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

  
//主函数
void main()
{
    
    
	uchar i=0;

	TMOD=0X11;//定时器0,工作方式1。
	TH0=0XFC;	//定时1ms
	TL0=0X18;
	TH1=(65536-10000)/256;
	TL1=(65536-10000)%256;
	ET1=1;
	TR1=1;	
	ET0=1;//打开定时器0中断允许
	EA=1;//打开总中断
//	Ds1302Init();   //解注释 显示初始时间	2023年9月3日星期天12点00分00秒 可到ds1302.c修改
while(1)
{
    
    	
	disp();//显示
	switch(mode)//LED
	{
    
    
		case 0:led1=0;led2=1;led3=1;led4=1;led5=1;break;
		case 1:led1=1;led2=0;led3=1;led4=1;led5=1;break;
		case 2:led1=1;led2=1;led3=0;led4=1;led5=1;break;
		case 3:led1=1;led2=1;led3=1;led4=0;led5=1;break;
		case 4:led1=1;led2=1;led3=1;led4=1;led5=0;
	}
	i=key_scan();//按键检测
	if(i==1)//日期
	{
    
    
		mode=0;flag=0;
	}
	if(i==2)//时间
	{
    
    
		mode=1;flag=0;
	}
	if(i==3)//闹钟
	{
    
    
		mode=2;flag=0;
	}
	if(i==4)//秒表
	{
    
    
		mode=3;flag=0;
	}
	if(i==5)//倒计时
	{
    
    
		mode=4;flag=0;
	}
	if(i==9)//停止响铃
	{
    
    
		TR0=0;num=0;
	}
	if(i==6)//设置
	{
    
    
		if(mode<2)
		{
    
    
		if(flag<3)
			flag++;
		else
			flag=0;
		}
		if(mode==2)
		{
    
    
		if(flag<2)
			flag++;
		else
			flag=0;
		}
		if(mode==4)
		{
    
    
		if(flag<3)
			flag++;
		else
			flag=0;
		}
	}
	if(i==7)//加
	{
    
    
		if(mode==0)//日期设置// ds1302_time[7] = {秒, 分, 时, 日, 月, 星期, 年};
		{
    
    
			if(flag==1)	//年
			{
    
    
				if(ds1302_time[6]<99)
					ds1302_time[6]++;					
				Ds1302Init();
			}
			if(flag==2)	//月
			{
    
    
				if(ds1302_time[4]<12){
    
    
					ds1302_time[4]++;
				}else{
    
    
					ds1302_time[4] = 1;
				}
									
				Ds1302Init();
			}
			if(flag==3)	//日
			{
    
    
				if(ds1302_time[3]<MonthDays(ds1302_time[6],ds1302_time[4])){
    
    
					ds1302_time[3]++;//如果日期小于于当前月份最后一天 
				}else{
    
    
					ds1302_time[3] = 1;
				}
										
				Ds1302Init();
			}
		}
		if(mode==1)//时间设置
		{
    
    
			if(flag==1)	//时
			{
    
    
				if(ds1302_time[2]<99)
					ds1302_time[2]++;					
				Ds1302Init();
			}
			if(flag==2)	//分
			{
    
    
				if(ds1302_time[1]<59)
					ds1302_time[1]++;					
				Ds1302Init();
			}
			if(flag==3)	//秒
			{
    
    
				if(ds1302_time[0]<59)
					ds1302_time[0]++;					
				Ds1302Init();
			}
		}
		if(mode==2)//闹钟设置
		{
    
    
			if(flag==1)	//时
			{
    
    
				if(shi<23)
					shi++;					
//				At24c02Write(0,shi);
			}
			if(flag==2)	//分
			{
    
    
				if(fen<59)
					fen++;					
//				At24c02Write(1,fen);
			}
		}
		if(mode==4)//倒计时设置
		{
    
    
			if(flag==1)	//时
			{
    
    
				if(shi1<23)
					shi1++;		
			}
			if(flag==2)	//分
			{
    
    
				if(fen1<59)
					fen1++;	
			}
			if(flag==3)	//秒
			{
    
    
				if(miao1<59)
					miao1++;
			}
		}
	}
	if(i==8)//减
	{
    
    
		if(mode==0)//日期设置
		{
    
    
			if(flag==1)	//年
			{
    
    
				if(ds1302_time[6]>0)
					ds1302_time[6]--;					
				Ds1302Init();
			}
			if(flag==2)	//月
			{
    
    
				if(ds1302_time[4]>1){
    
    
					ds1302_time[4]--;
				}else{
    
    
					ds1302_time[4] = 12;
				}					
				Ds1302Init();
			}
			if(flag==3)	//日
			{
    
    
				if(ds1302_time[3]>1){
    
    
					ds1302_time[3]--;		
				}else{
    
    
					ds1302_time[3] =MonthDays(ds1302_time[6],ds1302_time[4]);//日期从1变为当前月份最后一天 
				}
								
				Ds1302Init();
			}
		}
		if(mode==1)//时间设置
		{
    
    
			if(flag==1)	//时
			{
    
    
				if(ds1302_time[2]>0)
					ds1302_time[2]--;					
				Ds1302Init();
			}
			if(flag==2)	//分
			{
    
    
				if(ds1302_time[1]>0)
					ds1302_time[1]--;					
				Ds1302Init();
			}
			if(flag==3)	//秒
			{
    
    
				if(ds1302_time[0]>0)
					ds1302_time[0]--;					
				Ds1302Init();
			}
		}
		if(mode==2)//闹钟设置
		{
    
    
			if(flag==1)	//时
			{
    
    
				if(shi>0)
					shi--;					
//				At24c02Write(0,shi);
			}
			if(flag==2)	//分
			{
    
    
				if(fen>0)
					fen--;					
//				At24c02Write(1,fen);
			}
		}
		if((mode==4)&&(start==0))//倒计时设置
		{
    
    
			if(flag==1)	//时
			{
    
    
				if(shi1>0)
					shi1--;		
			}
			if(flag==2)	//分
			{
    
    
				if(fen1>0)
					fen1--;	
			}
			if(flag==3)	//秒
			{
    
    
				if(miao1>0)
					miao1--;
			}
		}
	}
	//倒计时,秒表控制
	if(mode>2)
	{
    
    
		if(i==10)//开始
		{
    
    
			start=1;
			flag=0;
		}
		if(i==11)//暂停
			start=!start;
		if(i==12)//复位
		{
    
    
			start=0;
			fen2=0;miao2=0;haomiao=0;
			shi1=0;fen1=0;miao1=0;
		}
	}
	
}
}

4. Schematic diagram

The schematic diagram is drawn using AD and can be used for physical reference.

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

element model quantity
Microcontroller AT89C51 1
capacitance 10uf 1
capacitance 30pf 2
crystal oscillator 12MHZ 1
resistance 10k 1
button 17
decoder 74LS138 1
memory 24C02 1
Real Time Clock DS1302 1
LED green 2
LED yellow 2
LED red 3
resistance 100 euros 5
resistance 1 k 1
triode PNP 1
buzzer Passive 1
Digital Tube 8-bit common cathode 1
exclusion 10k 1
crystal oscillator 32.768khz 1

5. Design report

7027-word design report, including introduction, hardware design, software design, software and hardware block diagram, debugging, summary and outlook, etc.

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

3. Schematic diagram

5. Functional requirements

6. Components list

7. Design report

8. Software and hardware flow chart

9. Explanation video

Altium Designer Software Information

filename.bat

KEIL software information

Proteus software information

Microcontroller learning materials

directory listing.txt

Defense skills

Common descriptions for design reports

74HC138(Chinese information).pdf

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

img

Data download link (clickable):

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

For more resources click the link below:

https://docs.qq.com/sheet/DS0xIa0llTmtNakRW

WeChat public account: Jiasheng MCU

img

(clickable):

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

For more resources click the link below:

https://docs.qq.com/sheet/DS0xIa0llTmtNakRW

WeChat public account: Jiasheng MCU

[External link pictures are being transferred...(img-KgN9htrx-1695978329675)]

Guess you like

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