摘要水质检测是水资源管理与保护的重要基础,是保护水环境的重要手段。针对我国水质检测系统存在的问题,本论文设计了基于单片机的水质实时检测系统。在此设计电路完成后,它可实现检验五种参数是否达标。本设计的系统编程采用C语言,用单片机AT89S52作系统核心,主要完成对显示电路设计、键盘电路设计等功能。应选用的传感器分别为温度、PH值、电导率、浑浊度和溶解氧。本设计不足在于除温度传感器容易买到外,由于其它四种传感器价格较贵采用模拟检验。整个系统分为复位电路、单片机控制单元电路、A∕D转换电路、输入∕输出电路、LED显示电路、电源电路。主要的设计是几种传感器所采集的数据通过多路开关,传送到A/D转换器再传送到单片机中进行检测。在接通电源的条件下,本系统能够显示检验水质的各种参数,并通过报警电路进行异常情况报警。关键词:AT89S52;DS18B20;LED显示;C语言ABSTRACTThetestingofwaterresourcesistheimportantfoundationofmanagementandprotectionofdetection.Itisalsooneofthemostimportantmeansofprotectingwaterenvironment.Aimingatproblemsofwaterqualityinspectionsystem,thispaperdesignsthereal-timedetectionbasedonsingle-chipwatersystem.Inthecircuitdesign,itcantestfiveparameters.ThedesignusesClanguageonsystemprogramminginAT89S52single-chipmicrocomputer.Thissystemmainlyrealizethedisplaycircuitdesign,thekeyboardcircuitdesignandsoon.Sensorsfortemperature,PHvalue,conductivity,turbidityandoxygenareusedinthisdesign.Exceptfortemperaturesensoriseasytobuy,theotherfoursensorsaretooexpensivetoget,soitusedasimulatedtestinthisdesign.Thewholesystemisdividedintoresetcircuit,single-chipmicrocomputercontrolcircuit,A/Dcircuit,input/outputcircuit,LEDdisplaycircuitandthepowercircuit.Themaindesignistodealwithsignalcomesfromseveralkindsofsensors,andthentransferittoA/Dconvertertoteleporttochipin.Whenturningonthepower,thissystemcandisplaythevariousparametersandqualityinspectionaswellasalarmcircuitabnormalitiesinalarm.KeyWords:AT89S52;DS18B20;Leddisplay;Clanguage目录1引言................................................................................................................................12系统概述........................................................................................................................32.1系统总体设计目标.................................................................................................32.2系统总体设计方案.................................................................................................42.2.1系统工作原理................................................................................................42.2.2系统设计方案................................................................................................42.2.3系统结构框图..............................................................................................133系统硬件电路设计......................................................................................................143.1系统硬件电路.......................................................................................................143.2设计方案的介绍...................................................................................................143.2.1单片机的最小系统电路设计.....................................................................143.2.2系统显示电路.............................................................................................153.2.3键盘电路设计.............................................................................................173.2.4稳压电源设计.............................................................................................183.3系统实现的关键技术...........................................................................................183.3.1抗干扰技术.................................................................................................183.4AT89S52芯片介绍................................................................................................203.4.1引脚功能说明.............................................................................................213.4.2振荡器特征.................................................................................................233.4.3波特率发生器.............................................................................................243.4.4掉电模式.....................................................................................................253.4.5Flash闪速存储器的编程............................................................................253.4.6空闲模式.....................................................................................................263.4.7程序存储器的加密位.................................................................................264系统的软件设计..........................................................................................................274.1C语言程序设计....................................................................................................274.1.1C语言简介..................................................................................................274.1.2C语言的特点..............................................................................................274.1.3C源程序的结构特点..................................................................................274.2系统程序的设计....................................................................................................284.2.1程序设计步骤..............................................................................................284.2.2系统程序编制思想......................................................................................284.3系统主程序...............................................