Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

XMEGA ADC Selecting Channels

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
syndetic1

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Sun Nov 28, 2021 1:31 am    Post subject: XMEGA ADC Selecting Channels Reply with quote

Hi guys,

I am having trouble understanding the MUX selection on the XMEGA.

Here is what I know. At the end is a question on how to measure the internal ground voltage.
Chip is ATXMEGA128A3U-AU

I have the ADCs configured for single ended operation.
1
Config Adca = Single , Convmode = Unsigned , Resolution = 12bit , Dma = Off , Reference = Int1v , Event_mode = None , Prescaler = 32 , Ch0_gain = 1 , Ch0_inp = Single_ended , Mux0 = &B0000000, Ch1_gain = 1 , Ch1_inp = INTERNAL , Mux1 = &B1_000 , Ch2_gain = 1 , Ch2_inp = Single_ended , Mux2 = &B10000000 , Ch3_gain = 1 , Ch3_inp = Single_ended , Mux3 = &B1100000

Config AdcB = Single , Convmode = Unsigned , Resolution = 12bit , Dma = Off , Reference = Int1v , Event_mode = None , Prescaler = 32 , Ch0_gain = 1 , Ch0_inp = Single_ended , Mux0 = &B0000000, Ch1_gain = 1 , Ch1_inp = INTERNAL , Mux1 = &B1_000 , Ch2_gain = 1 , Ch2_inp = Single_ended , Mux2 = &B10000000 , Ch3_gain = 1 , Ch3_inp = Single_ended , Mux3 = &B1100000


2 From
http://ww1.microchip.com/downloads/en/Appnotes/00002535A.pdf
"In devices with two ADCs, the inputs can only be connected to the corresponding port. Meaning that ADCA can be connected only to PORT A, and ADC B can be connected only to PORT B."
The XMEGA I am using has 2 ADCs

3 The GetADC command in BASCOM looks like this:
var = GETADC( ADC , channel ,MUX)
Where ADC is A or B
Channel is a virtual channel number 0, 1, 2, 3 - I am using channel 0.
MUX is as follows

4 MUX
MUX is an 8 bit register.
Bit 7 is always 0
Bits 6543 - 4 bits select the source to the positive side of the ADC
Bits 210 - 3 bits select the negative side. 000 selects Ground

So to read PortA.0 the BASCOM command is:
MyVar = GETADC(ADCA, 0 , &b00000000)
PortA.1 is GETADC(ADCA, 0 , &b00001000)
and to read PortB
PortB0 MyVar = GETADC(ADCB, 0 , &b01000000) ie channel 8
PortB1 MyVar = GETADC(ADCB, 0 , &b01001000) ie channel 9

5 The data sheet tells me that there are various internal voltage sources including ground.
QUESTION
How do I read the internal ground voltage?
What is the config statement I need and what is the info to put in the GETADC command

Thanks in advance




(BASCOM-AVR version : 2.0.8.4 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Nov 28, 2021 2:07 pm    Post subject: Re: XMEGA ADC Selecting Channels Reply with quote

syndetic1 wrote:
How do I read the internal ground voltage?

Not at all. If ground would be different to 0 volt, it would be broken.
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 586
Location: Cleveland, OH

usa.gif
PostPosted: Sun Nov 28, 2021 10:32 pm    Post subject: Reply with quote

Actually, I think it is very reasonable to read the Internal Ground Voltage.
This is the Ground against which the other inputs are measured, in single ended input mode.

The issues is that depending upon the PCB, there may be significant currents flowing through the ground trace / plane, causing it's voltage to be different from the voltage source (-), and different from the ground level inside the chip.

Remember that if you have the data sheet in front of you, you can always re-configure the ADC by setting the registers yourself.

JC
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Mon Nov 29, 2021 1:52 am    Post subject: Reply with quote

JC wrote:
Actually, I think it is very reasonable to read the Internal Ground Voltage.

I say it's nonsense, as if you want to measure something, you need a reference to measure it against.
What one of the chip's 6 GND's will be your reference then?
Quote:
The issues is that depending upon the PCB, there may be significant currents flowing through the ground trace / plane, causing it's voltage to be different from the voltage source (-), and different from the ground level inside the chip.

If your PCB design would lead to different levels on the various chip GND's, you better start a new life in some better suited profession.
Quote:
Remember that if you have the data sheet in front of you, you can always re-configure the ADC by setting the registers yourself.

If you or the TO would have actually have had a look into the data sheet, you'd have noticed that there is no such option of muxing an ADC input to GND.

Without knowing the chips internal layout, one can at least assume that GND pin 60 belongs to AVCC pin 61, which would lead to the further assumption, that these pin 60 an 61 serve the ADC sampling block.
This again would tell, that even if there would be tiny voltage shifts between several GND's, reference GND pin 60 is the one for which the ADC-result is valid.
Thus it makes no sense to measure this GND.
Back to top
View user's profile
syndetic1

Bascom Member



Joined: 02 Jan 2007
Posts: 76

blank.gif
PostPosted: Mon Nov 29, 2021 3:24 am    Post subject: Others have ADC issues Reply with quote

This bloke has a very interesting blog
https://blog.frankvh.com/2010/01/03/atmel-xmega-adc-problems-solutions/
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Mon Nov 29, 2021 11:21 am    Post subject: Re: Others have ADC issues Reply with quote

syndetic1 wrote:
This bloke has a very interesting blog

I would lend him credibility if he would not only offer opinions, instead providing measured data as proof.

Me prefers to read first source AVR1300, instead of second source opinions.
From the blog:
Quote:
but my experiments seemed to favour

A "seemed to favor" is indeed mighty rocket science. LOL

However, proof that the blog did not work for you is: The blogger wrote about a benefit tying the negative input pin in differential mode and no gain to GND, creating thus a single ended input.

You asked:
Quote:
How do I read the internal ground voltage?

If you do not know by now, you still did not read the data sheet.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum