单片机课程设计篮球计时计分器正文1 下载本文

内容发布更新时间 : 2024/6/6 22:19:53星期一 下面是文章的全部内容请认真阅读。

eaintheaccidentinvestigation,managementandreporting,eachpostshouldbedevelopedunderthissystemspecialistscheck,cleartheexaminatons,time,cyclesandotherrelevantregulations.Strengtheningsitesupervisionandexamination,todetectandinvestigateillegalcommand,illegaloperationsandviolationsofoperatingrules.Secondsafetyreferstotheproductionsite,technologymanagement,equipment,facilities,andsooncanleadtoaccidentsrisksexist.1,accordingtotheextentofthesecurityrisks,solvingisdividedintoa,b,andclevelsofdifficulty;A-level:difficult,miningdifficulties,shallbereportedtothecompany'sproblems.B-class:difficulttoresolvedif

基于单片机的篮球赛计时计分器的设计

一 系统设计方案

1.1 设计题目

篮球计时计分器

1.2 系统功能要求

本系统可实现功能如下:

(1)主控部分:选择单片机为核心元件构成系统。

(2)计时部分:能记录整个赛程的比赛时间,并能修改时间、暂停时间。 (3)计分部分:能随时刷新甲、乙两队在整个赛程中的比分。 (4)中场交换比赛场地时,能交换甲、乙两队比分的位置。 (5)比赛时间结束时,能发出报警指令。

1.3 系统总体方案设计

本设计由AT89C51编程控制LED七段数码管作球赛计时计分系统具有赛程定时设置、赛程时间暂停、性能稳定、操作方便且易携带等特点。 1.3.1系统设计方案论证

本设计是基于89C52单片机的键盘控制及显示电路设计,从系统的设计功能上看,系统可分为两大部分,即键盘输入控制部分和显示部分,对于每一个部分都有不同的设计方案,起初我拟订了下面两种方案:

第一种方案:

键盘控制采用矩阵扫描键盘,可以用普通按键构成4×4矩阵键盘,直接接到89C51单片机的P0口,高四位作为行,低四位作为列,通过软件完成键盘的扫描和定位。显示部分采用动态显示,采用移位寄存器74LS164和译码器74LS138通过显示驱动程序驱动七段数码管显示。此方案成本低,所用到的两个外围芯片价格都很低廉,而且单片机的I/O口占用较少,可以节约单片机接口资源。 第二种方案:

键盘控制采用独立是式键盘,每个按键的\接零端\均接地,每个按键的\测

iculties,shallconsistofminingorganizationstosolveproblems.C-class:fromsegmentsandbusinessrisksthatmustbeaddressedintheDepartment.2,open-pitmineunsafetypesinclude:electrical,transport,blasting,fire,andotherslope.3,accordingtotheseverityofthehazardfilledinbyunittroubleshooting,registrationform(seeatteaintheaccidentinvestigation,managementandreporting,eachpostshouldbedevelopedunderthissystemspecialistscheck,cleartheexaminatons,time,cyclesandotherrelevantregulations.Strengtheningsitesupervisionandexamination,todetectandinvestigateillegalcommand,illegaloperationsandviolationsofoperatingrules.Secondsafetyreferstotheproductionsite,technologymanagement,equipment,facilities,andsooncanleadtoaccidentsrisksexist.1,accordingtotheextentofthesecurityrisks,solvingisdividedintoa,b,andclevelsofdifficulty;A-level:difficult,miningdifficulties,shallbereportedtothecompany'sproblems.B-class:difficulttoresolvedif试端\各接一条输入线,通过检测输入线的电平状态就可以很容易地判断哪个键被按下了,这种方法操作速度高而且软件结构很简单。这种方法比较适合按键较少或操作速度较高的场合。显示部分采用静态显示方法,所谓静态显示,就是每一个显示器都要占用单独的具有锁存功能的接口用于笔划段字形代码。这样单片机只要把要显示的字形代码发送到接口电路,就不用管它了,直到要显示新的数据时,再发送新的字形码,因此,使用这种方法单片机中CPU的开销小。 方案的确定:

本设计要求按键较多,且本次设计只是对所学知识的一次实践,设计要求简单,容易实现,成本低。比较以上两中设计方案,第二种成本低,占用单片机资源少,且容易实现,这样的设计比较适合本次设计,故选用第二种设计方案。 1.3.2系统构成框图

基于AT89S52单片机的篮球计时计分器的系统框图如图1所示:

图1系统框图

开始暂停 场地交换 加分设定 时间设定 单 片 机 控 制 系 统 时间显示 分数显示 定时报警 本系统采用单片机AT89C51作为本设计的核心元件,利用七段共阴极LED数码管作为显示器件。在此设计中共接入8个七段共阴极LED显示器,其中4个用于计录甲、乙两队的分数,每队2个LED显示器显示范围可达到0~99分,足够满足赛程要求;另外4个LED显示器则用来计录赛程的时间,其中2个用于显示分钟,2个用于显示秒钟。赛程计时采用倒计时方式。即比赛前将时间设置好,比赛开始时启动计时,直到计时到零为至。计时范围可达0~99分钟,也完全满足实际赛程的需要。

其次,为了配合计时器和计分器校正、调整时间和比分,我们在设计中设立

iculties,shallconsistofminingorganizationstosolveproblems.C-class:fromsegmentsandbusinessrisksthatmustbeaddressedintheDepartment.2,open-pitmineunsafetypesinclude:electrical,transport,blasting,fire,andotherslope.3,accordingtotheseverityofthehazardfilledinbyunittroubleshooting,registrationform(seeatteaintheaccidentinvestigation,managementandreporting,eachpostshouldbedevelopedunderthissystemspecialistscheck,cleartheexaminations,time,cyclesandotherrelevantregulations.Strengtheningsitesupervisionandexamination,todetectandinvestigateillegalcommand,illegaloperationsandviolationsofoperatingrules.Secondsafetyreferstotheproductionsite,technologymanagement,equipment,facilities,andsooncanleadtoaccidentsrisksexist.1,accordingtotheextentofthesecurityrisks,solvingisdividedintoa,b,andclevelsofdifficulty;A-level:difficult,miningdifficulties,shallbereportedtothecompany'sproblems.B-class:difficulttoresolvedif了10个按键。其中6个用于甲、乙两队的分数;另外4个则用于完成设置、调整、启动和暂停时间等功能。 1.3.3 基本功能介绍

(1) 赛程时间设置

在计时电路中,先按EXCHANGE-TIME键,转换到调时模式,再按键开关K1、K6用来设置时间。启动时,初始时间为12分钟。比如:当比赛时上半场时间为20分,则通过按K1键加分钟,直到显示20。当想向下调时间可按k6键减时间。时间设置好后,等待比赛开始。

当比赛结束时,如果需增加比赛时间,这时增加比赛时间同样由按键开关K1、K6用来设置,且方法和上面一样。

(2) 赛程时间启/停设置

在比赛要开始的时候按RUN/STOP键可开始计时,当中途要暂停时可按再按一次该键暂停。 (3)比分交换控制

比分交换控制由EXCHANGE键完成。我们知道,因为比分交换是在上半场赛程结束后进行的,此时只需要按该键则两队的分数会交换,比如上半场的比分为10:14,按了EXCHANGE键后,则LED分数显示为14:10。

(4) 比分刷新控制

由于在比赛中,甲、乙两队的比分是不断变化的,所以需设置比分刷新控制装置;此功能由图3所示的计分电路中的按键开关K1~K6完成: K1键: 完成TEAM1队加1分操作; K2键: 完成TEAM1队加2分操作; K3键: 完成TEAM1队加3分操作; K4键: 完成TEAM2队加1分操作; K5键: 完成TEAM2队加2分操作; K6键: 完成TEAM2队加3分操作。

(5)计分计时显示

计分计时显示器是采用七段共阴LED数码管显示。其中计时是用4个LED显示器,计分用4个LED显示器;计时显示格式为00,计分显示格式为00.00 。

(6)赛程结束报警

当比赛结束时,系统会自动报警声,提示比赛结束。

iculties,shallconsistofminingorganizationstosolveproblems.C-class:fromsegmentsandbusinessrisksthatmustbeaddressedintheDepartment.2,open-pitmineunsafetypesinclude:electrical,transport,blasting,fire,andotherslope.3,accordingtotheseverityofthehazardfilledinbyunittroubleshooting,registrationform(seeatt3