⑴ 利用51单片机,4个数码管设计一个计时器,要求在数码管上显示的数据从0开始每1秒钟加1。
共阳数码管中断程序:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]=
{
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x83,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};
uint num,a;
uchar ,shi,ge;
void init();
void delay(uint);
void display(uchar,ucharshi,ucharge);
uint fb();
uint fs();
uint fg();
void main()
{
init();
while(1)
{
display(fb(),fs(),fg());
}
}
void init()
{
num=0;
a=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void display(uchar,ucharshi,ucharge)
{
P1=0xfd;
P0=table[];
delay(1);
P1=0xfb;
P0=table[shi];
delay(1);
P1=0xf7;
P0=table[ge];
delay(1);
}
void timeoff() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65526-50000)%256;
a++;
if(a%20==0)
{
num++;
if(num==999)
{
num=0;
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
uint fb()
{
=num/100;
return ;
}
uint fs()
{
shi=num%100/10;
return shi;
}
uint fg()
{
ge =num%100%10;
return ge;
}
(1)设计计时装置扩展阅读
2个可编程定时/计数器·5个中断源,2个优先级(52有6个)
一个全双工串行通信口
外部数据存储器寻址空间为64kB
外部程序存储器寻址空间为64kB
逻辑操作位寻址功能·双列直插40PinDIP封装
单一+5V电源供电
CPU:由运算和控制逻辑组成,同时还包括中断系统和部分外部特殊功能寄存器;
RAM:用以存放可以读写的数据,如运算的中间结果、最终结果以及欲显示的数据;
ROM:用以存放程序、一些原始数据和表格;
I/O口:四个8位并行I/O口,既可用作输入,也可用作输出
T/C:两个定时/记数器,既可以工作在定时模式,也可以工作在记数模式;
五个中断源的中断控制系统;
一个全双工UART(通用异步接收发送器)的串行I/O口,用于实现单片机之间或单片机与微机之间的串行通信;
片内振荡器和时钟产生电路,石英晶体和微调电容需要外接。最佳振荡频率为6M—12M。
参考资料来源:网络-51单片机
⑵ 除了水还可以用哪些能流动的物体来制作计时工具
除了水还可以用细沙来计时,比如沙漏就是用细而均匀的颗粒。沙漏的发明也是被逼出来的:算一年、一个月、一天的时间都能算,要是算一碗水烧开的时间的标准就不知道了。当然具体是哪国人发明的已经无从考证,历史学家的说法是:沙漏最初是作为辅助的天文仪器使用的。古时没有玻璃,人们就用简易的容器制作,时间是按照流沙从容器流过的数量来计算。1360年汉人詹希元创制的“五轮沙漏”甚至还有用到了齿轮的机械拨动装置,有木人击鼓报告时刻的花样。
⑶ 可以计时的简单装置如何制作,小学五年级科学作业。谢谢!
材料:线香、秒表、刻度尺、彩笔
方法:
1、用刻度尺测量线香的长度L1
2、点燃线香、同时按下秒表按钮开始计时,10s钟熄灭线香。测量线香长度L2
3、10s线香燃烧的长度 L=L1-L2 并分成10等分,每份为1s燃烧的长度L0
4、以L0为标度,在每根线香上用彩笔标出刻度
这样一个简单、经济的计时器就制成了。
⑷ 想设计一个计时电路,给电计时,断电停止计时,并且数显装置能够显示计时时间,怎么设计好,用到那些元器
555,4017,4511,数码管,如用单片机则电路较简单,但要会写程序
⑸ 如何设计计量时间的钟表
毕业设计设计题目 秒表/时钟计时器的设计设计 类型 工程设 导师姓名 席东河 1、用六位LED数码管显示时、分、秒; 2、使用按键开关可实现时分调整; 3、秒表/时钟功能转换; 4、关闭显示即省
⑹ vb怎么设计简单的计时器
控件:左侧序号(TextBox):p1p2p3p4p5p6p7p8
右侧时间(TextBox):tt1t2t3t4t5t6t7t8
下侧按钮(Button):Button1Button2Button3
'正文---------------------------------------------------------------
PublicClassForm1
DimStartTimeAsDecimal
DimGettedTimeAsDecimal
DimTimeOfTopAsDecimal
DimStopMomentAsByte
DimFirstTimeAsDecimal
PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
t1.Text=""
t2.Text=""
t3.Text=""
t4.Text=""
t5.Text=""
t6.Text=""
t7.Text=""
t8.Text=""
a2.Text=""
a3.Text=""
a4.Text=""
a5.Text=""
a6.Text=""
a7.Text=""
a8.Text=""
t.Text="0.0"
p1.Visible=False
p2.Visible=False
p3.Visible=False
p4.Visible=False
p5.Visible=False
p6.Visible=False
p7.Visible=False
p8.Visible=False
t1.Visible=False
t2.Visible=False
t3.Visible=False
t4.Visible=False
t5.Visible=False
t6.Visible=False
t7.Visible=False
t8.Visible=False
a2.Visible=False
a3.Visible=False
a4.Visible=False
a5.Visible=False
a6.Visible=False
a7.Visible=False
a8.Visible=False
Button1.Enabled=True
Button2.Enabled=True
Timer1.Enabled=False
Timer2.Enabled=False
Timer3.Enabled=False
Timer4.Enabled=False
Timer5.Enabled=False
Timer6.Enabled=False
Timer7.Enabled=False
Timer8.Enabled=False
a2.Left=71
a3.Left=71
a4.Left=71
a5.Left=71
a6.Left=71
a7.Left=71
a8.Left=71
EndSub
PrivateFunctionToTime(ByValTimeLengthAsDecimal)AsString
DimhAsDecimal
DimmAsDecimal
DimsAsDecimal
DimHoursAsString
DimMinutesAsString
DimSecondsAsString
DimNoHourAsBoolean
DimNoMinutesAsBoolean
IfInt(TimeLength/3600)=0Then
Hours=""
NoHour=True
Else
NoHour=False
h=Int(TimeLength/3600)
Hours=h&":"
EndIf
m=Int((TimeLength-h*3600)/60)
Ifm.ToString.Length=1Andm<>0Then
NoMinutes=False
IfNoHour=TrueThen
Minutes=m&":"
Else
Minutes="0"&m&":"
EndIf
ElseIfm=0Then
NoMinutes=True
IfNoHour=TrueThen
Minutes=""
Else
Minutes="0"&m&":"
EndIf
Else
NoMinutes=False
Minutes=m&":"
EndIf
s=TimeLength-3600*h-60*m
IfInt(s).ToString.Length=2Or(NoHour=TrueAndNoMinutes=True)Then
Seconds=s
Else
Seconds="0"&s
EndIf
IfNoHour=TrueAndNoMinutes=TrueAndInt(Seconds).ToString.Length=1Then
SelectCaseSeconds.Length
Case1
Seconds=Seconds&".000"
Case3
Seconds=Seconds&"00"
Case4
Seconds=Seconds&"0"
EndSelect
Else
SelectCaseSeconds.Length
Case2
Seconds=Seconds&".000"
Case4
Seconds=Seconds&"00"
Case5
Seconds=Seconds&"0"
EndSelect
EndIf
ToTime=Hours&Minutes&Seconds
EndFunction
PrivateSubGetTime()
GettedTime=DateDiff(DateInterval.Second,Today,Now)+My.Computer.Clock.LocalTime.Millisecond/1000
EndSub
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
GetTime()
StartTime=GettedTime
Timer1.Enabled=True
t.Text="0.0"
Button1.Enabled=False
EndSub
PrivateSubTimer1_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer1.Tick
GetTime()
IfTimeOfTop+0.1<GettedTime-StartTimeThen
TimeOfTop=TimeOfTop+0.1
t.Text=ToTime(TimeOfTop).Remove(ToTime(TimeOfTop).Length-2)&""
EndIf
EndSub
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Click
StopMoment=StopMoment+1
SelectCaseStopMoment
Case1
GetTime()
t1.Text=ToTime(GettedTime-StartTime)
FirstTime=GettedTime
p1.Visible=True
t1.Visible=True
Case2
GetTime()
t2.Text=ToTime(GettedTime-StartTime)
a2.Text="+"&ToTime(GettedTime-FirstTime)
Timer2.Enabled=True
p2.Visible=True
t2.Visible=True
a2.Visible=True
Case3
GetTime()
t3.Text=ToTime(GettedTime-StartTime)
a3.Text="+"&ToTime(GettedTime-FirstTime)
Timer3.Enabled=True
p3.Visible=True
t3.Visible=True
a3.Visible=True
Case4
GetTime()
t4.Text=ToTime(GettedTime-StartTime)
a4.Text="+"&ToTime(GettedTime-FirstTime)
Timer4.Enabled=True
p4.Visible=True
t4.Visible=True
a4.Visible=True
Case5
GetTime()
t5.Text=ToTime(GettedTime-StartTime)
a5.Text="+"&ToTime(GettedTime-FirstTime)
Timer5.Enabled=True
p5.Visible=True
t5.Visible=True
a5.Visible=True
Case6
GetTime()
t6.Text=ToTime(GettedTime-StartTime)
a6.Text="+"&ToTime(GettedTime-FirstTime)
Timer6.Enabled=True
p6.Visible=True
t6.Visible=True
a6.Visible=True
Case7
GetTime()
t7.Text=ToTime(GettedTime-StartTime)
a7.Text="+"&ToTime(GettedTime-FirstTime)
Timer7.Enabled=True
p7.Visible=True
t7.Visible=True
a7.Visible=True
Case8
GetTime()
t8.Text=ToTime(GettedTime-StartTime)
a8.Text="+"&ToTime(GettedTime-FirstTime)
Timer8.Enabled=True
p8.Visible=True
t8.Visible=True
a8.Visible=True
Timer1.Enabled=False
t.Text=t8.Text
Button2.Enabled=False
EndSelect
EndSub
PrivateSubButton3_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesButton3.Click
StartTime=0
GettedTime=0
TimeOfTop=0
StopMoment=0
FirstTime=0
t1.Text=""
t2.Text=""
t3.Text=""
t4.Text=""
t5.Text=""
t6.Text=""
t7.Text=""
t8.Text=""
a2.Text=""
a3.Text=""
a4.Text=""
a5.Text=""
a6.Text=""
a7.Text=""
a8.Text=""
t.Text="0.0"
p1.Visible=False
p2.Visible=False
p3.Visible=False
p4.Visible=False
p5.Visible=False
p6.Visible=False
p7.Visible=False
p8.Visible=False
t1.Visible=False
t2.Visible=False
t3.Visible=False
t4.Visible=False
t5.Visible=False
t6.Visible=False
t7.Visible=False
t8.Visible=False
a2.Visible=False
a3.Visible=False
a4.Visible=False
a5.Visible=False
a6.Visible=False
a7.Visible=False
a8.Visible=False
Button1.Enabled=True
Button2.Enabled=True
Timer1.Enabled=False
Timer2.Enabled=False
Timer3.Enabled=False
Timer4.Enabled=False
Timer5.Enabled=False
Timer6.Enabled=False
Timer7.Enabled=False
Timer8.Enabled=False
a2.Left=71
a3.Left=71
a4.Left=71
a5.Left=71
a6.Left=71
a7.Left=71
a8.Left=71
EndSub
PrivateSubTimer2_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer2.Tick
a2.Left=a2.Left+10
Ifa2.Left=171Then
Timer2.Enabled=False
EndIf
EndSub
PrivateSubTimer3_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer3.Tick
a3.Left=a3.Left+10
Ifa3.Left=171Then
Timer3.Enabled=False
EndIf
EndSub
PrivateSubTimer4_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer4.Tick
a4.Left=a4.Left+10
Ifa4.Left=171Then
Timer4.Enabled=False
EndIf
EndSub
PrivateSubTimer5_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer5.Tick
a5.Left=a5.Left+10
Ifa5.Left=171Then
Timer5.Enabled=False
EndIf
EndSub
PrivateSubTimer6_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer6.Tick
a6.Left=a6.Left+10
Ifa6.Left=171Then
Timer6.Enabled=False
EndIf
EndSub
PrivateSubTimer7_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer7.Tick
a7.Left=a7.Left+10
Ifa7.Left=171Then
Timer7.Enabled=False
EndIf
EndSub
PrivateSubTimer8_Tick(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesTimer8.Tick
a8.Left=a8.Left+10
Ifa8.Left=171Then
Timer8.Enabled=False
EndIf
EndSub
EndClass
'正文完-------------------------------------------------------------
⑺ 利用单片机设计实现一个60秒倒计时显示装置,并且计时到后发出报警声音。
#include<reg52.h>
sbitbz=P3^1;
unsignedchara[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xd8,0x80,0x90};
unsignedcharn,time=60;
main()
{
P1=a[0];
P2=a[6];
TMOD=0X01;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
EA=1;
ET0=1;
TR0=1;
while(1);
}
timer0()interrupt1
{
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
if(time!=0)
{
n++;
if(n==100)
{
n=0;
time--;
P1=a[time%10];
P2=a[time/10];
}
}
elsebz=~bz;
}
⑻ 计时工具的设计运用了物体运动的什么规律
计时工具的设计运用了物体运动周期性变化的规律。不管是在古代时候的那种日晷,包括用其他一种方式来计时,都是运用了这一规律。
例如在单摆运动中,从平衡位置处开始计时,小球向左摆,动能减小,重力势能增加,直到最高点,从最高点处开始下落到平衡位置的过程中,动能增加,重力势能减小。这是单摆运动的一个周期。
计时装置漏刻介绍
早期漏刻大多使用单只漏壶,滴水速度受到壶中液位高度的影响,液位高,滴水速度较快,液位低,滴水速度较慢。为解决这一问题,古人进一步创制出多级漏刻装置。
所谓多级漏刻,即使用多只漏壶,上下依次串联成为一组,每只漏壶都依次向其下一只漏壶中滴水。
⑼ 自制计时器的设计原理
设定一段时间如5分钟,对滴水计时器的滴水数量进行计数为N.则滴水的时间间隔为5*60/N(秒).
⑽ 30秒倒计时电路的设计
首先要有个可以产生1秒的时钟电路,可以通过CD4040加32768HZ的晶镇分频,分频后是2HZ,还要在分一次可以用CD4013之类的双D触发器实现,但我一般1秒的记时喜欢使用家庭的石英钟的电路.他的脉冲的0.5HZ也就是2秒发一次,但需要通过二极管来整出来,因为他的0.5HZ是分别发的然后对地是1赫兹. 然后就是记时电路,可以用2 个CD4028是带有正负记时的十进制记数电路,有进位和借位(在减记数时用到借位)BCD码输出,通过CD4511或CD4543(我比较喜欢CD4543,因为他的6和9显示的比较人性化,而4511显示的6没有最上面的横,和b的样子差不多,9没有下面的一横和q差不多)来进行数码管驱动,而4543的好处是他可以选择共阳极还是共阴数码管.然后把4028设定到负计时方式(通过引脚的电平来控制)然后可以用个电子开关比如CD4066来控制设定的时间这个可以定时到99秒,但要是显示30秒,需要预先设定到3和0十位的3需要先自己做个小脉冲发生器,来进行设定,这个自己就可以设计出电路来了吧~