先上数据
有C1: R2=10k,R18=100,R1=0mv,ADC输出0.00022mV
有C1: R2=100k,R18=100,R1=4.8mV,ADC输出12mV
有C1: R2=10k,R18=100,R1=4.8mV,ADC输出4.6mV
有C1: R2=1k,R18=100,R1=4.8mv,ADC输出1.6mV
无C1: R2=1k,R18=100,R1=0mv,ADC输出0mV
无C1: R2=10k,R18=100,R1=4.8mv,ADC输出1.6mV
现在确定R2=10k,R18=100,c1=0.1uF,当R1有电流时,测量电压基本吻合,无电影时不能归零。当去掉C1后无电流时,输出也为0,但是有电流后测量的数据和实际又对不上.大家帮忙分析一下问题出在哪里。是不是前端电路的问题。万分感谢!
float ADC0_value(uchar mode,uchar p,uchar n)
{
volatile uchar i=7;
unsigned long tem;
long tem1;
float v;
RedLed=~RedLed;
ADC0MD=0x80; //空闲
ADC0CN|=0x07;
if(mode==0)
{
ADC0CN &= ~0x10;//单端输入
}
else
{
ADC0CN |=0x10;//差分输入
}
ADC0MUX=p|n; //端口选择
lab:
AD0INT=0;
ADC0MD=0x82; //单次转换
RedLed=~RedLed; //很重要,完全关闭adc0后重新打开必须启动延时
// delay_ms(1); //很重要,完全关闭adc0后重新打开必须启动延时。
while (!AD0INT);
AD0INT=0;
ADC0MD=0x80; //空闲
// ADC0MD&=~0x80; //,关闭ADC0
// tem=65536*ADC0H+256*ADC0M+ADC0L;
if(mode==0)
{
tem=(unsigned long)ADC0H<<16;
tem+=((unsigned long)ADC0M<<8)+(unsigned long)ADC0L;
if((tem>=0xffffff)&&i>0)
{
ADC0MD=0x80; //空闲
ADC0CN--;
i--;
goto lab;
}
v=(float)tem/(16777216/VERF)/(1<<i); //以下转换成电压
if((p==TEMPERATURE_P)||(n==TEMPERATURE_N))
{
v=(757.0-1000.0*v)/1.73;//温度转换
}
}
else
{
tem1=(long)ADC0H<<24;
tem1+=((long)ADC0M<<16)+((long)ADC0L<<8);
if((tem1>=0x80000000)&&i>0)
{
ADC0MD=0x80; //空闲
ADC0CN--;
i--;
goto lab;
}
v=(float)tem1/(8388608/VERF)/(1<<i); //以下转换成电压
v/=256;
}
// RedLed=~RedLed;
return v;
}E:\Desktop\20201230152821.jpg |
坐等大佬支援