Author Topic: Measuring signal amplitude with ADC  (Read 11174 times)

0 Members and 1 Guest are viewing this topic.

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Measuring signal amplitude with ADC
« on: December 07, 2013, 03:35:22 am »
I have a relatively fast (4MHz) signal riding on 2.5V DC. I need to measure the peak amplitude but don't want to go through a diode or rectifier. If I take many samples with the ADC and take the maximum, will this work even if the sampling rate is much lower than 4MHz? I understand about Nyquist rate, but here I just need the amplitude and seems that with enough "random" samples I should be qble to get it? Probably missing something here... Thoughts? Thanks in advance.
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: Measuring signal amplitude with ADC
« Reply #1 on: December 07, 2013, 03:49:02 am »
I have a relatively fast (4MHz) signal riding on 2.5V DC. I need to measure the peak amplitude but don't want to go through a diode or rectifier. If I take many samples with the ADC and take the maximum, will this work even if the sampling rate is much lower than 4MHz? I understand about Nyquist rate, but here I just need the amplitude and seems that with enough "random" samples I should be qble to get it? Probably missing something here... Thoughts? Thanks in advance.

If the ADC's sample and hold and any front-end buffer circuit has enough speed/BW for the 4MHz signal, then undersampling the signal long enough might gets you min and max values, as long as the sample rate isn't harmonically related to the 4MHz signal. In other words, it depends on the ADC and sample rate.
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #2 on: December 07, 2013, 05:51:50 am »
Thanks for your insight w2aew (love your Youtube channel btw; just watched two of your videos this morning before going to work:)
To be more precise, this would be the ADC inside an Arduino Uno... nothing very fancy. The 4 MHz signal and the sampling frequency in the Arduino are not synchronous.  I do see the issue if they were derived from each other... I guess you could end-up always sampling at the same point. Since they are not synchronous (in my circuit they are different oscillators) I was hoping that the sampling would be more or less "random" relative to the input signal over time, and thus could infer max an min with enough samples. I guess I'll give it a try. Reality tends to always throw a curve ball at me with analog stuff though...
Thanks again.
Paulo
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline Jon86

  • Frequent Contributor
  • **
  • Posts: 526
  • Country: gb
Re: Measuring signal amplitude with ADC
« Reply #3 on: December 07, 2013, 10:57:18 am »
Why do you want to avoid rectifying it? Board space issues?
Death, taxes and diode losses.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Measuring signal amplitude with ADC
« Reply #4 on: December 07, 2013, 01:05:50 pm »
The answer is no.

Yes, if you only care about the amplitude of a repeating waveform, you can sample long enough and wait for the max.

However, you will need the signal to hold while each sampling is taking place - the adc module's datasheet for the acquisition time spec. Most onboard adcs are 1-2MSPS - NXP just announced a chip with extremely fast adc.

So what you want is really not doable on an avr, without outboard help - you can, for example, build a sample/hold circuitry. Though for a 4Mhz signal, it is not a sample task.
================================
https://dannyelectronics.wordpress.com/
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #5 on: December 07, 2013, 03:17:43 pm »
Why do you want to avoid rectifying it? Board space issues?

With a simple diode there's the drop which would be significant for this application. A precision rectifier at 4 MHz is not so trivial.Probably doable with fast enough opamp and Schottky diode but I woul rather avoid this if I could...
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #6 on: December 07, 2013, 03:22:25 pm »
The answer is no.

Yes, if you only care about the amplitude of a repeating waveform, you can sample long enough and wait for the max.

However, you will need the signal to hold while each sampling is taking place - the adc module's datasheet for the acquisition time spec. Most onboard adcs are 1-2MSPS - NXP just announced a chip with extremely fast adc.

So what you want is really not doable on an avr, without outboard help - you can, for example, build a sample/hold circuitry. Though for a 4Mhz signal, it is not a sample task.

Thanks Danny. Yep, the sample and hold at 4Mhz is not so simple which is why I was trying to avoid it. Anyone managed to build a precision rectifier at 4Mhz? Preliminary sims even with a 80 MHz Gbw opamp don't look so good (using the two-diode "improved" circuit)...
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline PA4TIM

  • Super Contributor
  • ***
  • Posts: 1164
  • Country: nl
  • instruments are like rabbits, they multiply fast
    • PA4TIMs shelter for orphan measurement stuff
Re: Measuring signal amplitude with ADC
« Reply #7 on: December 07, 2013, 03:51:53 pm »
You need an opamp with a very high slewrate and build a precision rectifier.

Do not only look to the gain bandwidth product. I'm just working on a project that i used to measure RMS AC+DC signals upto 1 MHz. I used 4x OP37 (AC amplification) and 5x LT1028 (TRMS AC+DC converter) Both opamps have GBW around 50 MHz. The front end goes indeed over 1MHz. The ADC limits it all to 500 kHz but I sacrificed the BW in favour of a high crest factor. The bottleneck  to get faster was slewrate .
A friend is working on the same design (we designed it together) first wanted to use the OP37 too, but after my experience he searched for faster slew opamps and used  an other LT opamp that also has a GBW around 50 MHz but the slewrate is extreme high, something like 2000V/us if I remember well ) and his version even amplifies a squarwave over  1 MHz with ease.
 
www.pa4tim.nl my collection measurement gear and experiments Also lots of info about network analyse
www.schneiderelectronicsrepair.nl  repair of test and calibration equipment
https://www.youtube.com/user/pa4tim my youtube channel
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7159
  • Country: nl
Re: Measuring signal amplitude with ADC
« Reply #8 on: December 07, 2013, 03:58:46 pm »
What kind of precision rectifier did you try? The naive one will drive the input stage into saturation and is going to be slow regardless.
« Last Edit: December 07, 2013, 04:00:36 pm by Marco »
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #9 on: December 07, 2013, 04:04:12 pm »
You need an opamp with a very high slewrate and build a precision rectifier.

Do not only look to the gain bandwidth product. I'm just working on a project that i used to measure RMS AC+DC signals upto 1 MHz. I used 4x OP37 (AC amplification) and 5x LT1028 (TRMS AC+DC converter) Both opamps have GBW around 50 MHz. The front end goes indeed over 1MHz. The ADC limits it all to 500 kHz but I sacrificed the BW in favour of a high crest factor. The bottleneck  to get faster was slewrate .
A friend is working on the same design (we designed it together) first wanted to use the OP37 too, but after my experience he searched for faster slew opamps and used  an other LT opamp that also has a GBW around 50 MHz but the slewrate is extreme high, something like 2000V/us if I remember well ) and his version even amplifies a squarwave over  1 MHz with ease.

Thanks for the advice! I'll give that a try.
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #10 on: December 07, 2013, 04:05:41 pm »
What kind of precision rectifier did you try? The naive one will drive the input stage into saturation and is going to be slow regardless.
As I mentioned, it's the improved two-diode circuit which avoids the saturation issue. Based on P4TIm response, the issue may have been my choice of opamp. Need high slew-rate...
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: Measuring signal amplitude with ADC
« Reply #11 on: December 07, 2013, 06:45:35 pm »
I have a relatively fast (4MHz) signal riding on 2.5V DC. I need to measure the peak amplitude but don't want to go through a diode or rectifier. If I take many samples with the ADC and take the maximum, will this work even if the sampling rate is much lower than 4MHz?
another good example of analog problem tried to be solved with a "computer". do you know what you are doing is a brute force? i hope your problem is already solved with the rectifier answered by others.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #12 on: December 07, 2013, 07:26:51 pm »
I have a relatively fast (4MHz) signal riding on 2.5V DC. I need to measure the peak amplitude but don't want to go through a diode or rectifier. If I take many samples with the ADC and take the maximum, will this work even if the sampling rate is much lower than 4MHz?
another good example of analog problem tried to be solved with a "computer". do you know what you are doing is a brute force? i hope your problem is already solved with the rectifier answered by others.

With due respect, you can't possibly know much about what I'm trying to do and what I've tried so far to make a qualified assertion that this is "brute force". I've actually tried several analog circuits before, two based on bipolar transistors and one using an OPAMP (that unfortunately was not fast enough). So I started analog, but if a simple digital solution to a problem exists, I'll take it. Analog is not without it's problems too, especially at these frequencies.
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: Measuring signal amplitude with ADC
« Reply #13 on: December 07, 2013, 07:49:09 pm »
With due respect, i'm not the analog expert here and cant find you the right diode or opamp superdiode for the said BW. but taking random data and hope for the best is a brute force. analitically... how much random sample you will need? maybe someone mathematically inclined should be able to calculate for you, but it will be harder if sampling rate is unspecified. and my earlier post did not specifically point at you so dont take it personally ;)
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7159
  • Country: nl
Re: Measuring signal amplitude with ADC
« Reply #14 on: December 07, 2013, 07:57:52 pm »
The input bandwidth of the Arduino ADC is 40 KHz, this will never work without a sample and hold circuit ... or in this case you'll probably want a resettable peak detector. This datasheet has one with 270 ns response, which seems fast enough (just use an open drain output to zero the capacitor when necessary).

http://www.analog.com/static/imported-files/data_sheets/AD8033_8034.pdf
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #15 on: December 07, 2013, 08:11:06 pm »
Since I thought this could be a fun experiment, I hooked-up the output of my amplifier (signal to be measured) to the Arduino ADC and collected some data with various input levels. I used my Scope (AC coupled) to measure both pk-pk and rms values. Input frequency was 4.9 MHz.
I set the Arduino to take 300 samples for each measurement, each sample separated by 200 ms (this is not a problem in my application as I have a lot of time to take the measurements...). I then computed the rms and pk-pk in the Arduino. The results were interesting if a bit inconclusive. See attached plots. The measurements are off but the interesting part is that, for small signal amplitudes, it actually tracks the input. I was able to fit a second order polynomial quite well as shown in one figure. For larger amplitudes (> 1V pk-pk) the thing falls apart and seems to not track the input anymore (still withing the 5V rail though). So, this might be usable if the amplitude is kept low... requires some more study. I understand an OPAMP based solution is better but I'm just exploring ideas here for fun. It's a hobby after all ;)





Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #16 on: December 07, 2013, 08:13:24 pm »
Another plot, showing polynomial fit to 1V input
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #17 on: December 07, 2013, 09:31:42 pm »
I think what is happening  is that a small portion of the signal passes through and is still "seen" by the ADC. Don't expect much accuracy from this but could be used on a pinch..
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: Measuring signal amplitude with ADC
« Reply #18 on: December 07, 2013, 09:44:12 pm »
did you register the "sample and hold time" of an ADC adviced by others? esp by w2aew? you should take that advice seriously, esp from w2aew. no doubt experiment is fun, but wasting time is not for some ;)
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #19 on: December 07, 2013, 10:05:17 pm »
did you register the "sample and hold time" of an ADC adviced by others? esp by w2aew? you should take that advice seriously, esp from w2aew. no doubt experiment is fun, but wasting time is not for some ;)
If you think experimenting with electronics is "waste" of time, I think you are in the wrong forum. Please, if you have nothing constructive to say, move on. You should get off your high-horse.
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: Measuring signal amplitude with ADC
« Reply #20 on: December 08, 2013, 07:58:50 am »
You should get off your high-horse.
>:D man do i sound like Bored@Home? lucky its me, have you met Bored@Work? welcome to the forum (until you get "cooling off" period).
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16387
  • Country: za
Re: Measuring signal amplitude with ADC
« Reply #21 on: December 08, 2013, 01:20:52 pm »
Looks like at low levels the S&H is able to slew to the signal but at higher voltages it is unable to track reliably.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: Measuring signal amplitude with ADC
« Reply #22 on: December 08, 2013, 03:58:08 pm »
lets say 400KHz ADC clock is used (not full resolution), 1.5 clocks is needed to make a stable sampling (assuming you dont take first conversion into account which takes 13.5 clocks, from atmega8 datasheet), thats 3.75us "switched on". the 4MHz oscillates 15 times already during that window, and assuming "optimistically" the "switched on" is 1/15th of the 1.5ADClk, 4MHz will make a full cycle as seen by the holding capacitor. good luck! the rest of the homework i leave it to you ;) maybe you can find out how much holding capacitance and switch resistance from your polynomial fit.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Measuring signal amplitude with ADC
« Reply #23 on: December 08, 2013, 05:04:23 pm »
Looks like at low levels the S&H is able to slew to the signal but at higher voltages it is unable to track reliably.

Thanks Sean. That's probably playing a role here. Plus the input must be attenuated  because, though it "tracks" in slope, the ADC reports about 1/5th of the real amplitude I measured in the scope.
Frankly, I wasn't even expecting to see anything correlating to the input in this experiment given the limitations of this ADC as several have noted in this thread. I find it interesting though that you can get some sort of half-useful information at these low amplitudes. I don't claim to understand what is causing it but would be interested in finding. Like Feynman used to say, reality "is what it is", and if  theory doesn't agree with reality, guess who is right? ;)...
Paulo
Professional Tinkerer,
www.paulorenato.com
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf