View previous topic :: View next topic |
Author |
Message |
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Wed Oct 16, 2013 11:11 pm Post subject: Wrong ADC reading |
|
|
Hi,
On my desk i have 3 prototype's with an Atmega1281 on it.
There are 24, 10 and 3.3 VDC powersupply's on board.
Each powersupply feeds a resistor divider, in the middle of the divider there is a resistor of 10K to the ADC pin of the 1281.
For example the 3.3 volt goes into a resistor divider of 2 x 10k, so in the middle there is 1.65 volt (in reality 1.79 volt).
This middle point voltage goes to a 10K resistor to the ADC pin.
So far so good, but.
With a reference voltage of 2.56 i expect an ADC reading of (1024/2.56)x1.79=716
But the actual reading is 844 !!!
The same is valid for the 24 en 10 volt measurements, the ADC reading is not as expected (to high).
When i measure the voltage on the ADC pin it is 2.11 volt which compares to 844, so this is fine.
But where is the 2.11 volt coming from, in the middle of the divider the voltage is 1.79 volt
So there is a voltage of 0.32 over the resistor which is in serie with the ADC input pin.
All the proto's act the same.
This is the config ADC line:
config ADC = single, prescaler = auto, reference = INTERNAL_2.56
The voltage on the Aref pin is 2.55 volt, so the reference voltage is correct.
Frank.
(BASCOM-AVR version : 2.0.7.6 ) |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Wed Oct 16, 2013 11:35 pm Post subject: |
|
|
Sounds a bit like you have the ADC port set to inputs ( correct ) but with pullups enabled ( not correct ). Try explicitly setting
portf = 0
in your configuration code.
I presume you have the AVCC line connected to Vcc, as it must be. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Thu Oct 17, 2013 8:02 pm Post subject: |
|
|
Avcc is connected to Vcc which is 3.3 volt
I did try the PORTF = 0 but in doesn't help.
This is really strange.
The proto's are a renewal of an earlyer design with an Atmega64 on it.
On that design there was no problem and the hardware concerning the 24, 10 and 3.3 volt is not changed.
What's next to try? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Thu Oct 17, 2013 8:24 pm Post subject: |
|
|
I assume you disabled jtag?
And did you connect via L and decoupling cap as shown in the manual?
That it worked with a different older chip means nothing. only that the chips have different characteristics.
I would remove the chip connections to the A/D input and then measure the resistance divider. Is that really giving the right voltage?
You can also try to connect a small cap to the input pin of the a/d converter. it will remove noise. i guess what you pick up is noise. for the a/d converter it is important that none of the port pins from the a/d converter switch during conversion.
forget that your old design worked : just start at the begin step by step. _________________ Mark |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Thu Oct 17, 2013 8:38 pm Post subject: |
|
|
aaargh, it was the JTAG.
Everytime when i read here the advise to disable JTAG (and that is quite often) i think to myself "everybody know that you must disable JTAG"
And now i do it myself.
I guess i think that i got what i deserve, i will no longer think bad about others. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Thu Oct 17, 2013 8:51 pm Post subject: |
|
|
I only mentioned JTAG for users that read this topic later. I could not imagine you would have checked this first thing. But i know one can become blind for certain things ;-0 _________________ Mark |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Sun Feb 15, 2015 9:22 pm Post subject: |
|
|
When reading an ADC pin, do you have to configure the pin as an input and turn off the pullup, or is this done for you in the getadc(xxx) command? The help does not show the pin being configured, but several authors have mentioned "turn off the pullup explicitly" _________________ Neil |
|
Back to top |
|
|
Plons
Joined: 24 May 2005 Posts: 435 Location: Hilversum - The Netherlands
|
Posted: Sun Feb 15, 2015 11:43 pm Post subject: |
|
|
After reset, all ports are set as inputs with pull-up disabled. Therefor you do not need to worry about it ..... unless you alter the port configuration. AFAIK the Getadc(xx) does not alter the portsetting. A simple test can confirm this. _________________ Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel" |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Mon Feb 16, 2015 7:08 am Post subject: |
|
|
Thanks Plons. _________________ Neil |
|
Back to top |
|
|
|