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 @ 2024-07-13 20:28  为鲸  阅读(5)  评论(0编辑  收藏  举报