discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird behaviour of the analog signal source (was: Re: How ensure con


From: Lukas Haase
Subject: Re: Weird behaviour of the analog signal source (was: Re: How ensure consistency with timing signals)
Date: Tue, 3 Mar 2020 16:52:01 +0100

Hi Sylvain,

Thank you very much for your answer. Much appreciated!

> Von: "Sylvain Munaut" <address@hidden>
>
> Hi,
>
> > How can (or better: *should*) a fully digital signal source have phase 
> > noise?
>
> Limited precision arithmetic
>
>
> > Also, for 1Hz at 5MSps I always get either 5005789 or 5005790 samples 
> > (instead of 5000000) ... this is fairly deterministic.
>
> That's because the signal source works with phase increments per step.
> So it computes how much the phase changes per sample. The precision
> limit of that numbers will then create precision errors.
>
> > Example 1: I pipe the output of the signal source into a file:
> >
> > https://snipboard.io/xY1JvE.jpg
> >
> > Now, I would not care too much about a constant phase shift or similar, but 
> > it can be seen that the frequency slowly drifts (this is also seen if I 
> > just plot them on top of each other).
>
> Frequency doesn't drift.
> Frequency is stable but is not exactly 1 Hz which means the phase slowly 
> drifts.

Ok, that explains a lot: We are facing constant a frequency offset. I can 
reproduce the FFT shapes from gr exported data in MATLAB fairly accurately by 
creating for example:

  f = 1;
  fs = 5e6;
  data_gr = read_float_binary('baszmeg1.dat');
  t = 0:1/fs:(length(data)-1)/fs;
  data_ideal = sin(2*pi*t*f)';
  data_nonideal = sin(2*pi*t*1.0012*f)';

data_gr and data_nonideal matches well.

I am by no means an expert on this but just for my understanding I would be 
curious:

1.) I still do not understand why for 1 Hz at 5MSps I can get a period that's 
"500578.5" on average. The frequency error is a whopping 0.1158%! 
((5005789.5-5000000)/5000000*100). Huge.

2.) Why is it implemented that way? Why does Simulink, ADS, Cadence Spectre 
et.al. provide correct and accurate results?

3.) What would you do if you would want to create precise timing signals? Is a 
custom block really the only way? And then, how would you implement it?

> > Example 2: I extend the block diagram with blocks that should never alter 
> > the behaviour as they are only reading samples:
> > [...]
> > However, now the saved data is distorted:
> >
> > https://snipboard.io/amyn3X.jpg
>
> Yeah, that's weird, not sure where that would come from.
> I looked at the code and can't see anything wrong with it, but then
> again I might not be looking at the code from the version you're
> running.

Two additional weird observations (block diagram 
https://snipboard.io/W6kyF0.jpg):

1.) If I remove the second signal source, Complex to Float and Controller I 
still see these spikes appearing in the "QT GUI Time Sink". However, they do 
not show up in the file exported by "File Sink". This is contradicting because 
they clearly process the same signal.

2.) If I put all these blocks back in again, I see the weird distorted waveform 
ALSO in the exported file (not only in the QT GUI Time Sink). It is interesting 
that it requires "Controller", the second signal source to be enabled as well 
as QT GUI Time Sink displaying all signals at the same time. If any of these 
conditions are not met, the signal is distorted only in the QT Time Sink but 
not in the exported file.

I know that it is impossible to give a solution to this remotely but this is so 
weird that don't even know where to start looking.

If it were you, how would you approach debugging this?

Thanks,
Lukas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]