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.

adc result is not accurate..

Status
Not open for further replies.
Joined
Feb 22, 2012
Messages
82
Helped
25
Reputation
50
Reaction score
25
Trophy points
1,298
Activity points
0
hi....


I am using pic18f46j11. and crystal is 20 MHz. i design a code but its output is not sum how accurate. when input voltage at AN0 is 3.4 v (max.)
output is 3C9 (3.21 V) instead of 3FF (3.4 V). when other inputs is given output is accurate. I am little bit confused about output. I am attaching my program herewith. have a look.
 

Attachments

  • adc.txt
    1.5 KB · Views: 66

shouldn't you use & (and) instead of |(or) when setting config value?
 

shouldn't you use & (and) instead of |(or) when setting config value?

but my friend.. my program is simulating and running successfully, so there is no problem of & OR. and my problem is inaccurate result. so it doesn't matters.
 
Sources for A2D errors include a noise and/or incorrect voltage reference, the sample and hold settling time and the number of bits
 

Building on what klystron said, what are you using for your reference voltage? It is properly de-coupled as if it changes then your measurement will be wrong. You say that you have tried using the other A2D channels and they give you the correct result??
 

hi....

i am using 20MHz crystal so what will be my A/D Acquisition Time Select bits and A/D Conversion Clock Select bits ??? i m currently using 2 Tad and Fosc/16 is it correct ???
should i use extra delay in between OpenADC() and ConvertADC() as in my program ???
 
Yes that all sounds fine but are you using the internal voltage as your reference that the A2D channel takes its measurements against or are you using an external reference voltage? If you are using an external reference voltage you need to make sure that the voltage being supplied is constant, this is done with a de-coupling capacitor between the reference voltage and ground, or if you are using the internal voltage then the cap needs to go between the power lines of the uC.

/Pheetuz
 

hi....

i am using 20MHz crystal so what will be my A/D Acquisition Time Select bits and A/D Conversion Clock Select bits ??? i m currently using 2 Tad and Fosc/16 is it correct ???
should i use extra delay in between OpenADC() and ConvertADC() as in my program ???

Please see the followings, it may help you:-

Use of Vref+ pin of PIC16F97xA ADC [applicable to all micro] at https://www.edaboard.com/blog/1544/
ADC Conversion Clock Select bit setting for PIC16F87XA microcontroller at https://www.edaboard.com/blog/1542/

---------- Post added at 19:33 ---------- Previous post was at 19:30 ----------

hi....

i am using 20MHz crystal so what will be my A/D Acquisition Time Select bits and A/D Conversion Clock Select bits ??? i m currently using 2 Tad and Fosc/16 is it correct ???
should i use extra delay in between OpenADC() and ConvertADC() as in my program ???

Fosc/16 is not correct. Recalculate
 

hi, friends. thanks for your help.



I have changed my program slightly... but still, i have no accuracy as i required. The error of 0.03V is coming.. I have attached my program here. I am using internal voltage as vref. Now i am using fosc/8 and 2 Tad. my crystal is 20MHz/4 = 5 Mhz.
 

Attachments

  • adc final.txt
    2 KB · Views: 70
0.03V is a pretty small error and may even be caused by noise at the input. Connect a filter at the input. For this you can use an RC filter. Try with a 1k resistor between signal input and ADC input pin and a 0.1uF capacitor from ADC input pin to ground. I assume your input is DC and is not high frequency pulse.

Is this error coming only in simulation? Are you testing all of this in simulation?

Try increasing the acquisition time further to 4 or 8 TAD. Also try with FOSC/64 and FOSC/16. Basically, just slow it down and see if it benefits.

From your calculations in post #1, I can tell that your reference voltage is 3.4V. In the code, you set ADC to use VDD and VSS for reference. So, your PIC is powered by 3.4V. Is that right? Make sure that the 3.4V supply is stable. Measure the supply voltage. There's every possibility it's not 3.400V and thus you get a small error. Use a 0.1uF capacitor in parallel with a 100uF across VDD and VSS.

Hope this helps.
Tahmid.
 

What was the problem in the end?

the problem was we have to count oscillator frequency/4. i used 20Mhz crystal. so 20Mhz/4 = 5 Mhz. this is my osc. frequency. so i changed my calculations. i have already given my code that runs successfully.
 
hi friends, same problem arises when i changed my pic from pic18f46j11 to picf4550.

adc result is not accurate again. i am attaching my program ...

have a look....
 

Attachments

  • adcf4550.txt
    2.2 KB · Views: 50
Yes, Tahmid. But still output is not accurate. I am getting output from accelerometer so i require exact value.
 

How large is the variation?



Tahmid,

If i am giving 2.60V than output of adc will be between 2.50 to 2.70 and it varies every time. I don't understand that how it could be ? because program and hardware is correct. I am measuring voltage on multimeter and DSO. if my power supply is faulty than fault will be displayed on DSO but it's not.
 

Tahmid,

If i am giving 2.60V than output of adc will be between 2.50 to 2.70 and it varies every time. I don't understand that how it could be ? because program and hardware is correct. I am measuring voltage on multimeter and DSO. if my power supply is faulty than fault will be displayed on DSO but it's not.

Did you connect the filter at the input?
Did you decouple and filter the supply voltage? Measure the voltage on the PIC VDD and see if it is stable at 5.0V.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top