用单片机实现交通信号灯控制
摘 要
近年来随着科技的飞速发展,单片机的应用正在不断地走向深入,同时带动传统控制检测日新月异更新。在实时检测和自动控制的单片机应用系统中,单片机往往作为一个核心部件来使用,仅单片机方面知识是不够的,还应根据具体硬件结构,以及对具体应用对象特点的软件结合,加以完善。
本系统由单片机系统、键盘、交通灯演示系统组成。系统包括左转、右转、以及基本的交通灯的功能。系统除基本交通灯的功能外,还具有倒计时、时间设置、紧急情况处理、分段调整信号灯的点亮,时间以及根据具体情况手动控制等功能。
本系统硬件电路实现简单而且稳定,交通信号灯模拟控制系统设计利用单片机的定时器定时,令十字路口的红绿灯交替点亮和熄灭,并利用LED数码管显示时间。用89S51做输出口,控制发光二极管的熄与灭,模拟交通灯管理。本系统若能用LCD做显示器就大大增强了其实用性。
关键词:89S51单片机,交通灯,计时,显示
I
USE SINGLE-CHIP CONTROL TRAFFIC LIGHTS
ABSTRACT
In recent years, with the rapid development of science and technology, the application of SCM is to keep at the same time, traditional control testing update on Crescent benefits. In real-time detection and automatic control system of single-chip applications, often as a single-chip core component to use only single-chip is not enough knowledge, but also the specific hardware structure and application of object-specific characteristics software, to be improved.
The system consists of single-chip microcomputer system, keyboard, traffic lights that my system. System, including left turn, right turn, as well as the basic function of traffic lights. Traffic lights system in addition to basic functions, also has a countdown, the time setting, emergency handling, at times to adjust the light signal, according to the specific circumstances of time and manual control functions.
Hardware circuit of the system simple and stable simulation of traffic signal control system design using single-chip timer timing, so that the traffic lights at the crossroads and turn out light and LED digital display with time. 89S51 do with output, control burning out light-emitting diodes to simulate the management of traffic lights. If the system used for display on the LCD greatly enhance its usability.
KEY WORDS: 89S51 Single-chip, traffic lights, time to show
II
洛阳理工学院毕业设计(论文)
目 录
前 言 .......................................................................................................... 1 第1章 单片机的发展及应用 .................................................................... 2 1.1 单片机的发展 ................................................................................. 2 1.2 单片机的应用 ................................................................................. 3 1.3 89S51单片机的简介....................................................................... 3 1.4 89S51单片机的引脚....................................................................... 5 1.5 89S51单片机的特点....................................................................... 6 第2章 交通的基本情况 ............................................................................ 7 2.1交通灯的结构 .................................................................................... 7 2.2交通灯的工作过程 ............................................................................ 7 2.3交通灯的控制方案 ............................................................................ 8 2.4交通灯控制的行车图 ........................................................................ 8 第3章 方案论证与理论分析 .................................................................. 10 3.1方案论证 .......................................................................................... 10 3.1.1电源提供方案 ......................................................................... 10 3.1.2 显示界面方案 ........................................................................ 10 3.1.3 LED连接方案 ........................................................................ 11 3.1.4 输入方案 ................................................................................ 11 3.2 理论分析与计算 ............................................................................. 12 第4章 硬件电路设计 .............................................................................. 14 4.1 灯控制电路设计 ............................................................................. 14 4.2 LED显示系统 ................................................................................. 14 4.2.1 LED的显示方法与接口 ........................................................ 14 4.2.2 74LS164简介 ......................................................................... 16 4.3 晶阵介绍 ......................................................................................... 17 4.4 电源设计 ......................................................................................... 18 4.5 按键原理 ......................................................................................... 19 第5章 软件设计 ...................................................................................... 21 5.1 主程序流程图 ................................................................................. 21
III
洛阳理工学院毕业设计(论文) 5.2 中断服务程序模块 ......................................................................... 22 5.3 显示程序模块 ................................................................................. 23 结 论 ........................................................................................................ 25 谢 辞 .......................................................................................................... 26 参考文献 .................................................................................................... 27 附 录 ........................................................................................................ 28外文资料翻译 ................................................................................ 34
IV