Hi Olin,
At 12:29 24/06/2002 -0400, Olin Lathrop wrote:
> > 1. I select the channel.
> >
> > 2. Then I am allow for an acquisition time of 22 us (the datasheet
> > mentions 20 us for a 10 K source)
> >
> > 3. Then I start the conversion (set the 'GO' bit)
> >
> > 4. Once the conversion is over, I wait _at least_ 11 us (the
> > datasheet also mentions that a delay of 2 x Tad needs to be
> > honoured here)
>
>There is no need to wait after the conversion is over, since it's over. The
>best way to wait for the conversion to complete is to monitor the GO/DONE
>bit in ADCON0, or the ADIF flag in PIR1.
That's what I do (I monitor ADIF in PIR1) but when I see ADIF=1 I still wait
an extra iteration. This is because in the mid-range reference manual I have
read that you must allow for at least 2 Tad extra between two consecutive
acquisitions (actually after finishing the conversion but before starting
the next acquisition). Isn't this correct?
>When reading multiple channels, I
>usually switch to the next channel as soon as a conversion completes, then
>get the ADRES values, etc.
Yep.
{Quote hidden}> > 5. Go back to step 1, but with the next channel.
> >
> >
> > Now my problem is the following: I just set one of the three channels
> > (let's say RA0) to a 4V source, and leave the other two (RA1 and RA3
> > in this example) unused (i.e. just connected to GND through the 10K
> > resistor). The first channel (4 V) is read OK, but for the next one
> > I read I get a non-zero value (about $008). Looks like the S & H
> > capacitor is not completely discharged.
> >
> > I've checked the followin:
> >
> > - Set RA1 to 4 V instead of RA0. In this case it is RA3 the one
> > that reads a non-zero value.
> >
> > - Replace the 10K resistor with a 1K resistor; in this case I
> > measure about $004 instead of $008 in the 'next' channel.
> >
> >
> > Does someone have a clue? What's happening here?
>
>It seems like you are doing everything right. Could the unused inputs be
>picking up noise?
But would it should this behaviour then? I mean, the unused inputs
seem to be somehow 'tracking' the channel that is set to 4 V. If I
set all three channels to unused (so all three are connected to GND
via 10K resistors) then I do measure zero on all of them...
>Are you really sure the 22uS wait is really 22uS?
Yes -- that's both calculated and checked (for debugging purposes)
by inspecting the timer value in each iteration. If any iteration
takes less than 11 us I turn on an 'error led'.
>It
>seems very suspicious that you were still reading 4 with a 1K resistor.
Indeed :-/
G.
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspam
.....mitvma.mit.edu with SET PICList DIGEST in the body