Searching \ for '[PIC]: 16F877 A/D Accuracy' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=a%2Fd
Search entire site for: '16F877 A/D Accuracy'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 16F877 A/D Accuracy'
2001\03\09@224908 by Jeethu Rao

flavicon
face
I just wanted to test the accuracy of the PIC16f877 ADC. So, I wrote a simple routine to perform a A/D convertion and to read the ADRESH and ADRESL regs, convert them to ASCII and then transmit them through the UART to a terminal Program on a PC. I used only the AN0 input. And I did'nt opt for external voltage refs.And Finally te results were right justified

But I was getting readings between 00 and 12 (Decimal). Is this normal or Is it because I'm not using External Refs ? I connected the AN0 pin to Ground and I get a perfect 00 on the ADRESL Reg. The track connected to the AN0 pin is quite long. So is it because of some stray capacitance or RF Interferance ?
Can someone suggest a fix for this problem ?

Jeethu Rao

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\03\10@011911 by Robert Rolf

picon face
Noise. Probably from Vref. Also from stray lead noise. Possibly too
high a source impedance.

I put a good bypass cap on the PIC power leads, and also a small value
cap (100pf) right at the AN0 pin to minimize the effects of charge
dumping
of the multiplexor.

The quickest way to find your problem is to use a good scope. Be sure
you
ground the scope probe with a SHORT lead, right at the PIC gnd, or
you'll
be chasing ground noise rather than your real noise source.

Also, make sure that your A/D conversion is complete. Reading before the
conversion is complete can give you a partial result wherein the LSB's
are still set high.


Jeethu Rao wrote:
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\10@021221 by dr. Imre Bartfai

flavicon
face
1. Could you send us the settings of the ADCONx registers?
2. Did you feed the AN0 with a voltage between 0 and 5 V from a source
with an internal resistance not higher than 10k?
3. Did you consider both ADRESH and ADRESL during evaluation of the
result?
4. Did you provide enough sampling time?
5. Did you check the GO_DONE bit to establish the conversion is done?

By my opinion the A/D modul works correctly. However, external parts can
be responsible for a portion of nonlinearity.

Regards,
Imre


On Sat, 10 Mar 2001, Jeethu Rao wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\10@130306 by Jacob M Hartman

flavicon
face
Make sure that you are giving the ADC caps enough time to charge.  Charging
takes about 20 microsecs.  The following code is a typical way to do it:


       movlw   B'10000001'      ; Select ADC channel 0
       movwf   ADCON0

       clrf    TMR0             ; Make sure we wait full timer length
       bcf     INTCON, T0IF     ;  so that ADC cap can fully charge
ADC_CHARGE_WAIT
       btfss   INTCON, T0IF     ; Wait for TIMER0 to overflow
       goto    ADC_CHARGE_WAIT

       bsf     ADCON0, GO       ; Start A/D conversion
ADC_RUN_WAIT
       btfss   PIR1, ADIF       ; Wait for conversion to complete
       goto    ADC_RUN_WAIT
       bcf     PIR1, ADIF

       movf    ADRESH, W        ; Copy the high byte of the result into W


One oversight I've run into is not resetting the TMR0 before waiting, in
which case you may not be waiting long enough, or not resetting the T0IF
flag, in which case you would not be waiting at all!

The other cause could be having too high a resistance (> 10K) on the ADC
pin, but if you're grounding the pin that obviously isn't the problem.

Best luck!
Jake


{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\03\11@232409 by Jeethu Rao

flavicon
face
"dr. Imre Bartfai" wrote:

> 1. Could you send us the settings of the ADCONx registers?
> 2. Did you feed the AN0 with a voltage between 0 and 5 V from a source
> with an internal resistance not higher than 10k?
> 3. Did you consider both ADRESH and ADRESL during evaluation of the
> result?
> 4. Did you provide enough sampling time?
> 5. Did you check the GO_DONE bit to establish the conversion is done?

1.)In MPLAB SIM, after all the init was done,

Reg           Hex  Dec   Bin
adcon0       81   129   10000001   .
adcon1       8E   142   10001110   .

2.) No, For the initial test, I just left it blank. Just to see if the
result will also be Zero

3.)Yes,I considered both ADRESH, ADRESL.  I set the result as right
justified and I setup a routine which would Send me both the ADRESH and
ADRESL regs through the UART when I keyed in "A123" in a serial terminal.

4.) For the sampling time, I simply used something like
    clrf         i_ad_loop
    incfsz     i_ad_loop,f     ;TACQ Delay Loop
    goto $-1

5.)For the actual A/D sampling I used

    bsf    adcon0,go
    btfsc adcon0,go ;Loop until Clear
    goto $-1

I hope this Info will help you to help me ;-)

Thanking you,

Jeethu Rao

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\12@113541 by Mike Mansheim

flavicon
face
> 3.)Yes,I considered both ADRESH, ADRESL.  I set the result as right
> justified and I setup a routine which would Send me both the ADRESH and
> ADRESL regs through the UART when I keyed in "A123" in a serial terminal.

Seems to me there are two areas that could be causing your trouble:  the
actual a/d reading and the information transmission.  Are you 100% sure
the "data out" transmission routine works properly?

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\03\13@014144 by dr. Imre Bartfai

flavicon
face
Hi,

I must confess, for real-life application (also for others) I do not
consider using MPLAB. However, the main point I see is your answer to the
question #2. Letting the A/D input float results undefined conversion
outcome. At the moment I do not see obvious mistake. I advice to apply a
defined voltage to the AN0 (e. g. +2V or whatever) and then read the
result. It is not true floating ("blank"?) input would produce zero.

I hope this helps.

Regards,
Imre


On Sun, 11 Mar 2001, Jeethu Rao wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...