Measuring signal amplitude with ADC - Page 1
Forum section: electronics / projects

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 03:35:22 am
content: 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.

author: w2aew
author_rank: Super Contributor
timestamp: December 07, 2013, 03:49:02 am
content: Quote from: prenato on December 07, 2013, 03:35:22 amIf 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.

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 05:51:50 am
content: 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

author: Jon86
author_rank: Frequent Contributor
timestamp: December 07, 2013, 10:57:18 am
content: Why do you want to avoid rectifying it? Board space issues?

author: dannyf
author_rank: Super Contributor
timestamp: December 07, 2013, 01:05:50 pm
content: 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.

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 03:17:43 pm
content: Quote from: Jon86 on December 07, 2013, 10:57:18 amWith 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...

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 03:22:25 pm
content: Quote from: dannyf on December 07, 2013, 01:05:50 pmThanks 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)...

author: PA4TIM
author_rank: Super Contributor
timestamp: December 07, 2013, 03:51:53 pm
content: 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.

author: Marco
author_rank: Super Contributor
timestamp: December 07, 2013, 03:58:46 pm
content: 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.

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 04:04:12 pm
content: Quote from: PA4TIM on December 07, 2013, 03:51:53 pmThanks for the advice! I'll give that a try.

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 04:05:41 pm
content: Quote from: Marco on December 07, 2013, 03:58:46 pmAs 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...

author: Mechatrommer
author_rank: Super Contributor
timestamp: December 07, 2013, 06:45:35 pm
content: Quote from: prenato on December 07, 2013, 03:35:22 amanother 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.

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 07:26:51 pm
content: Quote from: Mechatrommer on December 07, 2013, 06:45:35 pmWith 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.

author: Mechatrommer
author_rank: Super Contributor
timestamp: December 07, 2013, 07:49:09 pm
content: 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

author: Marco
author_rank: Super Contributor
timestamp: December 07, 2013, 07:57:52 pm
content: 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

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 08:11:06 pm
content: 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

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 08:13:24 pm
content: Another plot, showing polynomial fit to 1V input

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 09:31:42 pm
content: 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..

author: Mechatrommer
author_rank: Super Contributor
timestamp: December 07, 2013, 09:44:12 pm
content: 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

author: prenato
author_rank: Regular Contributor
timestamp: December 07, 2013, 10:05:17 pm
content: Quote from: Mechatrommer on December 07, 2013, 09:44:12 pmIf 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.

author: Mechatrommer
author_rank: Super Contributor
timestamp: December 08, 2013, 07:58:50 am
content: Quote from: prenato on December 07, 2013, 10:05:17 pmman do i sound like Bored@Home? lucky its me, have you met Bored@Work? welcome to the forum (until you get "cooling off" period).

author: SeanB
author_rank: Super Contributor
timestamp: December 08, 2013, 01:20:52 pm
content: 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.

author: Mechatrommer
author_rank: Super Contributor
timestamp: December 08, 2013, 03:58:08 pm
content: 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 youmaybe you can find out how much holding capacitance and switch resistance from your polynomial fit.

author: prenato
author_rank: Regular Contributor
timestamp: December 08, 2013, 05:04:23 pm
content: Quote from: SeanB on December 08, 2013, 01:20:52 pmThanks 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?...