Searching \ for '[PIC:] Analog to Digital Coversion Problems (pic16' 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=analog
Search entire site for: 'Analog to Digital Coversion Problems (pic16'.

Exact match. Not showing close matches.
PICList Thread
'[PIC:] Analog to Digital Coversion Problems (pic16'
2004\06\18@163114 by dimov stefan

picon face
I've tried to measure DC and display the corresponding
number from the ADC on a LCD .I used pic16F877. For
initiation of the ADC I used AN546.
 But when I'm  changing the voltage gradually from 0V
to 5V the LCD shows only four values respectivly : 0,
257, 514, 771.
 Where is the culprit?



__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail

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

2004\06\18@165642 by Paul James E.

picon face
Stefan_d6,

Are you using all 10 bits?  and do tou have the result left justified
or right justified?   If you are using all 10 bits and have it right
justified, and are using the ms BYTE, the values displayed would be
0, 256, 512, 768.  And your numbers are very close to these.  The reason
is you're only displaying the two most significant bits.  Check your
A/D setup and try displaying the LS byte only.  It should go smoothly
between 0 and 255.  Once you get this part working, then you can deal
with the two MS bits.   Hope this helps.


                                                Regards,

                                                  Jim




{Quote hidden}

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

2004\06\18@170058 by Andrew Kieran

picon face
Stefan,

Check the left/right justification of the result as set by
ADCON1, bit 7.  If you plan to use all 10 bits of the result,
then your result should be right-justified so set this bit.

Your conversion result will be in ADRESH:ADRESL as follows:

000000xx:xxxxxxxx

where '0' are the leading zeros in front of the result and 'x'
represents the conversion result.

But be careful with ADRESL; the low byte of the result.  It is
in Bank1 so you need to change STATUS, RP0 to access it.

Andrew
akieran_at_ureach.com


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


---- On    , dimov stefan (.....stefan_d6KILLspamspam.....YAHOO.COM) wrote:

{Quote hidden}

us!
> email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the
body
>
>

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

2004\06\18@170747 by Philip Pemberton

face picon face
In message <@spam@20040618203124.39691.qmailKILLspamspamweb51909.mail.yahoo.com>>          dimov stefan <KILLspamstefan_d6KILLspamspamYAHOO.COM> wrote:

> I've tried to measure DC and display the corresponding
> number from the ADC on a LCD .I used pic16F877. For
> initiation of the ADC I used AN546.
>   But when I'm  changing the voltage gradually from 0V
> to 5V the LCD shows only four values respectivly : 0,
> 257, 514, 771.
>   Where is the culprit?
Can you post your code here? It sounds like you're not setting the A/D up
correctly, or you're not reading the A/D value correctly.

Later.
--
Phil.                              | Acorn Risc PC600 Mk3, SA202, 64MB, 6GB,
RemoveMEphilpemTakeThisOuTspamdsl.pipex.com              | ViewFinder, 10BaseT Ethernet, 2-slice,
http://www.philpem.dsl.pipex.com/  | 48xCD, ARCINv6c IDE, SCSI
... Procrastination means never having to say you're sorry.

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

2004\06\18@170954 by cisco J. A. Ares

flavicon
face
how are you converting the ADC result for LCD reading? Can you make a
different interface to read that? RS232 to a terminal PC?

Francisco


dimov stefan wrote:

{Quote hidden}

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

2004\06\18@175955 by Chris Emerson

flavicon
face
On Fri, Jun 18, 2004 at 01:31:24PM -0700, dimov stefan wrote:
>   But when I'm  changing the voltage gradually from 0V
> to 5V the LCD shows only four values respectivly : 0,
> 257, 514, 771.
>   Where is the culprit?

I bet there's a typo, and you're using ADRESH twice instead of
ADRESH:ADRESL.   Those numbers in hex are 0x0000, 0x0101, 0x0202, and 0x0303,
which look rather suspicious.

Chris

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

2004\06\18@195402 by Andrew Kieran

picon face
I think Chris has nailed it.  This oupute described could easily
result from reading the ADRESH register twice.  The most likely
reason for this is failure to switch banks.  ADRESH and ADRESL
are at the same address; except one (ADRESH) is in bank 0 and
the other (ADRESL), is in bank1.

To use the lower eight bits, use:

       bsf     STATUS, RP0             ; switch to Bank1
       movf    ADRESL ^ 0x80, W
       bcf     STATUS, RP0             ; switch to Bank0

Then you'll have ADRESL in the w register.

Andrew



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


---- On    , Chris Emerson (EraseMEpicspamNOSREME.ORG) wrote:

> On Fri, Jun 18, 2004 at 01:31:24PM -0700, dimov stefan wrote:
> >   But when I'm  changing the voltage gradually from 0V
> > to 5V the LCD shows only four values respectivly : 0,
> > 257, 514, 771.
> >   Where is the culprit?
>
> I bet there's a typo, and you're using ADRESH twice instead of
> ADRESH:ADRESL.   Those numbers in hex are 0x0000, 0x0101,
0x0202, and 0x0303,
> which look rather suspicious.
>
> Chris
>
> --
> http://www.piclist.com#nomail Going offline? Don't AutoReply
us!
> email RemoveMElistservEraseMEspamEraseMEmitvma.mit.edu with SET PICList DIGEST in the
body
>
>

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

2004\06\19@060217 by dimov stefan

picon face
OK, I fixed the flaws as Chris and Andrew said.To read
the ADRESH:ADRESL I used the following code:

           bsf   STATUS,RP0       ;bank 1
               movf    ADRESL,W
               movwf   L_byte

               bcf       STATUS,RP0     ;bank 0
               movf    ADRESH,W
             movwf   H_byte

    ;L_byte and H_byte are registers where the result
     ;is stored and then transformed to BCD using
four       ;additional registers-R0,R1,R2,R3.These
registers       ;(numbers) are displayed on the LCD

but the result wasn't too encouraging - the LCD showed
correspondingly 0000,0256,0512 and 0768 ,i.e. only the
two bits of the ADRESH. When I used only ADRESL
(H_byte=0) the LCD showed 0000 regardless of changing
the voltage from 0V to 5V.
So,I think the ADRESL is always empty.I don't know
why!
The following is the Initiation of the ADC:

        InitADC
               bsf       STATUS,RP0   ;bank 1
               movlw     B'10000000'  ;right justif.
           movwf         ADCON1           ;all Analog
               clrf      ADRESL

               bcf       STATUS,RP0   ;bank 0
           movlw   B'11000001'  ;RC osc,ch 0(RA0),
            movwf   ADCON0       ;Conv. stopped,ADC
ON
               clrf      ADRESH

        return

Any ideas?

Bye
Stefan



--- Andrew Kieran <RemoveMEakieranTakeThisOuTspamspamUREACH.COM> wrote:
{Quote hidden}

__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestSTOPspamspamEraseMEmitvma.mit.edu

2004\06\19@060623 by dimov stefan

picon face
OK, I fixed the flaws as Chris and Andrew said.To read
the ADRESH:ADRESL I used the following code:

           bsf   STATUS,RP0       ;bank 1
               movf    ADRESL,W
               movwf   L_byte

               bcf       STATUS,RP0     ;bank 0
               movf    ADRESH,W
             movwf   H_byte

    ;L_byte and H_byte are registers where the result
     ;is stored and then transformed to BCD using
four       ;additional registers-R0,R1,R2,R3.These
registers       ;(numbers) are displayed on the LCD

but the result wasn't too encouraging - the LCD showed
correspondingly 0000,0256,0512 and 0768 ,i.e. only the
two bits of the ADRESH. When I used only ADRESL
(H_byte=0) the LCD showed 0000 regardless of changing
the voltage from 0V to 5V.
So,I think the ADRESL is always empty.I don't know
why!
The following is the Initiation of the ADC:

        InitADC
               bsf       STATUS,RP0   ;bank 1
               movlw     B'10000000'  ;right justif.
           movwf         ADCON1           ;all Analog
               clrf      ADRESL

               bcf       STATUS,RP0   ;bank 0
           movlw   B'11000001'  ;RC osc,ch 0(RA0),
            movwf   ADCON0       ;Conv. stopped,ADC
ON
               clrf      ADRESH

        return

Any ideas?

Bye
Stefan




__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu

2004\06\19@063121 by Howard Winter

face
flavicon
picon face
On Sat, 19 Jun 2004 03:05:00 -0700, dimov stefan wrote:

>
>             bsf     STATUS,RP0     ;bank 1
>             movf    ADRESL,W
>             movwf   L_byte
>
>             bcf     STATUS,RP0     ;bank 0
>             movf    ADRESH,W
>             movwf   H_byte

What are the addresses of L_byte and H_byte?  You may have a banking problem unless they are in an "access
bank", which is always visible.

Cheers,

Howard Winter
St.Albans, England

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamEraseMEmitvma.mit.edu

2004\06\19@082343 by Chris Emerson

flavicon
face
On Sat, Jun 19, 2004 at 03:00:07AM -0700, dimov stefan wrote:
> OK, I fixed the flaws as Chris and Andrew said.To read
> the ADRESH:ADRESL I used the following code:
>
>             bsf   STATUS,RP0       ;bank 1
>                 movf    ADRESL,W
>                 movwf   L_byte
>
>                 bcf       STATUS,RP0     ;bank 0
>                 movf    ADRESH,W
>               movwf   H_byte

Where are L_byte and H_byte?  If they're in banked areas, don't forget
the bank bits need to be right when accessing them too.  I bet you're
writing the ADRESL value to a register in bank 1, but then reading the
corresponding addressin bank 0 later (which was never written to) when
doing the BCD conversion.

The easiest way to avoid banking problems like this is to use "banksel"
before every register access:

       banksel ADRESL
       movf ADRESL, W

       banksel L_byte
       movwf L_byte

       banksel ADRESH
       movf ADRESH, W

       banksel H_byte
       movwf H_byte

That way banking errors are much less likely.  Doing this will usually
increase the code size, but it's not worth worrying about that until you
start running out of code space.

Chris

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

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