Search code examples
audiosignal-processinggnuradiognuradio-companion

gnuradio phase drift of AM demodulation


I am beginning a project using GNUradio and an inexpensive SDR.

http://www.amazon.com/gp/product/B00SXZDUAQ?psc=1&redirect=true&ref_=oh_aui_search_detailpage

One portion of the project requires me to generate a reference audio tone and compare the phase of that tone to demodulated audio.

To simulate this portion of the system, I have generated a simple GNUradio flowchart:

gnuradio flowgraph

I had some issues with the source and demodulated audio in that they would drift relative to each other. This occurred on the scope sync on the original flowgraph. To aid in troubleshooting I sent the demodulated audio out thru the soundcard’s second channel and monitored both audio streams in addition to the modulated RF on an external oscilloscope:

scope photo #1

Initially all seems well but, the demodulated audio drifts in relation to the original source and RF:

scope photo #2

My question is: am I doing something wrong in the flowgraph or am I expecting too much performance out of an inexpensive SDR?

Thanks in advance for any insights


Solution

  • You cannot expect to see zero phase drift in anything short of a fully digital simulation, or a fully analog circuit with exactly one oscillator, because no two (physical) oscillators have identical frequencies.

    In your case, there are two relevant oscillators involved:

    1. The sample clock in the RTL-SDR unit.
    2. The sample clock in your sound card output.

    Within an GNU Radio flowgraph, there is no time reference per se and everything depends on the sources and sinks which are connected to hardware.

    The relevant source in your flowgraph is the RTL-SDR hardware; insofar as its oscillator is different from its nominal value (28.8 MHz, as it happens), everything it produces will be off-frequency in an absolute sense (both RF carrier frequencies and audio frequencies of demodulated output).

    But you don't actually have an absolute frequency reference; you have the tone produced by your sound card. The sound card has its own oscillator, which determines the rate at which samples are converted to analog signals, and therefore the rate at which samples are consumed from the flowgraph.

    Therefore, your reference signal will drift relative to your received and demodulated signal, at a rate determined by the difference in frequency error between the two oscillators.

    Additionally, since your sound card will be accepting samples from the flowgraph at a slightly different real-time rate than the RTL-SDR is producing them, you will notice periodic glitches in the audio as the error accumulates and must be dealt with; they will start occurring either immediately (if the source is slower than the sink, requiring the sound card to play silence instead) or after a delay for buffers to hit their maximum size (if the source is faster than the sink, requiring the RTL-SDR to drop some samples).