Microchip
直播中

陈炜

7年用户 213经验值
私信 关注
[问答]

如何正确设置采集时间?

你好,我正在研究PIC16F882,使用双通道AN0和AN1,使用内部Osc。代码也在模拟器和硬件上工作。但问题是,当我旋转AN0时,AN1也会改变,反之亦然。我认为问题在于采集时间。如何正确设置采集时间?-Kr

以上来自于百度翻译


      以下为原文

    Hello,

I am working on PIC16F882 and using Two Channels AN0 and AN1 using Internal Osc..
Code is working on simulator and Hardware as well.

But problem is that when i am rotating AN0, the AN1 also changes and vice versa.

I think the problem is in Acquisition Time. How to set Acquisition Time in Proper Way ?


-
Kr

回帖(9)

赵护林

2019-7-24 14:02:00
这里是代码。请参阅并提出建议。

以上来自于百度翻译


      以下为原文

    HERE IS CODE . Please See and Advice.
举报

王焕树

2019-7-24 14:12:23
不要尝试创建自己的延迟。使用编译器提供的_u._ms()和_u._us()宏。尝试将:更改为:并对其他通道执行相同的操作。

以上来自于百度翻译


      以下为原文

    Don't try to create your own delays.
Use the __delay_ms() and __delay_us() macros provided by the compiler.
 
Try changing:
    SELECT_CHANNEL_0();   
    delay(2) ;
    temp =  ReadADC();
    delay(2) ;
    Result();
to:
    SELECT_CHANNEL_0();    //select new channel  
    __delay_us(20);    //wait 20us
    Result();    //start conversion, and wait for it to complete
    temp =  ReadADC();    //fetch result from ADC
 
and do the same for the other channel.
举报

陈晨

2019-7-24 14:25:06
实际时间在数据表中列出,但是如果输入是高阻抗而没有电容器则可以更长。

以上来自于百度翻译


      以下为原文

    The actual time is listed in the data sheet but can be longer if the input is high impedance with no Capacitor
举报

赵护林

2019-7-24 14:39:17
HI QHB,我已经编辑了您的延迟功能在我的代码中。但是,当我旋转AN0时,同样的问题,AN1也会改变,反之亦然。两个通道应该独立地改变。//11=FRC(来自专用内部振荡器的时钟=500kHz max)ADCS1=1;ADCS0=1;请通知--Kr。

以上来自于百度翻译


      以下为原文

    Hi qhb ,
 
I have edit your delay function  in my code .  But same problem when i am rotating AN0, the AN1 also changes and vice versa.
 
  __delay_us(20);    //wait 20u
 
Both the channels should independently . 
 
Also changed ..
 
// 11 = FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
ADCS1 = 1 ;
ADCS0 = 1 ;
 
Please Advice.
 
 
 
 
 
--Kr
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分