DSPRelated.com
Forums

Recreating Undersampled Data

Started by Rob Gaddi May 17, 2017
I've got a situation coming up that I'm trying to think through in advance.

I'm running an ADC at let's say 1 Msps, sampling an input waveform that 
is known to be a triangle wave at roughly 2 1/16 MHz.  So with every ADC 
sample I advance across the input waveform by about 22.5 degrees, having 
missed a bit along the way.  And I acquire that data and now I'm looking 
at it offline, and I'd like to get a visualization of approximately what 
the input waveform looked like.  Basically, see what I would see if I 
were willing to stick a scope probe in there.

First guess is I'd probably upsample that data to 33 Msps, at which 
point it seems like some form of FIR interpolation kernel is called for. 
  Any idea how to figure out what that kernel should be?  It seems like 
there's some simple answer that should work if, for instance, my input 
signal is 1% slower than I expect it to be.  Which clearly a 33 point 
triangle wave is not.

The input signal is not guaranteed to be stationary through the 
acquisition, so I can't just throw a least squares solver at the overall 
waveform, but will at least be sufficiently slowly varying so that 
zombie Claude Shannon doesn't rise to yell at me.

Anyone have thoughts?

Thanks,
Rob

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
Rob Gaddi  <rgaddi@highlandtechnology.invalid> wrote:

>I'm running an ADC at let's say 1 Msps, sampling an input waveform that >is known to be a triangle wave at roughly 2 1/16 MHz. So with every ADC >sample I advance across the input waveform by about 22.5 degrees, having >missed a bit along the way. And I acquire that data and now I'm looking >at it offline, and I'd like to get a visualization of approximately what >the input waveform looked like. Basically, see what I would see if I >were willing to stick a scope probe in there.
I would try something like: 1) Interpolate to a higher sample rate (say, 100 Ms/sec) by zero-insertion. 2) Put this through a bank of bandpass filters with center frequencies n * (2 1/16) MHz for integers n = 1, 2, 3 .... 3) Sum these filtered signals and you should get a version of your original triangle wave. You want the bandpass filters to probably be linear phase and delay-matched. Steve
On Wed, 17 May 2017 14:05:04 -0700, Rob Gaddi wrote:

> I've got a situation coming up that I'm trying to think through in > advance. > > I'm running an ADC at let's say 1 Msps, sampling an input waveform that > is known to be a triangle wave at roughly 2 1/16 MHz. So with every ADC > sample I advance across the input waveform by about 22.5 degrees, having > missed a bit along the way. And I acquire that data and now I'm looking > at it offline, and I'd like to get a visualization of approximately what > the input waveform looked like. Basically, see what I would see if I > were willing to stick a scope probe in there. > > First guess is I'd probably upsample that data to 33 Msps, at which > point it seems like some form of FIR interpolation kernel is called for. > Any idea how to figure out what that kernel should be? It seems like > there's some simple answer that should work if, for instance, my input > signal is 1% slower than I expect it to be. Which clearly a 33 point > triangle wave is not. > > The input signal is not guaranteed to be stationary through the > acquisition, so I can't just throw a least squares solver at the overall > waveform, but will at least be sufficiently slowly varying so that > zombie Claude Shannon doesn't rise to yell at me. > > Anyone have thoughts?
Oh, God. Someone's abusing Nyquist and Shannon again. If you knew the exact frequency (or better, phase) of the triangle wave, then you could reconstruct it the way that the old sampling O-scopes did: put a "dot of light" on your "screen" corresponding to a sample, at the correct offset from x = 0. So calculate the period of the wave, Tp. Then plot the samples at time (n * 1us) mod Tp. You'll build up a nice pretty triangle wave. If you DON'T know the exact frequency, then phase-lock to the fundamental (multiply by a sine wave) and use the frequency command to your NCO to calculate Tp, and see above. Trying to filter after the fact in order to reconstruct won't work unless you bandpass filter the incoming triangle wave, and that would destroy it's triangular character. Or read this: <http://www.wescottdesign.com/articles/Sampling/ sampling.pdf>, especially the section titled "Nyquist and Repetitive Signals" starting on page 13. The nice thing to remember is that even though a steady triangle wave has frequency components going off into infinity, its actual occupied bandwidth is zero. A triangle wave with some jitter has a non-zero occupied bandwidth, just to make life interesting. That section assumes you know the frequency you're dealing with -- but you can get to that with the whole phase-lock business. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On 5/17/2017 5:05 PM, Rob Gaddi wrote:
> I've got a situation coming up that I'm trying to think through in advance. > > I'm running an ADC at let's say 1 Msps, sampling an input waveform that > is known to be a triangle wave at roughly 2 1/16 MHz. So with every ADC > sample I advance across the input waveform by about 22.5 degrees, having > missed a bit along the way. And I acquire that data and now I'm looking > at it offline, and I'd like to get a visualization of approximately what > the input waveform looked like. Basically, see what I would see if I > were willing to stick a scope probe in there. > > First guess is I'd probably upsample that data to 33 Msps, at which > point it seems like some form of FIR interpolation kernel is called for. > Any idea how to figure out what that kernel should be? It seems like > there's some simple answer that should work if, for instance, my input > signal is 1% slower than I expect it to be. Which clearly a 33 point > triangle wave is not. > > The input signal is not guaranteed to be stationary through the > acquisition, so I can't just throw a least squares solver at the overall > waveform, but will at least be sufficiently slowly varying so that > zombie Claude Shannon doesn't rise to yell at me. > > Anyone have thoughts?
If I am understanding your problem correctly, you have a triangle wave with content at 2.0625 Fs and harmonics. I am pretty sure this will alias the fundamental and the lower harmonics into the baseband. The fundamental will be at 0.0625 Fs, the 2nd harmonic will be at 0.125 Fs and so on. Once the harmonics reach 0.5 Fs the apparent frequency will fold back, but since their amplitudes will be low, they should not impact the results significantly. So you should be able to view the data directly treating 0.0625 Fs as the fundamental frequency of your triangle wave. Why would you need to shift or mix the data at all? -- Rick C
rickman  <gnuarm@gmail.com> wrote:

>If I am understanding your problem correctly, you have a triangle wave >with content at 2.0625 Fs and harmonics. I am pretty sure this will >alias the fundamental and the lower harmonics into the baseband. The >fundamental will be at 0.0625 Fs, the 2nd harmonic will be at 0.125 Fs >and so on. Once the harmonics reach 0.5 Fs the apparent frequency will >fold back, but since their amplitudes will be low, they should not >impact the results significantly. So you should be able to view the >data directly treating 0.0625 Fs as the fundamental frequency of your >triangle wave.
Yes, but you might want to view the triangle wave signal with the correct time-axis, such that it truly does look like the original signal as seen on TV (er, as seen on an oscilloscope). Unless harmonics are aliasing on top of each other, you should be able to filter out a pretty good version of the original signal. S.
On 5/17/2017 10:01 PM, Steve Pope wrote:
> rickman <gnuarm@gmail.com> wrote: > >> If I am understanding your problem correctly, you have a triangle wave >> with content at 2.0625 Fs and harmonics. I am pretty sure this will >> alias the fundamental and the lower harmonics into the baseband. The >> fundamental will be at 0.0625 Fs, the 2nd harmonic will be at 0.125 Fs >> and so on. Once the harmonics reach 0.5 Fs the apparent frequency will >> fold back, but since their amplitudes will be low, they should not >> impact the results significantly. So you should be able to view the >> data directly treating 0.0625 Fs as the fundamental frequency of your >> triangle wave. > > Yes, but you might want to view the triangle wave signal with the correct > time-axis, such that it truly does look like the original signal > as seen on TV (er, as seen on an oscilloscope). > > Unless harmonics are aliasing on top of each other, you should > be able to filter out a pretty good version of the original signal.
Maybe I'm not clear on what you are saying. Are you suggesting that you get more information or a "better" reconstruction somehow by upsampling the signal? I believe the signal will look the same if viewed at the lower sample rate, no? It will appear to be sampled at 16x the fundamental rate, correct? Upsampling only fills in "estimated" data at the intermediate points which in no way contain additional information. Or do I misunderstand and you are agreeing with me that upsampling isn't useful? Or maybe I don't understand the value gained by upsampling. -- Rick C
rickman  <gnuarm@gmail.com> wrote:

>On 5/17/2017 10:01 PM, Steve Pope wrote:
>> rickman <gnuarm@gmail.com> wrote:
>>> If I am understanding your problem correctly, you have a triangle wave >>> with content at 2.0625 Fs and harmonics.
>> Yes, but you might want to view the triangle wave signal with the correct >> time-axis, such that it truly does look like the original signal >> as seen on TV (er, as seen on an oscilloscope).
>> Unless harmonics are aliasing on top of each other, you should >> be able to filter out a pretty good version of the original signal.
>Maybe I'm not clear on what you are saying. Are you suggesting that you >get more information or a "better" reconstruction somehow by upsampling >the signal?
More information - no. Better reconstruction - yes. Let's say the original continuous-time signal has components at 2.0625 MHz and 4.125 MHz. We sample this at 1 MHz by multiplying it by the signal delta(t - n * 1 usec) , for all integers n. The resulting continuous-time signal has components at 2.0625 MHz and 4.125 MHz plus a bunch of aliases of these. If we can filter out all these aliases, leaving just these two components, we are left with the original continuous time signal. It will, for example, have zero-crossings in the same places as the original signal. I consider this "better" for the purposes described by the OP. (I did mention upsampling but conceptually that is not necessary; it is just part of implementing the above-described filter.) Steve
On 5/18/2017 1:30 AM, Steve Pope wrote:
> rickman <gnuarm@gmail.com> wrote: > >> On 5/17/2017 10:01 PM, Steve Pope wrote: > >>> rickman <gnuarm@gmail.com> wrote: > >>>> If I am understanding your problem correctly, you have a triangle wave >>>> with content at 2.0625 Fs and harmonics. > >>> Yes, but you might want to view the triangle wave signal with the correct >>> time-axis, such that it truly does look like the original signal >>> as seen on TV (er, as seen on an oscilloscope). > >>> Unless harmonics are aliasing on top of each other, you should >>> be able to filter out a pretty good version of the original signal. > >> Maybe I'm not clear on what you are saying. Are you suggesting that you >> get more information or a "better" reconstruction somehow by upsampling >> the signal? > > More information - no. > > Better reconstruction - yes. > > Let's say the original continuous-time signal has components at 2.0625 > MHz and 4.125 MHz. > > We sample this at 1 MHz by multiplying it by the signal > > delta(t - n * 1 usec) , for all integers n. > > The resulting continuous-time signal has components at 2.0625 MHz and > 4.125 MHz plus a bunch of aliases of these. If we can filter out all > these aliases, leaving just these two components, we are left with the > original continuous time signal. It will, for example, have > zero-crossings in the same places as the original signal. I consider > this "better" for the purposes described by the OP. > > (I did mention upsampling but conceptually that is not necessary; > it is just part of implementing the above-described filter.)
Perhaps I don't understand what you mean by "a bunch of aliases of these". The 1 MHz sampled signal will have the alias of the 2.0625 MHz signal showing up at 0.0625 MHz, no where else. If the signal is repetitive over a period of 1/2.0625 MHz, then the reconstruction of the 1 MHz sampled signal will be perfect, but appear to be a 0.0625 MHz signal. Given the harmonics of that fundamental wrap to appropriate aliases, the frequency content as well as the time sampled signal is perfectly preserved. Since the signal is not perfectly repetitive over the fundamental frequency there will be perturbations, but they will not be any better reconstructed at a higher sample rate. Rather they would be distorted by the filtering in a way that makes them harder to visualize. The information has been lost by the slow sampling. Reconstruction does not require upsampling. -- Rick C
On Wed, 17 May 2017 18:28:13 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

>On Wed, 17 May 2017 14:05:04 -0700, Rob Gaddi wrote: > >> I've got a situation coming up that I'm trying to think through in >> advance. >> >> I'm running an ADC at let's say 1 Msps, sampling an input waveform that >> is known to be a triangle wave at roughly 2 1/16 MHz. So with every ADC >> sample I advance across the input waveform by about 22.5 degrees, having >> missed a bit along the way. And I acquire that data and now I'm looking >> at it offline, and I'd like to get a visualization of approximately what >> the input waveform looked like. Basically, see what I would see if I >> were willing to stick a scope probe in there. >> >> First guess is I'd probably upsample that data to 33 Msps, at which >> point it seems like some form of FIR interpolation kernel is called for. >> Any idea how to figure out what that kernel should be? It seems like >> there's some simple answer that should work if, for instance, my input >> signal is 1% slower than I expect it to be. Which clearly a 33 point >> triangle wave is not. >> >> The input signal is not guaranteed to be stationary through the >> acquisition, so I can't just throw a least squares solver at the overall >> waveform, but will at least be sufficiently slowly varying so that >> zombie Claude Shannon doesn't rise to yell at me. >> >> Anyone have thoughts? > >Oh, God. Someone's abusing Nyquist and Shannon again. > >If you knew the exact frequency (or better, phase) of the triangle wave, >then you could reconstruct it the way that the old sampling O-scopes >did: put a "dot of light" on your "screen" corresponding to a sample, at >the correct offset from x = 0. > >So calculate the period of the wave, Tp. Then plot the samples at time >(n * 1us) mod Tp. You'll build up a nice pretty triangle wave.
I like this idea, assuming it meets the requirements of whatever Rob is trying to accomplish.
>If you DON'T know the exact frequency, then phase-lock to the fundamental >(multiply by a sine wave) and use the frequency command to your NCO to >calculate Tp, and see above. > >Trying to filter after the fact in order to reconstruct won't work unless >you bandpass filter the incoming triangle wave, and that would destroy >it's triangular character. > >Or read this: <http://www.wescottdesign.com/articles/Sampling/ >sampling.pdf>, especially the section titled "Nyquist and Repetitive >Signals" starting on page 13. The nice thing to remember is that even >though a steady triangle wave has frequency components going off into >infinity, its actual occupied bandwidth is zero. A triangle wave with >some jitter has a non-zero occupied bandwidth, just to make life >interesting.
The sampling clock pretty much always has jitter, so there's that. Since Rob indicated that stationarity is not gauranteed, there's that, too. But, to Tim's point, the total occupied bandwidth may still be small.
>That section assumes you know the frequency you're dealing with -- but >you can get to that with the whole phase-lock business.
There's usually a way. The beauty in this case is that it's known to be a triangle waveform, so it should be possible to build some tracking loops that facilitate the mentioned techniques. --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
On 05/17/2017 07:01 PM, Steve Pope wrote:
> rickman <gnuarm@gmail.com> wrote: > >> If I am understanding your problem correctly, you have a triangle wave >> with content at 2.0625 Fs and harmonics. I am pretty sure this will >> alias the fundamental and the lower harmonics into the baseband. The >> fundamental will be at 0.0625 Fs, the 2nd harmonic will be at 0.125 Fs >> and so on. Once the harmonics reach 0.5 Fs the apparent frequency will >> fold back, but since their amplitudes will be low, they should not >> impact the results significantly. So you should be able to view the >> data directly treating 0.0625 Fs as the fundamental frequency of your >> triangle wave. > > Yes, but you might want to view the triangle wave signal with the correct > time-axis, such that it truly does look like the original signal > as seen on TV (er, as seen on an oscilloscope). > > Unless harmonics are aliasing on top of each other, you should > be able to filter out a pretty good version of the original signal. > > > S. >
That makes a lot of sense, and interestingly enough your technique makes very few a priori assumptions about the signal being sampled; only that each of the harmonics fits into a narrow bin. Let me see if I've got this right: The idea is that I started with a mostly periodic signal, so all my data is located in what is effectively pure spectral lines with some sideband stuff around. So my signal has had all the aliases folded on top of the baseband, but they all still have enough differentiation that you can pick them apart visually; here's the 2.0625 fundamental at 0.0625, here's the 4.125 2nd harmonic at 0.125 and so on and so forth. By zero-stuffing the signal, it spatters identical copies of that spectrum up in frequency, now my fundamental is at all of 0.0625, 0.9375, 1.0625, 1.9375, 2.0625, 2.9375, and so on until we hit the new limit of the interpolated frequency. Because I know my fundamental is at 2.0625 I can drop a 30 kHz wide bandpass filter onto the interpolated signal centered at 2.0625 and pick the fundamental back out. And another one at 4.125 to pluck the 2nd harmonic, and 6.1875 for the 3rd and so on until the 8th harmonic at 16.5. Beyond that point all my harmonics have been aliasing back on one another, 7th to 9th, etc and so my retrieval stops, but a triangle wave drops off as n^-2 so for my simple visual task they didn't exist anyhow. That high of a Q on the bandpass filter is computationally expensive, but I'm doing it offline so I don't care. The periodic nature of the bandpass means I could probably speed things up by consolidating the whole thing into an interpolated FIR but my codeslinging time is more valuable than my compute time so, again, don't care. Because all those bandpass filters can be same-length FIR linear phase they all have the same group delay, so their results can simply be summed together, shift that delay back out, and I've got my oscilloscope. This is kind of a fascinating answer. I'll give it a try when I get a chance and see how it turns out. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.