ADS1115转换读取通道时,数据错误

		while(1)
		{
		ADS1115_ConfigRegister(ads1115_VDD_iic_addr,1);
		HAL_Delay(1);
		float volt =  ADS1115_GetAinVoltage(ads1115_VDD_iic_addr);
//		printf("I_volt: %f\r\n ",(volt - hall_sensor_init_value));
		ampere = (volt - hall_sensor_init_value)*22.72;
		printf("%f,%f,",setpoint,ampere);
			
		laser_temp = NTC_READ_TEMP();
		NTC_temp_x100 = laser_temp*100;
		printf("temp is %f\r\n",laser_temp);
			
		}
0.000000,65.821259,temp is 67.614662
0.000000,65.825516,temp is 67.614662
0.000000,65.825516,temp is 67.614662
0.000000,65.825516,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,0.029820,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,0.025560,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,0.029820,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,0.025560,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,0.029820,temp is 29.550028
0.000000,65.825516,temp is 29.550028
0.000000,0.029820,temp is 29.550028

正常下数据2应该是0.几,数据3应该是29.几,但是实际测试时,两个通道随机出现问题

解决办法:需要在配置寄存器时,后方需要加入1ms的延时(可能更短 需要尝试),在读取转换寄存器的结果时,需要提前延时相应的毫秒数来读取

//转换时间:
//128 SPS (samples per second): 7.8 ms
//250 SPS: 4 ms
//490 SPS: 2 ms
//860 SPS: 1.16 ms

 

posted @   为鲸  阅读(142)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示