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.

the value from ADC not consistence :cry:

Status
Not open for further replies.

duyungirl

Newbie level 4
Joined
Dec 25, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
malaysia
Activity points
1,327
Hello everyone,
i need some help about reading voltage that going to ADC of PIC18F252 and then display that value to LCD.my input of adc is from current sensor that produce output in term of voltage

My range input voltage should be 4.00V to 4.10v only,and the output produce at lcd also in that range but the problem here at certain time the output at lcd go outside that range (but in short time). Why its happen?. I really need precision value to calculate some formula.

And second problem,the output that display at lcd are change from one to another are to fast (about 1 second).


below is my coding

unsigned char ch;
unsigned int adc_rd;
char *text;
long tlong,;

void LCD()
{

Delay_ms(500);// need delay
adc_rd = ADC_Read(2); // A/D conversion. Pin RA2 is an input.
Lcd_Out(2,1,text); // Write result in the second line
tlong = (long)adc_rd * 4800; // Convert the result in millivolts
tlong = (tlong / 1024)
ch = tlong / 1000; // Extract volts (thousands of millivolts)
// from result

Lcd_Chr(2,9,48+ch); // Write result in ASCII format
ch = (tlong / 100) % 10; // Extract hundreds of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
Lcd_Chr_CP('.');
ch = (tlong/ 10) % 10; // Extract tens of millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format
ch = tlong % 10; // Extract digits for millivolts
Lcd_Chr_CP(48+ch); // Write result in ASCII format

Delay_ms(1);


}

please somebody help me
:cry:
 

Hi,

Your 'precision' result will depend on your ADC circuitry .

See my reply to this similar post for some simple ways of improving things.
 

im not understand that link u give to me (http://www.winpicprog.co.uk/pic_tutorial_analogue_board.htm)
- what the function of AD0,AD1?What's that, at circuit not show where AD0,AD1,AD3?It is refer to RA0,RA1,RA2?

- CH0 and CH2 is connect to where?

it is circuit suitable for my ADC? my analog input to PIC is between 4.0 to 4.10V only,how come it increase my input voltage?have any additional/replacement component need i do?

- how i do know my reference voltage is 2.5v?how to know and how to choose the value of reference voltage?have any formula to calculate?

i hope u can help me..i really appreciate your kind. TQ..
 

Hi,

Ok, lets forget about that winpicprog tutorial and stick to the basic stuff.

With a 18F chip running at 5v this means that the 10 bit ADC will read 0 to 5v in 1024 steps, so each step represents 0.00488 v.
Thats a very very small amount of voltage.

If you scoped the supply voltages to the pic and your current sensor they will probably vary by more than that, plus the internal working of your current sensor and the pic will also produce some variance.

Short of using high quailty circuitry you will have to accept that you will always see some ' jitter' on your adc result.
In your case you are monitoring a narrow window of just 0.1v which is just 20 ADC steps.

From simple adc circuitry you can almost always say that the last 2 bits of the 10 bit result can be discarded as the 'jitter' is just too great.
This leaves you with an 8 bit result, ie just 256 steps, so that means 1 step will equal just under 0.02v, or 5 steps to span your 4.00 to 4.10 range.

Even with 8 bits you will still see some jitter, to elimanate most of this do an adc read, then add the value into x16 or x256 averaging routine with a small delay between each adc read allow the adc circuit to recover.

Do not have any details of your circuitry but , again keeping things simple, put a 100nf cap across the adc input and 0v to help smooth things more.

Cannot help you with the code as I do not know C.
 

i have put 100nF cap at my input adc,parallel witch input of adc..it still happen..not change anthing :(

so how? :cry:
 

Hi,

Seems like you need to work on the software as I mentioned above.

Reducing your adc result the the high 8 bits will help and then doing 16 or 256 adc reads into an average routine should make it much more stable, but at the cost of a lower resolution.

Have used this method on 2 different type of adc input with good results.

What resolutions are you working to within your range of 4.00 to 4.10 , from your code it looks like you are displaying the voltage down to 4.000 ?
Are you expecting to see reading of 4.052v or 4.053v, doubt with simple circuitry you will just not get any better than 4.00v in 0.02v step
 

thanks for your help..

what do u mean by reduce to my adc result the the high 8 bits?it mean i need change my PIC to PIC18F TO PIC16F(since i know,PIC16F sing 8 bit)?

and how to make do 16 or 256 adc reads into an average routine in programming?it means i need to sorting method to sort my adc value and get the average value.for example i sort and adding 8 value of adc and then divide it total value with 8?


why u say my coding it looks like displaying the voltage down to 4.000.Have something wrong at my coding?Yes,i expected to see reading of 4.052v or 4.053v.

i use Vref+=5v and Vref- = gnd.
 

Hi,

what do u mean by reduce to my adc result the the high 8 bits?it mean i need change my PIC to PIC18F TO PIC16F(since i know,PIC16F sing 8 bit)?

No, your adc result is ten bits 0000000000 , simply remove the2 low order bits to produce a 8 bit number.

and how to make do 16 or 256 adc reads into an average routine in programming?it means i need to sorting method to sort my adc value and get the average value.for example i sort and adding 8 value of adc and then divide it total value with 8?

Thats the basic idea ..



Yes,i expected to see reading of 4.052v or 4.053v.

Well you have missed the point of whats been said already.... you cannot get that kind of resolution with such simple circuitry without jitter.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top