我用MSP430F5529LP来变成ADS1115,结果转换出来的数据一直是0.004左右,请问这是怎么回事啊,下面是我的配置和转化方法
:我选的是 2.048v,(指针寄存器我就没有写出了),麻烦给位大侠帮我看一下吧,万分感谢啊
寄存器配置:
void confige1115(uchar channel)
{
uchar i;
unsigned int chan[4];
switch(channel)
{
case 0:chan[2] = 0x54;break; //confige register FS= +-2.048v
case 1:chan[2] = 0x52;break; //AIN接GND 参考电压+-4.096V 连续转换
case 2:chan[2] = 0x62;break;
case 3:chan[2] = 0x72;break;
default:break;
}
chan[0] = 0x90; //写入主机地址
chan[1] = 0x01; //指向配置寄存器 chan[3] = 0x83; //低字节地址,ADS1115为下降沿单次模式,转换速率为128SPS,比较器关闭
start_iic(); //开始标志
for(i=0;i<4;i++)
{
sendbyte_IIC(chan[i]); //写入数据到控制到ADS1115
answers_ACK();
//_NOP();
}
stop_IIC();
}
读取结果
uint read_result(void)
{
uchar result_h,result_l;
SCL_H;
start_iic();
sendbyte_IIC(0X91);
//answers_ACK();
result_h = readbyte_IIC();
result_l = readbyte_IIC();
delay(1);
stop_IIC();
result = (result_h<<8)+result_l;
return result;
}
结果转换
{// } sum = read_result();
volue = ((float)sum/32767*2.048)*1000; //采集值/电压范围(32767)*2.048参考电压*1000放大1000倍
volt[0] = volue/1000;
volt[2] = (volue – volt[0]*1000)/100;
volt[3] = (volue – volt[0]*1000 – volt[2]*100)/10;
volt[4] = (volue – volt[0]*1000 – volt[2]*100 – volt[3]*10);
volt[1] = 10;
for(j=0;j<5;j++)
{
Write_Data(shuzi[volt[j]]);
}
user151383853:
有点复杂, 建议找调试器帮忙, 从时序, 设置一步步地验证, 会容易找到问题一些