discuss-gnuradio
[Top][All Lists]
Advanced

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

How ensure consistency with timing signals


From: Lukas Haase
Subject: How ensure consistency with timing signals
Date: Wed, 26 Feb 2020 18:01:05 +0100

Hello,

I use a square wave to generate control/clocking signal for some control logic:

https://snipboard.io/WQ8p6d.jpg

The work function of the "Controller" block looks like:

    def work(self, input_items, output_items):
        d = np.diff(input_items[0])
        inds = np.where(d == 1)
        for ind in inds[0]:
            nedge = self.nitems_read(0) + ind
            delta = nedge - self.nedge_prev
            print("EDGE @ " + str(nedge) + ", Delta=" + str(delta))
            self.nedge_prev = nedge
        return len(output_items[0])

I.e., it detects the rising edge. The code above stores the previous edge and 
shows the delta between them.
If the frequency of the square wave exactly divides the sampling rate, I would 
expect that this delta is always constant/consistent (and I need this for my 
application).

However, with samp_rate=5M and freq=10:

EDGE @ 10751169, Delta=500054
EDGE @ 11251224, Delta=500055
EDGE @ 11751278, Delta=500054
EDGE @ 12251332, Delta=500054
EDGE @ 12751387, Delta=500055
EDGE @ 13251441, Delta=500054
EDGE @ 13751496, Delta=500055
EDGE @ 14251550, Delta=500054

One interval is not only not always constant but is 54/55 samples larger than 
the expected 500000.
When making the interval small (e.g., samp_rate=5M, freq=1k, it works:

EDGE @ 65072534, Delta=5000
EDGE @ 65077534, Delta=5000
EDGE @ 65082534, Delta=5000
EDGE @ 65087534, Delta=5000
EDGE @ 65092534, Delta=5000
EDGE @ 65097534, Delta=5000
EDGE @ 65102534, Delta=5000

I tried tried offsetting the frequency by a slight but but no change. E.g., 
freq = 1.0 / (1.0/10 - 1.0/samp_rate)

I know I could implement a logic that adds a constant directly in the work 
function but to keep things manageable I would really prefer to use clock 
signals (there will be a bunch of them floating around in the end).


Thanks,
Lukas






reply via email to

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