Author Topic: ADC unrealiable in ATmega32?  (Read 13667 times)

0 Members and 1 Guest are viewing this topic.

Online Psi

  • Super Contributor
  • ***
  • Posts: 9951
  • Country: nz
Re: ADC unrealiable in ATmega32?
« Reply #25 on: May 26, 2012, 11:08:43 pm »
Nope, there's no sequence point within the quoted expression, so the compiler is free to evaluate ADCL and ( ADCH << 8 ) in whichever order it feels like today.
...
Ah, now, that's subtly different -- when you're doing that you use the short-circuiting boolean operators && and ||, which are explicitly defined to evaluate the left operand first and only evaluate the right operand if required to compute the final result...

Just tested this with PIC C and guess what?
...
It starts by reading the high value  ::)


Thanks guys, learn something every day :)


Safe way to combine low and high is going to be
Code: [Select]
uint16_t adc_value;
adc_value = ADCL;
adc_value = adcvalue | (ADCH << 8) ;
Or just use ADCW
« Last Edit: May 26, 2012, 11:12:07 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8517
  • Country: us
    • SiliconValleyGarage
Re: ADC unrealiable in ATmega32?
« Reply #26 on: May 27, 2012, 12:24:19 am »
Thats the technique i described above : sliding window integration.
No, it's not. Do read again. Do try it. Compare results. Repeat.

Their difference is that they shift down only 3 positions where i do 4. So they claim to get 'additional bits, which is nonsense. You can't get 16 bit out of a 10 bit converter no matter how hard you try.

The second trick they employ is injecting noise in the input. They are essentially making a sigma delta on top of their a/d. But this again is nonsense... I wouldn't trust that. First of all your 'random' generator is not going to be random at all. It'll be based on a prbs polynomal. If you try to convert a perfectly stable static input it will still bounce all over the place..

Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline aluck

  • Regular Contributor
  • *
  • Posts: 242
  • Country: ru
Re: ADC unrealiable in ATmega32?
« Reply #27 on: May 27, 2012, 07:18:17 am »
No, it's not. Do read again. Do try it. Compare results. Repeat.
The second trick they employ is injecting noise in the input. They are essentially making a sigma delta on top of their a/d. But this again is nonsense... I wouldn't trust that. First of all your 'random' generator is not going to be random at all. It'll be based on a prbs polynomal.
You missed 2 points:
 1. It is not just "a noise". If you superimpose 10Vpp noise over 250 mV signal - it wouldn't make any sense. You need artificially produced noise "with a ripple peak-to-peak value of a few LSB" (page 9).
 2. It is not designed to replace 16-bit ADC with el-cheapo 8-bit. You are losing sampling rate at exponentional progression. For each additional 1 bit you have to double the number of measurements, so for getting additional 8 bit you will need 2^8 oversampling.

So far, you are just theorizing. Just give it a try and let us know of your results. If you still not satisfied - let's summon Atmel people here and question them a little bit Torquemada style.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf