From eac0a7a13f45849a0c15ca1ee019eb760c5ae2af Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Thu, 26 Nov 2020 19:25:58 +0100 Subject: [PATCH] Fixed FIR bug with the pluto module --- plutosdr_source/CMakeLists.txt | 1 + plutosdr_source/src/main.cpp | 43 ++++++++++++++++++++++--------- readme.md | 5 ++++ root_dev/config.json | 6 ++--- root_dev/soapy_source_config.json | 14 +++++----- 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/plutosdr_source/CMakeLists.txt b/plutosdr_source/CMakeLists.txt index 38480820..760d0990 100644 --- a/plutosdr_source/CMakeLists.txt +++ b/plutosdr_source/CMakeLists.txt @@ -21,6 +21,7 @@ if (MSVC) target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/") target_link_libraries(plutosdr_source PUBLIC libiio) + target_link_libraries(plutosdr_source PUBLIC libad9361) else (MSVC) find_package(PkgConfig) diff --git a/plutosdr_source/src/main.cpp b/plutosdr_source/src/main.cpp index 1c9b2868..c2bc6bf7 100644 --- a/plutosdr_source/src/main.cpp +++ b/plutosdr_source/src/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #define CONCAT(a, b) ((std::string(a) + b).c_str()) @@ -84,11 +85,16 @@ private: } // Configure pluto - iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", _this->freq); // Freq - iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "sampling_frequency", _this->sampleRate); // Sample rate - iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "gain_control_mode", "manual"); // manual gain - iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "hardwaregain", _this->gain); // gain + iio_channel_attr_write_bool(iio_device_find_channel(_this->phy, "altvoltage1", true), "powerdown", true); + iio_channel_attr_write_bool(iio_device_find_channel(_this->phy, "altvoltage0", true), "powerdown", false); + iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "rf_port_select", "A_BALANCED"); + iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", round(_this->freq)); // Freq + iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "sampling_frequency", round(_this->sampleRate)); // Sample rate + iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "gain_control_mode", gainModes[_this->gainMode]); // manual gain + iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false), "hardwaregain", round(_this->gain)); // gain + ad9361_set_bb_rate(_this->phy, round(_this->sampleRate)); + _this->running = true; _this->workerThread = std::thread(worker, _this); spdlog::info("PlutoSDRSourceModule '{0}': Start!", _this->name); @@ -115,11 +121,11 @@ private: static void tune(double freq, void* ctx) { PlutoSDRSourceModule* _this = (PlutoSDRSourceModule*)ctx; + _this->freq = freq; if (_this->running) { // SET PLUTO FREQ HERE - iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", _this->freq); + iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "altvoltage0", true), "frequency", round(_this->freq)); } - _this->freq = freq; spdlog::info("PlutoSDRSourceModule '{0}': Tune: {1}!", _this->name, freq); } @@ -130,25 +136,37 @@ private: ImGui::Text("IP"); ImGui::SameLine(); ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); - ImGui::InputText("", &_this->ip[3], 16); + ImGui::InputText(CONCAT("##_pluto_ip_", _this->name), &_this->ip[3], 16); - // SELECT PLUTO HERE + ImGui::Text("Samplerate"); + ImGui::SameLine(); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (_this->running) { style::beginDisabled(); } + if (ImGui::InputFloat(CONCAT("##_samplerate_select_", _this->name), &_this->sampleRate, 1, 1000, 0)) { + core::setInputSampleRate(_this->sampleRate); + } + if (_this->running) { style::endDisabled(); } + ImGui::Text("Gain Mode"); ImGui::SameLine(); ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); - if (ImGui::Combo("", &_this->gainMode, gainModesTxt)) { - + if (ImGui::Combo(CONCAT("##_gainmode_select_", _this->name), &_this->gainMode, gainModesTxt)) { + if (_this->running) { + iio_channel_attr_write(iio_device_find_channel(_this->phy, "voltage0", false), "gain_control_mode", gainModes[_this->gainMode]); + } } ImGui::Text("PGA Gain"); ImGui::SameLine(); ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (_this->gainMode) { style::beginDisabled(); } if (ImGui::SliderFloat(CONCAT("##_gain_select_", _this->name), &_this->gain, 0, 76)) { if (_this->running) { // SET PLUTO GAIN HERE - iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false),"hardwaregain", _this->gain); + iio_channel_attr_write_longlong(iio_device_find_channel(_this->phy, "voltage0", false),"hardwaregain", round(_this->gain)); } } + if (_this->gainMode) { style::endDisabled(); } } static void worker(void* ctx) { @@ -190,13 +208,14 @@ private: std::string name; dsp::stream stream; - double sampleRate; + float sampleRate; SourceManager::SourceHandler handler; std::thread workerThread; struct iio_context *ctx = NULL; struct iio_device *phy = NULL; struct iio_device *dev = NULL; bool running = false; + bool ipMode = true; double freq; char ip[1024] = "ip:192.168.2.1"; int port = 1234; diff --git a/readme.md b/readme.md index 2b169d9c..52a7da56 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,7 @@ SDR++ is a cross-platform and open source SDR software with the aim of being bloat free and simple to use. ## Current Features + * Uses SoapySDR for wide hardware support * Hardware accelerated graphics (OpenGL + ImGui) * SIMD accelerated DSP (parts of the DSP are still missing) @@ -10,12 +11,14 @@ SDR++ is a cross-platform and open source SDR software with the aim of being blo * Full waterfall update when possible. Makes browsing signals easier and more pleasant ## Comming soon + * Multi-VFO * Plugins * Digital demodulators and decoders * Quick replay (replay last n seconds, cool if you missed a short signal) ## Small things to add + * Switchable bandwidth for demodulators * Switchable audio output device and sample rate * Recording @@ -29,6 +32,7 @@ SDR++ is a cross-platform and open source SDR software with the aim of being blo * Input filter bandwidth option ## Known issues (please check before reporting) + * Random crashes (yikes) * Gains aren't stepped * The default gains might contain a bogus value before being adjusted @@ -38,6 +42,7 @@ SDR++ is a cross-platform and open source SDR software with the aim of being blo # Building on Windows ## Requirements + * cmake * vcpkg (for the packages listed below) * fftw3 diff --git a/root_dev/config.json b/root_dev/config.json index cfabfd72..9243ccde 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -3,7 +3,7 @@ "Radio": { "device": "Speakers (Realtek High Definiti", "sampleRate": 48000.0, - "volume": 0.3777777850627899 + "volume": 0.546875 }, "Radio 1": { "device": "Speakers (Realtek High Definition Audio)", @@ -20,7 +20,7 @@ "bandPlanEnabled": true, "defaultSink": "Audio", "fftHeight": 296, - "frequency": 99000000, + "frequency": 1090020000, "max": 0.0, "maximized": false, "menuOrder": [ @@ -33,7 +33,7 @@ "Display" ], "menuWidth": 300, - "min": -69.11764526367188, + "min": -70.5882339477539, "showWaterfall": true, "source": "", "sourceSettings": {}, diff --git a/root_dev/soapy_source_config.json b/root_dev/soapy_source_config.json index 6b133442..84c2fc7b 100644 --- a/root_dev/soapy_source_config.json +++ b/root_dev/soapy_source_config.json @@ -5,12 +5,12 @@ "gains": { "PGA": 0.0 }, - "sampleRate": 4000000.0 + "sampleRate": 8000000.0 }, "AirSpy HF+ [c852435de0224af7]": { "gains": { - "LNA": 6.0, - "RF": 0.0 + "LNA": 5.989999771118164, + "RF": 6.0 }, "sampleRate": 768000.0 }, @@ -22,17 +22,17 @@ }, "Generic RTL2832U OEM :: 00000001": { "gains": { - "TUNER": 7.244999885559082 + "TUNER": 0.0 }, - "sampleRate": 250000.0 + "sampleRate": 2560000.0 }, "HackRF One #0 901868dc282c8f8b": { "gains": { "AMP": 0.0, "LNA": 24.711999893188477, - "VGA": 16.02899932861328 + "VGA": 21.749000549316406 }, - "sampleRate": 8000000.0 + "sampleRate": 2000000.0 }, "Microphone (Realtek High Definition Audio)": { "sampleRate": 96000.0