编号:29
基于51单片机的数字电压表(ADC0832)
功能描述:
本设计由51单片机最小系统+ADC0832模块+两路模拟量输入模块+液晶1602显示模块
1、主控制器是AT89C82单片机
2、ADC0832模数转换器进行A/D转换,读取电压两路数据,电压检测范围0-5V 精度(8位)
3、利用两个电位器模拟 模拟量输入,
3、液晶1602显示两个电压值。
Proteus7.8以上版本均可使用
视频演示链接:
29、基于51单片机的数字电压表(ADC0832)
仿真图:
程序源码:
#include "reg52.h"
#include "lcd1602.h"
#include "delay.h"
#include "ADC0832.h"
void main(void)
{
unsigned char adc0,adc1;
unsigned char num=0;
unsigned char ADC_Get[10]={0}; //定义AD采样数组
float Voltage0 = 0.0;
float Voltage1 = 0.0;
Lcd1602_Init(); //LCD1602液晶初始化
Lcd1602_String(0,0,"V0: ");
Lcd1602_String(0,1,"V1: ");
while(1)
{
ADC_Get[num++]=ADC0832(1,0); //通道0 利用中值滤波算法
if(num>9)
{
num=0;
adc0=Error_Correct(ADC_Get,10); //取十个值作中值滤波
}
Voltage0 = (float)adc0 * 5.0/255;
Voltage0 = Voltage0 *100; //扩大100倍方便显示
Lcd1602_Write_Com(0x80+3);
Lcd1602_Write_Data((unsigned int)Voltage0/100+0x30);
Lcd1602_Write_Data('.');
Lcd1602_Write_Data((unsigned int)Voltage0%100/10+0x30);
Lcd1602_Write_Data((unsigned int)Voltage0%100%10+0x30);
Lcd1602_Write_Data('V');
adc1=ADC0832(1,1); //通道1
Voltage1 = (float)adc1 * 5.0/255;
Voltage1 = Voltage1 *100; //扩大100倍方便显示
Lcd1602_Write_Com(0xC0+3);
Lcd1602_Write_Data((unsigned int)Voltage1/100+0x30);
Lcd1602_Write_Data('.');
Lcd1602_Write_Data((unsigned int)Voltage1%100/10+0x30);
Lcd1602_Write_Data((unsigned int)Voltage1%100%10+0x30);
Lcd1602_Write_Data('V');
}
}
软件免费下载地址:
1、Proteus仿真软件
文件内容:Proteus7.8安装包、Proteus8.6安装包、Proteus.8.10安装包、Proteus Professional 8.11 SP0安装包
链接:https://pan.baidu.com/s/11LNUZ9BJXWvXf1C4dPc3_w
提取码:2756
2、KEIL4 C51软件安装包
链接:https://pan.baidu.com/s/1CTZBqDsPsyIbjCIjI_birA
提取码:sy2a
文件下载:
https://pan.baidu.com/s/1yGw8HHvJRdcjF28ZcLcTjA?pwd=uys5