PIC based ADC problem related to step size!!!

Status
Not open for further replies.

emhawkable

Junior Member level 1
can some one tell me how can i increase step size in ADC of pic18f452. i know that
step size = Vref/2^n
the Vref i have seen so far is not more than 5 volts.
can i increase it to more than 5 volts , so i can increase my step size.
at present the maximum available step size to me is

step size = 5/1024=4.93 mV

i want it to increase it , if any one has any info regarding this . plz share it wid me.

enjunear

I think you can specify how many bits of resolution that the ADC will use, but I haven't done PIC coding in a number of years. Dig into the spec, looking at the ADC setup section, in specific. Look for ADC resolution or range topics.

To do it manually/direct, you could pull in the ADC's raw binary value (0-1023), then AND the result with a binary mask that takes off the least-significant bits. That will effectively lower your resolution by half, for each bit you mask off.

If you get in a 10-bit value, like 0101011011 (347), and binary AND to mask off the lowest two bits with 1111111100, then your result would be 0101011000 (344). The next value that would show up after masking in raw value would be 0101011100 (348). By masking off the lowest bit, you reduce your range by half (from 1024 values to 512 values). If you mask of the lowest two bits, that drops your range by another half (512 down to 256). The values will go from 0 to 1020, but will change in steps of 4 (5V / 256 = 19.5 mV/step). This also makes your minimum occur at 0, and your max occur at 1020. Your translation back to a floating variable would need to be something like (5 * X/1020). So, 5*1020/1020 = 5.0 V

Tahmid

Hi,

You can also just shift your value. If you divide your ADC results by 8, you can think of step size having become 8 times larger:
Code:
ADR = ADC_Read(0);//Read channel 0 and store result in ADR
ADR = ADR >> 3; //Divide by 8 - Right shift 3
//Processing on ADR here
Here, your answer would be between 0 and 127. So step size is 5/127 = 39.37 mV

Hope this helps.
Tahmid.

emhawkable

Junior Member level 1
thank you very much for ur help!! it solved my problem!!!

Status
Not open for further replies.