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.

10bit AD converter

Status
Not open for further replies.

Angy

New Member
I have a routine for 8bit AD convertion using 16c924 chip as follows. After convertion the digital value is stored in ADRES. Now I'm changing the processor to 16f946 where it uses the 10 bit with ADRESL and ADRESH register locations to save the values. Now will ADRES of 8bit A/D value be as same as ADRESL in 10BIT A/D?(note that the routine written for 10bit is different with respect to the micro)

READ_POT ; setting of 0 =2.5 volt = 127 count

BCF ADCON0,2
movlw B'01000001' ;select FOSC/8,ch0.enable A/D
movwf ADCON0 ;turn on A/D.
clrf ADRES ;clr result reg.
movlw .9 ;ADD DELAY
movwf AD
movf AD,1
BTFSC STATUS,Z
GOTO routine
routine1 DECFSZ AD,1
goto routine
routine bsf ADCON0,2 ;start conversion
WAIT
btfsC ADCON0,2 ;a/d done?
goto WAIT
MOVF ADRES,W
MOVWF POT ;SAVE RESULT IN LOCATION POT
 
Check my tutorials for how to use the ADC - you can configure it two ways, one has the two most significant bits in one register, the other has the two least significant bits in one register - the second is for if you want to only use it as 8 bits.
 
Thanks for the tutorial url, I will check it out.

Now let me write what I understood according the program above in terms of 10bit A/d.

This is one way of configuring it.
In 10bit A/D the converted value in adresl (two least significant bit) = converted value in ADRES in 8bit A/D
ADRESH = has two most significant bits
 
Thanks for the tutorial url, I will check it out.

Now let me write what I understood according the program above in terms of 10bit A/d.

This is one way of configuring it.
In 10bit A/D the converted value in adresl (two least significant bit) = converted value in ADRES in 8bit A/D
ADRESH = has two most significant bits

Yes, that's the normal mode - as a ten bit ADC.
 
On the 16c chip after the a/d converter I use the value from the adres to display and it displays 25. Now using the flash version of the chip it has 10bit a/d converter and the result is stored in adresl and adresh and when I use the value in the adresL register it displays only 2.5. can someone please advice what went wrong?
 
On the 16c chip after the a/d converter I use the value from the adres to display and it displays 25. Now using the flash version of the chip it has 10bit a/d converter and the result is stored in adresl and adresh and when I use the value in the adresL register it displays only 2.5. can someone please advice what went wrong?

Well it can't read 2.5 as it's only an 8 bit binary number, so no decimal point - if ones appearing your software is producing it.

But read my tutorial about using the A2D, it explains it all - and much simpler than the datasheet.
 
Thanks for the suggestion I understand that the decimal point is caused by the software but the result after a/d has to display 25.0(hundred digit, tenth digit,unit digit) but it reads 2.5 (tenth digit,unit digit) here the decimal point is not the problem cause I can remove it from the software but the placement of digits is the problem. So what am i doing wrong here?
 
Last edited:
Thanks for the suggestion I understand that the decimal point is caused by the software but the result after a/d has to display 25.0(hundred digit, tenth digit,unit digit) but it reads 2.5 (tenth digit,unit digit) here the decimal point is not the problem cause I can remove it from the software but the placement of digits is the problem. So what am i doing wrong here?

Like I said before, read my tutorial about using the ADC, pay particular attention to ADCON1 which your code doesn't appear to set at all?.
 
You are right i set ADCON1 in the initial stages since its the same for all modules.
I'm working on software with the order of the digits after a/d conversion
 
And as 3v0 would say, don't forget the
Code:
 tags!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top