Changed clock offset controller and company in order to remove from the gsm_input one of the resamplers.
This commit is contained in:
parent
a94adb1864
commit
83afe7390f
|
@ -4,29 +4,37 @@
|
|||
<import>import grgsm</import>
|
||||
<make>grgsm.clock_offset_corrector_tagged(
|
||||
fc=$fc,
|
||||
ppm=$ppm,
|
||||
samp_rate_in=$samp_rate_in,
|
||||
ppm=$ppm,
|
||||
osr=$osr
|
||||
)</make>
|
||||
<callback>set_fc($fc)</callback>
|
||||
<callback>set_ppm($ppm)</callback>
|
||||
<callback>set_samp_rate_in($samp_rate_in)</callback>
|
||||
<callback>set_osr($osr)</callback>
|
||||
<param>
|
||||
<name>fc</name>
|
||||
<key>fc</key>
|
||||
<value>fc</value>
|
||||
<type>float</type>
|
||||
<value>936.6e6</value>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>ppm</name>
|
||||
<key>ppm</key>
|
||||
<value>ppm</value>
|
||||
<type>float</type>
|
||||
<value>0</value>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>samp_rate_in</name>
|
||||
<key>samp_rate_in</key>
|
||||
<value>samp_rate_in</value>
|
||||
<type>float</type>
|
||||
<value>1625000.0/6.0*4.0</value>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>OSR</name>
|
||||
<key>osr</key>
|
||||
<value>osr</value>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
<sink>
|
||||
<name>ctrl</name>
|
||||
|
@ -45,6 +53,5 @@
|
|||
</source>
|
||||
<doc>Piotr Krysik
|
||||
Clock offset corrector with blocks that use tags to switch offsets
|
||||
</doc>
|
||||
<grc_source>gr-gsm/hier_blocks/misc_utils/gsm_clock_offset_corrector_tagged.grc</grc_source>
|
||||
</doc>
|
||||
</block>
|
||||
|
|
|
@ -3,33 +3,18 @@
|
|||
<name>Controlled Rotator</name>
|
||||
<key>gsm_controlled_rotator_cc</key>
|
||||
<import>import grgsm</import>
|
||||
<make>grgsm.controlled_rotator_cc($phase_inc,$samp_rate)</make>
|
||||
<make>grgsm.controlled_rotator_cc($phase_inc)</make>
|
||||
<callback>set_phase_inc($phase_inc)</callback>
|
||||
<callback>set_samp_rate($samp_rate)</callback>
|
||||
<param>
|
||||
<name>phase_inc</name>
|
||||
<key>phase_inc</key>
|
||||
<value>0</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>samp_rate</name>
|
||||
<key>samp_rate</key>
|
||||
<value>samp_rate</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>complex</type>
|
||||
</sink>
|
||||
<sink>
|
||||
<name>phase_inc</name>
|
||||
<type>float</type>
|
||||
<optional>1</optional>
|
||||
</sink>
|
||||
|
||||
<source>
|
||||
<name>out</name>
|
||||
<type>complex</type>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<name>GSM Clock Offset Control</name>
|
||||
<key>gsm_clock_offset_control</key>
|
||||
<import>import grgsm</import>
|
||||
<make>grgsm.clock_offset_control($fc, $samp_rate)</make>
|
||||
<make>grgsm.clock_offset_control($fc, $samp_rate, $osr)</make>
|
||||
<callback></callback>
|
||||
<param>
|
||||
<name>fc</name>
|
||||
|
@ -11,6 +11,12 @@
|
|||
<value>fc</value>
|
||||
<type>float</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>OSR</name>
|
||||
<key>osr</key>
|
||||
<value>osr</value>
|
||||
<type>int</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>samp_rate</name>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>title</key>
|
||||
<value>Clock offset corrector tagged</value>
|
||||
<value>Clock Offset Corrector Tagged</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
|
@ -93,7 +93,34 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(736, 19)</value>
|
||||
<value>(688, 21)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>gsm_symb_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>1625000.0/6.0</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>variable</key>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(808, 21)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -105,7 +132,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>samp_rate_in</value>
|
||||
<value>osr*gsm_symb_rate</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
|
@ -214,7 +241,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(328, 197)</value>
|
||||
<value>(344, 197)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -238,7 +265,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>resamp_ratio</key>
|
||||
<value>1.0</value>
|
||||
<value>samp_rate_in/samp_rate_out</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
|
@ -261,7 +288,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(608, 209)</value>
|
||||
<value>(600, 204)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -281,11 +308,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>phase_inc</key>
|
||||
<value>ppm/1.0e6*2*math.pi*fc/samp_rate_in</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>samp_rate</key>
|
||||
<value>samp_rate_out</value>
|
||||
<value>ppm/1.0e6*2*math.pi*fc/samp_rate_out</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
|
@ -358,6 +381,49 @@
|
|||
<value>import math</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>parameter</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(584, 23)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>osr</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>label</key>
|
||||
<value>OSR</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>short_id</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>intx</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>4</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>pad_sink</key>
|
||||
<param>
|
||||
|
@ -370,7 +436,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(784, 220)</value>
|
||||
<value>(776, 204)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -530,49 +596,6 @@
|
|||
<value>1625000.0/6.0*4.0</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>parameter</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>False</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(592, 20)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>samp_rate_out</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>label</key>
|
||||
<value>samp_rate_out</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>short_id</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>eng_float</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>1625000.0/6.0*4.0</value>
|
||||
</param>
|
||||
</block>
|
||||
<connection>
|
||||
<source_block_id>ctrl</source_block_id>
|
||||
<sink_block_id>gsm_msg_to_tag_0</sink_block_id>
|
||||
|
|
|
@ -81,6 +81,33 @@
|
|||
<value>GSM input adaptor</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>variable</key>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(752, 21)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>gsm_symb_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>1625000.0/6.0</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>variable</key>
|
||||
<param>
|
||||
|
@ -105,7 +132,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>1625000.0/6.0*osr</value>
|
||||
<value>gsm_symb_rate*osr</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
|
@ -210,11 +237,11 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(488, 217)</value>
|
||||
<value>(488, 281)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -265,7 +292,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(224, 198)</value>
|
||||
<value>(232, 199)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -283,6 +310,10 @@
|
|||
<key>minoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>osr</key>
|
||||
<value>osr</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>fc</key>
|
||||
<value>fc</value>
|
||||
|
@ -332,7 +363,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(712, 186)</value>
|
||||
<value>(712, 178)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -426,7 +457,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(904, 228)</value>
|
||||
<value>(904, 220)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
|
@ -604,6 +635,12 @@
|
|||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
<connection>
|
||||
<source_block_id>gsm_clock_offset_corrector_tagged_0</source_block_id>
|
||||
<sink_block_id>low_pass_filter_0_0</sink_block_id>
|
||||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
<connection>
|
||||
<source_block_id>low_pass_filter_0_0</source_block_id>
|
||||
<sink_block_id>pad_sink_0</sink_block_id>
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace gr {
|
|||
* class. gsm::controlled_rotator_cc::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make(double phase_inc, double samp_rate);
|
||||
static sptr make(double phase_inc);
|
||||
|
||||
virtual void set_phase_inc(double phase_inc) = 0;
|
||||
virtual void set_samp_rate(double samp_rate) = 0;
|
||||
// virtual void set_samp_rate(double samp_rate) = 0;
|
||||
};
|
||||
|
||||
} // namespace gsm
|
||||
|
|
|
@ -49,9 +49,10 @@ namespace gr {
|
|||
* class. gsm::clock_offset_control::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make(float fc, float samp_rate);
|
||||
static sptr make(float fc, float samp_rate, unsigned int osr);
|
||||
virtual void set_fc(float fc) = 0;
|
||||
virtual void set_samp_rate(float samp_rate) = 0;
|
||||
virtual void set_samp_rate(float samp_rate) = 0;
|
||||
virtual void set_osr(unsigned int osr) = 0;
|
||||
};
|
||||
|
||||
} // namespace gsm
|
||||
|
|
|
@ -32,22 +32,21 @@ namespace gr {
|
|||
namespace gsm {
|
||||
|
||||
controlled_rotator_cc::sptr
|
||||
controlled_rotator_cc::make(double phase_inc, double samp_rate)
|
||||
controlled_rotator_cc::make(double phase_inc)
|
||||
{
|
||||
return gnuradio::get_initial_sptr
|
||||
(new controlled_rotator_cc_impl(phase_inc, samp_rate));
|
||||
(new controlled_rotator_cc_impl(phase_inc));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
controlled_rotator_cc_impl::controlled_rotator_cc_impl(double phase_inc, double samp_rate)
|
||||
controlled_rotator_cc_impl::controlled_rotator_cc_impl(double phase_inc)
|
||||
: gr::sync_block("controlled_rotator_cc",
|
||||
gr::io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float)),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)))
|
||||
{
|
||||
set_phase_inc(phase_inc);
|
||||
set_samp_rate(samp_rate);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -64,11 +63,11 @@ namespace gr {
|
|||
d_r.set_phase_incr( exp(gr_complex(0, (double)phase_inc)) );
|
||||
}
|
||||
|
||||
void
|
||||
controlled_rotator_cc_impl::set_samp_rate(double samp_rate)
|
||||
{
|
||||
d_samp_rate = samp_rate;
|
||||
}
|
||||
// void
|
||||
// controlled_rotator_cc_impl::set_samp_rate(double samp_rate)
|
||||
// {
|
||||
// d_samp_rate = samp_rate;
|
||||
// }
|
||||
|
||||
int
|
||||
controlled_rotator_cc_impl::work(int noutput_items,
|
||||
|
@ -76,7 +75,7 @@ namespace gr {
|
|||
gr_vector_void_star &output_items)
|
||||
{
|
||||
//process phase_inc input
|
||||
if(input_items.size() == 2) {
|
||||
/*if(input_items.size() == 2) {
|
||||
int ii=0;
|
||||
const float *pp = (const float *)input_items[1];
|
||||
|
||||
|
@ -99,7 +98,8 @@ namespace gr {
|
|||
ii++;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//get complex input and output
|
||||
const gr_complex *in = (const gr_complex *)input_items[0];
|
||||
gr_complex *out = (gr_complex *)output_items[0];
|
||||
|
@ -121,11 +121,11 @@ namespace gr {
|
|||
processed_in = processed_in + samples_to_process;
|
||||
produced_out = produced_out + samples_to_process;
|
||||
// std::cout << "Rotator, phase inc: " << pmt::to_double(i_tag->value) << std::endl;
|
||||
|
||||
float freq_offset_setting = (pmt::to_double(i_tag->value) / (2*M_PI)) * d_samp_rate; //send stream tag with a new value of the frequency offset
|
||||
pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
|
||||
pmt::pmt_t value = pmt::from_double(freq_offset_setting);
|
||||
add_item_tag(0,i_tag->offset, key, value);
|
||||
//
|
||||
// float freq_offset_setting = (pmt::to_double(i_tag->value) / (2*M_PI)) * d_samp_rate; //send stream tag with a new value of the frequency offset
|
||||
// pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
|
||||
// pmt::pmt_t value = pmt::from_double(freq_offset_setting);
|
||||
// add_item_tag(0,i_tag->offset, key, value);
|
||||
}
|
||||
|
||||
d_r.rotateN((out+produced_out), const_cast<gr_complex *>(in+processed_in), (noutput_items-produced_out)); //const_cast<gr_complex *> is workaround old implementation of rotateN that is still present in ubuntu 14.04 packages
|
||||
|
|
|
@ -33,15 +33,15 @@ namespace gr {
|
|||
{
|
||||
private:
|
||||
gr_complex d_phase_inc;
|
||||
double d_samp_rate;
|
||||
// double d_samp_rate;
|
||||
blocks::rotator d_r;
|
||||
|
||||
public:
|
||||
controlled_rotator_cc_impl(double phase_inc, double samp_rate);
|
||||
controlled_rotator_cc_impl(double phase_inc);
|
||||
~controlled_rotator_cc_impl();
|
||||
|
||||
virtual void set_phase_inc(double phase_inc);
|
||||
virtual void set_samp_rate(double samp_rate);
|
||||
// virtual void set_samp_rate(double samp_rate);
|
||||
|
||||
// Where all the action really happens
|
||||
int work(int noutput_items,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endif
|
||||
|
||||
#include <sch.h>
|
||||
#include <gsm_constants.h>
|
||||
#include "clock_offset_control_impl.h"
|
||||
|
||||
namespace gr
|
||||
|
@ -33,17 +34,17 @@ namespace gr
|
|||
namespace gsm
|
||||
{
|
||||
clock_offset_control::sptr
|
||||
clock_offset_control::make(float fc, float samp_rate)
|
||||
clock_offset_control::make(float fc, float samp_rate, unsigned int osr)
|
||||
{
|
||||
return gnuradio::get_initial_sptr
|
||||
(new clock_offset_control_impl(fc, samp_rate));
|
||||
(new clock_offset_control_impl(fc, samp_rate, osr));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
clock_offset_control_impl::clock_offset_control_impl(float fc, float samp_rate)
|
||||
clock_offset_control_impl::clock_offset_control_impl(float fc, float samp_rate, unsigned int osr)
|
||||
: gr::block("clock_offset_control",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(0, 0, 0))
|
||||
|
@ -55,6 +56,7 @@ clock_offset_control_impl::clock_offset_control_impl(float fc, float samp_rate)
|
|||
|
||||
set_fc(fc);
|
||||
set_samp_rate(samp_rate);
|
||||
set_osr(osr);
|
||||
d_alfa = 0.3;
|
||||
d_ppm_estimate = -1e6;
|
||||
d_last_ppm_estimate = -1e6;
|
||||
|
@ -73,6 +75,11 @@ clock_offset_control_impl::~clock_offset_control_impl()
|
|||
{
|
||||
}
|
||||
|
||||
void clock_offset_control_impl::set_osr(unsigned int osr)
|
||||
{
|
||||
d_osr = osr;
|
||||
}
|
||||
|
||||
void clock_offset_control_impl::set_fc(float fc)
|
||||
{
|
||||
d_fc = fc;
|
||||
|
@ -114,7 +121,7 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
|
|||
|
||||
if(state == "fcch_search")
|
||||
{
|
||||
send_ctrl_messages(ppm);
|
||||
send_ctrl_messages(freq_offset);
|
||||
d_last_fcch_time = d_current_time;
|
||||
}
|
||||
else
|
||||
|
@ -138,7 +145,7 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
|
|||
{
|
||||
// pmt::pmt_t msg_ppm = pmt::from_double(ppm);
|
||||
// message_port_pub(pmt::intern("ppm"), msg_ppm);
|
||||
send_ctrl_messages(ppm);
|
||||
send_ctrl_messages(freq_offset);
|
||||
d_last_ppm_estimate = d_ppm_estimate;
|
||||
}
|
||||
}
|
||||
|
@ -160,17 +167,15 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
|
|||
}
|
||||
}
|
||||
|
||||
void clock_offset_control_impl::send_ctrl_messages(float ppm)
|
||||
void clock_offset_control_impl::send_ctrl_messages(float freq_offset)
|
||||
{
|
||||
// pmt::pmt_t msg_ppm = pmt::from_double(ppm);
|
||||
// message_port_pub(pmt::intern("ctrl"), msg_ppm);
|
||||
// d_last_fcch_time = d_current_time;
|
||||
double samp_rate_ratio = d_samp_rate / (d_osr * GSM_SYMBOL_RATE);
|
||||
|
||||
pmt::pmt_t msg_set_phase_inc = pmt::cons(pmt::intern("set_phase_inc"), pmt::from_double(2*M_PI*d_fc/d_samp_rate*ppm/1.0e6));
|
||||
message_port_pub(pmt::intern("ctrl"), msg_set_phase_inc);
|
||||
|
||||
pmt::pmt_t msg_set_resamp_ratio = pmt::cons(pmt::intern("set_resamp_ratio"), pmt::from_double(1+ppm/1.0e6));
|
||||
message_port_pub(pmt::intern("ctrl"), msg_set_resamp_ratio);
|
||||
pmt::pmt_t messages = pmt::make_dict();
|
||||
messages = dict_add(messages, pmt::string_to_symbol("set_phase_inc"), pmt::from_double(-2*M_PI*freq_offset/(d_osr * GSM_SYMBOL_RATE)));
|
||||
messages = dict_add(messages, pmt::string_to_symbol("set_resamp_ratio"), pmt::from_double((1-(freq_offset/d_fc))*samp_rate_ratio));
|
||||
messages = dict_add(messages, pmt::string_to_symbol("setting_freq_offset"), pmt::from_double(-freq_offset));
|
||||
message_port_pub(pmt::intern("ctrl"), messages);
|
||||
}
|
||||
|
||||
void clock_offset_control_impl::timed_reset()
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace gr {
|
|||
private:
|
||||
float d_fc;
|
||||
float d_samp_rate;
|
||||
unsigned int d_osr;
|
||||
float d_alfa;
|
||||
float d_ppm_estimate;
|
||||
float d_last_ppm_estimate;
|
||||
|
@ -44,15 +45,16 @@ namespace gr {
|
|||
bool d_first_time;
|
||||
|
||||
void process_measurement(pmt::pmt_t msg);
|
||||
void send_ctrl_messages(float ppm);
|
||||
void send_ctrl_messages(float freq_offset);
|
||||
void timed_reset();
|
||||
void reset();
|
||||
public:
|
||||
clock_offset_control_impl(float fc, float samp_rate);
|
||||
clock_offset_control_impl(float fc, float samp_rate, unsigned int osr);
|
||||
~clock_offset_control_impl();
|
||||
|
||||
virtual void set_fc(float fc);
|
||||
virtual void set_samp_rate(float samp_rate);
|
||||
virtual void set_osr(unsigned int osr);
|
||||
};
|
||||
} // namespace gsm
|
||||
} // namespace gr
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##################################################
|
||||
# GNU Radio Python Flow Graph
|
||||
# Title: Clock offset corrector tagged
|
||||
# Title: Clock Offset Corrector Tagged
|
||||
# Author: Piotr Krysik
|
||||
# Description: Clock offset corrector with blocks that use tags to switch offsets
|
||||
# Generated: Sun Jul 17 11:30:51 2016
|
||||
# Generated: Sun Jul 17 22:03:13 2016
|
||||
##################################################
|
||||
|
||||
from gnuradio import gr
|
||||
|
@ -15,9 +15,9 @@ import math
|
|||
|
||||
class clock_offset_corrector_tagged(grgsm.hier_block):
|
||||
|
||||
def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0):
|
||||
def __init__(self, fc=936.6e6, osr=4, ppm=0, samp_rate_in=1625000.0/6.0*4.0):
|
||||
gr.hier_block2.__init__(
|
||||
self, "Clock offset corrector tagged",
|
||||
self, "Clock Offset Corrector Tagged",
|
||||
gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
|
||||
gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
|
||||
)
|
||||
|
@ -27,20 +27,22 @@ class clock_offset_corrector_tagged(grgsm.hier_block):
|
|||
# Parameters
|
||||
##################################################
|
||||
self.fc = fc
|
||||
self.osr = osr
|
||||
self.ppm = ppm
|
||||
self.samp_rate_in = samp_rate_in
|
||||
|
||||
##################################################
|
||||
# Variables
|
||||
##################################################
|
||||
self.samp_rate_out = samp_rate_out = samp_rate_in
|
||||
self.gsm_symb_rate = gsm_symb_rate = 1625000.0/6.0
|
||||
self.samp_rate_out = samp_rate_out = osr*gsm_symb_rate
|
||||
|
||||
##################################################
|
||||
# Blocks
|
||||
##################################################
|
||||
self.gsm_msg_to_tag_0 = grgsm.msg_to_tag()
|
||||
self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(ppm/1.0e6*2*math.pi*fc/samp_rate_in,samp_rate_out)
|
||||
self.gsm_controlled_fractional_resampler_cc_0 = grgsm.controlled_fractional_resampler_cc(0, 1.0)
|
||||
self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(ppm/1.0e6*2*math.pi*fc/samp_rate_out)
|
||||
self.gsm_controlled_fractional_resampler_cc_0 = grgsm.controlled_fractional_resampler_cc(0, samp_rate_in/samp_rate_out)
|
||||
|
||||
##################################################
|
||||
# Connections
|
||||
|
@ -56,26 +58,40 @@ class clock_offset_corrector_tagged(grgsm.hier_block):
|
|||
|
||||
def set_fc(self, fc):
|
||||
self.fc = fc
|
||||
self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_in)
|
||||
self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_out)
|
||||
|
||||
def get_osr(self):
|
||||
return self.osr
|
||||
|
||||
def set_osr(self, osr):
|
||||
self.osr = osr
|
||||
self.set_samp_rate_out(self.osr*self.gsm_symb_rate)
|
||||
|
||||
def get_ppm(self):
|
||||
return self.ppm
|
||||
|
||||
def set_ppm(self, ppm):
|
||||
self.ppm = ppm
|
||||
self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_in)
|
||||
self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_out)
|
||||
|
||||
def get_samp_rate_in(self):
|
||||
return self.samp_rate_in
|
||||
|
||||
def set_samp_rate_in(self, samp_rate_in):
|
||||
self.samp_rate_in = samp_rate_in
|
||||
self.set_samp_rate_out(self.samp_rate_in)
|
||||
self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_in)
|
||||
self.gsm_controlled_fractional_resampler_cc_0.set_resamp_ratio(self.samp_rate_in/self.samp_rate_out)
|
||||
|
||||
def get_gsm_symb_rate(self):
|
||||
return self.gsm_symb_rate
|
||||
|
||||
def set_gsm_symb_rate(self, gsm_symb_rate):
|
||||
self.gsm_symb_rate = gsm_symb_rate
|
||||
self.set_samp_rate_out(self.osr*self.gsm_symb_rate)
|
||||
|
||||
def get_samp_rate_out(self):
|
||||
return self.samp_rate_out
|
||||
|
||||
def set_samp_rate_out(self, samp_rate_out):
|
||||
self.samp_rate_out = samp_rate_out
|
||||
self.gsm_controlled_rotator_cc_0.set_samp_rate(self.samp_rate_out)
|
||||
self.gsm_controlled_fractional_resampler_cc_0.set_resamp_ratio(self.samp_rate_in/self.samp_rate_out)
|
||||
self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_out)
|
||||
|
|
|
@ -1,66 +1,65 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
##################################################
|
||||
# Gnuradio Python Flow Graph
|
||||
# GNU Radio Python Flow Graph
|
||||
# Title: GSM input adaptor
|
||||
# Author: Piotr Krysik
|
||||
# Description: Adaptor of input stream for the GSM receiver. Contains frequency ofset corrector doing also resampling to integer multiplies of GSM sample rate and LP filter filtering GSM channel.
|
||||
# Generated: Wed Nov 19 08:23:52 2014
|
||||
# Generated: Sun Jul 17 17:36:46 2016
|
||||
##################################################
|
||||
|
||||
from gnuradio import filter
|
||||
from gnuradio import gr
|
||||
from gnuradio.filter import firdes
|
||||
from distutils.version import LooseVersion as version
|
||||
import grgsm
|
||||
|
||||
|
||||
class gsm_input(grgsm.hier_block):
|
||||
|
||||
def __init__(self, ppm=0, osr=4, fc=940e6, samp_rate_in=1e6):
|
||||
grgsm.hier_block.__init__(
|
||||
def __init__(self, fc=940e6, osr=4, ppm=0, samp_rate_in=1e6):
|
||||
gr.hier_block2.__init__(
|
||||
self, "GSM input adaptor",
|
||||
gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
|
||||
gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
|
||||
)
|
||||
self.message_port_register_hier_in("ctrl_in")
|
||||
|
||||
##################################################
|
||||
# Parameters
|
||||
##################################################
|
||||
self.ppm = ppm
|
||||
self.osr = osr
|
||||
self.fc = fc
|
||||
self.osr = osr
|
||||
self.ppm = ppm
|
||||
self.samp_rate_in = samp_rate_in
|
||||
|
||||
##################################################
|
||||
# Variables
|
||||
##################################################
|
||||
self.samp_rate_out = samp_rate_out = 1625000.0/6.0*osr
|
||||
self.gsm_symb_rate = gsm_symb_rate = 1625000.0/6.0
|
||||
self.samp_rate_out = samp_rate_out = gsm_symb_rate*osr
|
||||
|
||||
print "samp_rate_in ",samp_rate_in," samp_rate_out",samp_rate_out
|
||||
##################################################
|
||||
# Blocks
|
||||
##################################################
|
||||
self.message_port_register_hier_in("ctrl_in")
|
||||
|
||||
self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
|
||||
1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76))
|
||||
self.gsm_clock_offset_corrector_tagged_0 = grgsm.clock_offset_corrector_tagged(
|
||||
fc=fc,
|
||||
ppm=ppm,
|
||||
samp_rate_in=samp_rate_in,
|
||||
ppm=ppm,
|
||||
osr=osr,
|
||||
)
|
||||
self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out)
|
||||
|
||||
##################################################
|
||||
# Connections
|
||||
##################################################
|
||||
self.connect((self.low_pass_filter_0_0, 0), (self, 0))
|
||||
self.connect((self.fractional_resampler_xx_0, 0), (self.low_pass_filter_0_0, 0))
|
||||
self.connect((self.gsm_clock_offset_corrector_tagged_0, 0), (self.fractional_resampler_xx_0, 0))
|
||||
self.connect((self, 0), (self.gsm_clock_offset_corrector_tagged_0, 0))
|
||||
self.msg_connect((self, 'ctrl_in'), (self.gsm_clock_offset_corrector_tagged_0, 'ctrl'))
|
||||
self.connect((self.gsm_clock_offset_corrector_tagged_0, 0), (self.low_pass_filter_0_0, 0))
|
||||
self.connect((self.low_pass_filter_0_0, 0), (self, 0))
|
||||
self.connect((self, 0), (self.gsm_clock_offset_corrector_tagged_0, 0))
|
||||
|
||||
##################################################
|
||||
# Asynch Message Connections
|
||||
##################################################
|
||||
self.msg_connect((self, 'ctrl_in'), (self.gsm_clock_offset_corrector_tagged_0, 'ctrl'))
|
||||
def get_fc(self):
|
||||
return self.fc
|
||||
|
||||
def set_fc(self, fc):
|
||||
self.fc = fc
|
||||
|
@ -71,7 +70,8 @@ class gsm_input(grgsm.hier_block):
|
|||
|
||||
def set_osr(self, osr):
|
||||
self.osr = osr
|
||||
self.set_samp_rate_out(1625000.0/6.0*self.osr)
|
||||
self.set_samp_rate_out(self.gsm_symb_rate*self.osr)
|
||||
self.gsm_clock_offset_corrector_tagged_0.set_osr(self.osr)
|
||||
|
||||
def get_ppm(self):
|
||||
return self.ppm
|
||||
|
@ -86,12 +86,17 @@ class gsm_input(grgsm.hier_block):
|
|||
def set_samp_rate_in(self, samp_rate_in):
|
||||
self.samp_rate_in = samp_rate_in
|
||||
self.gsm_clock_offset_corrector_tagged_0.set_samp_rate_in(self.samp_rate_in)
|
||||
self.fractional_resampler_xx_0.set_resamp_ratio(self.samp_rate_in/self.samp_rate_out)
|
||||
|
||||
def get_gsm_symb_rate(self):
|
||||
return self.gsm_symb_rate
|
||||
|
||||
def set_gsm_symb_rate(self, gsm_symb_rate):
|
||||
self.gsm_symb_rate = gsm_symb_rate
|
||||
self.set_samp_rate_out(self.gsm_symb_rate*self.osr)
|
||||
|
||||
def get_samp_rate_out(self):
|
||||
return self.samp_rate_out
|
||||
|
||||
def set_samp_rate_out(self, samp_rate_out):
|
||||
self.samp_rate_out = samp_rate_out
|
||||
self.fractional_resampler_xx_0.set_resamp_ratio(self.samp_rate_in/self.samp_rate_out)
|
||||
self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76))
|
||||
|
|
Loading…
Reference in New Issue