This commit is contained in:
Carles Fernandez 2019-10-08 14:55:40 +02:00
commit df4a218ab4
8 changed files with 302 additions and 105 deletions

View File

@ -37,12 +37,14 @@
#include "configuration_interface.h"
#include <glog/logging.h>
#include <iio.h>
#include <exception>
#include <fcntl.h> // for open, O_WRONLY
#include <fstream> // for std::ifstream
#include <iostream> // for cout, endl
#include <string> // for string manipulation
#include <unistd.h> // for write
#include <algorithm> // for max
#include <cmath> // for abs
#include <exception> // for exceptions
#include <fcntl.h> // for open, O_WRONLY
#include <fstream> // for std::ifstream
#include <iostream> // for cout, endl
#include <string> // for string manipulation
#include <unistd.h> // for write
#include <utility>
#include <vector>
@ -277,34 +279,43 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
const std::string &role, unsigned int in_stream, unsigned int out_stream,
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue))
{
std::string default_gain_mode("slow attack");
double default_tx_attenuation_db = -10.0;
double default_manual_gain_rx1 = 64.0;
double default_manual_gain_rx2 = 64.0;
std::string default_rf_port_select("A_BALANCED");
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
sample_rate_ = configuration->property(role + ".sampling_frequency", 12500000);
bandwidth_ = configuration->property(role + ".bandwidth", 12500000);
rx1_en_ = configuration->property(role + ".rx1_enable", true);
rx2_en_ = configuration->property(role + ".rx2_enable", true);
buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000);
quadrature_ = configuration->property(role + ".quadrature", true);
rf_dc_ = configuration->property(role + ".rf_dc", true);
bb_dc_ = configuration->property(role + ".bb_dc", true);
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual"));
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual"));
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", 64.0);
rf_port_select_ = configuration->property(role + ".rf_port_select", std::string("A_BALANCED"));
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", default_gain_mode);
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", default_gain_mode);
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", default_manual_gain_rx1);
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", default_manual_gain_rx2);
rf_port_select_ = configuration->property(role + ".rf_port_select", default_rf_port_select);
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
filter_auto_ = configuration->property(role + ".filter_auto", true);
samples_ = configuration->property(role + ".samples", 0);
filter_auto_ = configuration->property(role + ".filter_auto", false);
enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000);
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_);
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", -3.0);
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db);
tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000);
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
// turn switch to A/D position
std::string default_device_name = "/dev/uio1";
std::string device_name = configuration->property(role + ".devicename", default_device_name);
switch_position = configuration->property(role + ".switch_position", 0);
if (switch_position != 0 && switch_position != 2)
{
std::cout << "SignalSource.switch_position configuration parameter must be either 0: read from file(s) via DMA, or 2: read from AD9361" << std::endl;
std::cout << "SignalSource.switch_position configuration parameter set to its default value switch_position=0 - read from file(s)" << std::endl;
switch_position = 0;
}
switch_fpga = std::make_shared<Fpga_Switch>(device_name);
switch_fpga->set_switch_position(switch_position);
@ -348,8 +359,9 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
std::cout << "Configuration parameter rf_port_select should take one of these values:" << std::endl;
std::cout << " A_BALANCED, B_BALANCED, A_N, B_N, B_P, C_N, C_P, TX_MONITOR1, TX_MONITOR2, TX_MONITOR1_2" << std::endl;
std::cout << "Error: provided value rf_port_select=" << rf_port_select_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_port_select=A_BALANCED" << std::endl;
rf_port_select_ = std::string("A_BALANCED");
std::cout << " This parameter has been set to its default value rf_port_select=" << default_rf_port_select << std::endl;
rf_port_select_ = default_rf_port_select;
LOG(WARNING) << "Invalid configuration value for rf_port_select parameter. Set to rf_port_select=" << default_rf_port_select;
}
if ((gain_mode_rx1_ != "manual") and (gain_mode_rx1_ != "slow_attack") and (gain_mode_rx1_ != "fast_attack") and (gain_mode_rx1_ != "hybrid"))
@ -357,8 +369,9 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
std::cout << "Error: provided value gain_mode_rx1=" << gain_mode_rx1_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value gain_mode_rx1=manual" << std::endl;
gain_mode_rx1_ = std::string("manual");
std::cout << " This parameter has been set to its default value gain_mode_rx1=" << default_gain_mode << std::endl;
gain_mode_rx1_ = default_gain_mode;
LOG(WARNING) << "Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx1=" << default_gain_mode;
}
if ((gain_mode_rx2_ != "manual") and (gain_mode_rx2_ != "slow_attack") and (gain_mode_rx2_ != "fast_attack") and (gain_mode_rx2_ != "hybrid"))
@ -366,38 +379,90 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
std::cout << "Configuration parameter gain_mode_rx2 should take one of these values:" << std::endl;
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
std::cout << "Error: provided value gain_mode_rx2=" << gain_mode_rx2_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value gain_mode_rx2=manual" << std::endl;
gain_mode_rx2_ = std::string("manual");
std::cout << " This parameter has been set to its default value gain_mode_rx2=" << default_gain_mode << std::endl;
gain_mode_rx2_ = default_gain_mode;
LOG(WARNING) << "Invalid configuration value for gain_mode_rx2 parameter. Set to gain_mode_rx2=" << default_gain_mode;
}
if (gain_mode_rx1_ == "manual")
{
if (rf_gain_rx1_ > 73.0 or rf_gain_rx1_ < -1.0)
{
std::cout << "Configuration parameter rf_gain_rx1 should take values between -1.0 and 73 dB" << std::endl;
std::cout << "Error: provided value rf_gain_rx1=" << rf_gain_rx1_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_gain_rx1=" << default_manual_gain_rx1 << std::endl;
rf_gain_rx1_ = default_manual_gain_rx1;
LOG(WARNING) << "Invalid configuration value for rf_gain_rx1 parameter. Set to rf_gain_rx1=" << default_manual_gain_rx1;
}
}
if (gain_mode_rx2_ == "manual")
{
if (rf_gain_rx2_ > 73.0 or rf_gain_rx2_ < -1.0)
{
std::cout << "Configuration parameter rf_gain_rx2 should take values between -1.0 and 73 dB" << std::endl;
std::cout << "Error: provided value rf_gain_rx2=" << rf_gain_rx2_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_gain_rx2=" << default_manual_gain_rx2 << std::endl;
rf_gain_rx2_ = default_manual_gain_rx2;
LOG(WARNING) << "Invalid configuration value for rf_gain_rx2 parameter. Set to rf_gain_rx2=" << default_manual_gain_rx2;
}
}
std::cout << "LO frequency : " << freq_ << " Hz" << std::endl;
config_ad9361_rx_local(bandwidth_,
sample_rate_,
freq_,
rf_port_select_,
gain_mode_rx1_,
gain_mode_rx2_,
rf_gain_rx1_,
rf_gain_rx2_,
quadrature_,
rf_dc_,
bb_dc_);
try
{
config_ad9361_rx_local(bandwidth_,
sample_rate_,
freq_,
rf_port_select_,
gain_mode_rx1_,
gain_mode_rx2_,
rf_gain_rx1_,
rf_gain_rx2_,
quadrature_,
rf_dc_,
bb_dc_);
}
catch (const std::runtime_error &e)
{
std::cout << "Exception cached when configuring the RX chain: " << e.what() << std::endl;
}
// LOCAL OSCILLATOR DDS GENERATOR FOR DUAL FREQUENCY OPERATION
if (enable_dds_lo_ == true)
{
config_ad9361_lo_local(bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
if (tx_bandwidth_ < static_cast<uint64_t>(std::floor(static_cast<float>(freq_dds_tx_hz_) * 1.1)) or (tx_bandwidth_ < 200000) or (tx_bandwidth_ > 1000000))
{
std::cout << "Configuration parameter tx_bandwidth value should be between " << std::max(static_cast<float>(freq_dds_tx_hz_) * 1.1, 200000.0) << " and 1000000 Hz" << std::endl;
std::cout << "Error: provided value tx_bandwidth=" << tx_bandwidth_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value tx_bandwidth=500000" << std::endl;
tx_bandwidth_ = 500000;
LOG(WARNING) << "Invalid configuration value for tx_bandwidth parameter. Set to tx_bandwidth=500000";
}
if (tx_attenuation_db_ > 0.0 or tx_attenuation_db_ < -89.75)
{
std::cout << "Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps" << std::endl;
std::cout << "Error: provided value tx_attenuation_db=" << tx_attenuation_db_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value tx_attenuation_db=" << default_tx_attenuation_db << std::endl;
tx_attenuation_db_ = default_tx_attenuation_db;
LOG(WARNING) << "Invalid configuration value for tx_attenuation_db parameter. Set to tx_attenuation_db=" << default_tx_attenuation_db;
}
try
{
config_ad9361_lo_local(tx_bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_,
phase_dds_deg_);
}
catch (const std::runtime_error &e)
{
std::cout << "Exception cached when configuring the TX carrier: " << e.what() << std::endl;
}
}
}
if (switch_position != 0 && switch_position != 2)
{
std::cout << "SignalSource.switch_position configuration parameter must be either 0: read from file(s) via DMA, or 2: read from AD9361" << std::endl;
}
if (in_stream_ > 0)
{
LOG(ERROR) << "A signal source does not have an input stream";

View File

@ -83,9 +83,6 @@ private:
uint64_t freq_; // frequency of local oscillator
uint64_t sample_rate_;
uint64_t bandwidth_;
uint64_t buffer_size_; // reception buffer
bool rx1_en_;
bool rx2_en_;
bool quadrature_;
bool rf_dc_;
bool bb_dc_;
@ -101,6 +98,7 @@ private:
bool enable_dds_lo_;
uint64_t freq_rf_tx_hz_;
uint64_t freq_dds_tx_hz_;
uint64_t tx_bandwidth_;
double scale_dds_dbfs_;
double phase_dds_deg_;
double tx_attenuation_db_;
@ -109,7 +107,6 @@ private:
uint32_t out_stream_;
size_t item_size_;
long samples_;
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;

View File

@ -36,6 +36,7 @@
#include "configuration_interface.h"
#include "gnss_sdr_valve.h"
#include <glog/logging.h>
#include <algorithm> // for max
#include <exception>
#include <iostream>
#include <utility>
@ -47,6 +48,8 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
{
std::string default_item_type = "gr_complex";
std::string default_dump_file = "./data/signal_source.dat";
std::string default_gain_mode("slow attack");
double default_tx_attenuation_db = -10.0;
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
sample_rate_ = configuration->property(role + ".sampling_frequency", 2600000);
@ -58,8 +61,8 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
rf_dc_ = configuration->property(role + ".rf_dc", true);
bb_dc_ = configuration->property(role + ".bb_dc", true);
RF_channels_ = configuration->property(role + ".RF_channels", 1);
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual"));
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual"));
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", default_gain_mode);
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", default_gain_mode);
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", 64.0);
rf_port_select_ = configuration->property(role + ".rf_port_select", std::string("A_BALANCED"));
@ -68,7 +71,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
filter_filename_ = configuration->property(role + ".filter_filename", std::string(""));
Fpass_ = configuration->property(role + ".Fpass", 0.0);
Fstop_ = configuration->property(role + ".Fstop", 0.0);
filter_auto_ = configuration->property(role + ".filter_auto", true);
filter_auto_ = configuration->property(role + ".filter_auto", false);
item_type_ = configuration->property(role + ".item_type", default_item_type);
samples_ = configuration->property(role + ".samples", 0);
dump_ = configuration->property(role + ".dump", false);
@ -76,11 +79,12 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
// AD9361 Local Oscillator generation for dual band operation
enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000);
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_);
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0);
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db);
tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000);
item_size_ = sizeof(gr_complex);
@ -92,6 +96,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
std::cout << "Error: provided value rf_port_select=" << rf_port_select_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_port_select=A_BALANCED" << std::endl;
rf_port_select_ = std::string("A_BALANCED");
LOG(WARNING) << "Invalid configuration value for rf_port_select parameter. Set to rf_port_select=A_BALANCED";
}
if ((gain_mode_rx1_ != "manual") and (gain_mode_rx1_ != "slow_attack") and (gain_mode_rx1_ != "fast_attack") and (gain_mode_rx1_ != "hybrid"))
@ -99,8 +104,9 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
std::cout << "Error: provided value gain_mode_rx1=" << gain_mode_rx1_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value gain_mode_rx1=manual" << std::endl;
gain_mode_rx1_ = std::string("manual");
std::cout << " This parameter has been set to its default value gain_mode_rx1=" << default_gain_mode << std::endl;
gain_mode_rx1_ = default_gain_mode;
LOG(WARNING) << "Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx1=" << default_gain_mode;
}
if ((gain_mode_rx2_ != "manual") and (gain_mode_rx2_ != "slow_attack") and (gain_mode_rx2_ != "fast_attack") and (gain_mode_rx2_ != "hybrid"))
@ -108,10 +114,15 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
std::cout << "Configuration parameter gain_mode_rx2 should take one of these values:" << std::endl;
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
std::cout << "Error: provided value gain_mode_rx2=" << gain_mode_rx2_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value gain_mode_rx2=manual" << std::endl;
gain_mode_rx2_ = std::string("manual");
std::cout << " This parameter has been set to its default value gain_mode_rx2=" << default_gain_mode << std::endl;
gain_mode_rx2_ = default_gain_mode;
LOG(WARNING) << "Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx2=" << default_gain_mode;
}
if (filter_auto_)
{
filter_source_ = std::string("Auto");
}
if ((filter_source_ != "Off") and (filter_source_ != "Auto") and (filter_source_ != "File") and (filter_source_ != "Design"))
{
std::cout << "Configuration parameter filter_source should take one of these values:" << std::endl;
@ -122,6 +133,31 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
std::cout << "Error: provided value filter_source=" << filter_source_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value filter_source=Off" << std::endl;
filter_source_ = std::string("Off");
LOG(WARNING) << "Invalid configuration value for filter_source parameter. Set to filter_source=Off";
}
if (gain_mode_rx1_ == "manual")
{
if (rf_gain_rx1_ > 73.0 or rf_gain_rx1_ < -1.0)
{
std::cout << "Configuration parameter rf_gain_rx1 should take values between -1.0 and 73 dB" << std::endl;
std::cout << "Error: provided value rf_gain_rx1=" << rf_gain_rx1_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_gain_rx1=64.0" << std::endl;
rf_gain_rx1_ = 64.0;
LOG(WARNING) << "Invalid configuration value for rf_gain_rx1 parameter. Set to rf_gain_rx1=64.0";
}
}
if (gain_mode_rx2_ == "manual")
{
if (rf_gain_rx2_ > 73.0 or rf_gain_rx2_ < -1.0)
{
std::cout << "Configuration parameter rf_gain_rx2 should take values between -1.0 and 73 dB" << std::endl;
std::cout << "Error: provided value rf_gain_rx2=" << rf_gain_rx2_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_gain_rx2=64.0" << std::endl;
rf_gain_rx2_ = 64.0;
LOG(WARNING) << "Invalid configuration value for rf_gain_rx2 parameter. Set to rf_gain_rx2=64.0";
}
}
std::cout << "device address: " << uri_ << std::endl;
@ -162,14 +198,38 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
// configure LO
if (enable_dds_lo_ == true)
{
if (tx_bandwidth_ < static_cast<uint64_t>(std::floor(static_cast<float>(freq_dds_tx_hz_) * 1.1)) or (tx_bandwidth_ < 200000) or (tx_bandwidth_ > 1000000))
{
std::cout << "Configuration parameter tx_bandwidth value should be between " << std::max(static_cast<float>(freq_dds_tx_hz_) * 1.1, 200000.0) << " and 1000000 Hz" << std::endl;
std::cout << "Error: provided value tx_bandwidth=" << tx_bandwidth_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value tx_bandwidth=500000" << std::endl;
tx_bandwidth_ = 500000;
LOG(WARNING) << "Invalid configuration value for tx_bandwidth parameter. Set to tx_bandwidth=500000";
}
if (tx_attenuation_db_ > 0.0 or tx_attenuation_db_ < -89.75)
{
std::cout << "Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps" << std::endl;
std::cout << "Error: provided value tx_attenuation_db=" << tx_attenuation_db_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value tx_attenuation_db=" << default_tx_attenuation_db << std::endl;
tx_attenuation_db_ = default_tx_attenuation_db;
LOG(WARNING) << "Invalid configuration value for tx_attenuation_db parameter. Set to tx_attenuation_db=" << default_tx_attenuation_db;
}
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
try
{
config_ad9361_lo_remote(uri_,
tx_bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_,
phase_dds_deg_);
}
catch (const std::runtime_error& e)
{
std::cout << "Exception cached when configuring the TX carrier: " << e.what() << std::endl;
}
}
}
}
@ -205,14 +265,38 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
// configure LO
if (enable_dds_lo_ == true)
{
if (tx_bandwidth_ < static_cast<uint64_t>(std::floor(static_cast<float>(freq_dds_tx_hz_) * 1.1)) or (tx_bandwidth_ < 200000) or (tx_bandwidth_ > 1000000))
{
std::cout << "Configuration parameter tx_bandwidth value should be between " << std::max(static_cast<float>(freq_dds_tx_hz_) * 1.1, 200000.0) << " and 1000000 Hz" << std::endl;
std::cout << "Error: provided value tx_bandwidth=" << tx_bandwidth_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value tx_bandwidth=500000" << std::endl;
tx_bandwidth_ = 500000;
LOG(WARNING) << "Invalid configuration value for tx_bandwidth parameter. Set to tx_bandwidth=500000";
}
if (tx_attenuation_db_ > 0.0 or tx_attenuation_db_ < -89.75)
{
std::cout << "Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps" << std::endl;
std::cout << "Error: provided value tx_attenuation_db=" << tx_attenuation_db_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value tx_attenuation_db=" << default_tx_attenuation_db << std::endl;
tx_attenuation_db_ = default_tx_attenuation_db;
LOG(WARNING) << "Invalid configuration value for tx_attenuation_db parameter. Set to tx_attenuation_db=" << default_tx_attenuation_db;
}
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
try
{
config_ad9361_lo_remote(uri_,
tx_bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_,
phase_dds_deg_);
}
catch (const std::runtime_error& e)
{
std::cout << "Exception cached when configuring the TX carrier: " << e.what() << std::endl;
}
}
}
}

View File

@ -43,6 +43,7 @@
#endif
#include "concurrent_queue.h"
#include <pmt/pmt.h>
#include <cstdint>
#include <memory>
#include <string>
@ -84,11 +85,11 @@ private:
std::string role_;
// Front-end settings
std::string uri_; // device direction
unsigned long freq_; // frequency of local oscilator
unsigned long sample_rate_;
unsigned long bandwidth_;
unsigned long buffer_size_; // reception buffer
std::string uri_; // device direction
uint64_t freq_; // frequency of local oscilator
uint64_t sample_rate_;
uint64_t bandwidth_;
uint64_t buffer_size_; // reception buffer
bool rx1_en_;
bool rx2_en_;
bool quadrature_;
@ -109,18 +110,19 @@ private:
// DDS configuration for LO generation for external mixer
bool enable_dds_lo_;
unsigned long freq_rf_tx_hz_;
unsigned long freq_dds_tx_hz_;
uint64_t freq_rf_tx_hz_;
uint64_t freq_dds_tx_hz_;
double scale_dds_dbfs_;
double phase_dds_deg_;
double tx_attenuation_db_;
uint64_t tx_bandwidth_;
unsigned int in_stream_;
unsigned int out_stream_;
std::string item_type_;
size_t item_size_;
long samples_;
int64_t samples_;
bool dump_;
std::string dump_filename_;

View File

@ -43,6 +43,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
{
std::string default_item_type = "gr_complex";
std::string default_dump_file = "./data/signal_source.dat";
std::string default_gain_mode("slow attack");
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000);
@ -51,12 +52,12 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
quadrature_ = configuration->property(role + ".quadrature", true);
rf_dc_ = configuration->property(role + ".rf_dc", true);
bb_dc_ = configuration->property(role + ".bb_dc", true);
gain_mode_ = configuration->property(role + ".gain_mode", std::string("manual"));
gain_mode_ = configuration->property(role + ".gain_mode", default_gain_mode);
rf_gain_ = configuration->property(role + ".gain", 50.0);
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
filter_auto_ = configuration->property(role + ".filter_auto", true);
filter_auto_ = configuration->property(role + ".filter_auto", false);
filter_source_ = configuration->property(role + ".filter_source", std::string("Off"));
filter_filename_ = configuration->property(role + ".filter_filename", std::string(""));
filter_filename_ = configuration->property(role + ".filter_filename", filter_file_);
Fpass_ = configuration->property(role + ".Fpass", 0.0);
Fstop_ = configuration->property(role + ".Fstop", 0.0);
item_type_ = configuration->property(role + ".item_type", default_item_type);
@ -64,6 +65,11 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
if (filter_auto_)
{
filter_source_ = std::string("Auto");
}
if (item_type_ != "gr_complex")
{
std::cout << "Configuration error: item_type must be gr_complex" << std::endl;
@ -73,11 +79,37 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
// basic check
if ((gain_mode_ != "manual") and (gain_mode_ != "slow_attack") and (gain_mode_ != "fast_attack") and (gain_mode_ != "hybrid"))
{
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
std::cout << "Configuration parameter gain_mode should take one of these values:" << std::endl;
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
std::cout << "Error: provided value gain_mode=" << gain_mode_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value gain_mode=manual" << std::endl;
gain_mode_ = std::string("manual");
std::cout << " This parameter has been set to its default value gain_mode=" << default_gain_mode << std::endl;
gain_mode_ = default_gain_mode;
LOG(WARNING) << "Invalid configuration value for gain_mode parameter. Set to gain_mode=" << default_gain_mode;
}
if (gain_mode_ == "manual")
{
if (rf_gain_ > 73.0 or rf_gain_ < -1.0)
{
std::cout << "Configuration parameter rf_gain should take values between -1.0 and 73 dB" << std::endl;
std::cout << "Error: provided value rf_gain=" << rf_gain_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value rf_gain=64.0" << std::endl;
rf_gain_ = 64.0;
LOG(WARNING) << "Invalid configuration value for rf_gain parameter. Set to rf_gain=64.0";
}
}
if ((filter_source_ != "Off") and (filter_source_ != "Auto") and (filter_source_ != "File") and (filter_source_ != "Design"))
{
std::cout << "Configuration parameter filter_source should take one of these values:" << std::endl;
std::cout << " Off: Disable filter" << std::endl;
std::cout << " Auto: Use auto-generated filters" << std::endl;
std::cout << " File: User-provided filter in filter_filename parameter" << std::endl;
std::cout << " Design: Create filter from Fpass, Fstop, sampling_frequency and bandwidth parameters" << std::endl;
std::cout << "Error: provided value filter_source=" << filter_source_ << " is not among valid values" << std::endl;
std::cout << " This parameter has been set to its default value filter_source=Off" << std::endl;
filter_source_ = std::string("Off");
LOG(WARNING) << "Invalid configuration value for filter_source parameter. Set to filter_source=Off";
}
item_size_ = sizeof(gr_complex);

View File

@ -42,6 +42,7 @@
#endif
#include "concurrent_queue.h"
#include <pmt/pmt.h>
#include <cstdint>
#include <memory>
#include <string>
@ -85,11 +86,11 @@ private:
std::string role_;
// Front-end settings
std::string uri_; // device direction
unsigned long freq_; // frequency of local oscilator
unsigned long sample_rate_;
unsigned long bandwidth_;
unsigned long buffer_size_; // reception buffer
std::string uri_; // device direction
uint64_t freq_; // frequency of local oscilator
uint64_t sample_rate_;
uint64_t bandwidth_;
uint64_t buffer_size_; // reception buffer
bool quadrature_;
bool rf_dc_;
bool bb_dc_;
@ -107,7 +108,7 @@ private:
std::string item_type_;
size_t item_size_;
long samples_;
int64_t samples_;
bool dump_;
std::string dump_filename_;

View File

@ -493,7 +493,8 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
uint64_t freq_rf_tx_hz_,
double tx_attenuation_db_,
int64_t freq_dds_tx_hz_,
double scale_dds_dbfs_)
double scale_dds_dbfs_,
double phase_dds_deg_)
{
// TX stream config
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
@ -535,10 +536,16 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
int ret;
// set output amplifier attenuation
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -tx_attenuation_db_);
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
if (ret < 0)
{
std::cout << "Failed to set out_voltage0_hardwaregain value " << -tx_attenuation_db_ << " error " << ret << std::endl;
std::cout << "Failed to set out_voltage0_hardwaregain value " << -std::abs(tx_attenuation_db_) << ". Error " << ret << std::endl;
}
// shut down signal in TX2
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.75);
if (ret < 0)
{
std::cout << "Failed to set out_voltage1_hardwaregain value -89.75 dB. Error " << ret << std::endl;
}
struct iio_device *dds;
@ -568,13 +575,13 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
}
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", 0.0);
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", phase_dds_deg_ * 1000.0);
if (ret < 0)
{
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
}
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", 270000.0);
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", phase_dds_deg_ * 1000.0 + 270000.0);
if (ret < 0)
{
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;
@ -628,7 +635,8 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
uint64_t freq_rf_tx_hz_,
double tx_attenuation_db_,
int64_t freq_dds_tx_hz_,
double scale_dds_dbfs_)
double scale_dds_dbfs_,
double phase_dds_deg_)
{
// TX stream config
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
@ -670,12 +678,18 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
int ret;
// set output amplifier attenuation
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -tx_attenuation_db_);
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
if (ret < 0)
{
std::cout << "Failed to set out_voltage0_hardwaregain value " << -tx_attenuation_db_ << " error " << ret << std::endl;
std::cout << "Failed to set out_voltage0_hardwaregain value " << -std::abs(tx_attenuation_db_) << ". Error " << ret << std::endl;
}
// shut down signal in TX2
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.75);
if (ret < 0)
{
std::cout << "Failed to set out_voltage1_hardwaregain value -89.75 dB. Error " << ret << std::endl;
}
struct iio_device *dds;
dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc");
struct iio_channel *dds_channel0_I;
@ -703,13 +717,13 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
}
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", 0.0);
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", phase_dds_deg_ * 1000.0);
if (ret < 0)
{
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
}
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", 270000.0);
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", phase_dds_deg_ * 1000.0 + 270000.0);
if (ret < 0)
{
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;

View File

@ -115,7 +115,8 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
uint64_t freq_rf_tx_hz_,
double tx_attenuation_db_,
int64_t freq_dds_tx_hz_,
double scale_dds_dbfs_);
double scale_dds_dbfs_,
double phase_dds_deg_);
bool config_ad9361_lo_remote(const std::string &remote_host,
uint64_t bandwidth_,
@ -123,7 +124,8 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
uint64_t freq_rf_tx_hz_,
double tx_attenuation_db_,
int64_t freq_dds_tx_hz_,
double scale_dds_dbfs_);
double scale_dds_dbfs_,
double phase_dds_deg_);
bool ad9361_disable_lo_remote(const std::string &remote_host);