Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

My first ADC, plz help

Status
Not open for further replies.

X4ce

New Member
hey!

Im using 16f877 for displaying LM35 on 7-segment.

Im doing as follow:

i) I amplified the signal using LM358, gain of ~5

ii) Put software Vref+ (VDD)

Vdd=5V so i used a gain of 5 using LM358, is that right ???

iii) Displayed my ADRESH on PORTC & ADRESL on PORTB (using left justified)

PORTC reads
PORTC# 7 6 5 4 3 2 1 0
0 1 0 1 1 0 1 0

PORTB reads
PORTB# 7 6 5 4 3 2 1 0
1 1 1 1 1 1 1 1

Why im getting PORTB all highs ????


If i use PORTB 2 LSB then my result is fine as follow


LSB
---
0 1 0 1 1 0 1 0 1 1

=~ is 363 so 36.3C but why im getting PORTB all highs ??

Im new to this PIC programming n learning, and for my conversion how do i combine ADRESH & ADRESL in single address.

Please help
 
Last edited:
Yeh im thinking & have decided to go through your tutorials but i need to complete this project before going on to tutorials.

Is my procedure right to get ADC? my PORTB(ADRESL) should be giving LSB of 10bit ADC. But i always get highs on all portB.

And can you gimme some hint for putting ADRESH & ADRESL in a single register? may be this is a dumb question but i think registers are 8 bit n my result is in 10bit

Thanks
 
X4ce said:
Yeh im thinking & have decided to go through your tutorials but i need to complete this project before going on to tutorials.

Is my procedure right to get ADC? my PORTB(ADRESL) should be giving LSB of 10bit ADC. But i always get highs on all portB.

And can you gimme some hint for putting ADRESH & ADRESL in a single register? may be this is a dumb question but i think registers are 8 bit n my result is in 10bit

The whole point is that my analogue tutorial answers all your questions, if you read it you will find what you want to know!.
 
Do you have full list of components required for your tutorial boards, so i can get all the components in one time & start working
 
X4ce said:
Do you have full list of components required for your tutorial boards, so i can get all the components in one time & start working

No, the components are only listed on the diagram, there aren't very many of them, so I saw no point in a seperate parts list.

However, you don't need to build the tutorial boards (assuming you've already got working hardware), just read the tutorial which explains (more simply than the datasheet) how to use the analogue inputs.

An important thing to remember, explained in my tutorial, is that ADRESH and ADRESL are in different banks!.
 
Code:
Convert:                        ; Takes number in NumH:NumL
                                ; Returns decimal in
                                ; TenK:Thou:Hund:Tens:Ones
        swapf   NumH, w
        iorlw     B'11110000'
        movwf   Thou
        addwf   Thou,f
        addlw   0XE2
        movwf   Hund
        addlw   0X32
        movwf   Ones

        movf    NumH,w
        andlw   0X0F
        addwf   Hund,f
        addwf   Hund,f
        addwf   Ones,f
        addlw   0XE9
        movwf   Tens
        addwf   Tens,f
        addwf   Tens,f

        swapf   NumL,w
        andlw   0X0F
        addwf   Tens,f
        addwf   Ones,f

        rlf     Tens,f
        rlf     Ones,f
        comf    Ones,f
        rlf     Ones,f

        movf    NumL,w
        andlw   0X0F
        addwf   Ones,f
        rlf     Thou,f

        movlw   0X07
        movwf   TenK


        movlw   0X0A                             ; Ten
Lb1:
        addwf   Ones,f
        decf    Tens,f
        btfss   3,0
        goto   Lb1
Lb2:
        addwf   Tens,f
        decf    Hund,f
        btfss   3,0
        goto   Lb2
Lb3:
        addwf   Hund,f
        decf    Thou,f
        btfss   3,0
        goto   Lb3
Lb4:
        addwf   Thou,f
        decf    TenK,f
        btfss   3,0
        goto   Lb4

        retlw	0x00

Thanks Nigel i got this thing up by using your example 11.1.

No doubt you have explained better then datasheet and example codes are self explainable but some parts of codes are not self-explanatory. Like this one they need to be exlained if someone is new to DLD.

However next im gonna do your i2c tutorial for building digital clock, using PCF8583.

Thanks Nigel
 
X4ce said:
No doubt you have explained better then datasheet and example codes are self explainable but some parts of codes are not self-explanatory. Like this one they need to be exlained if someone is new to DLD.

As the comments explain, this isn't my code, I got it off the PICList, I've never even bothered studying it to see how it works - it works great, I use it, end of story! :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top