Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

PIC based ADC problem related to step size!!!

Status
Not open for further replies.

emhawkable

Junior Member level 1
Joined
Jun 24, 2011
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,417
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

Advanced Member level 3
Joined
Dec 21, 2010
Messages
960
Helped
309
Reputation
618
Reaction score
303
Trophy points
1,343
Location
USA, midwest
Activity points
9,749
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

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
Hi,
Use 8-bit resolution. In the ADCON1 register, clear ADFM (ADFM = 0). Then, you can just read ADRESH as the 8-bit result. Then, your step size becomes 5/256 = 19.53 mV

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
Joined
Jun 24, 2011
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,417
thank you very much for ur help!! it solved my problem!!! :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top