Searching \ for '[PIC]: 16f877 AD problems' 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/devices.htm?key=16F
Search entire site for: '16f877 AD problems'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 16f877 AD problems'
2002\10\05@153704 by Fredrik Axtelius

picon face
Hi!!

I have some problems reading stuff from my AD.
I have a 16f877@4MHz and analog data from an "LM35 Precision Centigrade Temperature Sensor" on AN0.
The data on AN0 looks stable when I check it with my DWM.

This his how I set up the AD.
ADCON1=0b.1000.1110;   // A:0 to analog, right justify AD results
ADCON0=0b.1000.0001;   // AD clock to OSC/32, PORTA:0=input, A/D on
ADIE=0;
ADIF=0;

No problems there I think, setting GO bit of ADCON0 surly gives me close the what I excpected in ADRESH/L BUT I have a feeling im reading data from ADRESH/L before the AD conversion is finished.

This is how I read the AD.

 GO=1;            // GO is defined as ADCON0 bit 2
 while (GO) {}

 // delayms(250);

 i = ((int16)ADRESH<<8);
 i = i + ADRESL;

The result I get in I is kinda fuzzy even though the data source SHOULD be quite stable.

If you made it this far, heres my question:
Is there something wrong in my code or is my analog source of data not as perfect as I think?
Just wanted some help to check my source before I run of and borrow an oscilloscope.

tia
/Fredrik

--
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


2002\10\05@161835 by Olin Lathrop

face picon face
> Is there something wrong in my code or is my analog
> source of data not as perfect as I think?

You looked at your source with a scope, so you know it's fine.  I can think
of tree possibilities:

1  -  You are not waiting long enough during the acquisition phase.

2  -  You are not waiting long enough for a full conversion.  You did show
the A/D setup, but I didn't compare it with the manual to verify it.

3  -  Your source impedence is over 10K ohms.  Above this impedence, the
offset due to leakage in the A/D can be significant, and the acquisition
time will also be slower.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
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


2002\10\05@175516 by ian.forse

flavicon
face
Fredrik,

I normally get +/- 2 counts of noise from a low impedance dc source.  How
many counts is your fuzzy.  I believe that it is possible to take the ADC
reading while the 877 is in sleep mode which should have less noise.

I have some code on my web site http://www.mdm1.bravepages.com which has 2 filters
to try and remove noise.  You can read the output as RS232 so ignore the
MDM-1 display part.

Ian


> {Original Message removed}

2002\10\05@193018 by akieran

picon face
Fredrik,
There's nothing wrong with your code.  I had the same
experience with the LM34; the farenheit version of your chip.
You are experiencing noise on the A/D converter.

This is reduced by putting the PIC to sleep during the A/D
conversion.  (It is awaken by an interupt that is generated
when the conversion process has completed.)  But even in this
mode, the noise is still a problem.

If you want stable readings, you need to filter or average your
results.  I choose to maintain each displayed reading until a
new reading is stable for n consecutive conversions, where I
vary n from 10 to 40 readings.  Even with high values for n,
the display responds quickly to sudden temperature increases
(such as when I warm the sensor with my finger).

Cheers,
Andrew


________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


---- On    , Fredrik Axtelius (spam_OUTfredrik.axteliusTakeThisOuTspamTELIA.COM)
wrote:

> Hi!!
>
> I have some problems reading stuff from my AD.
> I have a 16f877@4MHz and analog data from an "LM35 Precision
Centigrade Temperature Sensor" on AN0.
> The data on AN0 looks stable when I check it with my DWM.
>
> This his how I set up the AD.
> ADCON1=0b.1000.1110;   // A:0 to analog, right justify AD
results
> ADCON0=0b.1000.0001;   // AD clock to OSC/32, PORTA:0=input,
A/D on
> ADIE=0;
> ADIF=0;
>
> No problems there I think, setting GO bit of ADCON0 surly
gives me close the what I excpected in
> ADRESH/L BUT I have a feeling im reading data from ADRESH/L
before the AD conversion is finished.
{Quote hidden}

source SHOULD be quite stable.
>
> If you made it this far, heres my question:
> Is there something wrong in my code or is my analog source of
data not as perfect as I think?
> Just wanted some help to check my source before I run of and
borrow an oscilloscope.
>
> tia
> /Fredrik
>
> --
> 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
>
>

--
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


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