1、1 基于单片机的水位控制系统设计基于单片机的水位控制系统设计 摘要摘要 本设计是采用AT89C51单片机为核心芯片,及其他相关硬件来实现的水位控制 系统,并用两位七段共阴LED显示器示水位高度,检测水位数据。当水位低于用户设 定的值时,系统会实施报警安全提示,并自动打开电机上水。当水位达到设定值时, 系统停止报警,并自动关闭电机。当水位高于另一设定值时,系统再次报警,电 机自动打开放水,直到水位正常,报警停止,电机自动关闭。 关键字:关键字:单片机,LED显示器,电机 Abstract This design uses AT89C51 chip microcomputer as the mos
2、t important chip,and other related hardware to realize the water level control system,with the two-position,seven segment and common negative LED display to show the water level height,to check the water level data.When water level is under the users set point, the system will give an alarm and impl
3、ement safe hint, and automatically open electric motor to provide water.When water level reaches the set point,system will stop giving an alarm,and automatically close down the electric motor.When water level is over the set point,system will give an alarm again and the electric motor will automatic
4、ally open to turn on the water,until water level is normal,system will stop giving an alarm, and automatically close down the electric motor. Key words:single-chip microcomputer, LED display, electric motor 1 引言引言 单片机原理及系统课程设计报告 2 本设计对水箱的水位进行控制,主要为了避免水箱的“无水”和“溢水”现 象,使水位保持在一定的范围内,同时也避免了对水资源的浪费。本设计利用了
5、 单片机来实现这一功能。这一小块芯片上集成了一个微型计算机的各个组成部分, 它的诞生使众多自动化控制系统得以实现。让51单片机与数码显示连接可随时掌 握水位高度,与电机相连实现自动给水排水功能。 2 设计方案及原理设计方案及原理 1.1 设计原设计原理理 该水位控制系统由一片AT89C51单片机芯片,一块两位七段共阴LED显示器, 一片电机驱动芯片1298,一个电机,8个高低排列符合物理顺序的按键,用来模拟 水位的高低,每一个按键代表10cm高的水位,当水位低于30cm时,系统会实施报 警安全提示,并自动打开电机上水。当水位达到设定值时,系统停止报警,并自动关 闭电机。但是当水位60cm时,系
6、统也会报警,电机自动打开放水,直到水位正常, 报警停止,电机自动关闭,使水位始终保持在30cm-60cm之间。同时数码管也会随 时显示水位的高低数值。 1.2 设计方案设计方案 (1)硬件设计硬件设计 系统电路是由按键输入电路,二极管、LED显示输出电路,晶振电路,及复 位电路组成。选用一片AT89C51单片机,三个发光二极管,一块两位七段共阴LED 显示器,一片电机驱动芯片1298,一个电机,8个高低排列符合物理顺序的按键, 一个蜂鸣器。按键由P1口输入(P1.0为最高水位,P1.7为最低水位) ,显示器由P0 口输出,P1口接报警装置,P2口接电机驱动装置。具体系统组成框图及电路原理 设计图如下图所示: 图 1 系统组成框图 晶振电路 AT89C51 单片机 LED 显示输出 报警装置 电机驱动装置 复位电路 按键输入 单片机原理及系统课程设计报告 3 图 2 电路原理整体设计图 图 3 电机驱动电路 图 4 按键输入电路 (2)软件设计)软件设计 实验程序由 C 语言编写,keil C 编译,proteus 仿真实验电路。程序除主程序 外,