mirror of
https://github.com/romanz/amodem.git
synced 2026-03-17 15:16:00 +08:00
add drift calculation on carrier
This commit is contained in:
5
recv.py
5
recv.py
@@ -49,7 +49,6 @@ def take(symbols, i, n):
|
||||
def receive(x, freqs):
|
||||
x = list(x)
|
||||
lp = loop.FreqLoop(x, freqs, prefix=0.0)
|
||||
lp.sampler.freq += -3e-6
|
||||
|
||||
symbols = iter(lp)
|
||||
|
||||
@@ -63,6 +62,10 @@ def receive(x, freqs):
|
||||
return None
|
||||
log.info('Prefix OK')
|
||||
|
||||
err = sigproc.drift( S[np.array(prefix, dtype=bool)] ) / (Tsym * Fc)
|
||||
log.info('Frequency error: %.2f ppm', err * 1e6)
|
||||
lp.sampler.freq -= err
|
||||
|
||||
filters = {}
|
||||
|
||||
full_scale = len(freqs)
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import sigproc
|
||||
import itertools
|
||||
import common
|
||||
import show
|
||||
import pylab
|
||||
import numpy as np
|
||||
|
||||
def test_qam():
|
||||
q = sigproc.QAM(bits_per_symbol=8, radii=[0.25, 0.5, 0.75, 1.0])
|
||||
@@ -8,3 +12,13 @@ def test_qam():
|
||||
S = q.encode(list(stream))
|
||||
decoded = list(q.decode(list(S)))
|
||||
assert decoded == bits
|
||||
|
||||
def test_drift():
|
||||
fc = 10e3
|
||||
f = fc * (1 + 50e-6)
|
||||
x = np.cos(2 * np.pi * f / common.Fs * np.arange(common.Fs))
|
||||
S = sigproc.extract_symbols(x, fc)
|
||||
S = np.array(list(S))
|
||||
print 1e6 * sigproc.drift(S) / (fc * common.Tsym)
|
||||
show.constellation(S, 'carrier')
|
||||
pylab.show()
|
||||
|
||||
Reference in New Issue
Block a user