ADC, minimum Vref?

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

I'm using the ADC on an attiny26 in single-ended mode with voltage reference set to external reference on the AREF pin. I've noticed a strange thing: when I set the voltage on the AREF pin to lower than ~1.6V, the output of the ADC saturates (0x3ff.) This is even when there's no signal on the ADC input.

Is it supposed to do this?

 

 

This topic has a solution.
Last Edited: Tue. Oct 10, 2017 - 05:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


                                                        VCC     VCC
                                                         +       +
                                                         '       |
               .------------.                            |       |
               |            |                  /|       .-.     |C
               |  attiny26  |                 /+|------>| |pot  |C
               |            |             .--<  |       | |     |C
               |            |             |   \-|---.   '-'      |
               |            |             |    \|   |    |       |
               |       AREF o-------------o---------'    |       |
               |            |                           ===      |
               |            |                           GND      |
               |       AVCC o------------------------------------o
               |            |       ___     LED                  |
               |       PA4  o------|___|----|<----.              |
               |            |                     |             ---
               |            |       ___           |             ---
               |       ADC6 o------|___|----------o              |
               '------------'                     |              |
                                                  |             ===
                                                  |             GND
                                                  |
                                                 ===
                                                 GND
.NOLIST
.INCLUDE "tn26def.inc"
.LIST

.macro outb
ldi r16,(@1)
out @0,r16
.endm

.CSEG
.ORG $0000

rjmp main ; Reset handler
reti ; EXT_INT0
reti ; PIN_CHANGE
reti ; TIM1_CMP1A ;
reti ; TIM1_CMP1B ;
reti ; TIM1_OVF ;
reti ; TIM0_OVF ;
reti ; USI_STRT ;
reti ; USI_OVF ;
reti ; EE_RDY ;
reti ; ANA_COMP ;
rjmp ADC_ISR


ADC_ISR:
    in r16,ADCL
    in r17,ADCH

    cpi r17,$3
    brne out1
    cpi r16,$ff
    brne out1


    outb PORTA,1<<PA4  ; blink led
    ldi	r24, 0x3F      ; delay 20ms
    ldi	r25, 0x9C
    sbiw	r24, 0x01
    brne	PC-1
    outb PORTA,0

out1:
    reti

main:
    outb SP, RAMEND
    outb DDRA,1<<PA4

;enable ADC
    outb ADMUX,1<<REFS0|0b00110<<MUX0 ; AREF,ADC6
    outb ADCSR,1<<ADEN|1<<ADIE|1<<ADSC|1<<ADFR|1<<ADPS2|1<<ADPS1 ;f/64

	outb MCUCR,(1<<SE)
    sei
main_loop:
	sleep
	nop
	rjmp main_loop

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

andy8080 wrote:
This is even when there's no signal on the ADC input.

Ummm--floating pins float.  They can have any level.  What happens when you tie the signal low?

 

andy8080 wrote:
when I set the voltage on the AREF pin to lower than ~1.6V, the output of the ADC saturates (0x3ff.)
andy8080 wrote:
attiny26

Tiny26?!?  Haven't heard of that one for a long while. ;)  Anyway, what does the datasheet say about minimum reference voltage?

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

What happens when you tie the signal low?

it was tied low. But before that, I fed the ADC a signal. When I adjusted Vref, the range of ADC values got larger the smaller I set Vref. But at ~1.6V it just saturated, abruptly too (I expected it would just clip)

Anyway, what does the datasheet say about minimum reference voltage?

o-ohkay.... Thank you so much! I missed this, I was CTRL-F'ing the datasheet, but only for "AREF."

 

And there I was thinking one could ADC-convert arbitrarily small voltages and get full scale resolution by setting Vref to roughly the Vpp of the signal, from a peak detector (because ADC=Vin/Vref*1024) as a kind of software AGC :)

 

Last Edited: Tue. Oct 10, 2017 - 06:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

andy8080 wrote:
And there I was thinking one could digitize arbitrarily small voltages by setting Vref to roughly the Vpp of the signal

The AVR8 min VREF varies somewhat from model to model and generation to generation (about 1V on Mega88A family), but is usually speced at about 1V.

 

Note that some models have a gain feature, including yours.  On differential channel pairs, with all that entails.

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

andy8080 wrote:

And there I was thinking one could ADC-convert arbitrarily small voltages and get full scale resolution by setting Vref to roughly the Vpp of the signal, from a peak detector (because ADC=Vin/Vref*1024) as a kind of software AGC :)

 

That would be nice, certainly.  Sadly, underneath all software is hardware, which is quite unforgiving. :)

 

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

andy8080 wrote:
And there I was thinking one could ADC-convert arbitrarily small voltages and get full scale resolution by setting Vref to roughly the Vpp of the signal, from a peak detector (because ADC=Vin/Vref*1024) as a kind of software AGC :)

Remember earlier I "commented" on the Tiny26 model choice?

 

Step into the new decade, and what are the options on the substitute Tiny261?

So, now you select the internal bandgap reference, and roughly 1mV per ADC count.  [yes, the initial tolerances aren't that good -- we do a one-time cal at ISP time]

 

And you still have the optional 20x gain for really tiny stuff.  [and again, with all that entails measuring tiny signals]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:
Step into the new decade, ...
(rolling the ball further than the 00s)

tiny416 has an internal 550mV reference (5% across temperature and voltage) though the ADC (3LSb typ error) is single-ended with no gain.

There's tinyAVR 1-series code for ADC oversampling to 12 bits.

 


http://www.microchip.com/wwwproducts/en/attiny26

http://www.microchip.com/wwwproducts/en/attiny261a

http://www.microchip.com/wwwproducts/en/attiny416

http://www.microchip.com/DevelopmentTools/ProductDetails.aspx?PartNO=ATTINY416-XNANO

http://start.atmel.com/#examples/oversampling

 

"Dare to be naïve." - Buckminster Fuller

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

I think these new "fancier modes" are due to the original ADC ext AREF pin being tied to the internal source (when selected)...so you couldn't switch back & forth between your own supplied ext ref & the internal bandgap --they'd collide at the pin.

 

The mega88 has a min Vref of 1V...makes sense, since its internal bandgap  ref is 1.1V (+/-10%)

When in the dark remember-the future looks brighter than ever.

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

avrcandies wrote:

I think these new "fancier modes" are due to the original ADC ext AREF pin being tied to the internal source (when selected)...so you couldn't switch back & forth between your own supplied ext ref & the internal bandgap --they'd collide at the pin.

 

The mega88 has a min Vref of 1V...makes sense, since its internal bandgap  ref is 1.1V (+/-10%)

 

Butting in but trying to understand this for an attiny25.  Would the "when selected" qualification mean you can switch back and forth (just not fast)?  Also will it be possible, on an attiny25 to select the "BG" as the table calls it as input when AREF is the reference?  The reference table metions that selecting AREF turns off the internal reference.  That would seem to imply that wont work, but it's not quite clear.  

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

Butting in but trying to understand this for an attiny25.  Would the "when selected" qualification mean you can switch back and forth (just not fast)?  Also will it be possible, on an attiny25 to select the "BG" as the table calls it as input when AREF is the reference?  The reference table metions that selecting AREF turns off the internal reference.  That would seem to imply that wont work, but it's not quite clear.  

Which table, exactly?  This one, I assume?:

 

 

The datasheet also has this:

 

 

Both are misleading.  The internal voltage reference will be >>disconnected<< from the ADC as a reference, but not necessarily 'turned off'.

 

 

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Wed. Nov 8, 2017 - 07:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

why would one have the internal reference as input to the ADC (single-ended mode, too)? I just looked and the 25/45/85 (and the 26L) indeed let one do it. calibration? to get 1/x response (x being Vref)?

Last Edited: Wed. Nov 8, 2017 - 09:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

what's the point of having the internal reference as input to the ADC (single-ended mode, too)? calibration? to get 1/x response?

Calibration.  Another use is to measure VCC.  With the reference set to VCC, and the MUX set to VBG, you can estimate VCC with the equation:

 

VCC = 2ADC_BITS * VBG / ADCSAMPLE

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Wed. Nov 8, 2017 - 09:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Calibration.  Another use is to measure VCC.

ah ok. thanks!

Last Edited: Wed. Nov 8, 2017 - 09:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:
what's the point of having the internal reference as input to the ADC (single-ended mode, too)? calibration? to get 1/x response? Calibration. Another use is to measure VCC.

Search for "do it badly".  http://www.avrfreaks.net/forum/a...

 

I'm losing track here -- isn't this thread insistent on using Tiny26 which has none of these new-fangled facilities?  If set on the Tiny26, then why worry about it?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Flintrock asked about the t25 in #10.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Oops, I didn't get back to this for a while.  Thanks for the helpful reply joeymorin.  The need for this may have disappeared for the moment, but it could still end up useful.   Yes, reading vcc is the reason I would (and do) use internal reference as input.  You have to invert the result as stated (one way or another).  Sorry, yes, I may have derailed the thread a little or maybe it was already derailed a little, but this seemed to fit.  I think it was theusch who sent me here, lol.  He did say he was losing track though.  

Last Edited: Sat. Nov 18, 2017 - 05:02 AM