%Compare 2 vectors, fail if they are not close enough
-function pass = vcompare(va,vb,vname,tname,tol)
+function pass = vcompare(vc,voct,vname,tname,tol)
%Get delta of vectors
- dvec = abs(abs(va)-abs(vb));
+ dvec = abs(abs(vc)-abs(voct));
%Normalize difference
- dvec = dvec ./ abs(max(abs(va)));
+ dvec = dvec ./ abs(max(abs(voct)));
maxdvec = abs(max(dvec));
pass = maxdvec<tol;
o_rx_timing = [o_rx_timing states.rx_timing];
end
-
+ % One part-per-thousand allowed on important parameters
pass = vcompare(o_f1_dc, t_f1_dc, 'f1_dc', tname,.001);
pass = pass && vcompare(o_f2_dc, t_f2_dc, 'f2_dc', tname,.001);
- % Note fx_int tolerances higher because FP error is accumulated here
- pass = pass && vcompare(o_f1_int, t_f1_int, 'f1_int', tname,.02);
- pass = pass && vcompare(o_f2_int, t_f2_int, 'f2_int', tname,.02);
- pass = pass && vcompare(o_rx_timing, t_rx_timing,'rx_timing',tname,.011);
- pass = pass && vcompare(o_EbNodB, t_EbNodB, 'EbNodB', tname,.15);
- pass = pass && vcompare(o_ppm , t_ppm, 'ppm', tname,.011);
+ pass = pass && vcompare(o_f1_int, t_f1_int, 'f1_int', tname,.001);
+ pass = pass && vcompare(o_f2_int, t_f2_int, 'f2_int', tname,.001);
+ pass = pass && vcompare(o_rx_timing, t_rx_timing,'rx_timing',tname,.001);
+
+ % Much larger tolerances on unimportant statistics
+ pass = pass && vcompare(o_EbNodB, t_EbNodB, 'EbNodB', tname,.05);
+ pass = pass && vcompare(o_ppm , t_ppm, 'ppm', tname,.02);
+
diffpass = sum(xor(obits,bits'))<4;
diffbits = sum(xor(obits,bits'));
function pass = ebno_battery_test(timing_offset,fading,df,dA)
%Range of EbNodB over which to test
- ebnodbrange = fliplr(5:13);
+ ebnodbrange = (5:13);
ebnodbs = length(ebnodbrange);
mode = 5;
fsk->EbNodB = 0;
fsk->f1_est = 0;
fsk->f2_est = 0;
+ fsk->twist_est = 0;
+ fsk->ppm = 0;
return fsk;
}
/* Estimate tone frequencies */
fsk_demod_freq_est(fsk,fsk_in,&f1,&f2,&twist);
- fsk->f1_est = f1;
- fsk->f2_est = f2;
- fsk->twist_est = twist;
-
/* allocate memory for the integrated samples */
/* Note: This must be kept after fsk_demod_freq_est for memory usage reasons */
f1_int = (COMP*) alloca(sizeof(COMP)*(nsym+1)*P);
/* Allocate circular buffers for integration */
f1_intbuf = (COMP*) alloca(sizeof(COMP)*Ts);
f2_intbuf = (COMP*) alloca(sizeof(COMP)*Ts);
+
+ /* If this is the first run and we haven't already estimated freq, save the new est */
+ if(fsk->f1_est<1 || fsk->f2_est<1){
+ fsk->f1_est = f1;
+ fsk->f2_est = f2;
+ fsk->twist_est = twist;
+ }
/* Figure out how much to nudge each sample downmixer for every sample */
- dphi1 = comp_exp_j(-2*M_PI*((float)(f1)/(float)(Fs)));
- dphi2 = comp_exp_j(-2*M_PI*((float)(f2)/(float)(Fs)));
+ /* Use old freq. estimate here so that old samples will be converted at old
+ * frequency, to match behaviour of fsk_horus */
+ dphi1 = comp_exp_j(-2*M_PI*((float)(fsk->f1_est)/(float)(Fs)));
+ dphi2 = comp_exp_j(-2*M_PI*((float)(fsk->f2_est)/(float)(Fs)));
dc_i = 0;
cbuf_i = 0;
sample_src = &fsk_in[0];
dc_i = 0;
using_old_samps = 0;
+
+ /* Recalculate delta-phi after switching to new sample source */
+ phi1_c = comp_normalize(phi1_c);
+ phi2_c = comp_normalize(phi2_c);
+ dphi1 = comp_exp_j(-2*M_PI*((float)(f1)/(float)(Fs)));
+ dphi2 = comp_exp_j(-2*M_PI*((float)(f2)/(float)(Fs)));
}
/* Downconvert and place into integration buffer */
f1_intbuf[dc_i]=fcmult(sample_src[dc_i],phi1_c);
sample_src = &fsk_in[0];
dc_i = 0;
using_old_samps = 0;
+
+ /* Recalculate delta-phi after switching to new sample source */
+ phi1_c = comp_normalize(phi1_c);
+ phi2_c = comp_normalize(phi2_c);
+ dphi1 = comp_exp_j(-2*M_PI*((float)(f1)/(float)(Fs)));
+ dphi2 = comp_exp_j(-2*M_PI*((float)(f2)/(float)(Fs)));
}
/* Downconvert and place into integration buffer */
f1_intbuf[cbuf_i+j]=fcmult(sample_src[dc_i],phi1_c);
}
- fsk->phi1_c = comp_normalize(phi1_c);
- fsk->phi2_c = comp_normalize(phi2_c);
+ fsk->phi1_c = phi1_c;
+ fsk->phi2_c = phi2_c;
+
+ fsk->f1_est = f1;
+ fsk->f2_est = f2;
+ fsk->twist_est = twist;
/* Stash samples away in the old sample buffer for the next round of bit getting */
memcpy((void*)&(fsk->samp_old[0]),(void*)&(fsk_in[nin-nstash]),sizeof(float)*nstash);