读出来的数据经过解算 气压大于标准大气压 而且变化幅度很大 而且气压竟然和温度有对应关系
这是我之前测试的时候得到的三组数据
P:100881.98 T:26.60
P:101418.71 T:18.80
P:101955.44 T:31.00
气压差为536.73 温度差为2.2度
不知道为什么会出现这种情况
以下是部分代码,希望有经验的前辈多多指教!
[mw_shl_code=c,true]u32 MS561101BA_DO_CONVERSION(u8 command)
{
u32 conversion=0;
u32 conv1,conv2,conv3;
IIC_Start();
IIC_Send_Byte(MS561101BA_SlaveAddress);
while(IIC_Wait_Ack());
IIC_Send_Byte(command);
while(IIC_Wait_Ack());
IIC_Stop();
Delay_Ms(20);
IIC_Start();
IIC_Send_Byte(MS561101BA_SlaveAddress);
while(IIC_Wait_Ack());
IIC_Send_Byte(0x00);
while(IIC_Wait_Ack());
IIC_Stop();
IIC_Start();
IIC_Send_Byte(MS561101BA_SlaveAddress+1);
while(IIC_Wait_Ack());
conv1=IIC_Read_Byte(1);
conv2=IIC_Read_Byte(1);
conv3=IIC_Read_Byte(0);
IIC_Stop();
conversion= (conv1<<16) + (conv2<<8) + conv3;
return conversion;
}
//读取数字温度
void MS561101BA_GetTemperature(u8 OSR_Temp)
{
D2_Temp= MS561101BA_DO_CONVERSION(OSR_Temp);
Delay_Ms(10);
dT=D2_Temp - (((u32)Cal_C[5])<<8);
Temperature=D2_Temp;//2000+dT*((u32)Cal_C[6])/8388608.0;
}
//读取数字气压
void MS561101BA_GetPressure(u8 OSR_Pres)
{
float Aux,OFF2,SENS2; //温度校验值
D1_Pres= MS561101BA_DO_CONVERSION(OSR_Pres);
Delay_Ms(10);
OFF=(u32)(Cal_C[2]<<16)+((u32)Cal_C[4]*dT)/128.0;
SENS=(u32)(Cal_C[1]<<15)+((u32)Cal_C[3]*dT)/256.0;
//温度补偿
/*if(Temperature < 2000)// second order temperature compensation when under 20 degrees C
{
Temperature2 = (dT*dT) / 0x80000000;
Aux = (Temperature-2000)*(Temperature-2000);
OFF2 = 2.5*Aux;
SENS2 = 1.25*Aux;
if(Temperature < -1500)
{
Aux = (Temperature+1500)*(Temperature+1500);
OFF2 = OFF2 + 7*Aux;
SENS2 = SENS + 5.5*Aux;
}
}else //(Temperature > 2000)
{
Temperature2 = 0;
OFF2 = 0;
SENS2 = 0;
}
Temperature = Temperature - Temperature2;
OFF = OFF - OFF2;
SENS = SENS - SENS2; */
Pressure=D1_Pres;//(D1_Pres*SENS/2097152.0-OFF)/32768.0;
}
[/mw_shl_code]
|