diff --git a/FPGA/VNA/Sweep.vhd b/FPGA/VNA/Sweep.vhd index 9f95290..db63133 100644 --- a/FPGA/VNA/Sweep.vhd +++ b/FPGA/VNA/Sweep.vhd @@ -153,7 +153,7 @@ begin if RESET = '1' then point_cnt <= (others => '0'); stage_cnt <= (others => '0'); - state <= TriggerSetup; + state <= WaitTriggerLow; START_SAMPLING <= '0'; RELOAD_PLL_REGS <= '0'; SWEEP_HALTED <= '0'; @@ -164,9 +164,22 @@ begin source_active <= '0'; else case state is + when WaitTriggerLow => + if SYNC_ENABLED = '1' and (std_logic_vector(stage_cnt) = PORT1_STAGE or std_logic_vector(stage_cnt) = PORT2_STAGE) then + TRIGGER_OUT <= '0'; + end if; + if TRIGGER_IN = '0' or SYNC_ENABLED = '0' then + TRIGGER_OUT <= '0'; + if stage_cnt = 0 then + -- first stage in point, need to trigger PLL setup + state <= TriggerSetup; + else + -- PLLs already configured correctly + state <= SettingUp; + end if; + end if; when TriggerSetup => RELOAD_PLL_REGS <= '1'; - stage_cnt <= (others => '0'); if PLL_RELOAD_DONE = '0' then state <= SettingUp; end if; @@ -206,24 +219,16 @@ begin if settling_cnt > 0 then settling_cnt <= settling_cnt - 1; else - if SYNC_ENABLED = '1' then - -- need to wait for the trigger - state <= WaitTriggerHigh; - if source_active = '1' then - -- this device generates the stimulus signal, it needs start the trigger itself - TRIGGER_OUT <= '1'; - end if; - else - -- can start sampling directly - START_SAMPLING <= '1'; - if SAMPLING_BUSY = '1' then - state <= Exciting; - end if; + -- need to wait for the trigger + state <= WaitTriggerHigh; + if SYNC_ENABLED = '1' and (std_logic_vector(stage_cnt) = PORT1_STAGE or std_logic_vector(stage_cnt) = PORT2_STAGE) then + -- this device generates the stimulus signal, it needs start the trigger itself + TRIGGER_OUT <= '1'; end if; end if; when WaitTriggerHigh => - if TRIGGER_IN = '1' then - TRIGGER_OUT <= '1'; -- pass on trigger signal + if TRIGGER_IN = '1' or SYNC_ENABLED = '0' then + TRIGGER_OUT <= SYNC_ENABLED; -- pass on trigger signal if enabled START_SAMPLING <= '1'; if SAMPLING_BUSY = '1' then state <= Exciting; @@ -234,26 +239,13 @@ begin START_SAMPLING <= '0'; if SAMPLING_BUSY = '0' then RESULT_INDEX <= std_logic_vector(stage_cnt) & std_logic_vector(point_cnt); - if SYNC_ENABLED = '1' then - state <= WaitTriggerLow; - if source_active = '1' then - -- this device generated the stimulus signal, it needs to reset the trigger itself - TRIGGER_OUT <= '0'; - end if; - else - state <= SamplingDone; - end if; - end if; - when WaitTriggerLow => - if TRIGGER_IN = '0' then - TRIGGER_OUT <= '0'; state <= SamplingDone; end if; when SamplingDone => if stage_cnt < unsigned(STAGES) then stage_cnt <= stage_cnt + 1; - -- can go directly to settling - state <= Settling; + -- can go directly to preperation for next stage + state <= WaitTriggerLow; else state <= NextPoint; end if; @@ -261,10 +253,12 @@ begin when NextPoint => if point_cnt < unsigned(NPOINTS) then point_cnt <= point_cnt + 1; - state <= TriggerSetup; + stage_cnt <= (others => '0'); + state <= WaitTriggerLow; else point_cnt <= (others => '0'); state <= Done; + TRIGGER_OUT <= '0'; end if; when others => end case; diff --git a/FPGA/VNA/VNA.gise b/FPGA/VNA/VNA.gise index bcce93c..261e9bf 100644 --- a/FPGA/VNA/VNA.gise +++ b/FPGA/VNA/VNA.gise @@ -224,7 +224,7 @@ - + @@ -253,7 +253,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -284,7 +284,7 @@ - + @@ -298,7 +298,7 @@ - + @@ -312,7 +312,7 @@ - + @@ -365,7 +365,7 @@ - + diff --git a/FPGA/VNA/top.bin b/FPGA/VNA/top.bin index cd69dfd..ff682eb 100644 Binary files a/FPGA/VNA/top.bin and b/FPGA/VNA/top.bin differ diff --git a/Software/PC_Application/Device/virtualdevice.cpp b/Software/PC_Application/Device/virtualdevice.cpp index a087f75..51c690a 100644 --- a/Software/PC_Application/Device/virtualdevice.cpp +++ b/Software/PC_Application/Device/virtualdevice.cpp @@ -588,7 +588,12 @@ void VirtualDevice::compoundDatapointReceivecd(Protocol::VNADatapoint<32> *data, if(!std::isnan(ref.real()) && !std::isnan(input.real())) { // got both required measurements QString name = "S"+QString::number(i+1)+QString::number(map.first+1); - m.measurements[name] = input / ref; + auto S = input / ref; + if(inputDevice != stimulusDev) { + // can't use phase information when measuring across devices + S = abs(S); + } + m.measurements[name] = S; } } } diff --git a/Software/PC_Application/Traces/trace.cpp b/Software/PC_Application/Traces/trace.cpp index 43de7ea..b8a4c37 100644 --- a/Software/PC_Application/Traces/trace.cpp +++ b/Software/PC_Application/Traces/trace.cpp @@ -143,7 +143,7 @@ void Trace::addData(const Trace::Data &d, const VirtualDevice::SASettings &s, in } void Trace::setName(QString name) { - name = name; + _name = name; emit nameChanged(); } @@ -305,8 +305,8 @@ void Trace::fromMath() } void Trace::setColor(QColor color) { - if(color != color) { - color = color; + if(_color != color) { + _color = color; emit colorChanged(this); } } diff --git a/Software/PC_Application/Traces/traceeditdialog.cpp b/Software/PC_Application/Traces/traceeditdialog.cpp index a3e3823..0be6a09 100644 --- a/Software/PC_Application/Traces/traceeditdialog.cpp +++ b/Software/PC_Application/Traces/traceeditdialog.cpp @@ -323,6 +323,7 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) : t.swapMathOrder(index.row()); ui->view->setCurrentIndex(index.sibling(index.row() + 1, 0)); }); + connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &TraceEditDialog::okClicked); } TraceEditDialog::~TraceEditDialog() @@ -330,7 +331,7 @@ TraceEditDialog::~TraceEditDialog() delete ui; } -void TraceEditDialog::on_buttonBox_accepted() +void TraceEditDialog::okClicked() { trace.setName(ui->name->text()); trace.setVelocityFactor(ui->vFactor->value()); diff --git a/Software/PC_Application/Traces/traceeditdialog.h b/Software/PC_Application/Traces/traceeditdialog.h index bce9ae7..e8b31b1 100644 --- a/Software/PC_Application/Traces/traceeditdialog.h +++ b/Software/PC_Application/Traces/traceeditdialog.h @@ -46,7 +46,7 @@ public: ~TraceEditDialog(); private slots: - void on_buttonBox_accepted(); + void okClicked(); private: Ui::TraceEditDialog *ui;