设计要求
1.以MCS-51系列单片机为核心器件,设计一个简单的直流数字电压表;
2.电压量程:0~5V;
3.最小分辨率:0.01V;
4.所用元器件较少,成本低,且测量精度和可靠性较高;
系统概述
本设计是基于Atmel 51单片机开发平台和自动控制原理的基础上实现的一种数字电压表系统。
该系统采用AT89C51单片机作为控制核心,以ADC0809为模数转换芯片,实现量程0到5V的被测电压数据采样;LCD1602字符液晶显示被测电压值。
同时,数字电压表测量精度为0.01V,能够满足一般测量要求,系统框架如下图所示。

仿真电路


原理图及PCB


仿真结果分析
打开Proteus仿真文件,文件后缀名为DSN.双击单片机,加载DianYa.hex文件(位于C程序文件夹中),运行仿真,结果如下图所示。

图中可以看出,LCD显示AD转换通道IN0电压(Voltage)的大小为1.84V,用Proteus软件自带的电压表(Volts)测量的结果为1.85V,两者偶有0.01V的偏差,属于仿真正常现象。
通过点击滑动变阻器RP2上下红色箭头,模拟被测电压值的改变(0~5V之间),LCD实时跟踪显示电压的变化。设计获取,蒋宇智QQ(2327603104),或关注公众号:交院小智。
下图为调整滑动变阻器后,LCD显示的电压值为4.25V,与Volts电压表显示结果一致。

综上所述,数字电压表Proteus仿真设计运行效果满足设计要求。
部分C代码
#include"include.h"
#define TIME0H 0x3C
#define TIME0L 0xB0
uchar uc_Clock=0;
bit b_DATransform=0;
void vShowVoltage(uint uiNumber)
{
uchar ucaNumber[3],ucCount;
if(uiNumber>999)
uiNumber=999;
ucaNumber[0]=uiNumber/100;
ucaNumber[1]=(uiNumber-100*(int)ucaNumber[0])/10;
ucaNumber[2]=uiNumber-100*(int)ucaNumber[0]-10*ucaNumber[1];
for(ucCount=0;ucCount<3;ucCount++)
{
vShowOneChar(ucaNumber[ucCount]+48);
if(ucCount==0)
vShowOneChar('.');
}
}
void main()
{
TMOD=0x01;
TH0=TIME0H;
TL0=TIME0L;
TR0=1;
ET0=1;
EA=1;
vdInitialize();
vWriteCMD(0x84);
vShowChar("voltage");
vWriteCMD(0xC9);
vShowChar("(V)");
while(1)
{
if(b_DATransform==1)
{
b_DATransform=0;
vWriteCMD(0xC4);
vShowVoltage(uiADTransform());
}
}
}
资源内容
(1)基于51单片机的数字电压表设计论文完整版;
(2)C程序;
(3)Proteus仿真文件;
(4)原理图及PCB文件;
(5)Visio流程图;
(6)元器件清单;
(7)参考资料;
资源截图






|