编号:32
基于51单片机的数字电压表(PCF8591)
功能描述:
本设计由51单片机最小系统+PCF8591模块+四路模拟量输入模块+一路DA输出+液晶1602显示模块
1、主控制器是89C82单片机。
2、PCF8591模数转换器进行A/D转换,读取四路电压数据,电压检测范围0-5V 精度(8位);实现一路数模转换(D/A)输出电压范围0-5V(8位)。
3、利用四个个电位器模拟 模拟量输入,D/A输出电压。
3、液晶1602显示四路电压值。
Proteus7.8以上版本均可使用
视频演示链接:
32、基于51单片机的数字电压表(PCF8591)
仿真图:
程序源码:
#include "reg52.h"
#include "LCD1602.h"
#include "delay.h"
#include "PCF8591.h"
void main(void)
{
unsigned char BUF[4]; //接收数据缓存区
unsigned int Voltage0 = 0;
unsigned int Voltage1 = 0;
unsigned int Voltage2 = 0;
unsigned int Voltage3 = 0;
Lcd1602_Init(); //LCD1602液晶初始化
Lcd1602_String(0,0," ");
Lcd1602_String(0,1," ");
while(1)
{
PCF8591_DAC(PCF8591_DAC,128);
BUF[0] = PCF8591_Read_ADC(PCF8591_ADC_Channel0);//ADC0 模数转换
BUF[1] = PCF8591_Read_ADC(PCF8591_ADC_Channel1);//ADC1 模数转换
BUF[2] = PCF8591_Read_ADC(PCF8591_ADC_Channel2);//ADC2 模数转换
BUF[3] = PCF8591_Read_ADC(PCF8591_ADC_Channel3);//ADC3 模数转换
Voltage0 = (long)BUF[0] * 500/ 255; //转换为电压值
Voltage1 = (long)BUF[1] * 500/ 255; //转换为电压值
Voltage2 = (long)BUF[2] * 500/ 255; //转换为电压值
Voltage3 = (long)BUF[3] * 500/ 255; //转换为电压值
Lcd1602_String(0,0,"V0:"); //显示电压
Lcd1602_Write_Data(Voltage0/100+0x30);
Lcd1602_Write_Data('.');
Lcd1602_Write_Data(Voltage0%100/10+0x30);
Lcd1602_Write_Data(Voltage0%100%10+0x30);
Lcd1602_String(8,0,"V1:"); //显示电压
Lcd1602_Write_Data(Voltage1/100+0x30);
Lcd1602_Write_Data('.');
Lcd1602_Write_Data(Voltage1%100/10+0x30);
Lcd1602_Write_Data(Voltage1%100%10+0x30);
Lcd1602_String(0,1,"V2:"); //显示电压
Lcd1602_Write_Data(Voltage2/100+0x30);
Lcd1602_Write_Data('.');
Lcd1602_Write_Data(Voltage2%100/10+0x30);
Lcd1602_Write_Data(Voltage2%100%10+0x30);
Lcd1602_String(8,1,"V3:"); //显示电压
Lcd1602_Write_Data(Voltage3/100+0x30);
Lcd1602_Write_Data('.');
Lcd1602_Write_Data(Voltage3%100/10+0x30);
Lcd1602_Write_Data(Voltage3%100%10+0x30);
delay_ms(100);
}
}
软件免费下载地址:
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/1VQnVV2sl2etj209QY5QQQA?pwd=gsrr