Files
imdd_silas/projects/MPI/MPI_August/rx_model.m
2026-03-25 10:57:48 +01:00

46 lines
1.2 KiB
Matlab

function rx_bits = rx_model(Rx,Ref,Phdiod,Lp_phdiod,Scpe,Eq,Pmap)
%%%%% Local Parameter %%%%%%%%
fsym = Ref.fs;
%%%%%% Square Law %%%%%%
Rx_sig = Phdiod.process(Rx);
%%%%%% Lowpass PhDiode %%%%%%
Rx_sig = Lp_phdiod.process(Rx_sig);
% Rx_sig.spectrum("displayname","Received Signal after PhD","fignum",201);
%%%%%% Scope %%%%%%
Scpe_sig = Scpe.process(Rx_sig);
Scpe_sig.plot("displayname","SIgnal after Scope","fignum",1999);
% Scpe_sig.spectrum("displayname",'after scope','fignum',123);
%%%%%% Sample to 2x fsym %%%%%%
Scpe_sig = Scpe_sig.resample("fs_in",Scpe.fadc,"fs_out",2*fsym);
% Scpe_sig.plot('fignum',12345,'displayname','bla')
%%%%%% Sync Rx signal with reference %%%%%%
[Scpe_sig,D,cuts] = Scpe_sig.tsynch("reference",Ref,"fs_ref",fsym);
%%%%% EQUALIZE %%%%%%
[EQ_sig] = Eq.process(Scpe_sig,Ref);
% EQ_sig.normalize("mode","rms").plot('fignum',23,'displayname','before eq')
%%%%% DEMAP %%%%%%
rx_bits = Pmap.demap(EQ_sig);
%%%% Look at Pam levels %%%%%
if 1
a = Pmap.separate_pamlevels(EQ_sig);
figure(14);hold on;scatter(1:EQ_sig.length,a,1,'.');
end
end