-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplutoLoopback.m
More file actions
32 lines (32 loc) · 1.23 KB
/
Copy pathplutoLoopback.m
File metadata and controls
32 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
% User tunable (samplesPerSymbol>=decimation)
samplesPerSymbol = 12; decimation = 4;
% Set up radio
tx = sdrtx('Pluto','Gain',-20);
rx = sdrrx('Pluto','SamplesPerFrame',1e6,'OutputDataType','double');
% Create binary data
data = randi([0 1],2^15,1);
% Create a QPSK modulator System object and modulate data
qpskMod = comm.QPSKModulator('BitInput',true); modData = qpskMod(data);
% Set up filters
rctFilt = comm.RaisedCosineTransmitFilter( ...
'OutputSamplesPerSymbol', samplesPerSymbol);
rcrFilt = comm.RaisedCosineReceiveFilter( ...
'InputSamplesPerSymbol', samplesPerSymbol, ...
'DecimationFactor', decimation);
% Pass data through radio
tx.transmitRepeat(rctFilt(modData)); data = rcrFilt(rx());
% Set up visualization and delay objects
VFD = dsp.VariableFractionalDelay; cd = comm.ConstellationDiagram;
% Process received data for timing offset
remainingSPS = samplesPerSymbol/decimation;
% Grab end of data where AGC has converged
data = data(end-remainingSPS*1000+1:end);
for index = 0:300
% Delay signal
tau_hat = index/50;delayedsig = VFD(data, tau_hat);
% Linear interpolation
o = sum(reshape(delayedsig,remainingSPS,...
length(delayedsig)/remainingSPS).',2)./remainingSPS;
% Visualize constellation
cd(o); pause(0.1);
end