搜索
bottom↓
回复: 2

求助xmega ADC 无符号转换结果偏大

[复制链接]

出0入8汤圆

发表于 2014-6-17 17:45:19 | 显示全部楼层 |阅读模式
本帖最后由 Cortex_M3 于 2014-6-17 17:47 编辑

再用xmega32a4 做ADC 无符号AD转换时,测量结果存在误差
具体配置函数如下
void ADC_Port_Configuration_Init(void)
{
  struct adc_config          adc_conf;
  struct adc_channel_config  adcch_conf;
  
        // Clear the configuration structures.
        // 清除配置结构
        memset(&adc_conf, 0, sizeof(struct adc_config));
        memset(&adcch_conf, 0, sizeof(struct adc_channel_config));
  
  /* Configure the ADC module:
        * - unsigned, 12-bit results
        * - VCC/1.6 voltage reference
        * - 200 kHz maximum clock rate
        * - manual conversion triggering
        */
/*
12位无符号模式,基准电压Vcc/1.6=2.06V
200KHz时钟频率
*/
        adc_set_conversion_parameters(&adc_conf, ADC_SIGN_OFF, ADC_RES_12, ADC_REF_VCC);
        adc_set_clock_rate(&adc_conf, 200000UL);
        adc_set_conversion_trigger(&adc_conf, ADC_TRIG_MANUAL, 3, 0);
        adc_write_configuration(&ADCA, &adc_conf);
  
        /* Configure ADC channel 0, 1 and 2:
        * - single-ended measurement from configured input pin
        * - interrupt flag set on completed conversion
        */
        adcch_set_input(&adcch_conf, ADCCH_POS_PIN0, ADCCH_NEG_NONE, 1); // PA0  VU_L
        adcch_set_interrupt_mode(&adcch_conf, ADCCH_MODE_COMPLETE);
        adcch_disable_interrupt(&adcch_conf);
        adcch_write_configuration(&ADCA, 0, &adcch_conf);    // 配置到通道0
       
        adcch_set_input(&adcch_conf, ADCCH_POS_PIN1, ADCCH_NEG_NONE, 1); // PA1  VU_R
        adcch_write_configuration(&ADCA, 1, &adcch_conf);    // 配置到通道1

        adcch_set_input(&adcch_conf, ADCCH_POS_PIN7, ADCCH_NEG_NONE, 1); // PA7  Temp
        adcch_write_configuration(&ADCA, 2, &adcch_conf);    // 配置到通道2

        // Enable the ADC and do one dummy conversion.
        adc_enable(&ADCA);
}

uint16_t Get_ADC_Vol(uint8_t ch)
{
        unt16_t value=0;
        adc_start_conversion(&ADCA, ch);
        adc_wait_for_interrupt_flag(&ADCA, ch);
        value = adcch_get_result(&ADCA, ch);
        return (uint16_t) value ;
}

麻烦各位坛友给看看。
PS:开发环境AVR studio

输入端接地,竟然还有150多的输出

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2014-6-18 09:43:16 | 显示全部楼层
In unsigned mode, the negative input is connected to half of the voltage reference (VREF) voltage minus a fixed offset.
The nominal value for the offset is:
_V = Vref x 0.05

楼主这个你减掉没。。

出0入8汤圆

 楼主| 发表于 2014-6-18 10:48:46 | 显示全部楼层
hell-prototypes 发表于 2014-6-18 09:43
In unsigned mode, the negative input is connected to half of the voltage reference (VREF) voltage mi ...

这个我知道
Vref = VCC/1.6 =2.06V
换算过去为RES = 204

直接减去会出现负的情况,因为我对地 大概是输出RES = 150

会有50 res 偏差
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-23 21:31

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表