Browse Source

changed sync_decim to compare to threshold instead of skip vs noskip

works good for strong stations (carrierSNR>=40dB)
dev
Clemens Richter 9 years ago
parent
commit
aa83f57d15
  1. 4
      apps/ifft-RDS-decoder_hier-block.grc
  2. 2
      apps/read_fmdec.grc
  3. 36
      lib/sync_decim_impl.cc

4
apps/ifft-RDS-decoder_hier-block.grc

@ -2402,7 +2402,7 @@
</param> </param>
<param> <param>
<key>log</key> <key>log</key>
<value>False</value> <value>log</value>
</param> </param>
<param> <param>
<key>maxoutbuf</key> <key>maxoutbuf</key>
@ -2414,7 +2414,7 @@
</param> </param>
<param> <param>
<key>threshold</key> <key>threshold</key>
<value>0.25</value> <value>1</value>
</param> </param>
<param> <param>
<key>min_diff</key> <key>min_diff</key>

2
apps/read_fmdec.grc

@ -1369,7 +1369,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in
</param> </param>
<param> <param>
<key>threshold</key> <key>threshold</key>
<value>0.25</value> <value>1</value>
</param> </param>
<param> <param>
<key>min_diff</key> <key>min_diff</key>

36
lib/sync_decim_impl.cc

@ -27,7 +27,7 @@
#define DECIM 2 #define DECIM 2
#define lout log && std::cout #define lout log && std::cout
//#define SYNC_COUNTER_MAX 5//higher value -> slower sync, less cpu load //#define SYNC_COUNTER_MAX 5//higher value -> slower sync, less cpu load
#define SYNC_COUNTER_MAX 7//higher value -> slower sync, less cpu load #define SYNC_COUNTER_MAX 200//higher value -> slower sync, less cpu load
//#include <pmt.h> //#include <pmt.h>
namespace gr { namespace gr {
namespace multirds { namespace multirds {
@ -97,6 +97,7 @@ namespace gr {
gr_vector_const_void_star &input_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items) gr_vector_void_star &output_items)
{ {
//if (noutput_items>8){
const float *in = (const float *) input_items[0]; const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0]; float *out = (float *) output_items[0];
if(outbit_counter>4000){ if(outbit_counter>4000){
@ -124,51 +125,67 @@ namespace gr {
} }
} }
last_input=in[(noutput_items-1)*DECIM+1];//to use for next iteration of work last_input=in[(noutput_items-1)*DECIM+1];//to use for next iteration of work
lout<<noutput_items<<std::endl; //lout<<noutput_items<<std::endl;
/*synchronize:*/ /*synchronize:*/
if(mode==COPY and dosync_counter>=SYNC_COUNTER_MAX){ if(mode==COPY and dosync_counter>=SYNC_COUNTER_MAX){
lout<<noutput_items<<std::endl;
dosync_counter=0; dosync_counter=0;
float out_noskip; float out_noskip;
float out_skip; float out_skip;
int skip_is_better_counter=0; int skip_is_better_counter=0;
if (noutput_items>8)//TODO: what if there are never more than 9 outputs requested if (noutput_items>4)//TODO: what if there are never more than 9 outputs requested
{ {
for (int i = 0; i < noutput_items; i++) { for (int i = 0; i < noutput_items; i++) {//TODO set max loop length -> cpu load
if(i==0){ if(i==0){
out_skip=last_input-in[DECIM*i];} out_skip=last_input-in[DECIM*i];}
else{ else{
out_skip=in[DECIM*i-1]-in[DECIM*i];} out_skip=in[DECIM*i-1]-in[DECIM*i];}
out_noskip=in[DECIM*i]-in[DECIM*i+1]; out_noskip=in[DECIM*i]-in[DECIM*i+1];
if (std::abs(out_skip)>std::abs(out_noskip)){
/*if (std::abs(out_skip)>std::abs(out_noskip)){
skip_is_better_counter++; skip_is_better_counter++;
} }
else{ else{
skip_is_better_counter--; skip_is_better_counter--;
}*/
if (std::abs(out_skip)>threshold){
skip_is_better_counter++;
}
if (std::abs(out_noskip) >threshold){
skip_is_better_counter--;
} }
//lout<<"state:"<< mode; //lout<<"state:"<< mode;
//lout<<"noutputs:"<<noutput_items;
//lout<<"in:"<<in[DECIM*i];
//lout<<"\t,out_noskip:"<<out_noskip; //lout<<"\t,out_noskip:"<<out_noskip;
//lout<<"\t,out_skip:"<<out_skip<<std::endl; //lout<<"\t,out_skip:"<<out_skip<<std::endl;
} }
if (skip_is_better_counter>3){//2017-05-02 lowered from 6 if (skip_is_better_counter>3){//2017-05-02 lowered from 6
mode=SKIP;
pmt::pmt_t meta(pmt::from_long(4)); pmt::pmt_t meta(pmt::from_long(4));
pmt::pmt_t data(pmt::from_long(mode)); pmt::pmt_t data(pmt::from_long(SKIP));
pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair
message_port_pub(pmt::mp("ctrl"), pdu); message_port_pub(pmt::mp("ctrl"), pdu);
mode=SKIP;
lout<<"switched to skip"<< std::endl; lout<<"switched to skip"<< std::endl;
} }
else if (skip_is_better_counter<-3){ else if (skip_is_better_counter<-3){
pmt::pmt_t meta(pmt::from_long(4)); pmt::pmt_t meta(pmt::from_long(4));
pmt::pmt_t data(pmt::from_long(mode)); pmt::pmt_t data(pmt::from_long(NOSKIP));
pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair
message_port_pub(pmt::mp("ctrl"), pdu); message_port_pub(pmt::mp("ctrl"), pdu);
mode=NOSKIP; mode=NOSKIP;
lout<<"switched to noskip"<< std::endl; lout<<"switched to noskip"<< std::endl;
} }
} }
else{//wait for longer input
dosync_counter=SYNC_COUNTER_MAX-2;
}
} }
else if(mode==COPY){ else if(mode==COPY){
dosync_counter++; dosync_counter++;
@ -177,6 +194,9 @@ namespace gr {
// Tell runtime system how many output items we produced. // Tell runtime system how many output items we produced.
outbit_counter+=noutput_items; outbit_counter+=noutput_items;
return noutput_items; return noutput_items;
/*}
else{return 0;}*/
}/*end of work*/ }/*end of work*/
} /* namespace multirds */ } /* namespace multirds */
} /* namespace gr */ } /* namespace gr */

Loading…
Cancel
Save