APP下载

基于单片机的便携式高度测量仪的设计

2018-11-13张国强谌炎辉张茂盛

现代电子技术 2018年22期

张国强 谌炎辉 张茂盛

摘 要: 介绍一种以51系列单片机STC89C52作为核心控制器的便携式高度测量仪的设计方法。其采用气压传感器BMP180采集相应的气压等数据,采取I2C通信协议与单片机进行串口通信,用C语言编写了相关的计算和补偿的软件程序,将气压值转换成海拔高度。实践表明,该设计能够快速并且较准确地测量出测量仪所处位置的气压值和海拔高度。

关键词: STC89C52; 气压传感器; 程序设计; 通信协议; 串口通信; 高度测量仪

中图分类号: TN949.6?34; TP391.9 文献标识码: A 文章编号: 1004?373X(2018)22?0075?04

Abstract: A design method of the portable height measurement instrument with the 51?series microcontroller STC89C52 as the core controller is introduced. The barometric sensor BMP180 is used to collect the corresponding barometric pressure data. The serial port communication between the barometric sensor and SCM is conducted by using the I2C communication protocol. The related software program for calculation and compensation is compiled with C language, so as to convert the barometric pressure value to the altitude value. The practice shows that the design method can quickly and accurately measure the barometric value and altitude of the position that the measuring instrument is located at.

Keywords: STC89C52; barometric sensor; program design; communication protocol; serial port communication; height measurement instrument

在生態环境方面,海拔、气温、湿度、风速这些环境因素十分重要[1?2],在工业方面,海拔高度和大气压强影响许多产品的质量状况[3]。飞机在飞行时往往需要及时准确地获得飞行的海拔高度,从而确保飞行路线的准确。运动爱好者需要获得野外的海拔高度、温度及大气压强,以便制定合理的运动计划。因此,将温度、气压和海拔高度测量出来就显得尤为重要。本次设计的高度测量仪具有体积小、精度高、功耗低等优点,可以应用于飞行高度测量、户外运动等多种场合。

1 系统设计思路和原理

本系统主要基于单片机进行设计,根据大气压强和海拔高度的转换关系,通过数字气压传感器测量相关的气压数据,测量气压模块采用BMP180气压传感器,和单片机STC89C52进行通信,通信方式为I2C通信协议。单片机读取传感器传过来的一系列参数,例如大气、压力及补偿参数,通过软件进行计算和补偿,将实现相关数值计算的C程序烧写进单片机,并且将大气压强和海拔高度显示在LCD1602上[4?7]。……

登录APP查看全文