I
编号:
毕业设计说明书
题 目: SD卡存储采集
数据电路设计
题目类型: 理论研究 实验研究 √工程设计 工程技术研究 软件开发
2012年4月10日
II
摘 要
许多工业现场需要数据采集器完成各类数据采集工作。实际应用中要求数据采集器工作可靠,成本低廉,操作简单便于数据收集和分析;既要方便与PC机联机,又能独立完成数据采集、存储工作。
随着近年来SD卡储存容量的大幅度提高,价格降低,其应用范围越来越广泛。当数据采集系统需要较长的时间来捕捉和记录大量数据时,选择SD卡作为存储介质,是一个非常好的选择。例如在电能监测以及无功补偿系统中,要连续记录大量的电压、电流、有功功率、无功功率以及时间等参数,当单片机采集到这些数据时就可以利用SD作为存储媒质。
论文介绍了SD卡存储采集数据电路设计原理、电路以及程序,阐述了基于STC12C5A60S2芯片主控的DY_mini80E开发板实现数据的采集和数据的SD存储的设计电路过程和实现方法以及运行得到的结果分析。该系统能同时采集四路周期信号波形,并将四路模拟电压(0-5V)进行A/D转换,每秒钟转换一次,结果转换为ASCII码形式,且四路结果分别存储到SD卡预先建立好的CH1.txt、CH2.txt、CH3.txt、CH4.txt文档中。设计在STC12C5A60S2主控芯片的DY_mini80E开发板上,利用开发板上A/D转换模块PCF8591,外接SD接口模块,完成了调试实现。
关键词:数据采集;STC12C5A60S2;PCF8591;SD卡;REG1117-3.3;FAT32文件系统
III
Abstract
Many industry site need data collector of all kinds of data acquisition work completed. Practical application request data collector reliable, low cost, easy to operate, easy to data collection and analysis; Both convenient and PC online, and independently complete the data acquisition, storage work.
In recent years, with SD card storage capacity greatly raised, the lower prices, its application scope is more and more widely. When the data acquisition system needs a long time to catch and records of large quantities of data, choose SD card as a storage medium, is a very good choice. For example in the electrical energy monitoring and reactive compensation system, a record a lot of voltage, current, active power, reactive power and parameters such as time, when the SCM acquisition to these data can use SD as storage medium.
This paper introduces the SD card store data acquisition circuit design principle, circuit and program, this paper expounds the main control based on STC12C5A60S2 chip DY_mini80E development board realize data acquisition and data storage SD circuit design process and the realization methods and operation result analysis. The system can also collecting four ways of periodic signal waveform, and will be four road simulation voltage (0-5 V) for A/D conversion, every second conversion once, result into ASCII form, and four road respectively to the storage SD card established beforehand good CH1. TXT, CH2. TXT, CH3. TXT, CH4. TXT documents. The design of the main control chip in STC12C5A60S2 DY_mini80E development board, using the developed on board A/D conversion module PCF8591, external SD interface module, completed the debugging realized.
Keyword: Data collection;STC12C5A60S2; PCF8591; SD card; REG1117-3.3; FAT32 file system
IV
目 录
引言 .......................................................... 2 1 方案论证与选择 .............................................. 3
1.1 设计相关指标分析及系统构成 ...................................................... 3 1.2 主控电路芯片的选择 .............................................................. 3
2 SD卡简介 ................................................... 4
2.1 SD存储卡系统概念 ................................................................ 4 2.1.1总线拓扑 ....................................................................... 4 2.1.2总线协定 ....................................................................... 6 2.2 SD卡的引脚定义及SD卡的命令 ..................................................... 7 2.2.1 SD卡的引脚定义 ................................................................ 7 2.2.2 SD卡的命令 .................................................................... 8
3 硬件设计 .................................................. 10
3.1 电源模块 ....................................................................... 10 3.2 单片机最小系统 ................................................................. 11 3.2.1 STC12C5A60S2原理图以及它的特性 ............................................... 11 3.2.2 单片机STC12C5A60S2最小系统的组成 ............................................ 13 3.3 带SD卡的TFT彩屏 .............................................................. 15
4 软件设计 .................................................. 18
4.1 软件设计目标 ................................................................... 18 4.2 设计环境 ....................................................................... 18 4.3 系统软件设计 ................................................................... 18 4.3.1 系统初始化 ................................................................... 18 4.3.2 SD卡初始化 ................................................................... 19 4.3.3 数据块的读写 ................................................................. 20 4.3.4 SD卡存储时间和电压流程图 ..................................................... 23
V
4.3.5 定时器T0函数流程图 .......................................................... 24 4.3.6 主体程序流程图 ............................................................... 24
5 结论 ...................................................... 26 谢 辞 ..................................................... 27 参考文献 ..................................................... 28 附 录 ..................................................... 29