ADC_tempH=(ADC_tempH<<8)+ADC_tempL;
}
return(ADC_tempH);
}
signed int Avg_ADC(signed int *data )
{
uchar count,i,j;
signed int value_buf[12];
signed int temp;
signed long sum=0;
for (count=0;count<12;count++)
{
value_buf[count] =data[count];
}
for (j=0;j<11;j++)
{
for (i=0;i<11-j;i++)
{
if ( value_buf[i]>value_buf[i+1] )
{
temp = value_buf[i];
value_buf[i] = value_buf[i+1];
value_buf[i+1] = temp;
}
}
}
for(count=2;count<10;count++)
sum += value_buf[count];
return( (signed int)(sum>>3) );
}
signed int AD_conversion(void)
{
uchar j;
signed int temp;
signed int ADC0_temp[12]={0};
for(j=0;j<12;j++)
{
ADC0_temp[j]=Start_ADC();
delay_us(1);
}
temp=Avg_ADC(ADC0_temp);
return(temp);
}
signed int ADC_to_um(void)
{
signed long ADC_data_temp;
ADC_data_temp=AD_conversion();
ADC_data_temp=(signed int)(ADC_data_temp*0.62); //固定系数,按2mm对应32768得到
if( ADC_data_temp> 20000 )
{
ADC_data_temp=20000;
}
if( ADC_data_temp<-20000 )
{
ADC_data_temp=-20000;
}
return (ADC_data_temp);
}
//较准用测量函数
signed int ADC_Calib_um(signed int stander,signed int calib)
{
signed long ADC_data_temp;
ADC_data_temp=AD_conversion();
ADC_data_temp=(signed int)( (ADC_data_temp-calib)*0.62 )+stander; //计算校准后值
return (ADC_data_temp);
} 作者: 箫天 时间: 2013-3-3 22:52
支持程序开源!作者: ulpte 时间: 2013-3-17 19:28
提示: 作者被禁止或删除 内容自动屏蔽作者: zouchangchun 时间: 2013-4-11 19:59
提示: 作者被禁止或删除 内容自动屏蔽