Skip to content

Commit

Permalink
NetworkAnalyzer: Disable triggers before doing the sweep
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jul 6, 2017
1 parent 21bb304 commit 4708b00
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/network_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "network_analyzer.hpp"
#include "signal_generator.hpp"
#include "spinbox_a.hpp"
#include "osc_adc.h"
#include "hardware_trigger.hpp"
#include "ui_network_analyzer.h"

#include <gnuradio/analog/sig_source_c.h>
Expand Down Expand Up @@ -57,10 +59,12 @@ using namespace adiscope;
using namespace gr;

NetworkAnalyzer::NetworkAnalyzer(struct iio_context *ctx, Filter *filt,
std::shared_ptr<GenericAdc> adc_dev,
QPushButton *runButton, QJSEngine *engine,
ToolLauncher *parent) :
Tool(ctx, runButton, new NetworkAnalyzer_API(this), parent),
ui(new Ui::NetworkAnalyzer)
ui(new Ui::NetworkAnalyzer),
adc_dev(adc_dev)
{
iio = iio_manager::get_instance(ctx,
filt->device_name(TOOL_NETWORK_ANALYZER, 2));
Expand Down Expand Up @@ -387,6 +391,7 @@ void NetworkAnalyzer::startStop(bool pressed)
ui->phasegraph->reset();
ui->xygraph->reset();
ui->nicholsgraph->reset();
configHwForNetworkAnalyzing();
thd = QtConcurrent::run(this, &NetworkAnalyzer::run);
} else {
thd.waitForFinished();
Expand Down Expand Up @@ -516,6 +521,15 @@ struct iio_buffer * NetworkAnalyzer::generateSinWave(
return buf;
}

void NetworkAnalyzer::configHwForNetworkAnalyzing()
{
auto trigger = adc_dev->getTrigger();
if (trigger) {
for (uint i = 0; i < trigger->numChannels(); i++)
trigger->setTriggerMode(i, HardwareTrigger::ALWAYS);
}
}

double NetworkAnalyzer_API::getMinFreq() const
{
return net->ui->minFreq->value();
Expand Down
4 changes: 4 additions & 0 deletions src/network_analyzer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class QJSEngine;
namespace adiscope {
class NetworkAnalyzer_API;
class Filter;
class GenericAdc;

class NetworkAnalyzer : public Tool
{
Expand All @@ -54,6 +55,7 @@ namespace adiscope {

public:
explicit NetworkAnalyzer(struct iio_context *ctx, Filter *filt,
std::shared_ptr<GenericAdc> adc_dev,
QPushButton *runButton, QJSEngine *engine,
ToolLauncher *parent);
~NetworkAnalyzer();
Expand All @@ -62,6 +64,7 @@ namespace adiscope {
Ui::NetworkAnalyzer *ui;
struct iio_channel *dac1, *dac2;
struct iio_device *adc;
std::shared_ptr<GenericAdc> adc_dev;
boost::shared_ptr<iio_manager> iio;

QFuture<void> thd;
Expand All @@ -87,6 +90,7 @@ namespace adiscope {
size_t samples_count);

unsigned long get_best_adc_rate(double frequency);
void configHwForNetworkAnalyzing();

private Q_SLOTS:
void startStop(bool start);
Expand Down
2 changes: 1 addition & 1 deletion src/tool_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ bool adiscope::ToolLauncher::switchContext(const QString& uri)


if (filter->compatible((TOOL_NETWORK_ANALYZER))) {
network_analyzer = new NetworkAnalyzer(ctx, filter,
network_analyzer = new NetworkAnalyzer(ctx, filter, adc,
ui->stopNetworkAnalyzer, &js_engine, this);
}

Expand Down

0 comments on commit 4708b00

Please sign in to comment.