摘 要
本文介绍了一个基于单片机的称重系统设计,本设计以单片机为平台,利用金属应变片来感应人体的重量,传感器输出模拟量经 AD转换器转换成数字量传入单片机。利用超声波在介质中传播速度固定的原理可由超声波在空气中的传播时间算出传播距离,实现身高的测量。通过串口电路实现了单片机与上位机的通信。本设计硬件电路包括电源电路、单片机最小系统电路、液晶屏电路、串口通信电路、独立按键电路、蜂鸣器电路、超声波模块电路、AD转换器电路和全桥电路。软件部分包括主程序、系统初始化程序、AD转换器通信程序、按键检测程序、超声波信号发射及接收程序、液晶屏驱动程序。
整个设计系统由Atmel公司生产STC89C51单片机进行控制;软件实现功能开机检测,主要是开机后自动逐个扫描LED数码管,以防止某段数码管损坏造成视觉误差;出于人性化考虑我们还可以增加语音电路,实现自动语音播报重量。本设计一个能完成精确计量且LED数码显示的电子称,并且带有身高体重比例正常与否的语音提示。
关键词:STC89C51;称重仪;LED数码管;语音播报
ABSTRACT
This paper introduces the design of a weighing system based on a single chip microcomputer. The design is based on a single chip microcomputer and uses metal strain gauges to induce the weight of the human body. The analog output of the sensor is converted into digital input into a single chip microcomputer by AD converter. The propagation distance can be calculated from the propagation time of ultrasonic wave in the air by using the principle of the constant propagation speed of ultrasonic wave in the medium. The hardware circuit of this design includes power supply circuit, MCU minimum system circuit, LCD screen circuit, serial communication circuit, independent keystroke circuit, etc. Buzzer circuit D converter circuit and full bridge circuit. The software includes main program, system initialization program, AD converter communication program, key detection program, ultrasonic signal transmitting and receiving program, LCD screen driver program.
The whole design system is controlled by STC89C51 single-chip computer produced by Atmel Company, and the function of software realization is to start the detection, mainly to scan the LED digital tube one by one automatically after the boot, to prevent the damage of a section of digital tube from causing visual error. Due to the consideration of humanization, we can also increase the speech circuit and realize the weight of the automatic voice broadcast. This design can accomplish the accurate measurement and the LED digital display, and has the voice prompt with the normal ratio of height and weight.
Keywords: STC89C51; weighing instrument; LED digital tube; voice broadcast
目 录
1绪论 1
1.1选题背景及意义 1
1.2研究现状 1
1.2.1 国内外称重仪现状 1
1.2.2 称重仪的发展趋势 2
1.3研究内容 3
2基于单片机的称重系统总体方案设计 4
2.1设计方案的选定 4
2.2基于单片机的称重系统的工作过程 5
3基于单片机的称重系统的硬件电路设计 6
3.1电源电路 6
3.2单片机最小系统电路 6
3.3串口通信电路 7
3.4超声波模块接口电路 8
3.5独立按键电路 8
3.6液晶屏电路 9
3.7语音播放模块 10
3.7.1 语音播放芯片ISD25120 10
3.7.2 ISD25120的直接寻址模式 10
3.7.3 ISD25120的直接寻址任意分段方式 11
3.7.4 ISD25120的硬件电路 11
3.8 HX711 AD转换器模块接口电路 12
3.9全桥电路 12
3.10总体硬件电路及其工作原理 14
4基于单片机的称重系统软件程序设计 15
4.1主函数的编写 15
4.2系统初始化函数的编写 17
4.3 HX711 AD转换器通信函数的编写 18
4.4按键检测函数的编写 19
4.5超声波模块函数的编写 21
4.6液晶屏驱动函数的编写 22
4.7 ISD25120语音播报子程序 25
5开发平台及调试 26
5.1硬件的制作 26
5.2硬件的开发平台 27
5.3软件的调试 27
5.4软件的开发平台 28
5.5上位机软件 29
6总结 30
6.1特点 30
6.2不足与改进 30
参考文献 32
致 谢 33
附录:仿真电路图 34
附录:程序代码 35