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.

Can I make 8-bit ADC using PIC16F876 ?

Status
Not open for further replies.

aljamri

Member
Hi,

With valuable help from ETO fellows, I completed my first 10bit ADC using PIC16F876 (see this Thread)
Now I’m trying to implement the knowledge I gained there, to make another ADC, but with 8bit. Is it possible using the same PIC 16F876 ?
Thanks.
 
To make 8 bits even easier......

During initialisation, make sure bit ADFM is cleared to zero in register ADCON1 (left justified). You can simply read register ADRESH to get the 8 bits that you want.

Hope this helps
 
Well if you can make a 10 bit one then yes an eight bit is easy - just dont use the two lowest bits....

Hi Misterbenn;

But thats going to make 11111111 is = 1.25V if my +ref=5V if I ignore two MSB.

Thanks.
 
Last edited:
To make 8 bits even easier......

During initialisation, make sure bit ADFM is cleared to zero in register ADCON1 (left justified). You can simply read register ADRESH to get the 8 bits that you want.

Hope this helps

Hi hexreader;

Again my Vref=5V, I'll get maximum Digital Output by applying 1.25V only.

Thnaks
 
Last edited:
Hi hexreader;

Again my Vref=5V, I'll get maximum Digital Output by applying 1.25V only.

Thnaks

hi aljamri,
Its doesn't work like that.:D

If you have a 5Vref and set the adc for 10 bit resolution you will get for a 5V adc input 5V/1023 ie approx 4.88mV /bit

If you set the adc for 8bit resolution, for a 5V adc input you will get 19.6mV/bit.

Its the resolution that changes not the voltage range...OK.?
 
Last edited:
Your looking at this wrong

10 bit is 1023 = 5 volts b1111111111

127.5 x 0.0048875855327468230694037145650049 = .623 volts

8 bit is 255 = 5 volts b11111111

127.5 x 0.01960784313725490196078431372549 = 2.5 volts at 8 bit

Sorry ericgibbs you posted the same thing I'll leave it you hadn't posted when I was there
 
Last edited:
Just an additional note to the comments made above-

The main point is that you would get rid of the two LOWEST bits, the LSBs NOT the two Highest bits, the MSBs.

This way you only lose resolution, not range. hope that helps
 
Thanks for all.

If I want to send my ADC output to computer using parallel port, and I'll send it in form of 8-bit to read it in the computer as 5Volts, will the following work?


Code:
void main() {
  ADCON0 = 0b11000000;
  ADCON1 = 0b00001111;
  TRISA  = 0xFF;
  TRISC  = 0;
  PORTC  = 0;
  do {
  
      PORTC = ADC_Read(0);
     
  } while(1);
       }
 
:confused:
Your looking at this wrong

10 bit is 1023 = 5 volts b1111111111

127.5 x 0.0048875855327468230694037145650049 = .623 volts

8 bit is 255 = 5 volts b11111111

127.5 x 0.01960784313725490196078431372549 = 2.5 volts at 8 bit


Do you mean it can be done just by ignoring two bits ?! or I have to set the ADC differently to get 8-bit output
 
That's exactly what I'm looking for, how to set ADC to 8-bit instead of 10 bit.

Morning aljamri,
Corrected.!:eek:
When set for 8bit ADC, read the ADRESH register after the conversion, value will be 0 thru 255
 

Attachments

  • AAesp02.gif
    AAesp02.gif
    53.4 KB · Views: 209
Last edited:
Now it is clear for me.

Thanks for all, I like ETO :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top