Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

reduce adc bits of pic16f877

Status
Not open for further replies.

janlyn

Junior Member level 1
Joined
Dec 14, 2004
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
169
how to pic16f877 adc as 8 bit

hello all,
is it possible to reduce pic16f877's adc bits (10) to 8 bits??
 

adc pic 16f877 แบบ8บิต

One option will be to read all 10 bits and by shifting them to the right reject the last two .. so the result will be 8-bit data ..
 

    janlyn

    Points: 2
    Helpful Answer Positive Rating
hello IanP,

what u means is reject LSB?or MSB?
is the result same as directly convert to 8bit??
hope u can teach me...
thanks~
 

janlyn said:
hello IanP,

what u means is reject LSB?or MSB?
is the result same as directly convert to 8bit??
hope u can teach me...
thanks~

There is a simple solution for the PIC16F877(A):

If you want to have only an 8 bit result switch to left justified by clearing bitADFM in ADCON1 and only use the value in ADRESH as your 8 bit result and ignore the contents of ADRESL ...

Also see the datasheet of your PIC

best regards
 

    janlyn

    Points: 2
    Helpful Answer Positive Rating
Shift in the other 2 bits and reject the 2 LSBs:

7 6 7 6 5 4 3 2
 

    janlyn

    Points: 2
    Helpful Answer Positive Rating
C-Man and IanP,

thats mean we can only reject LSB?
ok...thanks a lot~
 

Hi Janlyn !

Just complementing:

If you read/consider only the ADRESH contents (if left justified) you get only the 8 MSbits. It works like if you take the number 12.9843 with four decimal places but you need only two decimal places, so you ignore the last two digits and read 12.98

Remember that you are using only 8 bits from the AD conversion, but I think that the time do do the 10 bits conversion (equivalent to 12 Tads) should be respected, so you can not do a faster conversion becuase you need only 8 bits. I don´t know what happens if you abort the conversion process after the first 8 bits MSB were discovered.

thanks for the points.
 

    janlyn

    Points: 2
    Helpful Answer Positive Rating
hi rkodaira,

thanks for ur explaination...now i understand..

Remember that you are using only 8 bits from the AD conversion, but I think that the time do do the 10 bits conversion (equivalent to 12 Tads) should be respected, so you can not do a faster conversion becuase you need only 8 bits. I don´t know what happens if you abort the conversion process after the first 8 bits MSB were discovered.

sorry..i have some query...do u mean tht 8bit conversion is slower than 10bit?
if i do not abort the conversion process after the first 8bit MSB were discovered, then conversion time is shorter than aborting the process?

hope u can teach me,thanks~
 

Ok, let me illustrate how the converter works. The PICs A/D converters are SAR (sucessive aproximation registers). If it is a 10 bits converter, it will spend 10 periods of Tad (plus 2 Tads for the converter), where each bit is discovered at each Tad.

An example: you know that the result has 10 bits, in other words, its range is from 0 to 1023 (decimal). So lets say that the voltage in the channel input is some voltage that produces the value 743 in the ADRES (ADRESH and ADRESL combined). You know that 743 dec = 1011100111 bin and it is 10 bits wide.

The converter takes the voltage in the input and compares to the midway between the Vref+ and Vref- (5 and 0V to simplify). The midway means 512 dec (or 2.5V).

1) First bit : is 743 greater or equal than 512 ? Yes, so first bit = 1
ADRESH.7 =1

The next comparation is the midway between 512 and 1023 = 768

2) Second bit: is 743 greater or equal than 768 ? No, so second bit = 0
ADRESH.6 = 0

Following the same procedure:
3) Is 743 greater or equal than 640 (midway for 512 and 768) ? Yes
ADRESH.5 = 1

4) Is 743 greater or equal than 704 (midway for 640 and 768) ? Yes
ADRESH.4 = 1

5) Is 743 greater or equal than 736 ? Yes
ADRESH.3 = 1

6) Is 743 greater or equal than 752 ? No
ADRESH.2 = 0

7) Is 743 greater or equal than 744 (midway for 736 and 752) ? No
ADRESH.1 = 0

8) Is 743 greater or equal than 740 (midway for 736 and 744) ? Yes
ADRESH.0 = 1

9) Is 743 greater or equal than 742 (midway for 740 and 744) ? Yes
ADRESL.7 = 1 NOTE THAT IT CHANGED THE REGISTER

10) Is 743 greater or equal than 743 (midway for 742 and 744) ? Yes is equal
ADRESL.6 = 1

After 10 comparations, the converter discovers the result. Notice that at step 8, you know the 8 bits most significative, but you have less precision (the value is between 740 and 744) because you threw away 2 bits. The 8 bits converters are faster because they spend less steps (8) to find the result, but are less accurate.

In theory, you could abort the conversion process after the step 8, because you want only the 8 MSbits, but I don´t remember if it is possible in the PICs. If possible, you save 2 Tads (around 4us, is worth ?).

Please, remember that taking 8 bits (0 to 255 steps) each step will correspond to 5V/255 = 0.0196V (or 4 times greater than 10 bit step).
 

    janlyn

    Points: 2
    Helpful Answer Positive Rating
rkodaira,

ok, now i understand..
thanks for ur explanation~

but 8 bit adc is easier to handle..the whole result is stored in one register.
if my input range of adc is 5 to 24v with resolution 0.1v,
8 bit should be enough, right?
 

With 8-bits and ≈20V range you are pretty close to 0.1 resolution ..
 

    janlyn

    Points: 2
    Helpful Answer Positive Rating
IanP,

thats mean i can used it,right?
thanks~
now i still in trying progress....
 

Now your task is to convert 5-24V to 1-5V so the whole range is covered ..
What you can do is to use a voltage devider (by 5 or 6) and an opamp as a buffer ..
 

hai

i fyou need 8 bits resolution then go for controller with 8 bit resoultion like 16f873
why u are doing unwanted things with 16f877
is there any particular reason
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top