沈阳理工大学学士学位论文
摘 要
随着电子科技的不断发展与进步,电压测量成为广大电子领域中必须掌握的过程,并且对测量的精度和采集功能的要求也越来越高,而电压的测量与显示系统甚为重要。本文介绍的重点是电压数据的采集与显示系统,数据采集与通信控制采用了单片机ATMEGA128来实现,硬件部分是以单片机为核心,还包括ISP下载模块,显示模块,复位和晶振部分,还有一些简单的外围电路。8路被测电压通过ATMEGA128自带的模-数转换,实现对采集到的数据进行模拟量到数字量的转换,由单片机对数据进行处理,用LED数码管模块来显示所采集的结果,由相关控制器完成数据接收和显示,c程序编写了更加明了化数据显示界面。本系统主要包括四大模块:数据采集模块、控制模块、显示模块、A/D转换模块。绘制电路原理图与工作流程图,并进行调试,最终设计完成了该系统的硬件电路。在软件编程上,采用了C语言进行编程,开发环境使用相关集成开发环境。开发了显示模块程序、通道切换程序、A/D转换程序。
关键词:单片机;LED;A/D转换;模块显示;电压测量
I
沈阳理工大学学士学位论文
Abstract
Along with the development of electronic technology progress, voltage measurement of electronic fields become broad must grasp of the process, and the accuracy of measurement and collection function requirements, and more and more is also high voltage measurement and display system is very important. This paper focuses on voltage data acquisition and display system, data collection and communication control using modular design, data collection and communication control adopted MCU ATMEGA128, hardware part is, still include singlechip mode - several module, ISP download module, display module, Reset and
part of vibration, and some simple outer circuit. 8 and the voltage to be measured by
ATMEGA128 own mode - and to count the collected data for analog to digital, by SCM processing of data, using a digital display module to show the tube, the related results of collecting data receiving and display controller, C programming and the data showed that the interface. This system mainly including four modules: the data acquisition module, control module, display module, A/D conversion module. Draw circuit principle diagram and the work flow, and debugging, finally completed the system design of hardware circuit. In software programming, the C language program development environment, use the integrated development environment. Develop A display module procedures, channel switching procedures, A/D conversion program..
Key words: SCM, LED, A/D conversion, module display voltage measurements.
II
沈阳理工大学学士学位论文
目 录
引 言……………………………………………………………………………………..…….1 1 绪论………………………………………………………………………………..….……2 1.1 研究背景及其目的意义………………………………………………………..……2 1.2 国内外研究现状…………………………………………………………..…………3 1.3 该课题研究的主要内容……………………………………………………….…….3 2 数据采集总体设计………………………………………………….………………….….5 2.1 系统设计的基本要求……………………………………………………………..…5 2.2 数据采集系统结构功能及简介………………………………………………….….5 2.3 硬件开发工具……………………………………………………………………..…6
2.3.1 Altium Designer6.9简介 ……………………………………………............6 2.3.2 Altium Designer6.9设计理念………………………………………………..6 2.3.3 Altium Designer6.9特点……………………………………………………..7 2.4 软件开发工具………………………………………………………………....…….8
2.4.1 ICCAVR…...…………………………………………….…………..………..8 2.5 SLISP软件………………………………………………….………………………9
2.5.1 软件特点………………………………………….…………………………10 2.5.2 软件使用步骤…………………………………………………………….…10
3 硬件设计……………………………………………………………………………….…12 3.1 CUP选型……………………………………………………………………………12
3.1.1 3.1.2 3.1.3 3.1.4 3.1.5
ATmega128L简介 ...................................................................................... .12 ATmega128L特点 ...................................................................................... .12 定时器\\计数器 ............................................................. 错误!未定义书签。 AVR单片机的中断系统 ............................................................................. 19 可编程I/O端口 ........................................................................................... 20
3.2 直流稳压电源…………………………………………………….………….......…24 3.3 单片机基本模块………………………………………………..………………..…25 3.3.1 ISP下载模块………………………………………………………..............25 3.3.2 复位电路模块…………………………………………………………….....25
3.3.3 晶振模块………………………………………………………………….....26
III
沈阳理工大学学士学位论文
3.3.4 蜂鸣器模块.....................................................................................................27 3.3.5 LED显示模块................................................................................................27 3.3.6 A/D转换模块.................................................................................................29
4 软件设计……………………………………………………………………………….…33 4.1 单片机C语言程序设计技术………………………………………………………33
4.1.1 单片机C语言的主要特点 ........................................................................... 33 4.2 主流程 ....................................................................................................................... 34
4.2.1 整体程序的设计 ........................................................................................... 34
4.2.2 ATmega128函数 ...........................................................................................34
4.2.3 AD转换函数 ................................................................................................. 35
4.3 系统运行 .................................................................................................................... 36
4.3.1 程序下载软件................................................................................................ 36
4.3.2 系统运行结果................................................................................................36 结 论…………………………………………………………………………….…….….…..39 致 谢…………………………………………………………………………………....….…40 参考文献…………………………………………………………………………………...…41 附录A 英文原文………………………………………………………………….……..…42 附录B 中文翻译……………………………………………………………………...……49 附录C 原理图………………………………………………………………………………54 附录D PCB图…………………………………………………………………………..….55 附录E 程序清单……………………………………………………………………………57
IV
沈阳理工大学学士学位论文
引 言
当今,电压采集技术应用范围非常的广阔。通常根据采集电压大小不同而采集装置不同,有些电压采集装置只适合于采集比较大的电压,则有些适用于采集比较小的电压。AVR的ATMEGA128单片机的快速性、可靠性以及易更新性使得它成为完成这一任务的目前很好的选择。利用ATMEGA128单片机设计的模块非常简洁,因为该芯片自身带有AD转换模块,可以将采集的模拟电压信号转换成数字量。
本系统针对电压采集精度的局限性,充分利用ATMEGA128单片机芯片的优越性,设计一种基于单片机的电压采集系统,实现实时测量,并用数码管显示其电压,对于促进电压检测技术的发展有着重要现实意义。
随着计算机技术的快速发展,电压采集装置在工业生产中迅速得到了应用。作为电力产业新领域,电压采集技术显示出强劲的发展势头,在安全生产,家用电器,数据采集等领域发挥出越来越重要的作用,甚至在一些特殊情况下。各种实际应用结果表明,该系统具有很好的应用效果和良好的应用前景。
1