Mega4809 ADC and AC configuration

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I want to use the Analog Comparator as well as the ADC for the same input voltage. I tried to assign pin PD1 for the the ADC (AIN1) as well as the AC (P3). However, Atmel Start doesn't allow that and reports a conflict. I generated the source with two different pins and modified the source so that the same pin is used for for the ADC and the AC. This seems to work without any problem!

 

Is there any reason why this should NOT be done?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you seen the app notes on those?

See attached

 

Attachment(s): 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I have seen the appnotes, but they don't say anything about sharing of the same analog input pin for ADC and AC. I don't have a problem with the basic functionality, I'm thinking about a possible interference of ADC and AC, like a reduced accuracy of the AC during ADC conversions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How you tried bypassing START and writing to the registers directly?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just looked at the generated Atmel Start sourcecode and created my own initialization code. That's much easier to use for me than the Atmel source with dozens of files.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Because the ADC uses a capacitor sample-and-hold you might see a dip in the source voltage during the acquisition phase if you aren't driving the pin from a low impedance source. Whether this affect the AC will, of course, depend on how you are using it.

 

What is your source impedance?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The source impedance is ~1k.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

eauth wrote:
sharing of the same analog input pin for ADC and AC.

Sharing the same pin???     Perhaps you need to start over and explain what it is you want to do.

 

Jim

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>Sharing the same pin??? 

 

Why not? Can't take an adc reading of an ac input pin? Maybe I'm missing something obvious, but sounds perfectly normal to me.

 

 

>However, Atmel Start doesn't allow that and reports a conflict

 

Atmel Start reports, but lets you decide (it did give you an option). The only thing it does with that info is set the pin you requested to analog (disables input, disables pullup, but curiously does nothing with direction). So you have both ac and adc setting the same pin to analog, not a problem. In this case you would be smarter than the wizard.

 

Not a fan of wizard code in any case, so using start to give you ideas and doing your own is a good option.

 

Compilers can turn out to be great wizards-

Ac0 ac0;

ac0.muxPos( ac0.PPIN3 ); //sets positive mux and also sets pin to analog

Adc0 adc0;

adc0.channel( adc0.AIN1 )//sets channel and also sets pin to analog (if is a pin)

 

(above code works for any avr0/1)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

eauth wrote:

The source impedance is ~1k.

 

You should be OK. If we just consider the addition of the AC then IL is spec'd at 5nA. So that's the additional current flowing through the 1k. So 1k x 5nA = 5uV. No problem with that.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."