a/d switch references--wait for the cap!!

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

Hello:

I've been working a bit with the mega48 A/D..All is pretty well, though I suddenly needed to switch back and forth between the references (AVcc & 1.1 internal bandgap), due to one of my channel voltages being rather small. I took the datasheet advice to discard the 1st reading after switching refs, but my results made no sense at all. It was quite tough to figure out--changed code,etc. None of the errors made sense logically. The program appeared perfect!

What the datasheet lacks is the fact that any cap on Vref will require a DELAY when switching the ref voltage, due to the charge time. Merely doing a 2nd conversion alone (right away) is not enough! Has anyone else run into this "gotcha" ? It really is simple to fix, once you know the source of the trouble. Otherwise you'll inspect your code forever with no error found.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

How big is your cap on Vref?

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

I am using 0.001, 0.01, 0.1uf caps (Vref to gnd) to investigate. You can see that the larger caps cause a larger error. The error can be reduced by inserting a delay between consecutive conversions (needed when the ref is switched). With 1000pf you can basically stack the conversions with no apparent error.

What I find interesting is the data sheet only mentions that you should do an extra conversion when switching the ref & toss the first one out. I did that, but with the cap you ALSO need some delay time. This was VERY hard to detect at first since my conversions were taking place at differnt times relative to switching the ref. So some conversions would be ok & other were mysteriously not.

At the end of the datasheet it mentions 32k ohms for the ref --perhaps this is part of the time constant we face. With 0.1uf that gives 3.2ms.

Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

I decided to dig out the ole digital scope (well actually all I had to do was turn it on). I monitored the Vref pin as I switched the A/D ref from Avcc (5V) to the internal 1.1V bandgap. Switching from 1.1V to Avcc is MUCH faster than going the other way
1000pf--> 62ns
10000pf-->500ns (0.01uf)
100000pf-->6000ns (0.1uf)
Avcc to 1.1 refernece switchover settling timing:
1000pf-->50us
10000pf-->300us
100000pf-->4ms (thats loooong)
It appears going from 5 to 1.1V has an approx 30K res for the time const.
Hope this helps someone down the road.
Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

More data:
I also measured the Avcc to 1.1Vref settling time with no cap & 100pf from Vref to gnd
no cap-->15us (faster than a conversion will occur)
100pf-->25us (about same as with no cap)
Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!