├── .gitattributes ├── .gitignore ├── About.cpp ├── About.h ├── About.resx ├── Arduino ├── UVnArduino.ino ├── si5351_nano.cpp └── si5351_nano.h ├── AssemblyInfo.cpp ├── AudioDevice.cpp ├── AudioDevice.h ├── AudioDevice.resx ├── AudioInput.cpp ├── AudioInput.h ├── Blue Gradient.jpg ├── Calibration.cpp ├── Calibration.h ├── Calibration.resx ├── Constants.h ├── CursorStatus.cpp ├── CursorStatus.h ├── CursorStatus.resx ├── DataDisplay.cpp ├── DataDisplay.h ├── Detector.cpp ├── Detector.h ├── DirectionalCoupler.cpp ├── DirectionalCoupler.h ├── DisplayRoutines.cpp ├── DisplayRoutines.h ├── Doc ├── 12_term_dg8saq.pdf ├── Background │ ├── 12_term_dg8saq.pdf │ ├── NA_Error_Models_and_Cal_Methods.pdf │ ├── TAPR3_Instruction_Manual_Issue_7.doc │ ├── TAPR3_Instruction_Manual_Issue_7.pdf │ ├── VNWA part3.pdf │ └── nanovna-sch.pdf ├── Everything S parameters.pdf ├── How to design a homemade male BNC calibration kit.pdf ├── How to measure on SOL calibration kits_REV1.pdf ├── How to measure very high impedances-Deutsch DG3OK.pdf ├── Measure quality of calibration standards.pdf ├── Measurement examples │ ├── 110MHz ceramic filter Polar.pdf │ ├── 110MHz ceramic filter.pdf │ ├── 433MHz resonator polar.pdf │ ├── 433MHz resonator.pdf │ ├── 51 ohm carbon resistor.pdf │ ├── RL series polar.pdf │ ├── cable polar.pdf │ └── cable.pdf ├── NA_Error_Models_and_Cal_Methods.pdf ├── PacificonSmithChart.pdf ├── S parameters explanation HamRadio_DG8SAQ_2013_English.pdf ├── Solving the one port model.docx ├── Some basic knowledge about a transmission line.pdf ├── T-Check.pdf ├── TRL calibration errors.pdf ├── VNA calibration method.pdf ├── VNA current bridge.asc ├── VNA current bridge.pdf ├── VNA dead bug style.jpg └── nanovna-sch.pdf ├── Form1.cpp ├── Form1.h ├── Form1.resx ├── Fourier.cpp ├── Fourier.h ├── InstrumentCal.cpp ├── InstrumentCal.h ├── InstrumentCal.resx ├── Light Blue Gradient.jpg ├── LoadConfigurationMenu.Image.png ├── MarkerEntry.cpp ├── MarkerEntry.h ├── MarkerEntry.resx ├── Mockup.cal ├── Mockup.cpp ├── Mockup.h ├── Mockup.resx ├── NumEntBox.cpp ├── NumEntBox.h ├── NumEntBox.resx ├── ReadMe.txt ├── SaveConfigurationMenu.Image.png ├── Serial.cpp ├── Serial.h ├── SerialPort.cpp ├── SerialPort.h ├── SerialPort.resx ├── Settings.h ├── SignalGenerator.cpp ├── SignalGenerator.h ├── SignalGenerator.resx ├── TAPR_VNA_Instruction_Manual_Issue_4_prelim.pdf ├── TDRSetupDialog.cpp ├── TDRSetupDialog.h ├── TDRSetupDialog.resx ├── TextEntry.cpp ├── TextEntry.h ├── TextEntry.resx ├── USB_EZ_interface.cpp ├── USB_EZ_interface.h ├── VNADebugOSComp.txt ├── VNAR3 Help.chm ├── VNAR3.sln ├── VNAR3.vcproj ├── VNAR3.vcxproj ├── VNAR3.vcxproj.filters ├── VNAR3.vcxproj_saved ├── VNAR4.4.zip ├── VNAR4.5.zip ├── VNAR4.zip ├── VNAdebug.csv ├── app.ico ├── app.rc ├── delete.png ├── icon1.ico ├── icon2.ico ├── icon3.ico ├── mycomplex.h ├── nanoVNA_1500.cal ├── nanoVNA_2100.cal ├── not_used ├── 5000Hz.mp3 ├── 500Hz stereo.mp3 ├── Detector.cpp ├── Detector.h ├── DirectionalCoupler.cpp ├── DirectionalCoupler.h ├── InstrumentCal.cpp ├── InstrumentCal.h ├── InstrumentCal.resx ├── fix_fft.c ├── fix_fft.h ├── refl_open.wav └── refl_through.wav ├── plus.png ├── printItem.Image.png ├── printPreviewItem.Image.png ├── red-not-ok-failure-symbol.png ├── resource.h ├── stdafx.cpp ├── stdafx.h └── taprlogo.gif /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows thumbnail cache files 2 | Thumbs.db 3 | ehthumbs.db 4 | ehthumbs_vista.db 5 | 6 | # Folder config file 7 | Desktop.ini 8 | 9 | # Recycle Bin used on file shares 10 | $RECYCLE.BIN/ 11 | 12 | # Windows Installer files 13 | *.cab 14 | *.msi 15 | *.msm 16 | *.msp 17 | *.log 18 | *.xml 19 | debug 20 | release 21 | 22 | # Windows shortcuts 23 | *.lnk 24 | 25 | # ========================= 26 | # Operating System Files 27 | # ========================= 28 | *.sdf 29 | *.chw 30 | VNAR3.opensdf 31 | serial_src.zip 32 | VNAdebug.txt 33 | VNACalDebug.txt 34 | *.wav 35 | NanoVNATee.csv 36 | *.csv 37 | nanoVNA.cal 38 | -------------------------------------------------------------------------------- /About.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "About.h" 3 | 4 | -------------------------------------------------------------------------------- /About.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | using namespace System; 23 | using namespace System::ComponentModel; 24 | using namespace System::Collections; 25 | using namespace System::Windows::Forms; 26 | using namespace System::Data; 27 | using namespace System::Drawing; 28 | 29 | 30 | 31 | namespace VNAR3 32 | { 33 | /// 34 | /// Summary for About 35 | /// 36 | /// WARNING: If you change the name of this class, you will need to change the 37 | /// 'Resource File Name' property for the managed resource compiler tool 38 | /// associated with all .resx files this class depends on. Otherwise, 39 | /// the designers will not be able to interact properly with localized 40 | /// resources associated with this form. 41 | /// 42 | 43 | /// About Status Box 44 | public ref class About : public System::Windows::Forms::Form 45 | { 46 | public: 47 | About(String^ vers) 48 | { 49 | InitializeComponent(); 50 | VersionLabel->Text = vers; 51 | } 52 | private: System::Windows::Forms::Label^ label4; 53 | private: System::Windows::Forms::Button^ LaunchBrowserButton; 54 | private: System::Windows::Forms::Panel^ panel1; 55 | private: System::Windows::Forms::Label^ label1; 56 | private: System::Windows::Forms::Label^ label2; 57 | private: System::Windows::Forms::Label^ label3; 58 | private: System::Windows::Forms::Label^ VersionLabel; 59 | private: System::Windows::Forms::Button^ button1; 60 | 61 | public: String^ vers; ///< VNAR software build number 62 | 63 | protected: 64 | ~About() 65 | { 66 | if(components) 67 | delete(components); 68 | }; 69 | 70 | private: 71 | /// 72 | /// Required designer variable. 73 | /// 74 | System::ComponentModel::Container^ components; 75 | 76 | /// 77 | /// Required method for Designer support - do not modify 78 | /// the contents of this method with the code editor. 79 | /// 80 | void InitializeComponent(void) 81 | { 82 | System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(About::typeid)); 83 | this->label1 = (gcnew System::Windows::Forms::Label()); 84 | this->label2 = (gcnew System::Windows::Forms::Label()); 85 | this->label3 = (gcnew System::Windows::Forms::Label()); 86 | this->VersionLabel = (gcnew System::Windows::Forms::Label()); 87 | this->button1 = (gcnew System::Windows::Forms::Button()); 88 | this->label4 = (gcnew System::Windows::Forms::Label()); 89 | this->LaunchBrowserButton = (gcnew System::Windows::Forms::Button()); 90 | this->panel1 = (gcnew System::Windows::Forms::Panel()); 91 | this->SuspendLayout(); 92 | // 93 | // label1 94 | // 95 | this->label1->BackColor = System::Drawing::Color::Transparent; 96 | this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 97 | static_cast(0))); 98 | this->label1->Location = System::Drawing::Point(40, 16); 99 | this->label1->Name = L"label1"; 100 | this->label1->Size = System::Drawing::Size(208, 24); 101 | this->label1->TabIndex = 0; 102 | this->label1->Text = L"TAPR Vector Network Analyzer"; 103 | this->label1->TextAlign = System::Drawing::ContentAlignment::TopCenter; 104 | // 105 | // label2 106 | // 107 | this->label2->BackColor = System::Drawing::Color::Transparent; 108 | this->label2->Image = (cli::safe_cast(resources->GetObject(L"label2.Image"))); 109 | this->label2->Location = System::Drawing::Point(112, 40); 110 | this->label2->Name = L"label2"; 111 | this->label2->Size = System::Drawing::Size(72, 72); 112 | this->label2->TabIndex = 1; 113 | // 114 | // label3 115 | // 116 | this->label3->BackColor = System::Drawing::Color::Transparent; 117 | this->label3->Location = System::Drawing::Point(24, 193); 118 | this->label3->Name = L"label3"; 119 | this->label3->Size = System::Drawing::Size(256, 32); 120 | this->label3->TabIndex = 2; 121 | this->label3->Text = L"Software Licensed Under GNU General Public License (GPL). See gpl.txt for details" 122 | L"."; 123 | this->label3->TextAlign = System::Drawing::ContentAlignment::TopCenter; 124 | // 125 | // VersionLabel 126 | // 127 | this->VersionLabel->BackColor = System::Drawing::Color::Transparent; 128 | this->VersionLabel->Location = System::Drawing::Point(24, 124); 129 | this->VersionLabel->Name = L"VersionLabel"; 130 | this->VersionLabel->Size = System::Drawing::Size(256, 55); 131 | this->VersionLabel->TabIndex = 3; 132 | this->VersionLabel->Text = L"Version: "; 133 | this->VersionLabel->TextAlign = System::Drawing::ContentAlignment::TopCenter; 134 | // 135 | // button1 136 | // 137 | this->button1->DialogResult = System::Windows::Forms::DialogResult::OK; 138 | this->button1->FlatStyle = System::Windows::Forms::FlatStyle::System; 139 | this->button1->Location = System::Drawing::Point(112, 234); 140 | this->button1->Name = L"button1"; 141 | this->button1->Size = System::Drawing::Size(75, 23); 142 | this->button1->TabIndex = 4; 143 | this->button1->Text = L"OK"; 144 | // 145 | // label4 146 | // 147 | this->label4->BackColor = System::Drawing::Color::Transparent; 148 | this->label4->Location = System::Drawing::Point(56, 312); 149 | this->label4->Name = L"label4"; 150 | this->label4->Size = System::Drawing::Size(192, 16); 151 | this->label4->TabIndex = 5; 152 | this->label4->Text = L"(Check TAPR website for updates)"; 153 | this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; 154 | // 155 | // LaunchBrowserButton 156 | // 157 | this->LaunchBrowserButton->FlatStyle = System::Windows::Forms::FlatStyle::System; 158 | this->LaunchBrowserButton->Location = System::Drawing::Point(92, 280); 159 | this->LaunchBrowserButton->Name = L"LaunchBrowserButton"; 160 | this->LaunchBrowserButton->Size = System::Drawing::Size(112, 24); 161 | this->LaunchBrowserButton->TabIndex = 6; 162 | this->LaunchBrowserButton->Text = L"Launch Browser"; 163 | this->LaunchBrowserButton->Click += gcnew System::EventHandler(this, &About::LaunchBrowserButton_Click); 164 | // 165 | // panel1 166 | // 167 | this->panel1->BackColor = System::Drawing::Color::Transparent; 168 | this->panel1->Location = System::Drawing::Point(32, 272); 169 | this->panel1->Name = L"panel1"; 170 | this->panel1->Size = System::Drawing::Size(248, 64); 171 | this->panel1->TabIndex = 7; 172 | // 173 | // About 174 | // 175 | this->AutoScaleBaseSize = System::Drawing::Size(5, 13); 176 | this->BackgroundImage = (cli::safe_cast(resources->GetObject(L"$this.BackgroundImage"))); 177 | this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch; 178 | this->ClientSize = System::Drawing::Size(304, 344); 179 | this->Controls->Add(this->LaunchBrowserButton); 180 | this->Controls->Add(this->label4); 181 | this->Controls->Add(this->button1); 182 | this->Controls->Add(this->VersionLabel); 183 | this->Controls->Add(this->label3); 184 | this->Controls->Add(this->label2); 185 | this->Controls->Add(this->label1); 186 | this->Controls->Add(this->panel1); 187 | this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; 188 | this->Name = L"About"; 189 | this->Text = L"About"; 190 | this->Load += gcnew System::EventHandler(this, &About::About_Load); 191 | this->ResumeLayout(false); 192 | 193 | } 194 | 195 | 196 | private: System::Void LaunchBrowserButton_Click(System::Object^ sender, System::EventArgs^ e) 197 | { 198 | System::Diagnostics::Process::Start("http://www.tapr.org/~n5eg/index_files/vna_library/current.htm"); 199 | } 200 | 201 | private: System::Void About_Load(System::Object^ sender, System::EventArgs^ e) { 202 | } 203 | }; 204 | } -------------------------------------------------------------------------------- /Arduino/si5351_nano.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com 3 | * All rights reserved. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * The software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Radio; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef SI5351_NANO_H 22 | #define SI5351_NANO_H 23 | 24 | 25 | #define SI5351_PLL_A 0 26 | #define SI5351_PLL_B 1 27 | 28 | #define SI5351_MULTISYNTH_DIV_4 4 29 | #define SI5351_MULTISYNTH_DIV_6 6 30 | #define SI5351_MULTISYNTH_DIV_8 8 31 | #define SI5351_R_DIV_1 (0<<4) 32 | #define SI5351_R_DIV_2 (1<<4) 33 | #define SI5351_R_DIV_4 (2<<4) 34 | #define SI5351_R_DIV_8 (3<<4) 35 | #define SI5351_R_DIV_16 (4<<4) 36 | #define SI5351_R_DIV_32 (5<<4) 37 | #define SI5351_R_DIV_64 (6<<4) 38 | #define SI5351_R_DIV_128 (7<<4) 39 | #define SI5351_DIVBY4 (3<<2) 40 | 41 | #define SI5351_REG_3_OUTPUT_ENABLE_CONTROL 3 42 | #define SI5351_REG_16_CLK0_CONTROL 16 43 | #define SI5351_REG_17_CLK1_CONTROL 17 44 | #define SI5351_REG_18_CLK2_CONTROL 18 45 | #define SI5351_REG_26_PLL_A 26 46 | #define SI5351_REG_34_PLL_B 34 47 | #define SI5351_REG_42_MULTISYNTH0 42 48 | #define SI5351_REG_50_MULTISYNTH1 50 49 | #define SI5351_REG_58_MULTISYNTH2 58 50 | 51 | #define SI5351_CLK_POWERDOWN (1<<7) 52 | #define SI5351_CLK_INTEGER_MODE (1<<6) 53 | #define SI5351_CLK_PLL_SELECT_B (1<<5) 54 | #define SI5351_CLK_INVERT (1<<4) 55 | 56 | #define SI5351_CLK_INPUT_MASK (3<<2) 57 | #define SI5351_CLK_INPUT_XTAL (0<<2) 58 | #define SI5351_CLK_INPUT_CLKIN (1<<2) 59 | #define SI5351_CLK_INPUT_MULTISYNTH_0_4 (2<<2) 60 | #define SI5351_CLK_INPUT_MULTISYNTH_N (3<<2) 61 | 62 | #define SI5351_CLK_DRIVE_STRENGTH_MASK (3<<0) 63 | #define SI5351_CLK_DRIVE_STRENGTH_2MA (0<<0) 64 | #define SI5351_CLK_DRIVE_STRENGTH_4MA (1<<0) 65 | #define SI5351_CLK_DRIVE_STRENGTH_6MA (2<<0) 66 | #define SI5351_CLK_DRIVE_STRENGTH_8MA (3<<0) 67 | 68 | 69 | #define SI5351_REG_177_PLL_RESET 177 70 | #define SI5351_PLL_RESET_B (1<<7) 71 | #define SI5351_PLL_RESET_A (1<<5) 72 | 73 | #define SI5351_REG_183_CRYSTAL_LOAD 183 74 | #define SI5351_CRYSTAL_LOAD_6PF (1<<6) 75 | #define SI5351_CRYSTAL_LOAD_8PF (2<<6) 76 | #define SI5351_CRYSTAL_LOAD_10PF (3<<6) 77 | 78 | #define SI5351_CRYSTAL_FREQ_25MHZ 25000000 79 | 80 | void si5351_init(void); 81 | 82 | void si5351_setupPLL(uint8_t pll, /* SI5351_PLL_A or SI5351_PLL_B */ 83 | uint8_t mult, 84 | uint32_t num, 85 | uint32_t denom); 86 | void si5351_setupMultisynth(uint8_t output, 87 | uint8_t pllSource, 88 | uint32_t div, 89 | uint32_t num, 90 | uint32_t denom, 91 | uint32_t rdiv, 92 | uint8_t drive_strength); 93 | 94 | void si5351_set_frequency(int channel, uint32_t freq, uint8_t drive_strength); 95 | int si5351_set_frequency_with_offset(uint32_t freq, int offset, uint8_t drive_strength); 96 | 97 | void si5351_disable_output(void); 98 | void si5351_enable_output(void); 99 | #endif 100 | -------------------------------------------------------------------------------- /AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | using namespace System; 4 | using namespace System::Reflection; 5 | using namespace System::Runtime::CompilerServices; 6 | using namespace System::Runtime::InteropServices; 7 | using namespace System::Security::Permissions; 8 | 9 | // 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | // 14 | [assembly:AssemblyTitleAttribute("")]; 15 | [assembly:AssemblyDescriptionAttribute("")]; 16 | [assembly:AssemblyConfigurationAttribute("Ver 3")]; 17 | [assembly:AssemblyCompanyAttribute("TAPR")]; 18 | [assembly:AssemblyProductAttribute("VNA")]; 19 | [assembly:AssemblyCopyrightAttribute("2011")]; 20 | [assembly:AssemblyTrademarkAttribute("")]; 21 | [assembly:AssemblyCultureAttribute("")]; 22 | 23 | // 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the value or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | 34 | [assembly:AssemblyVersionAttribute("3.3.*")]; 35 | 36 | [assembly:ComVisible(false)]; 37 | 38 | [assembly:CLSCompliantAttribute(true)]; 39 | 40 | [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; 41 | 42 | -------------------------------------------------------------------------------- /AudioDevice.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "AudioDevice.h" 3 | 4 | -------------------------------------------------------------------------------- /AudioDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdafx.h" 3 | #using 4 | #using 5 | //#using 6 | 7 | //#include 8 | //#include 9 | #pragma comment(lib,"winmm.lib") 10 | 11 | namespace VNAR3 { 12 | 13 | using namespace System; 14 | using namespace System::ComponentModel; 15 | using namespace System::Collections; 16 | using namespace System::Windows::Forms; 17 | using namespace System::Data; 18 | using namespace System::Drawing; 19 | 20 | /// 21 | /// Summary for AudioDevice 22 | /// 23 | public ref class AudioDevice : public System::Windows::Forms::Form 24 | { 25 | public: 26 | AudioDevice(void) 27 | { 28 | InitializeComponent(); 29 | // 30 | //TODO: Add the constructor code here 31 | // 32 | } 33 | 34 | protected: 35 | /// 36 | /// Clean up any resources being used. 37 | /// 38 | ~AudioDevice() 39 | { 40 | if (components) 41 | { 42 | delete components; 43 | } 44 | } 45 | private: System::Windows::Forms::ComboBox^ AudioInputDevices; 46 | protected: 47 | 48 | protected: 49 | 50 | private: 51 | /// 52 | /// Required designer variable. 53 | /// 54 | System::ComponentModel::Container ^components; 55 | 56 | #pragma region Windows Form Designer generated code 57 | /// 58 | /// Required method for Designer support - do not modify 59 | /// the contents of this method with the code editor. 60 | /// 61 | void InitializeComponent(void) 62 | { 63 | this->AudioInputDevices = (gcnew System::Windows::Forms::ComboBox()); 64 | this->SuspendLayout(); 65 | // 66 | // AudioInputDevices 67 | // 68 | this->AudioInputDevices->FormattingEnabled = true; 69 | this->AudioInputDevices->Items->AddRange(gcnew cli::array< System::Object^ >(2) {L"Item 1", L"Item 2"}); 70 | this->AudioInputDevices->Location = System::Drawing::Point(35, 20); 71 | this->AudioInputDevices->Name = L"AudioInputDevices"; 72 | this->AudioInputDevices->Size = System::Drawing::Size(155, 21); 73 | this->AudioInputDevices->TabIndex = 0; 74 | // 75 | // AudioDevice 76 | // 77 | this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 78 | this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 79 | this->ClientSize = System::Drawing::Size(284, 261); 80 | this->Controls->Add(this->AudioInputDevices); 81 | this->Name = L"AudioDevice"; 82 | this->Text = L"AudioDevice"; 83 | this->ResumeLayout(false); 84 | 85 | } 86 | #pragma endregion 87 | 88 | private: int FillDevices() 89 | { 90 | // CComboBox *pBox=(CComboBox*)GetDlgItem(IDC_DEVICES); 91 | System::Windows::Forms::ComboBox^ pBox=this->AudioInputDevices; 92 | int nDevices,nC1; 93 | WAVEINCAPS stWIC={0}; 94 | MMRESULT mRes; 95 | 96 | //pBox->Clear(); 97 | nDevices=waveInGetNumDevs(); 98 | 99 | for(nC1=0;nC1Items->Add((System::Object^) stWIC.szPname); 105 | // else 106 | //StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__); 107 | } 108 | if(pBox->Items->Count) 109 | { 110 | //pBox->SetCurSel(0); 111 | //OnCbnSelchangeDevices(); 112 | } 113 | return nDevices; 114 | } 115 | }; 116 | } 117 | -------------------------------------------------------------------------------- /AudioDevice.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AudioInput.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef AUDIOINPUT_H 3 | #define AUDIOINPUT_H 4 | #define WAVEHDRBUFFER 4 5 | 6 | #define MAXNUMPTS 2*192*10 // 192kHz 7 | extern int SAMPPERMS; 8 | // For debugging 9 | //#define NUMPTS 2*SAMP // stereo * 10 * SAMP 10 | 11 | //extern float decoded[1024][2]; 12 | extern int audio_delay; 13 | //extern volatile float gamma[4]; 14 | 15 | extern int sampleRate; 16 | extern int IFREQ; 17 | extern volatile double audioRefLevel; 18 | extern double audio_volume_reflection; 19 | extern double audio_phase_reflection; 20 | extern double audio_volume_transmission; 21 | extern double audio_phase_transmission; 22 | extern bool audio_simulation; 23 | extern unsigned int selectedAudio; 24 | extern int OpenAudio (void); 25 | extern void ArmAudio(int pM, System::IO::Ports::SerialPort^ port); 26 | void MarkFrequency(unsigned long freq); 27 | void MarkFrequency(void); 28 | extern bool RetreiveData(int i, int duration, float& m, float& p, float& tm, float& tp, float& r, unsigned long& fr,int avSamp); 29 | extern void StartAudioSimulation(int mode, int numPoints, int duration, __int64 startF, __int64 stepF,int cable_before, int cable_after, int direction, int r, int c, int sc, int l, float n); 30 | extern void SetAudioPower(int power); 31 | extern void DumpMeasurement(System::String ^); 32 | extern void GetMixerInfo(); 33 | extern int MixerGetVolume(void); 34 | extern void MixerSetVolume(int); 35 | 36 | 37 | #define SUMTYPE float 38 | 39 | typedef struct measurementType { 40 | float magnitude; 41 | float phase; 42 | float reference; 43 | float delta; 44 | unsigned long freq; 45 | float dcr; 46 | float dcs; 47 | int read; 48 | SUMTYPE samp_s; 49 | SUMTYPE samp_c; 50 | SUMTYPE ref_s; 51 | SUMTYPE ref_c; 52 | int force; 53 | int average; 54 | } measurementType; 55 | 56 | 57 | // Max gridsize = 1024, 1040 gives some extra data slots. 100 ms measurement means more then 200 samples point 58 | #define MAX_MEASUREMENTS 1040*300 59 | extern volatile measurementType measured[MAX_MEASUREMENTS]; 60 | extern volatile int measurementIndex[1100]; 61 | extern volatile int lastMeasurement; 62 | extern volatile measurementType actualMeasurement; 63 | extern volatile int nextDecoded; 64 | 65 | #endif -------------------------------------------------------------------------------- /Blue Gradient.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Blue Gradient.jpg -------------------------------------------------------------------------------- /Calibration.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Calibration.h" 3 | 4 | 5 | -------------------------------------------------------------------------------- /Constants.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010, Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | #pragma once 20 | 21 | // Constants.h 22 | // 23 | // 07-25-04 TCM Original 24 | // 05-10-05 TCM Delete VNA_XTAL_CONST and refereces to it. This is now 25 | // handled by an Internal Crystal Calibration function. 26 | // 03-19-06 TCM Add constants for the S21 measurement level offsets for 27 | // Mid and Lo levels. 28 | // 02-27-07 TCM Add constants for ExpectedValue mode, redefine glitch 29 | // constants. 30 | // 05-26-07 TCM Add constants for epsilon (allowed error before applying median 31 | // filter). 32 | // 06-08-2007 TCM Add constants for phase lead caused by 2 highpass poles in the 33 | // modamp AC coupling circuit. 34 | // 09-30-2007 TCM Add TargetPhLoMAG constant - to measure S21 phase with reduced generator 35 | // output level. This avoids rx preamp overload of the phase detector on 36 | // 'hot' rx signals. 37 | // 38 | // Constants for the VNA instrument + others. 39 | // 40 | 41 | #include 42 | 43 | ///\def Converts radians to degrees 44 | #define RAD2DEGR 180.0/Math::PI 45 | ///\def Converts degrees to radians 46 | #define DEGR2RAD Math::PI/180.0 47 | 48 | // Constants related to the actual numeric VNA instrument readings 49 | // These are used until the Detector Calibration is run or loaded from a file. 50 | //#define MAXREFLMAGNITUDE 2100 // temporary until Detector Calibration is run, 51 | // observed on S/N 1 52 | #define MAXTRANMAGNITUDE 3800 // temporary until Detector Calibration is run, 53 | // observed on S/N 1 54 | 55 | // Constants related to calibration grid (both instrument calibration and fixture calibration) 56 | ///\def Maximum Calibration Frequency 57 | #define MAXCALFREQ 300000000 58 | ///\def Minimum Calibration Frequency 59 | #define MINCALFREQ 400000 60 | ///\def Number of Calibration Points 61 | #define NUMCALPTS 1024.0 62 | ///\def Size of Phase Calibration Grid 63 | #define PHASECALGRIDSIZE 1024 64 | ///\def Error size for double-precision rank-order median filter 65 | #define EPSILON 0.005 66 | 67 | // def Maximum DDS output level DAC control word 68 | //#define MAX_DDS_LEVEL 0xFFF // Multiplier for DDS Amplitude, unsigned 12-bit int. Maximum = 0xFFF 69 | 70 | // Set the 0 db level to 2.5 dB below the maximum possible level 71 | //#define MAX_DDS_LEVEL 0xC00 // Multiplier for DDS Amplitude, unsigned 12-bit int. Maximum = 0xFFF 72 | 73 | ///\ DDS Maximum Level Control 74 | // Set the ~0 db level to 3 dB below the maximum possible level 75 | #define MAX_DDS_LEVEL 0xB4F // Multiplier for DDS Amplitude, unsigned 12-bit int. Maximum = 0xFFF 76 | 77 | // this constant is not dependent on MAX_DDS_LEVEL since it references the Q-DAC 78 | #define QDAC_ZERODBM 0xAAA //0xAAA // 0 dbm for Q-DAC ref level 79 | //0xFFF // about +3.5 dB too hot for Q-DAC 80 | 81 | // constants used by Time Domain display 82 | //#define TDRTIMETICK 4.167 // 4.167 nanoseconds per TDR time tick 83 | #define TDRTIMETICK ((1.0/(double)VNA->GetMaxFreq())*1e9) 84 | 85 | #define METERSPERNSEC 0.2998 // meters per nanosecond - free space 86 | #define FEETPERNSEC 0.9836 // feet per nanosecond - free space 87 | 88 | 89 | // constants that set the Mid and Lo levels for the target to measure S21 magnitude 90 | #define TARGETMIDMAG 17 91 | #define TARGETLOMAG 34 92 | 93 | // constant - sets Lo output level for the target to measure S21 phase with non-overloading signals 94 | #define TARGETPHLOMAG 20 95 | 96 | // constant: sample-to-sample deviation that constitutes a glitch (bad reading) 97 | #define GLITCHSIZE 30 98 | 99 | // Calling ExpectedValue with mode==true tests for phase detector saturation 100 | #define PHASEMODE true 101 | #define AMPLMODE false 102 | // Should normally only define one of either FASTGLITCH or SLOWGLITCH as true 103 | //#define FASTGLITCH // use FAST glitch correction algorithm 104 | //#define SLOWGLITCH // use SLOW glitch correction algorithm 105 | 106 | /// Array index enumeration for ReflectionMeasurements (in InstrumentCal and DisplayRoutines) 107 | enum ReflMeas { MagQ, PhaseI, PhaseQ }; ///< Array index for storing reflection measurements 108 | 109 | #define HIGHPASSPOLE (0) // Phase lead caused by 2 highpass 110 | // poles of AC coupling capacitors in the ModAmp. 111 | // 6.2 degrees at 200 Khz. 112 | 113 | // #define SHORT_RANGE 3800 114 | #define SHORT_RANGE 32000 115 | 116 | #define MAX_PHASE 181.0 117 | #define MIN_PHASE -181.0 118 | #define NormalizePhase(X) { while ((X) > 180.0) (X) -= 360.; while ((X) < -180.0) (X) += 360.0; } 119 | #define PHASE2SHORT(X) (short)(((X) - MIN_PHASE) * SHORT_RANGE / (MAX_PHASE - MIN_PHASE)) 120 | #define SHORT2PHASE(X) (((double)(X) * (MAX_PHASE - MIN_PHASE) / SHORT_RANGE ) + MIN_PHASE ) 121 | 122 | #define MAX_DB +30.0 123 | #define MIN_DB -180.0 124 | #define DB2SHORT(X) (short)((X)>MIN_DB?((X) - MIN_DB) * SHORT_RANGE / (MAX_DB - MIN_DB):0) 125 | #define SHORT2DB(X) (((double)(X) * (MAX_DB - MIN_DB) / SHORT_RANGE ) + MIN_DB ) 126 | //#define MAXSAMPLEVALUE ((int)((((unsigned long)1)<<(VALIDSAMPLEBITS - 1))-8)) 127 | #define MAXSAMPLEVALUE 0.9999999 128 | // #define MAXSAMPLEVALUE ((int)((((unsigned long)1)<<(15))-8)) 129 | 130 | #define todb(X) (20.0f * log10 ((float(X)/(float)MAXSAMPLEVALUE))) 131 | #define toLin(X) ( pow((float)10,(float)(X/20.0)) * (float) MAXSAMPLEVALUE) 132 | 133 | 134 | #define CALSUM 7 //number of measurements to average for calibration 135 | -------------------------------------------------------------------------------- /CursorStatus.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CursorStatus.h" 3 | 4 | -------------------------------------------------------------------------------- /CursorStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | #pragma once 20 | 21 | using namespace System; 22 | using namespace System::ComponentModel; 23 | using namespace System::Collections; 24 | using namespace System::Windows::Forms; 25 | using namespace System::Data; 26 | using namespace System::Drawing; 27 | 28 | 29 | namespace VNAR3 30 | { 31 | 32 | /// 33 | /// Summary for CursorStatus 34 | /// 35 | /// WARNING: If you change the name of this class, you will need to change the 36 | /// 'Resource File Name' property for the managed resource compiler tool 37 | /// associated with all .resx files this class depends on. Otherwise, 38 | /// the designers will not be able to interact properly with localized 39 | /// resources associated with this form. 40 | /// 41 | 42 | /// Display Mouse Coordinates Status 43 | public ref class CursorStatus : public System::Windows::Forms::Form 44 | { 45 | public: 46 | CursorStatus(String^ line1, String^ line2, String^ line3) 47 | { 48 | InitializeComponent(); 49 | label1->Text = line1; 50 | label2->Text = line2; 51 | label3->Text = line3; 52 | } 53 | 54 | protected: 55 | ~CursorStatus() 56 | { 57 | if(components) 58 | delete(components); 59 | } 60 | 61 | private: System::Windows::Forms::Panel^ panel1; 62 | private: System::Windows::Forms::Label^ label1; 63 | private: System::Windows::Forms::Label^ label2; 64 | private: System::Windows::Forms::Label^ label3; 65 | private: System::Windows::Forms::Label^ label4; 66 | 67 | private: 68 | /// 69 | /// Required designer variable. 70 | /// 71 | System::ComponentModel::Container^ components; 72 | 73 | /// 74 | /// Required method for Designer support - do not modify 75 | /// the contents of this method with the code editor. 76 | /// 77 | void InitializeComponent(void) 78 | { 79 | this->panel1 = (gcnew System::Windows::Forms::Panel()); 80 | this->label4 = (gcnew System::Windows::Forms::Label()); 81 | this->label3 = (gcnew System::Windows::Forms::Label()); 82 | this->label2 = (gcnew System::Windows::Forms::Label()); 83 | this->label1 = (gcnew System::Windows::Forms::Label()); 84 | this->panel1->SuspendLayout(); 85 | this->SuspendLayout(); 86 | // 87 | // panel1 88 | // 89 | this->panel1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; 90 | this->panel1->Controls->Add(this->label4); 91 | this->panel1->Controls->Add(this->label3); 92 | this->panel1->Controls->Add(this->label2); 93 | this->panel1->Controls->Add(this->label1); 94 | this->panel1->Location = System::Drawing::Point(0, 0); 95 | this->panel1->Name = L"panel1"; 96 | this->panel1->Size = System::Drawing::Size(232, 64); 97 | this->panel1->TabIndex = 0; 98 | // 99 | // label4 100 | // 101 | this->label4->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 102 | static_cast(0))); 103 | this->label4->ForeColor = System::Drawing::SystemColors::ControlText; 104 | this->label4->Location = System::Drawing::Point(64, 0); 105 | this->label4->Name = L"label4"; 106 | this->label4->Size = System::Drawing::Size(112, 16); 107 | this->label4->TabIndex = 3; 108 | this->label4->Text = L"Mouse Coordinates:"; 109 | this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; 110 | // 111 | // label3 112 | // 113 | this->label3->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 114 | static_cast(0))); 115 | this->label3->ForeColor = System::Drawing::SystemColors::ControlText; 116 | this->label3->Location = System::Drawing::Point(0, 48); 117 | this->label3->Name = L"label3"; 118 | this->label3->Size = System::Drawing::Size(230, 12); 119 | this->label3->TabIndex = 2; 120 | this->label3->Text = L"label3"; 121 | this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; 122 | // 123 | // label2 124 | // 125 | this->label2->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 126 | static_cast(0))); 127 | this->label2->ForeColor = System::Drawing::SystemColors::ControlText; 128 | this->label2->Location = System::Drawing::Point(0, 32); 129 | this->label2->Name = L"label2"; 130 | this->label2->Size = System::Drawing::Size(230, 12); 131 | this->label2->TabIndex = 1; 132 | this->label2->Text = L"label2"; 133 | this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; 134 | // 135 | // label1 136 | // 137 | this->label1->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 138 | static_cast(0))); 139 | this->label1->ForeColor = System::Drawing::SystemColors::ControlText; 140 | this->label1->Location = System::Drawing::Point(0, 16); 141 | this->label1->Name = L"label1"; 142 | this->label1->Size = System::Drawing::Size(230, 12); 143 | this->label1->TabIndex = 0; 144 | this->label1->Text = L"label1"; 145 | this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; 146 | // 147 | // CursorStatus 148 | // 149 | this->AutoScaleBaseSize = System::Drawing::Size(6, 14); 150 | this->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(255)), static_cast(static_cast(255)), 151 | static_cast(static_cast(192))); 152 | this->ClientSize = System::Drawing::Size(232, 64); 153 | this->ControlBox = false; 154 | this->Controls->Add(this->panel1); 155 | this->Font = (gcnew System::Drawing::Font(L"Arial", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 156 | static_cast(0))); 157 | this->ForeColor = System::Drawing::Color::Transparent; 158 | this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None; 159 | this->Location = System::Drawing::Point(15, 15); 160 | this->MaximizeBox = false; 161 | this->MinimizeBox = false; 162 | this->Name = L"CursorStatus"; 163 | this->Opacity = 0.93; 164 | this->ShowInTaskbar = false; 165 | this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide; 166 | this->StartPosition = System::Windows::Forms::FormStartPosition::Manual; 167 | this->Text = L"CursorStatus"; 168 | this->panel1->ResumeLayout(false); 169 | this->ResumeLayout(false); 170 | 171 | } 172 | 173 | 174 | }; 175 | } -------------------------------------------------------------------------------- /CursorStatus.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DataDisplay.cpp: -------------------------------------------------------------------------------- 1 | 2 | // DataDisplay.cpp -- Data display for single-frequency points; 3 | // used for debugging. 4 | 5 | #include "stdafx.h" 6 | #using 7 | #include "DataDisplay.h" 8 | 9 | DataDisplay::DataDisplay(VNA_RXBUFFER *RxData) 10 | { 11 | // Initialize the box 12 | Text = S"Data Point Display"; 13 | FormBorderStyle = FormBorderStyle::Fixed3D; 14 | Size = System::Drawing::Size(500,600); 15 | 16 | // Set up the labels 17 | REVMQ = new Label(); 18 | REVMQ->Size = System::Drawing::Size(300, 20); 19 | REVMQ->Location = Point(20, 30); 20 | REVMQ->Text = "Reflected Mag Q-ref "; 21 | d1 = new Label(); 22 | d1->Size = System::Drawing::Size(80, 20); 23 | d1->Location = Point(320, 30); 24 | d1->Text = Convert::ToString(RxData->ReflMQ); 25 | 26 | REVPQ = new Label(); 27 | REVPQ->Size = System::Drawing::Size(300, 20); 28 | REVPQ->Location = Point(20, 60); 29 | REVPQ->Text = "Reflected Phs Q-ref "; 30 | d2 = new Label(); 31 | d2->Size = System::Drawing::Size(80, 20); 32 | d2->Location = Point(320, 60); 33 | d2->Text = Convert::ToString(RxData->ReflPQ); 34 | 35 | VREF1 = new Label(); 36 | VREF1->Size = System::Drawing::Size(300, 20); 37 | VREF1->Location = Point(20, 90); 38 | VREF1->Text = "Reference Voltage 1 "; 39 | d3 = new Label(); 40 | d3->Size = System::Drawing::Size(80, 20); 41 | d3->Location = Point(320, 90); 42 | d3->Text = Convert::ToString(RxData->Vref1); 43 | 44 | FWDMQ = new Label(); 45 | FWDMQ->Size = System::Drawing::Size(300, 20); 46 | FWDMQ->Location = Point(20, 120); 47 | FWDMQ->Text = "Forward Mag Q-ref "; 48 | d4 = new Label(); 49 | d4->Size = System::Drawing::Size(80, 20); 50 | d4->Location = Point(320, 120); 51 | d4->Text = Convert::ToString(RxData->FwdMQ); 52 | 53 | FWDPQ = new Label(); 54 | FWDPQ->Size = System::Drawing::Size(300, 20); 55 | FWDPQ->Location = Point(20, 150); 56 | FWDPQ->Text = "Forward Phs Q-ref "; 57 | d5 = new Label(); 58 | d5->Size = System::Drawing::Size(80, 20); 59 | d5->Location = Point(320, 150); 60 | d5->Text = Convert::ToString(RxData->FwdPQ); 61 | 62 | REVMI = new Label(); 63 | REVMI->Size = System::Drawing::Size(300, 20); 64 | REVMI->Location = Point(20, 180); 65 | REVMI->Text = "Reflected Mag I-ref "; 66 | d6 = new Label(); 67 | d6->Size = System::Drawing::Size(80, 20); 68 | d6->Location = Point(320, 180); 69 | d6->Text = Convert::ToString(RxData->ReflMI); 70 | 71 | REVPI = new Label(); 72 | REVPI->Size = System::Drawing::Size(300, 20); 73 | REVPI->Location = Point(20, 210); 74 | REVPI->Text = "Reflected Phs I-ref "; 75 | d7 = new Label(); 76 | d7->Size = System::Drawing::Size(80, 20); 77 | d7->Location = Point(320, 210); 78 | d7->Text = Convert::ToString(RxData->ReflPI); 79 | 80 | FWDMI = new Label(); 81 | FWDMI->Size = System::Drawing::Size(300, 20); 82 | FWDMI->Location = Point(20, 240); 83 | FWDMI->Text = "Forward Mag I-ref "; 84 | d8 = new Label(); 85 | d8->Size = System::Drawing::Size(80, 20); 86 | d8->Location = Point(320, 240); 87 | d8->Text = Convert::ToString(RxData->FwdMI); 88 | 89 | FWDPI = new Label(); 90 | FWDPI->Size = System::Drawing::Size(300, 20); 91 | FWDPI->Location = Point(20, 270); 92 | FWDPI->Text = "Forward Phs I-ref "; 93 | d9 = new Label(); 94 | d9->Size = System::Drawing::Size(80, 20); 95 | d9->Location = Point(320, 270); 96 | d9->Text = Convert::ToString(RxData->FwdPI); 97 | 98 | HEAD = new Label(); 99 | HEAD->Size = System::Drawing::Size(300, 20); 100 | HEAD->Location = Point(20, 300); 101 | HEAD->Text = "Header for buffer "; 102 | d0 = new Label(); 103 | d0->Size = System::Drawing::Size(80, 20); 104 | d0->Location = Point(320, 300); 105 | d0->Text = Convert::ToString(RxData->Header); 106 | 107 | VREF2 = new Label(); 108 | VREF2->Size = System::Drawing::Size(300, 20); 109 | VREF2->Location = Point(20, 330); 110 | VREF2->Text = "Reference Voltage 2 "; 111 | d11 = new Label(); 112 | d11->Size = System::Drawing::Size(100, 20); 113 | d11->Location = Point(320, 330); 114 | d11->Text = Convert::ToString(RxData->Vref2); 115 | 116 | FREQ = new Label(); 117 | FREQ->Size = System::Drawing::Size(300, 20); 118 | FREQ->Location = Point(20, 360); 119 | FREQ->Text = "Frequency word "; 120 | d10 = new Label(); 121 | d10->Size = System::Drawing::Size(100, 20); 122 | d10->Location = Point(320, 360); 123 | d10->Text = Convert::ToString(RxData->Freq); 124 | 125 | 126 | OKButton = new Button(); 127 | OKButton->Text = S"OK"; 128 | OKButton->Name = "OKButton"; 129 | OKButton->Location = Point(200,500); 130 | OKButton->DialogResult = DialogResult::OK; 131 | 132 | AcceptButton = OKButton; 133 | Controls->Add(REVMQ); 134 | Controls->Add(REVPQ); 135 | Controls->Add(VREF1); 136 | Controls->Add(FWDMQ); 137 | Controls->Add(FWDPQ); 138 | Controls->Add(REVMI); 139 | Controls->Add(REVPI); 140 | Controls->Add(FWDMI); 141 | Controls->Add(FWDPI); 142 | Controls->Add(HEAD); 143 | Controls->Add(FREQ); 144 | Controls->Add(VREF2); 145 | Controls->Add(d1); 146 | Controls->Add(d2); 147 | Controls->Add(d3); 148 | Controls->Add(d4); 149 | Controls->Add(d5); 150 | Controls->Add(d6); 151 | Controls->Add(d7); 152 | Controls->Add(d8); 153 | Controls->Add(d9); 154 | Controls->Add(d0); 155 | Controls->Add(d10); 156 | Controls->Add(d11); 157 | Controls->Add(OKButton); 158 | 159 | } 160 | 161 | -------------------------------------------------------------------------------- /DataDisplay.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | // DataDisplay.h -- contains the VNA BUFFER typedefs. 23 | // Defines the format of the USB packets to and from the VNA 24 | // 25 | // Update: 06-04-04 TCM Add new RX buffer type (for fast reads) and REPLYTYPE defines 26 | // Update: 10-22-04 TCM Add support for extended dynamic range of S21 magnitude. 27 | // Break QDAC level into Hi and Lo, add S21M HI and S21M Lo types to 28 | // both FAST and FULL responses. Reduce FAST response from 5 to 4 29 | // frequencies per packet. 30 | // Update: 03-18-06 TCM Change Receive slow buffer to include MID-Level amplitude reading 31 | // and Transmit slow buffer to add value of Mid level. Change 32 | // IntegrationCount to MeasurementDelayTime. (Integration is done 33 | // by host in later versions). Target code needs to change to 34 | // accomodate these buffer revisions. 35 | // 10-14-2007 TCM Define MeasurementSet to encalsulate one set of raw measurements at one 36 | // point (one discrete frequency). 37 | 38 | 39 | #include "stdafx.h" 40 | 41 | // FORMAT of the FULL Response: 42 | // 43 | // Offset Word (LSB first, MSB second) Condition 44 | // ------ ------------------------------- -------------- 45 | // 0000 0100 Valid frame 46 | // 0002 S11MI S11PI VREF1 S21MIHi S21PI VREF2 Ref=I, TX=REFL 47 | // 000E S11MI S11PI Ref=I, TX=FWD 48 | // 0012 S11MQ S11PQ VREF1 S21MQHi S21PQ VREF2 Ref=Q, TX=REFL 49 | // 001E S11MQ S11PQ Ref=Q, TX=FWD 50 | // 0022 S21MQLo 51 | // 0024 S21MQMid 52 | // 0026 remainder of frame all zeros 53 | 54 | #define VNA_REPLYTYPE_FULL 0x0 // Full response buffer (complete data set) 55 | #define VNA_REPLYTYPE_FAST 0x1 // Fast response buffer (5 readings) 56 | 57 | /// Format of Received USB Packet from VNA for Slow mode 58 | typedef struct _VNA_RXBUFFER { 59 | ///\struct Received USB Packet from VNA for slow mode 60 | unsigned short Header; ///< Received Packet Type and Status 61 | unsigned short ReflMI; ///< Reflection Magnitude I 62 | unsigned short ReflPI; ///< Reflection Phase I 63 | unsigned short Vref1; ///< Voltage Reference 1 64 | unsigned short TranMI; ///< Transmission Magnitude I 65 | unsigned short TranPI; ///< Transmission Phase I 66 | unsigned short Vref2; ///< Voltage Reference 2 67 | unsigned short FwdMI; ///< Forward Magnitude I 68 | unsigned short FwdPI; ///< Forward Phase I 69 | unsigned short ReflMQ; ///< Reflection Magnitude Q 70 | unsigned short ReflPQ; ///< Reflection Phase Q 71 | unsigned short Vref1a; ///< Voltage Reference 1 72 | unsigned short TranMQHi; ///< Transmission Magnitude Q Hi count received 73 | unsigned short TranPQ; ///< Transmission Phase Q 74 | unsigned short Vref2a; ///< Voltage Reference 2 75 | unsigned short FwdMQ; ///< Forward Magnitude Q 76 | unsigned short FwdPQ; ///< Forward Phase Q 77 | unsigned short TranMQ; ///< Transmission Magnitude Q Lo count received 78 | unsigned short TranMQMid; ///< Transmission Magnitude Q Mid count received - only used for SLOW reads 79 | unsigned short TranPILow; ///< Transmission Phase I with low reference level 80 | unsigned short TranPQLow; ///< Transmission Phase Q with low reference level 81 | unsigned long Freq; 82 | unsigned short fill1, fill2, fill3, fill4, fill5; ///< filler (unused locations in buffer) 83 | unsigned short fill6, fill7, fill8, fill9, fill10; ///< filler 84 | unsigned short check; ///< filler 85 | } VNA_RXBUFFER; 86 | 87 | /// Format of Transmit USB Packet sent to VNA 88 | typedef struct _VNA_TXBUFFER { 89 | __int64 TxAccum; ///< 8 byte transmit DDS accumulator value (we use 6 LSBytes) 90 | unsigned short IDAClevelHi; ///< 2 byte I-DAC (Transmit Hi) level. Changed name in VNAR3 91 | unsigned short QDAClevel; ///< 2 byte Q-DAC (Reference) level 92 | unsigned short ReplyType; ///< Rx buffer reply type requested (VNA_REPLYTYPE_FULL or FAST) 93 | unsigned short MeasureDelay; ///< Instrument measurement settling time (VNAR 1.5) 94 | __int64 Freq2; ///< TxAccumulator values for multi-freq read frequency #2 (ReplyType > 0) 95 | __int64 Freq3; ///< TxAccumulator values for multi-freq read frequency #3 (ReplyType > 0) 96 | __int64 Freq4; ///< TxAccumulator values for multi-freq read frequency #4 (ReplyType > 0) 97 | __int64 dummy; // placeholder for Freq5 (removed to provide room for 3-Mag levels). 98 | 99 | unsigned short IDAClevelLo; ///< 2 byte I-DAC (Transmit Lo) level. New for VNAR3 100 | unsigned short IDAClevelMid; ///< 2 byte I-DAC (Transmit Mid) level. New for VNAR 1.5, only SLOW reads 101 | unsigned short IDAClevelPhLow; //< 2-byte I-DAC level for lower level phase measurements 102 | unsigned short fill1; 103 | unsigned short dummya, dummy0, dummy1, dummy2; 104 | } VNA_TXBUFFER; 105 | 106 | 107 | /// Format of Received USB Packet from VNA for Fast mode 108 | typedef struct _VNA_RXBUFF_FAST { // Gives 4 reading sets per USB packet 109 | unsigned short Header; 110 | unsigned short ReflMQ1, ReflPI1, ReflPQ1, TranMQ1Hi, TranPI1, TranPQ1, TranMQ1Lo, TranMQ1Mid; 111 | unsigned short ReflMQ2, ReflPI2, ReflPQ2, TranMQ2Hi, TranPI2, TranPQ2, TranMQ2Lo, TranMQ2Mid; 112 | unsigned short ReflMQ3, ReflPI3, ReflPQ3, TranMQ3Hi, TranPI3, TranPQ3, TranMQ3Lo, TranMQ3Mid; 113 | unsigned short ReflMQ4, ReflPI4, ReflPQ4, TranMQ4Hi, TranPI4Mix, TranPQ4Mix, TranMQ4LoMix; 114 | // The 'Mix' form of the last 3 parameters uses the highest nibble of each to Hold TranMQ4Mid 115 | // which has to be bit-mask removed and reassembled from the words. The actual value 116 | // of TranPI4, TranPQ4, and TranMQ4Lo are the lower 12 bits of each variable respectively 117 | // This is to enable room for one more 12-bit reply than could otherwise fit in the 64-byte 118 | // reply packet. Pretty messy. 119 | } VNA_RXBUFF_FAST; 120 | 121 | 122 | // TraceSet for one complete data point. The old code defined them this way: 123 | //trace1[m] = RxBuf->ReflMI; 124 | //trace2[m] = RxBuf->ReflMQ; 125 | //trace3[m] = RxBuf->ReflPI; 126 | //trace4[m] = RxBuf->ReflPQ; 127 | 128 | //trace5[m] = RxBuf->Vref1; 129 | 130 | //trace6[m] = RxBuf->TranMI; 131 | //trace7[m] = RxBuf->TranMQHi; 132 | //trace8[m] = RxBuf->TranPI; 133 | //trace9[m] = RxBuf->TranPQ; 134 | 135 | //trace10[m] = RxBuf->Vref2; 136 | //trace11[m] = RxBuf->TranMQ; 137 | //trace12[m] = RxBuf->TranMQMid; 138 | 139 | //trace13[m] = RxBuf->TranPILow; 140 | //trace14[m] = RxBuf->TranPQLow; 141 | 142 | /// Set of raw instrument readings for a measurement point at one frequency 143 | public ref struct MeasurementSet { 144 | unsigned short ReflMI; ///< Reflection Magnitude I (trace1) 145 | unsigned short ReflMQ; ///< Reflection Magnitude Q (trace2) 146 | unsigned short ReflPI; ///< Reflection Phase I (trace3) 147 | unsigned short ReflPQ; ///< Reflection Phase Q (trace4) 148 | unsigned short Vref1; ///< Reference voltage 1 (trace5) 149 | unsigned short TranMI; ///< Transmission Magnitude I (trace6) 150 | unsigned short TranMQHi; ///< Transmission Magnitude Q Hi (trace 7) 151 | unsigned short TranPI; ///< Transmission Phase I (trace 8) 152 | unsigned short TranPQ; ///< Transmission Phase Q (trace 9) 153 | unsigned short Vref2; ///< Reference voltage 2 (trace10) 154 | unsigned short TranMQ; ///< Transmission Magnitude Q Low (trace 11) 155 | unsigned short TranMQMid; ///< Transmission Magnitude Q Mid (trace 12) 156 | unsigned short TranPILow; ///< Transmission Phase I Low ref level (trace 13) 157 | unsigned short TranPQLow; ///< Transmission Phase Q Low ref level (trace 14) 158 | }; 159 | 160 | -------------------------------------------------------------------------------- /Detector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | // Routines to encapsulate the magnitude/phase detector IC 23 | // Refl and Tran detector routines are starting to diverge. 24 | // 25 | // 09-03-2007 TC McDermott 26 | // 27 | 28 | 29 | #include "stdafx.h" 30 | #using 31 | #using 32 | using namespace System; 33 | using namespace System::IO; 34 | using namespace System::Windows::Forms; 35 | 36 | /// Analog Devices AD8302 device-dependent constants 37 | public ref class Detector 38 | { 39 | public: 40 | int maxMagnitude; ///< maximum magnitude reading 41 | float unitsPerdB; ///< magnitude ADC counts per dB. (~57.0) 42 | array^ pherror; ///< phase error for each degree 43 | array^ MagTable; ///< refl magnitude raw data table 44 | array^ m; ///< y = mx + b from linear regression, by frequency 45 | array^ b; ///< y = mx + b from linear regression, by frequency 46 | array^ r; ///< 'r' is the correlation coefficient for the regression, by frequency 47 | array^ flat; ///< ADC count where amp detector bottoms out 48 | static const int t1 = 110; // twiddle factors for detector floor correction 49 | static const int t2 = 110; 50 | String^ name; // Name of detector (TxDet or RxDet) 51 | 52 | // New 06-09-2007 53 | double diffQDelayNs; ///< differential time delay of Q-reference compared to I-reference 54 | int Iasym, Qasym, IasymLo; ///< Phase detector lead/lag asymmetry 55 | 56 | int Qmin, Qmax, Imin, Imax; /// Phase Detector mins and maxes - New 06-16-2007 57 | int Qmid, Imid, Qmag, Imag; /// derived detector center lines & half-range 58 | 59 | int IminLo, ImaxLo, ImidLo, ImagLo; /// derived I phase detector low ref level mins and maxes - New 09-30-2007 60 | 61 | int beginIndex, endIndex; /// Index of 90-degrees and 90+360 degrees of the shorted cal cable 62 | 63 | bool phaseCalibrated; ///< true if phase values have been calibrated 64 | InstrumentCalDataSet^ Cal; 65 | 66 | Detector(InstrumentCalDataSet^ Cal);// Constructor, allocate default values 67 | bool PhaseCal(array^ Iphase, array^ Qphase, array^ IphaseLo); // construct phase points from raw data 68 | bool AmpCal(array^ Mag); // construct amplitude calibration table from raw data 69 | double IQtoDegrees(int I, int Q, int Freq, double MagDb, int ILo, int QLo); // convert I/Q ADC reading to degrees 70 | double MagTodBRefl(int Freq, int Mag); // convert detector magnitude count to dB. via piecewise linear fit 71 | double MagTodBTran(int Freq, int Mag, int LowMag, int MidMag); // convert detector magnitude count to dB. via table lookup 72 | double CompensateQDelay(double Degrees, int Freq); // compensate phase reading for Q-reference delay 73 | double CompensateAsymmetry(double Degrees); // compensate phase reading for detector assymmetry 74 | }; 75 | 76 | 77 | -------------------------------------------------------------------------------- /DirectionalCoupler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | // Routines to encapsulate directional coupler compensation 23 | 24 | 25 | #include "stdafx.h" 26 | #include "DisplayRoutines.h" 27 | #using 28 | #using 29 | using namespace System; 30 | using namespace System::ComponentModel; 31 | using namespace System::IO; 32 | using namespace System::Windows::Forms; 33 | 34 | ref class InstrumentCalDataSet; //so DirectionalCoupler class can forward-reference InstrumentCalDataSet 35 | 36 | /// Set of coefficients for 6-point periodic error model 37 | public ref struct PerErrModelCoeff { 38 | int freq; ///< frequency where set applies 39 | double offset; ///< offset angle of the correction in degrees 40 | double mag; ///< peak magnitude of the correction 41 | }; 42 | 43 | /// Encapsulate directional coupler error model 44 | public ref class DirectionalCoupler 45 | { 46 | public: 47 | 48 | // double calCableSurgeRealOhms, calCableSurgeImagOhms; // real and imaginary parts of cal cable surge impedance 49 | 50 | array^ DirMag; // Directivity cal raw data 51 | array^ DirIphs; // Directivity cal raw data 52 | array^ DirQphs; // Directivity cal raw data 53 | 54 | array^ PhRipCoeff; // Array of phase ripple coefficients 55 | array^ MagRipCoeff; // Array of mag ripple coefficients 56 | 57 | array^ phaseError; // Array of open-short angle error for LF phase computation 58 | array^ magError; // Array of open-short magnitude for magnitude compensation 59 | array^ openAngle; // Array of open angle for LF phase computation 60 | array^ shortAngle; // Array of short angle for LF phase computation 61 | 62 | bool DirCalibrated; ///< true if Directivity Calibration has been run or values loaded from cal file 63 | bool RippleCalibrated; ///< true if Mag & Phase ripple calibration has been run or values loaded from cal file 64 | 65 | double PhaseDCOffset; ///< Value of phase error offset (sum of all phaseError/numPoints) 66 | double MagDCOffset; ///< Value of mag error offset (sum of magError/numPoints) 67 | InstrumentCalDataSet^ Cal; ///< Cal data 68 | 69 | 70 | DirectionalCoupler(InstrumentCalDataSet^ Cal); // constructor 71 | // store coupler directivity calibration raw readings 72 | void DirectivityCal(array^ readings); 73 | // Compensate S11 reading for Coupler Directivity 74 | void CompensateDirectivity(InstrumentCalDataSet^ cal, double& rmagnitudeLin, double& rphase, int Freq); 75 | // Generate table of unit-length ripple compensation vectors 76 | bool GenerateShortOpenComp(InstrumentCalDataSet^ cal, array^ shortedrefl , array^ openrefl); 77 | double PhaseRippleCompensate(double phase, __int64 frequency); 78 | // Compensate coupler magnitude ripple error NEW 09-23-2007 79 | double MagRippleCorrection(double phase, __int64 frequency); 80 | // Update parameter estimates by descending along the gradient NEW 09-23-2007 81 | void DirectionalCoupler::Descend(array^ partialDerivative, array^ weight, array^ coeff); 82 | // Compute error predicted by point-wise periodic error model 83 | double DirectionalCoupler::PeriodicModelCorrection(__int64 frequency, double phase, array^ PerErrModelCoeff, 84 | double DCOffset); 85 | // Compute SumSqErr for model compared to error signature 86 | double DirectionalCoupler::SumSquareError(int startI, int stopI, array^ angle, 87 | array^ errSignature, array^ coeff, double DCOffset); 88 | // Compute gradient of the model parameter set vs. the SumSqError of the fit 89 | void DirectionalCoupler::Gradient(array^ partialDerivative, int startI, int stopI, 90 | array^ angle, array^ errSignature, array^ modelCoeff, 91 | double DCOffset); 92 | 93 | }; 94 | 95 | -------------------------------------------------------------------------------- /DisplayRoutines.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | /// Utility routines to convert VNA measurements into other 23 | /// useful types and coordinates. 24 | // 25 | 26 | 27 | #include "stdafx.h" 28 | #include "DirectionalCoupler.h" 29 | #include "Detector.h" 30 | #include "USB_EZ_interface.h" 31 | 32 | #include 33 | 34 | #include "DataDisplay.h" 35 | #using 36 | #using 37 | using namespace System; 38 | using namespace System::IO; 39 | using namespace System::Windows::Forms; 40 | 41 | 42 | /// Convert Magnitude to rectangular Y display coordinate 43 | int ToDisplayRectMag(double magnitude, System::Drawing::Rectangle scopeDisp, float dbScaleFactor, int refLevel); 44 | 45 | /// Convert Phase to rectangular Y display coordinate 46 | int ToDisplayRectPhs(double phase, System::Drawing::Rectangle scopeDisp); 47 | 48 | /// Convert Group Delay to rectangular Y display coordinate 49 | int ToDisplayRectGD(double groupdelay, System::Drawing::Rectangle scopeDisp, int scaleFactor); 50 | 51 | /// Convert Magnitude and Phase to polar (X,Y) display coordinates 52 | void ToDisplayPolar(double magnitude, double phase, int polarRad, int xoffset, int yoffset, int& X, int& Y); 53 | 54 | /// Convert Resistance portion of S11 to Y display coordinate 55 | int ToDisplayRectR(float resistance, int scale, System::Drawing::Rectangle scopeDisp); 56 | 57 | /// Convert Reactance portion of S11 to Y display coordinate 58 | int ToDisplayRectjX(float reactance, int scale, System::Drawing::Rectangle scopeDisp); 59 | 60 | int ToDisplayRectScaled(double value, System::Drawing::Rectangle scopeDisp, int scaleFactor); 61 | 62 | /// Compensate for ModAmpbuffer amplifer phase distortions 63 | double BufferAmpPhaseComp(double phaseDegrees, int Frequency); 64 | 65 | /// Frequency Grid Class 66 | public ref class FrequencyGrid 67 | { 68 | private: 69 | array<__int64>^ FrequencyIndex; ///< Grid of frequencies to measure 70 | __int64 startFreq; ///< Starting (lowest) Frequency of grid 71 | __int64 stopFreq; ///< Stopping (highest) Frequency of grid 72 | int indexer; ///< internal variable to index through grid 73 | double delta; ///< Frequency separation between points in the grid 74 | public: 75 | int points; ///< Number of points in the frequency grid 76 | int ferror; ///< Frequency error of internal crystal at 100 Mhz (from calibration) 77 | 78 | public: 79 | FrequencyGrid(int numPoints); ///< Constructor, allocate array 80 | void SetStartF(__int64 start); ///< Set start frequency of grid 81 | void SetStopF(__int64 stop); ///< Set stop frequency of grid 82 | __int64 Frequency(int gridpoint); ///< convert gridpoint to it's frequency 83 | long long int DDS(__int64 Frequency); ///< Derive DDS divisor value from Frequency 84 | int GridPoint(__int64 Frequency); ///< convert Frequency to gridpoint 85 | int Points(); ///< get number of points in grid 86 | __int64 StartF(); ///< get start frequency of grid 87 | __int64 StopF(); ///< get stop frequency of grid 88 | int Ferror(); ///< get Frequency error 89 | void set_Ferror(int FreqError); ///< set Frequency error 90 | 91 | private: 92 | void Build(void); 93 | }; 94 | 95 | /// Object to hold Calibration data, raw and computed. Holds both Instrument and Fixture Cal Data 96 | public ref class InstrumentCalDataSet 97 | { 98 | public: 99 | #if 0 100 | value struct mycomplex { private: double Real; double Imag; 101 | public: 102 | void mycomplex::operator= 103 | (const std::complex &c) 104 | { 105 | // do the copy 106 | Real = c.real(); 107 | Imag = c.imag(); 108 | 109 | // return the existing object so we can chain this operator 110 | return ; 111 | } 112 | }; 113 | #endif 114 | Detector^ RxDet, ^TxDet; ///< Holds detector constants 115 | DirectionalCoupler^ DirCoupler; ///< Holds Directional coupler error model 116 | 117 | // Fixture Cal data (may not be any) 118 | array^ EdReal, ^EdImag, ^EsReal, ^EsImag; 119 | // array^ Ed, ^Es; 120 | array^ EtReal, ^EtImag, ^ThReal, ^ThImag; 121 | double OpenC0, OpenC1, OpenC2, ShortL0, ShortL1, ShortL2,OpenLength,ShortLength,LoadL0,LoadR0,LoadLength; 122 | array^ S11shortReal, ^S11shortImag; 123 | array^ S11openReal, ^S11openImag; 124 | array^ S11termReal, ^S11termImag; 125 | array^ S21termReal, ^S21termImag; 126 | bool FixtureCalLogFreqMode; 127 | __int64 minCalFreq, maxCalFreq; 128 | VNADevice^ VNA; 129 | 130 | // array^ Ed; 131 | 132 | int FreqError; // Internal Crystal Frequency Error 133 | double reflTimeDelayEquivalent; // Equivalent time delay of reflection cable go and return (for RefExtn - not enabled) 134 | 135 | InstrumentCalDataSet(String^ StartUpDir, 136 | VNADevice^ VNADev ///< VNA Hardware Device 137 | ); 138 | /// resolve reflected measured data set to Magnitude and Phase 139 | void ResolveReflPolar(MeasurementSet^ dataPoint, __int64 Freq, double& rmag, double& rphs, bool CouplerComp); 140 | /// resolve transmitted measured data set to Magnitude and Phase 141 | void ResolveTranPolar(MeasurementSet^ dataPoint, __int64 Freq, double& rmag, double& rphs); 142 | /// get frequency of calibration grid point 143 | __int64 GetFreqFromFixtureCalGrid(long index, bool Freqmode); 144 | /// Convert Detector Magnitude Calibration Grid index to Frequency. 145 | __int64 GetFreqFromDetMagCalGrid(long index); 146 | /// Convert Phase Calibration Grid index to Frequency. 147 | int GetFreqFromPhaseCalGrid(long index); 148 | 149 | }; 150 | 151 | 152 | /// Derive error terms from cal measurements 153 | void CalToErrorTerms(InstrumentCalDataSet^ Cal); 154 | 155 | /// Convert measured S11 into actual S11 via Fixture calibration 156 | void CorrectS11(InstrumentCalDataSet^ Cal, __int64 Frequency, bool ReflExtn, bool calMode, double measmag, double measphs, double& rsltmag, double& rsltphs); 157 | 158 | /// Convert measured S21 into actual S21 via Foixture calibration 159 | void CorrectS21(InstrumentCalDataSet^ Cal, __int64 Frequency, bool calMode, double measmag, double measphs, double& rsltmag, double& rsltphs); 160 | 161 | /// Load calibration data from a previously saved file 162 | bool LoadCalDataSet(OpenFileDialog^ infile, InstrumentCalDataSet^ Cal); 163 | 164 | /// Save newly acquired calibration data to a file 165 | void SaveCalDataSet(SaveFileDialog^ outfile, InstrumentCalDataSet^ Cal); 166 | 167 | /// Convert Log Tx Level to linear value needed by DAC register 168 | unsigned short TxLevLinear(int tranLevel); 169 | 170 | /// Convert linear DAC level to dBm. 4095 = 0.0 dBm. 171 | float dBFromLinear(int DAClevel); 172 | 173 | /// Convert Return Loss (S11 mag) to SWR, then to vertical display coordinate 174 | int ToDisplayAsSWR(double mag, System::Drawing::Rectangle scopeDisp, int scaledB); 175 | 176 | /// Export S Parameters to a file 177 | void ExportSParams(int format, FrequencyGrid^ FG, array^ S11Mag, array^ S11Phs, 178 | array ^S21Mag, array^ S21Phs, array^ S22Mag, 179 | array^ S22Phs, array^S12Mag, array^ S12Phs); 180 | 181 | /// Store S Parameters to temporary storage 182 | void StoreSParams(bool calmode, bool ReflExtn, FrequencyGrid^ FG, InstrumentCalDataSet^ CalData, 183 | array^ Meas, array^ reflMag, array^ reflPhs, 184 | array^ tranMag, array^ tranPhs); 185 | 186 | /// Linear interpolation of Xval between Xlow and Xhigh yielding Y result between Ylow and Yhi 187 | //double Interpolate(int Xval, int Xlow, double Ylow, int Xhi, double Yhi); 188 | double Interpolate(__int64 Xval, __int64 Xlow, double Ylow, __int64 Xhi, double Yhi); 189 | //double Interpolate(int Xval, int Xlow, int Ylow, int Xhi, int Yhi); 190 | //double Interpolate(float Xval, float Xlow, float Ylow, float Xhi, float Yhi); 191 | 192 | /// Median filtering routine. Input is 7 measurements, returns the median value. 193 | int Median7(array^ data, ///< Raw data array from VNA 194 | int index); ///< Position in the array 195 | /// 196 | int Median7(array^ data); ///< Integer array 197 | /// 198 | int Median7(array^ data); ///< Unsigned Short array 199 | /// 200 | double Median7(array^ data, ///< double array 201 | int, ///< Position in the array to filter 202 | double epsilon = 0.0); ///< Don't filter if error is smaller than epsilon 203 | 204 | /// Determine range of middle 5 samples in a group of 7 samples. 205 | int Range /// \return Max-min range of the readings spanning 5 closest samples 206 | (array^ data, ///< Array of all measurement samples, one per frequency 207 | int index ///< Look at the 7 samples surrounding (and including) this index 208 | ); 209 | 210 | /// Return actual raw reading if it's close to the expected reading, else the median of the 211 | /// 7 adjacent samples that include the reading. 212 | int ExpectedValue 213 | (array^ data, ///< Array of all measurement samples, one per frequency 214 | int index, ///< The sample we wish to find the expected value of 215 | bool mode = false ///< Switch that allows for phase detector saturation.. true=phase, false=amplitude 216 | ); 217 | 218 | /// Deglitch an entire array of raw VNA readings using ExpectedValue - raw overload 219 | void DeGlitch(array^ raw, ///< Raw readings from VNA 220 | int count, ///< Number of points in the set 221 | bool mode); ///< phasemode = 1 means phase detector reading, =0 means amplitude reading 222 | /// Deglitch an entire array of raw VNA readings using ExpectedValue - dataset overload 223 | void DeGlitch(array^ dataSet, ///< Entire MeasurementSet 224 | int count); ///< number of points in the MeasurementSet 225 | /// Smooth a phase error table 226 | void SmoothPhaseTable(array^ table); ///< Table of phase error values (360 degrees table) 227 | /// DrawLine routines that checks and bounds points to display rectangle - rectangle overload 228 | void DrawLineBound(System::Drawing::Graphics^, System::Drawing::Rectangle, System::Drawing::Pen^, int, int, int, int); 229 | /// DrawLine routines that checks and bounds points to display rectangle - 2 points overload 230 | void DrawLineBound(System::Drawing::Graphics^, System::Drawing::Rectangle, System::Drawing::Pen^, System::Drawing::Point, System::Drawing::Point); 231 | /// Add 2 polar numbers 232 | void AddPolar(double& linearMag, double& phaseDegr, double linearMagadd, double phaseDegrAdd); 233 | /// Convert MeasurementDelay string to target's loop count 234 | int MeasureDelayStringToCount(String^ value); 235 | /// Wrap phase to +/- 180 degree range. 236 | int NormalizePhaseDegr(int phase); ///< phase as an int. 237 | /// Wrap phase to +/- 180 degree range. 238 | double NormalizePhaseDegr(double phase); ///< phase as a double. 239 | /// Wrap phase to +/- 180 degree range. 240 | float NormalizePhaseDegr(float phase); ///< phase as a float. 241 | 242 | /// Check S21 receive measurements for evidence of broadband noise ingress 243 | /// due to unshielded fixture and local strong signal source. 244 | bool ExcessRxNoiseIngress(array^ trace, ///< Entire raw measurementset. 245 | int points ///< Number of points in the dataset. 246 | ); 247 | /// Compute Frequency of grid point for linear(f) and log(f) fixture cal points 248 | //int GetFreqFromFixtureCalGrid(long index, bool Freqmode); 249 | -------------------------------------------------------------------------------- /Doc/12_term_dg8saq.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/12_term_dg8saq.pdf -------------------------------------------------------------------------------- /Doc/Background/12_term_dg8saq.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Background/12_term_dg8saq.pdf -------------------------------------------------------------------------------- /Doc/Background/NA_Error_Models_and_Cal_Methods.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Background/NA_Error_Models_and_Cal_Methods.pdf -------------------------------------------------------------------------------- /Doc/Background/TAPR3_Instruction_Manual_Issue_7.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Background/TAPR3_Instruction_Manual_Issue_7.doc -------------------------------------------------------------------------------- /Doc/Background/TAPR3_Instruction_Manual_Issue_7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Background/TAPR3_Instruction_Manual_Issue_7.pdf -------------------------------------------------------------------------------- /Doc/Background/VNWA part3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Background/VNWA part3.pdf -------------------------------------------------------------------------------- /Doc/Background/nanovna-sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Background/nanovna-sch.pdf -------------------------------------------------------------------------------- /Doc/Everything S parameters.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Everything S parameters.pdf -------------------------------------------------------------------------------- /Doc/How to design a homemade male BNC calibration kit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/How to design a homemade male BNC calibration kit.pdf -------------------------------------------------------------------------------- /Doc/How to measure on SOL calibration kits_REV1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/How to measure on SOL calibration kits_REV1.pdf -------------------------------------------------------------------------------- /Doc/How to measure very high impedances-Deutsch DG3OK.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/How to measure very high impedances-Deutsch DG3OK.pdf -------------------------------------------------------------------------------- /Doc/Measure quality of calibration standards.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measure quality of calibration standards.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/110MHz ceramic filter Polar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/110MHz ceramic filter Polar.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/110MHz ceramic filter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/110MHz ceramic filter.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/433MHz resonator polar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/433MHz resonator polar.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/433MHz resonator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/433MHz resonator.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/51 ohm carbon resistor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/51 ohm carbon resistor.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/RL series polar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/RL series polar.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/cable polar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/cable polar.pdf -------------------------------------------------------------------------------- /Doc/Measurement examples/cable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Measurement examples/cable.pdf -------------------------------------------------------------------------------- /Doc/NA_Error_Models_and_Cal_Methods.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/NA_Error_Models_and_Cal_Methods.pdf -------------------------------------------------------------------------------- /Doc/PacificonSmithChart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/PacificonSmithChart.pdf -------------------------------------------------------------------------------- /Doc/S parameters explanation HamRadio_DG8SAQ_2013_English.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/S parameters explanation HamRadio_DG8SAQ_2013_English.pdf -------------------------------------------------------------------------------- /Doc/Solving the one port model.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Solving the one port model.docx -------------------------------------------------------------------------------- /Doc/Some basic knowledge about a transmission line.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/Some basic knowledge about a transmission line.pdf -------------------------------------------------------------------------------- /Doc/T-Check.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/T-Check.pdf -------------------------------------------------------------------------------- /Doc/TRL calibration errors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/TRL calibration errors.pdf -------------------------------------------------------------------------------- /Doc/VNA calibration method.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/VNA calibration method.pdf -------------------------------------------------------------------------------- /Doc/VNA current bridge.asc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/VNA current bridge.asc -------------------------------------------------------------------------------- /Doc/VNA current bridge.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/VNA current bridge.pdf -------------------------------------------------------------------------------- /Doc/VNA dead bug style.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/VNA dead bug style.jpg -------------------------------------------------------------------------------- /Doc/nanovna-sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/Doc/nanovna-sch.pdf -------------------------------------------------------------------------------- /Form1.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Form1.h" 3 | 4 | using namespace VNAR3; 5 | 6 | [STAThreadAttribute] 7 | int main(array ^args) 8 | { 9 | // Enabling Windows XP visual effects before any controls are created 10 | Application::EnableVisualStyles(); 11 | Application::SetCompatibleTextRenderingDefault(false); 12 | 13 | // Create the main window and run it 14 | Application::Run(gcnew Form1(args)); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Form1.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 25, 15 122 | 123 | 124 | 25, 15 125 | 126 | 127 | 115, 15 128 | 129 | 130 | 131 | 132 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 133 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACKUlEQVQ4T7WS/09SURjG+adYra1WW20a 134 | amW2sJwRDVdSNIxpQck0siU1ycKtqCmUG9SgL+iQmFksbwa5JGVKuAnkBIkQARXiy9O9l2tM0a2t9Wzv 135 | L+e8z+c55z2H9V/k8YVheju1bRmHJ8G0looyjzi82Kz0ryz8C0t4bhlDJU+6PcBg/YK1VAY/onHYndN0 136 | vbQ5oDcTcE4FUCfqwPFzbVsDPrrmQEzMMZkFUcnLiRTcsyEYrQ5UnLoCs40oBURiSWiMBLK5PALByIZ0 137 | i/0rHJN+1DYqUCOQ47bmFe7pLEWIa9pHm4cdnj+p68nBSBIeXwQP9Tb67vKufjw2jqLytKwAcH8LoFs3 138 | BK35Mx4Y7Hjy+hO6tVa03TVA3K4Br0mJQ2RzeV0zTpy/AVXvACQKDQ7WXy4A7vS9QTyZopM3K5PNYZUc 139 | KHWScHQV84sJyDq1aGjpIk/AvISixwTzuwm8sDmhNY3gvm4QHepnkHb2QtSqBv+SEtzGdhzmy1B2UoIL 140 | 5Fqt8Dr21ogKgFaVnskrVXwlDX9wGeMzYXxwhTBAzIMnvoWK+hawy88UAFLlU6a9KHJ++JnIYOb7Ckbd 141 | UXB6dkL/fpGe/FHBNeypFhYBzTf7kM4AZBiiyTwWYnnMhnIY865hcDyBfvsSVGw21EMxGnCAKy6aKUkU 142 | j+AlDdTm39QG87qqG+So4l8Fh/xlZeRz7ec2Yd+xi9h9RIhdVWexgyOgjVua/00s1m8B2C9JiieXMwAA 143 | AABJRU5ErkJggg== 144 | 145 | 146 | 147 | 148 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 149 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABgklEQVQ4T52SvUtCURjG/RdcW9oKmqup 150 | ocAhg7b2CCMiyHCThNaWqCGKTClIxUQx/O5aaGpBpSGRfQwNoWSREISV5dcT59xz1dvVkH7wcDnwPj/e 151 | c7gyd/QOv+MMpWDjkjB7znBxk4bsL0ihFUb7EfqUKlg90daSvfA1G5eyZuYQPEnxEnekucR+cMnGpazu 152 | BNA/MlkLq4ix+hNsXEqpXKESQcQqYkzuUzYuJv2YAxeJw7DrpbH7o8hkc1LJljPGKnXIICm73ktwPPGx 153 | JLJUcnufEUs2bSFWq2PxRWj5pcKfn1GhEmETVuVZtwT5qQaWTb6aQAg5ky20uhWxgDxQI+ThiODwCziv 154 | 8mXyJQJZOI+5+cXWgmq1io9CkV5hNvlJJSRCWWf0Qj0z3VrwXSzj9a2A+NUDXIEYlZCiUNZoxrGtlTcX 155 | kG9jlgwu7IeO6XXUC3qMjk0hYlQABb1YQobJr9pOlL3dyHMdVKJTDYg3aZeJ4S4qIVv8W9LTKYdicAic 156 | YwM/QN9CSPM2ALQAAAAASUVORK5CYII= 157 | 158 | 159 | 160 | 161 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 162 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACMklEQVQ4T62S30uTURjH33+h+26CLrqt 163 | qTGci9XgLddQlg3DirAfb6RZmi7TRMXKNGr+gmyFSyetVpNwUpE/wBQpEWUqWZq5oiUONcUmgsHX85y9 164 | eVxFF9EXnpuX9/M553nOI/2XPH8WBpWvdQkt3kU8dM+jqTGEu45p1NV+gf1WANfLJ1FaMo7CgrfIyx3B 165 | +XN+qLgkEdjVCdTWrOBvWV5ZhSm1C4dSn/JScUnyPlnggsqKb+qvv4fg0PwydlleQKNRYD3oEQL3gzku 166 | KC35qv4enZ/wx+ACYsw+FFyawgFLsxA4G2a44KLtg4qIbISHJ0LYJnuRkz2G5CSnENTfDnJB1tkRFYvk 167 | V7jPH8RmgxuKMgCz2SEENdWfuUA5NaCif4Y7+z9hU3wjDh95hcTEOiG4UTmFjnawpwSOHX8D69FePm0a 168 | GPVM16aTI3A3UqwvIct2IbhSNoE2H9gOAM2uH+zdv6P82iwfKg2Mes7M8K/D+5NbYTRWCMHlwjF4HgH3 169 | natsccIwpWVHlSXdhrQzRRE4icH7PDAYyoTAljfKYKC6KsxPJoh9RoxOxuD7GYxOzkLJvYo9phYO63a7 170 | oNcXCQGtpeMO1q9NAoJP59/Eu8AcAtOLuFBsR6zBxeAmxCbcgy4+XwgyM4ZY30sc3mr0YMsOGY/beuBr 171 | 70NHdz96Xw9ir9kKjb4BcQzerq2HVpsjBJSTJ3r4etKG0ZLQO9NT0bRpYNQznUpF8M64rGjBv0WS1gBO 172 | tDjFuXzYbwAAAABJRU5ErkJggg== 173 | 174 | 175 | 176 | 177 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 178 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACR0lEQVQ4T8WQXUjTYRTG/xdddGWRFYVQ 179 | YHnhzSAooroIKaJQFMssSNKEmh9UGAtzfrSp6ebm5tSVLmubrqnTSjMK+5AKRSLU1JFmalYUlWJmqOTX 180 | r78u1KGEdx14eOFwnt95zisst5QGO5fUVjKNDv62ll8RMqObKVWEzbzhsnyET31vqbTpF6mj5ek/N4XE 181 | ZhMUnYMwM9zVZmFsqGJWvwftTPSbcViz6Wh9tiTkSIyOoCgDAdI8hIpiHaODpW7mqa8FTDjjKL2ppqQw 182 | A3N+KqacFK5p5eSp4t2hZRYNo98tc+Zp0UyXHJzSJbUIcKtIxa8vpjlzbaVmVg8dWdTYVdwtycBhTsNu 183 | UmI1XuaGIYlCnRyjJsEFKzFlMPwhdzZ2b72CqlIdU71K6Et313ux15MInTJ4E0treSi263oEszGNn91q 184 | +Kiluiybxkda19DC6K/DoSmEyQZ/xh778a5Ygkwa7DqlyKDgR4eSvoZkquxapnsU0B7lMrZGisbjTDYG 185 | MlZ3gOEHexio3IYy2kc8R+4CFOiSGWhL4LZNQ/MLMUlnnAg4Dc1hTL8MZvz5IUZq9zJYtZ1vZb40XVnN 186 | CX/v+Y80Zslpr0vhji0LulOgRYz76ijj9QGMPPFjqGYn/Q4Jny1bcWo9UUi3cDb65DwgNzOeCqsa570Y 187 | mvTCnBq1K6hTreR+6irKk9Zhjvfi6oXNhC3cPlP69IvoFWfITIgg8dwxzkcGcip0P4cP7mLfbgk7JD74 188 | enuxaeNa1q/xYIOnhzvgP5cg/AEXxt5pPX79WAAAAABJRU5ErkJggg== 189 | 190 | 191 | 192 | 224, 15 193 | 194 | 195 | 345, 15 196 | 197 | 198 | 199 | iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO 200 | wwAADsMBx2+oZAAAAERJREFUGFdj+I8boMgZGBhAWWCAIsfAgMqFUM+fP1+6dCk3NzeQBLIhgiA5oFFA 201 | HUAJOAkxnJA+OMBuHwTgcycK+P8fAMV6yKFcXrFRAAAAAElFTkSuQmCC 202 | 203 | 204 | 205 | 50 206 | 207 | -------------------------------------------------------------------------------- /Fourier.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2005 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | 21 | // TestFFT.pch will be the pre-compiled header 22 | // stdafx.obj will contain the pre-compiled type information 23 | 24 | #pragma once 25 | 26 | #include "stdafx.h" 27 | #include 28 | 29 | #define PI 3.1415926535897932384626433832795 30 | 31 | 32 | // Fast Fourier Transform. length must be exactly 2^n. 33 | // Inverse = true computes InverseFFT 34 | // Inverse = false computes FFT. 35 | // Overwrites the real and imaginary arrays in-place 36 | 37 | void FFT(double real[], double imag[], int length, bool Inverse = false) 38 | { 39 | 40 | double wreal, wpreal, wimag, wpimag, theta; 41 | double tempreal, tempimag, tempwreal, direction; 42 | 43 | int Addr, Position, Mask, BitRevAddr, PairAddr; 44 | int m, k; 45 | 46 | 47 | direction = -1.0; // direction of rotating phasor for FFT 48 | 49 | if(Inverse) 50 | direction = 1.0; // direction of rotating phasor for IFFT 51 | 52 | // bit-reverse the addresses of both the real and imaginary arrays 53 | // real[0..length-1] and imag[0..length-1] are the paired complex numbers 54 | 55 | for (Addr=0; Addr> 1; 60 | Mask = Addr; 61 | while (Mask) 62 | { 63 | if(Mask & 1) 64 | BitRevAddr += Position; 65 | Mask >>= 1; 66 | Position >>= 1; 67 | } 68 | 69 | if (BitRevAddr > Addr) // Swap 70 | { 71 | double s; 72 | s = real[BitRevAddr]; // real part 73 | real[BitRevAddr] = real[Addr]; 74 | real[Addr] = s; 75 | s = imag[BitRevAddr]; // imaginary part 76 | imag[BitRevAddr] = imag[Addr]; 77 | imag[Addr] = s; 78 | } 79 | } 80 | 81 | // FFT, IFFT Kernel 82 | 83 | for (k=1; k < length; k <<= 1) 84 | { 85 | theta = direction * PI / (double)k; 86 | wpimag = sin(theta); 87 | wpreal = cos(theta); 88 | wreal = 1.0; 89 | wimag = 0.0; 90 | 91 | for (m=0; m < k; m++) 92 | { 93 | for (Addr = m; Addr < length; Addr += (k*2)) 94 | { 95 | PairAddr = Addr + k; 96 | 97 | tempreal = wreal * real[PairAddr] - wimag * imag[PairAddr]; 98 | tempimag = wreal * imag[PairAddr] + wimag * real[PairAddr]; 99 | real[PairAddr] = real[Addr] - tempreal; 100 | imag[PairAddr] = imag[Addr] - tempimag; 101 | real[Addr] += tempreal; 102 | imag[Addr] += tempimag; 103 | } 104 | tempwreal = wreal; 105 | wreal = wreal * wpreal - wimag * wpimag; 106 | wimag = wimag * wpreal + tempwreal * wpimag; 107 | } 108 | } 109 | 110 | if(Inverse) // Normalize the IFFT coefficients 111 | for(int i=0; i 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /NumEntBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "NumEntBox.h" 3 | 4 | -------------------------------------------------------------------------------- /NumEntBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010, Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | using namespace System; 23 | using namespace System::ComponentModel; 24 | using namespace System::Collections; 25 | using namespace System::Windows::Forms; 26 | using namespace System::Data; 27 | using namespace System::Drawing; 28 | 29 | 30 | namespace VNAR3 31 | { 32 | /// 33 | /// Summary for NumEntBox 34 | /// 35 | /// WARNING: If you change the name of this class, you will need to change the 36 | /// 'Resource File Name' property for the managed resource compiler tool 37 | /// associated with all .resx files this class depends on. Otherwise, 38 | /// the designers will not be able to interact properly with localized 39 | /// resources associated with this form. 40 | /// 41 | 42 | /// Numeric Entry dialogBox 43 | public ref class NumEntBox : public System::Windows::Forms::Form 44 | { 45 | public: 46 | NumEntBox(void) 47 | { 48 | InitializeComponent(); 49 | } 50 | 51 | protected: 52 | ~NumEntBox() 53 | { 54 | if(components) 55 | delete(components); 56 | } 57 | 58 | private: System::Windows::Forms::Button^ OKButton; 59 | private: System::Windows::Forms::Button^ CancelButton; 60 | private: System::Windows::Forms::TextBox^ NumberBox; 61 | private: System::Windows::Forms::Label^ label1; 62 | 63 | private: 64 | /// 65 | /// Required designer variable. 66 | /// 67 | System::ComponentModel::Container^ components; 68 | 69 | /// 70 | /// Required method for Designer support - do not modify 71 | /// the contents of this method with the code editor. 72 | /// 73 | void InitializeComponent(void) 74 | { 75 | System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(NumEntBox::typeid)); 76 | this->OKButton = (gcnew System::Windows::Forms::Button()); 77 | this->CancelButton = (gcnew System::Windows::Forms::Button()); 78 | this->NumberBox = (gcnew System::Windows::Forms::TextBox()); 79 | this->label1 = (gcnew System::Windows::Forms::Label()); 80 | this->SuspendLayout(); 81 | // 82 | // OKButton 83 | // 84 | this->OKButton->DialogResult = System::Windows::Forms::DialogResult::OK; 85 | this->OKButton->FlatStyle = System::Windows::Forms::FlatStyle::System; 86 | this->OKButton->Location = System::Drawing::Point(48, 112); 87 | this->OKButton->Name = L"OKButton"; 88 | this->OKButton->Size = System::Drawing::Size(75, 23); 89 | this->OKButton->TabIndex = 1; 90 | this->OKButton->Text = L"OK"; 91 | // 92 | // CancelButton 93 | // 94 | this->CancelButton->DialogResult = System::Windows::Forms::DialogResult::Cancel; 95 | this->CancelButton->FlatStyle = System::Windows::Forms::FlatStyle::System; 96 | this->CancelButton->Location = System::Drawing::Point(168, 112); 97 | this->CancelButton->Name = L"CancelButton"; 98 | this->CancelButton->Size = System::Drawing::Size(75, 23); 99 | this->CancelButton->TabIndex = 2; 100 | this->CancelButton->Text = L"Cancel"; 101 | // 102 | // NumberBox 103 | // 104 | this->NumberBox->Location = System::Drawing::Point(72, 64); 105 | this->NumberBox->Name = L"NumberBox"; 106 | this->NumberBox->Size = System::Drawing::Size(144, 20); 107 | this->NumberBox->TabIndex = 0; 108 | this->NumberBox->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; 109 | // 110 | // label1 111 | // 112 | this->label1->BackColor = System::Drawing::Color::Transparent; 113 | this->label1->Location = System::Drawing::Point(96, 32); 114 | this->label1->Name = L"label1"; 115 | this->label1->Size = System::Drawing::Size(88, 16); 116 | this->label1->TabIndex = 3; 117 | this->label1->Text = L"Enter new value"; 118 | // 119 | // NumEntBox 120 | // 121 | this->AcceptButton = this->OKButton; 122 | this->AutoScaleBaseSize = System::Drawing::Size(5, 13); 123 | this->BackgroundImage = (cli::safe_cast(resources->GetObject(L"$this.BackgroundImage"))); 124 | this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch; 125 | this->ClientSize = System::Drawing::Size(292, 164); 126 | this->Controls->Add(this->label1); 127 | this->Controls->Add(this->NumberBox); 128 | this->Controls->Add(this->CancelButton); 129 | this->Controls->Add(this->OKButton); 130 | this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D; 131 | this->MaximizeBox = false; 132 | this->MinimizeBox = false; 133 | this->Name = L"NumEntBox"; 134 | this->Text = L"Direct Value Entry"; 135 | this->ResumeLayout(false); 136 | this->PerformLayout(); 137 | 138 | } 139 | 140 | private: __int64 GetFreq(String ^t) 141 | { 142 | __int64 suff = 1; 143 | if (t->Length > 1 && t[t->Length-1] > '9'){ 144 | switch(t[t->Length-1]) { 145 | case 'g': 146 | case 'G': 147 | suff *= 1000; 148 | case 'm': 149 | case 'M': 150 | suff *= 1000; 151 | case 'k': 152 | case 'K': 153 | suff *= 1000; 154 | default:; 155 | } 156 | } 157 | if (suff > 1) 158 | t = t->Remove(t->Length-1,1); 159 | return((__int64)(Convert::ToInt64(t) * suff)); 160 | } 161 | 162 | public: 163 | void set_NumericValue(__int64 number) { NumberBox->Text = number.ToString(); } // display existing value 164 | 165 | __int64 get_NumericValue() // retrieve value that user entered 166 | { 167 | __int64 n; 168 | try // make sure it's an long number 169 | { 170 | n = GetFreq(NumberBox->Text); 171 | } 172 | catch (System::FormatException^ pe) 173 | { 174 | MessageBox::Show(pe->Message, "Error"); 175 | } 176 | catch (System::OverflowException^ pe) 177 | { 178 | MessageBox::Show(pe->Message, "Error"); 179 | } 180 | 181 | return n; 182 | } 183 | 184 | }; 185 | 186 | } -------------------------------------------------------------------------------- /ReadMe.txt: -------------------------------------------------------------------------------- 1 | This project is a continuation of the TAPR VNA 3.1. 2 | It combines SW and HW designs from various VNA projects (in particular NanoVNA for the HW design and the DSP IF and the DG8SAQ VNWA for the resistive bridge design) to come with a cheap and simple design capable to measure from 1 MHz (or below) to at least 700MHz. It also can do TDR to check cables on short and open 3 | 4 | Main changes are (see VNA current pridge.pdf in Doc folder): 5 | - Using Arduino and SI5351 (on 5$ ebay breakout module) to generate test signal and 5kHz offset mixing signal. Both can be square wave as the mixing removes all unwanted harmonics (like Nano VNA) 6 | - 3 SA612 to do the downmixing to IF at 5khz (like Nano VNA), LM324 to convert balanced outputs to single ended and buffer the switches, 7 | - Added IF DSP on processing on PC (see audioinput.c) to extract the phase/magnitude from the IF. Using 16 bit audio processing delivers over 100dB dynamic range and full 360 degrees phase detection 8 | - Removal of all complex calibration of the phase/magnitude detectors as the IF DSP is completely lineair 9 | - Adding a mockup test device simulating the audio signals generated during a sweep of SOLT to enable testing the SW without connected HW module 10 | 11 | An example implementation uses (see Schematic in doc folder): 12 | - PC with this SW 13 | - Auduino module controlled by USB steering the SI5351 to sweep and the transmission/reflection switch 14 | - Resistor based reflection bridge and 50 ohm transmission sink, both according to DG8SAQ VNWA 15 | - 3 SA612 + ompamps to create the reference (left audio channel), reflection and transmission (right audio channel) audio IF signals 16 | - two FET's and two npn transistors to switch between reflection and transmission for right audio channel. 17 | 18 | The PC software builds on Microsoft Visual C++ 2010 Express (free) and probably also on the newer free versions 19 | The Arduino SW is normal arduino C++ and does run on any Arduino UNO or NANO or similar 20 | 21 | VNAR4.zip contains a ready to run executable (no installation needed). Due to the build in simulator (the mockup dialog) you can run and test the program without HW 22 | 23 | 24 | -------------------------------------------------------------------------------- /SaveConfigurationMenu.Image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/SaveConfigurationMenu.Image.png -------------------------------------------------------------------------------- /Serial.cpp: -------------------------------------------------------------------------------- 1 | // Serial.cpp 2 | 3 | #include "stdafx.h" 4 | #include "objbase.h" 5 | #include "DataDisplay.h" 6 | #include "Mockup.h" 7 | #include "Constants.h" 8 | #using 9 | #using 10 | 11 | using namespace System; 12 | #include "Serial.h" 13 | extern "C" 14 | { 15 | // Declare USB constants and structures 16 | #include "winioctl.h" /// IOCTL definitions 17 | // #include "c:\ntddk\inc\usb100.h" /// general USB 18 | #pragma warning(disable: 4200) // Supress C4200 warning in Microsoft-supplied headers 19 | // #include "c:\ntddk\inc\usbdi.h" // USB Device Interface 20 | #pragma warning(default: 4200) 21 | // #include "c:\ntddk\inc\devioctl.h" /// Device IOCTL definitions 22 | // #include "C:\Cypress\USB\Drivers\ezusbdrv\ezusbsys.h" /// Ezusb IOCTL codes 23 | } 24 | 25 | 26 | CSerial::CSerial() 27 | { 28 | 29 | memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) ); 30 | memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) ); 31 | m_hIDComDev = NULL; 32 | m_bOpened = FALSE; 33 | 34 | } 35 | 36 | CSerial::~CSerial() 37 | { 38 | 39 | Close(); 40 | 41 | } 42 | 43 | bool CSerial::Open( int nPort, int nBaud ) 44 | { 45 | 46 | if( m_bOpened ) return( TRUE ); 47 | 48 | wchar_t szPort[15]; 49 | wchar_t szComParams[50]; 50 | DCB dcb; 51 | 52 | wsprintf( szPort, L"COM%d", nPort ); 53 | m_hIDComDev = CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL ); 54 | if( m_hIDComDev == NULL ) return( FALSE ); 55 | 56 | memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) ); 57 | memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) ); 58 | 59 | COMMTIMEOUTS CommTimeOuts; 60 | CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF; 61 | CommTimeOuts.ReadTotalTimeoutMultiplier = 0; 62 | CommTimeOuts.ReadTotalTimeoutConstant = 0; 63 | CommTimeOuts.WriteTotalTimeoutMultiplier = 0; 64 | CommTimeOuts.WriteTotalTimeoutConstant = 5000; 65 | SetCommTimeouts( m_hIDComDev, &CommTimeOuts ); 66 | 67 | wsprintf( szComParams, L"COM%d:%d,n,8,1", nPort, nBaud ); 68 | 69 | m_OverlappedRead.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); 70 | m_OverlappedWrite.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); 71 | 72 | dcb.DCBlength = sizeof( DCB ); 73 | GetCommState( m_hIDComDev, &dcb ); 74 | dcb.BaudRate = nBaud; 75 | dcb.ByteSize = 8; 76 | unsigned char ucSet; 77 | ucSet = (unsigned char) ( ( FC_RTSCTS & FC_DTRDSR ) != 0 ); 78 | ucSet = (unsigned char) ( ( FC_RTSCTS & FC_RTSCTS ) != 0 ); 79 | ucSet = (unsigned char) ( ( FC_RTSCTS & FC_XONXOFF ) != 0 ); 80 | if( !SetCommState( m_hIDComDev, &dcb ) || 81 | !SetupComm( m_hIDComDev, 10000, 10000 ) || 82 | m_OverlappedRead.hEvent == NULL || 83 | m_OverlappedWrite.hEvent == NULL ){ 84 | DWORD dwError = GetLastError(); 85 | if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent ); 86 | if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent ); 87 | CloseHandle( m_hIDComDev ); 88 | return( FALSE ); 89 | } 90 | 91 | m_bOpened = TRUE; 92 | 93 | return( m_bOpened ); 94 | 95 | } 96 | 97 | bool CSerial::Close( void ) 98 | { 99 | 100 | if( !m_bOpened || m_hIDComDev == NULL ) return( TRUE ); 101 | 102 | if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent ); 103 | if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent ); 104 | CloseHandle( m_hIDComDev ); 105 | m_bOpened = FALSE; 106 | m_hIDComDev = NULL; 107 | 108 | return( TRUE ); 109 | 110 | } 111 | 112 | bool CSerial::WriteCommByte( unsigned char ucByte ) 113 | { 114 | bool bWriteStat; 115 | DWORD dwBytesWritten; 116 | 117 | bWriteStat = (bool)WriteFile( m_hIDComDev, (LPSTR) &ucByte, 1, &dwBytesWritten, &m_OverlappedWrite ); 118 | if( !bWriteStat && ( GetLastError() == ERROR_IO_PENDING ) ){ 119 | if( WaitForSingleObject( m_OverlappedWrite.hEvent, 1000 ) ) dwBytesWritten = 0; 120 | else{ 121 | GetOverlappedResult( m_hIDComDev, &m_OverlappedWrite, &dwBytesWritten, FALSE ); 122 | m_OverlappedWrite.Offset += dwBytesWritten; 123 | } 124 | } 125 | 126 | return( TRUE ); 127 | 128 | } 129 | 130 | int CSerial::SendData( const char *buffer, int size ) 131 | { 132 | 133 | if( !m_bOpened || m_hIDComDev == NULL ) return( 0 ); 134 | 135 | DWORD dwBytesWritten = 0; 136 | int i; 137 | for( i=0; i 4 | #using 5 | //#include 6 | //#include 7 | using namespace System; 8 | using namespace System::IO; 9 | using namespace System::Windows::Forms; 10 | 11 | 12 | 13 | //#include 14 | 15 | #ifndef __SERIAL_H__ 16 | #define __SERIAL_H__ 17 | 18 | #define FC_DTRDSR 0x01 19 | #define FC_RTSCTS 0x02 20 | #define FC_XONXOFF 0x04 21 | #define ASCII_BEL 0x07 22 | #define ASCII_BS 0x08 23 | #define ASCII_LF 0x0A 24 | #define ASCII_CR 0x0D 25 | #define ASCII_XON 0x11 26 | #define ASCII_XOFF 0x13 27 | 28 | 29 | class CSerial 30 | { 31 | 32 | public: 33 | CSerial(); 34 | ~CSerial(); 35 | 36 | bool Open( int nPort = 2, int nBaud = 9600 ); 37 | bool Close( void ); 38 | 39 | int ReadData( void *, int ); 40 | int SendData( const char *, int ); 41 | int ReadDataWaiting( void ); 42 | 43 | bool IsOpened( void ){ return( m_bOpened ); } 44 | 45 | protected: 46 | bool WriteCommByte( unsigned char ); 47 | 48 | void * m_hIDComDev; 49 | OVERLAPPED m_OverlappedRead, m_OverlappedWrite; 50 | bool m_bOpened; 51 | 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /SerialPort.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "SerialPort.h" 3 | 4 | -------------------------------------------------------------------------------- /SerialPort.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /Settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #using 4 | #using 5 | #using 6 | #using 7 | 8 | // 9 | // This source code was auto-generated by xsd, Version=1.1.4322.2032. 10 | // 11 | namespace VNAR3 { 12 | using namespace System; 13 | using namespace System::Data; 14 | using namespace System::Xml; 15 | using namespace System::Runtime::Serialization; 16 | 17 | using namespace System; 18 | public __gc class Settings; 19 | 20 | 21 | [Serializable, 22 | System::ComponentModel::DesignerCategoryAttribute(S"code"), 23 | System::Diagnostics::DebuggerStepThrough, 24 | System::ComponentModel::ToolboxItem(true)] 25 | public __gc class Settings : public System::Data::DataSet { 26 | 27 | public: Settings(); 28 | protected: Settings(System::Runtime::Serialization::SerializationInfo * info, System::Runtime::Serialization::StreamingContext context); 29 | public: virtual System::Data::DataSet * Clone(); 30 | 31 | protected: virtual System::Boolean ShouldSerializeTables(); 32 | 33 | protected: virtual System::Boolean ShouldSerializeRelations(); 34 | 35 | protected: virtual System::Void ReadXmlSerializable(System::Xml::XmlReader * reader); 36 | 37 | protected: virtual System::Xml::Schema::XmlSchema * GetSchemaSerializable(); 38 | 39 | public private: System::Void InitVars(); 40 | 41 | private: System::Void InitClass(); 42 | 43 | private: System::Void SchemaChanged(System::Object * sender, System::ComponentModel::CollectionChangeEventArgs * e); 44 | }; 45 | 46 | 47 | inline Settings::Settings() { 48 | this->InitClass(); 49 | System::ComponentModel::CollectionChangeEventHandler * schemaChangedHandler = new System::ComponentModel::CollectionChangeEventHandler(this, SchemaChanged); 50 | this->Tables->CollectionChanged += schemaChangedHandler; 51 | this->Relations->CollectionChanged += schemaChangedHandler; 52 | } 53 | 54 | inline Settings::Settings(System::Runtime::Serialization::SerializationInfo * info, System::Runtime::Serialization::StreamingContext context) { 55 | System::String * strSchema = (__try_cast(info->GetValue(S"XmlSchema", __typeof(System::String)))); 56 | if ((strSchema != 0)) { 57 | System::Data::DataSet * ds = new System::Data::DataSet(); 58 | ds->ReadXmlSchema(new System::Xml::XmlTextReader(new System::IO::StringReader(strSchema))); 59 | this->DataSetName = ds->DataSetName; 60 | this->Prefix = ds->Prefix; 61 | this->Namespace = ds->Namespace; 62 | this->Locale = ds->Locale; 63 | this->CaseSensitive = ds->CaseSensitive; 64 | this->EnforceConstraints = ds->EnforceConstraints; 65 | this->Merge(ds, false, System::Data::MissingSchemaAction::Add); 66 | this->InitVars(); 67 | } 68 | else { 69 | this->InitClass(); 70 | } 71 | this->GetSerializationData(info, context); 72 | System::ComponentModel::CollectionChangeEventHandler * schemaChangedHandler = new System::ComponentModel::CollectionChangeEventHandler(this, SchemaChanged); 73 | this->Tables->CollectionChanged += schemaChangedHandler; 74 | this->Relations->CollectionChanged += schemaChangedHandler; 75 | } 76 | 77 | inline System::Data::DataSet * Settings::Clone() { 78 | VNAR3::Settings * cln = (__try_cast(__super::Clone())); 79 | cln->InitVars(); 80 | return cln; 81 | }; 82 | 83 | inline System::Boolean Settings::ShouldSerializeTables() { 84 | return false; 85 | }; 86 | 87 | inline System::Boolean Settings::ShouldSerializeRelations() { 88 | return false; 89 | }; 90 | 91 | inline System::Void Settings::ReadXmlSerializable(System::Xml::XmlReader * reader) { 92 | this->Reset(); 93 | System::Data::DataSet * ds = new System::Data::DataSet(); 94 | ds->ReadXml(reader); 95 | this->DataSetName = ds->DataSetName; 96 | this->Prefix = ds->Prefix; 97 | this->Namespace = ds->Namespace; 98 | this->Locale = ds->Locale; 99 | this->CaseSensitive = ds->CaseSensitive; 100 | this->EnforceConstraints = ds->EnforceConstraints; 101 | this->Merge(ds, false, System::Data::MissingSchemaAction::Add); 102 | this->InitVars(); 103 | }; 104 | 105 | inline System::Xml::Schema::XmlSchema * Settings::GetSchemaSerializable() { 106 | System::IO::MemoryStream * stream = new System::IO::MemoryStream(); 107 | this->WriteXmlSchema(new System::Xml::XmlTextWriter(stream, 0)); 108 | stream->Position = 0; 109 | return System::Xml::Schema::XmlSchema::Read(new System::Xml::XmlTextReader(stream), 0); 110 | }; 111 | 112 | inline System::Void Settings::InitVars() { 113 | }; 114 | 115 | inline System::Void Settings::InitClass() { 116 | this->DataSetName = S"Settings"; 117 | this->Prefix = S""; 118 | this->Namespace = S"http://tempuri.org/Settings.xsd"; 119 | this->Locale = new System::Globalization::CultureInfo(S"en-US"); 120 | this->CaseSensitive = false; 121 | this->EnforceConstraints = true; 122 | }; 123 | 124 | inline System::Void Settings::SchemaChanged(System::Object * sender, System::ComponentModel::CollectionChangeEventArgs * e) { 125 | if ((e->Action == System::ComponentModel::CollectionChangeAction::Remove)) { 126 | this->InitVars(); 127 | } 128 | }; 129 | } 130 | -------------------------------------------------------------------------------- /SignalGenerator.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "SignalGenerator.h" 3 | 4 | -------------------------------------------------------------------------------- /SignalGenerator.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, -41 122 | 123 | -------------------------------------------------------------------------------- /TAPR_VNA_Instruction_Manual_Issue_4_prelim.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/TAPR_VNA_Instruction_Manual_Issue_4_prelim.pdf -------------------------------------------------------------------------------- /TDRSetupDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "TDRSetupDialog.h" 3 | 4 | -------------------------------------------------------------------------------- /TDRSetupDialog.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2005-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | /// \author Thomas C. McDermott, N5EG 20 | 21 | #pragma once 22 | 23 | using namespace System; 24 | using namespace System::ComponentModel; 25 | using namespace System::Collections; 26 | using namespace System::Windows::Forms; 27 | using namespace System::Data; 28 | using namespace System::Drawing; 29 | 30 | 31 | 32 | namespace VNAR3 33 | { 34 | /// 35 | /// Summary for TDRSetupDialog 36 | /// 37 | /// WARNING: If you change the name of this class, you will need to change the 38 | /// 'Resource File Name' property for the managed resource compiler tool 39 | /// associated with all .resx files this class depends on. Otherwise, 40 | /// the designers will not be able to interact properly with localized 41 | /// resources associated with this form. 42 | /// 43 | public ref class TDRSetupDialog : public System::Windows::Forms::Form 44 | { 45 | public: 46 | TDRSetupDialog(void) 47 | { 48 | InitializeComponent(); 49 | } 50 | 51 | protected: 52 | ~TDRSetupDialog() 53 | { 54 | if(components) 55 | delete(components); 56 | } 57 | 58 | private: System::Windows::Forms::Label^ label1; 59 | private: System::Windows::Forms::TextBox^ TDRStartTextBox; 60 | private: System::Windows::Forms::TextBox^ TDRStopTextBox; 61 | private: System::Windows::Forms::Label^ label2; 62 | private: System::Windows::Forms::Label^ label3; 63 | private: System::Windows::Forms::Button^ OKbutton; 64 | private: System::Windows::Forms::Button^ Cancelbutton; 65 | private: System::Windows::Forms::Label^ label4; 66 | private: System::Windows::Forms::TextBox^ TDRVFTextBox; 67 | private: System::Windows::Forms::GroupBox^ groupBox1; 68 | private: System::Windows::Forms::RadioButton^ MetersRadioButton; 69 | private: System::Windows::Forms::RadioButton^ FeetRadioButton; 70 | 71 | public: 72 | float TDRStart, TDRStop; 73 | 74 | 75 | 76 | private: 77 | /// 78 | /// Required designer variable. 79 | /// 80 | System::ComponentModel::Container^ components; 81 | 82 | /// 83 | /// Required method for Designer support - do not modify 84 | /// the contents of this method with the code editor. 85 | /// 86 | void InitializeComponent(void) 87 | { 88 | System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(TDRSetupDialog::typeid)); 89 | this->label1 = (gcnew System::Windows::Forms::Label()); 90 | this->TDRStartTextBox = (gcnew System::Windows::Forms::TextBox()); 91 | this->TDRStopTextBox = (gcnew System::Windows::Forms::TextBox()); 92 | this->label2 = (gcnew System::Windows::Forms::Label()); 93 | this->label3 = (gcnew System::Windows::Forms::Label()); 94 | this->OKbutton = (gcnew System::Windows::Forms::Button()); 95 | this->Cancelbutton = (gcnew System::Windows::Forms::Button()); 96 | this->TDRVFTextBox = (gcnew System::Windows::Forms::TextBox()); 97 | this->label4 = (gcnew System::Windows::Forms::Label()); 98 | this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); 99 | this->FeetRadioButton = (gcnew System::Windows::Forms::RadioButton()); 100 | this->MetersRadioButton = (gcnew System::Windows::Forms::RadioButton()); 101 | this->groupBox1->SuspendLayout(); 102 | this->SuspendLayout(); 103 | // 104 | // label1 105 | // 106 | this->label1->Anchor = System::Windows::Forms::AnchorStyles::Top; 107 | this->label1->BackColor = System::Drawing::Color::Transparent; 108 | this->label1->Font = (gcnew System::Drawing::Font(L"Verdana", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 109 | static_cast(0))); 110 | this->label1->Location = System::Drawing::Point(56, 24); 111 | this->label1->Name = L"label1"; 112 | this->label1->Size = System::Drawing::Size(192, 23); 113 | this->label1->TabIndex = 0; 114 | this->label1->Text = L"TDR Display Control"; 115 | this->label1->TextAlign = System::Drawing::ContentAlignment::TopCenter; 116 | // 117 | // TDRStartTextBox 118 | // 119 | this->TDRStartTextBox->Location = System::Drawing::Point(200, 72); 120 | this->TDRStartTextBox->Name = L"TDRStartTextBox"; 121 | this->TDRStartTextBox->Size = System::Drawing::Size(80, 20); 122 | this->TDRStartTextBox->TabIndex = 1; 123 | this->TDRStartTextBox->Text = L"0"; 124 | // 125 | // TDRStopTextBox 126 | // 127 | this->TDRStopTextBox->Location = System::Drawing::Point(200, 112); 128 | this->TDRStopTextBox->Name = L"TDRStopTextBox"; 129 | this->TDRStopTextBox->Size = System::Drawing::Size(80, 20); 130 | this->TDRStopTextBox->TabIndex = 2; 131 | this->TDRStopTextBox->Text = L"4350"; 132 | // 133 | // label2 134 | // 135 | this->label2->BackColor = System::Drawing::Color::Transparent; 136 | this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8)); 137 | this->label2->Location = System::Drawing::Point(16, 72); 138 | this->label2->Name = L"label2"; 139 | this->label2->Size = System::Drawing::Size(152, 23); 140 | this->label2->TabIndex = 3; 141 | this->label2->Text = L"TDR Display Start Time, nsec."; 142 | // 143 | // label3 144 | // 145 | this->label3->BackColor = System::Drawing::Color::Transparent; 146 | this->label3->Location = System::Drawing::Point(16, 112); 147 | this->label3->Name = L"label3"; 148 | this->label3->Size = System::Drawing::Size(152, 23); 149 | this->label3->TabIndex = 4; 150 | this->label3->Text = L"TDR Display Stop time, nsec."; 151 | // 152 | // OKbutton 153 | // 154 | this->OKbutton->DialogResult = System::Windows::Forms::DialogResult::OK; 155 | this->OKbutton->FlatStyle = System::Windows::Forms::FlatStyle::System; 156 | this->OKbutton->Location = System::Drawing::Point(64, 312); 157 | this->OKbutton->Name = L"OKbutton"; 158 | this->OKbutton->Size = System::Drawing::Size(72, 24); 159 | this->OKbutton->TabIndex = 5; 160 | this->OKbutton->Text = L"OK"; 161 | this->OKbutton->Click += gcnew System::EventHandler(this, &TDRSetupDialog::OKbutton_Click); 162 | // 163 | // Cancelbutton 164 | // 165 | this->Cancelbutton->DialogResult = System::Windows::Forms::DialogResult::Cancel; 166 | this->Cancelbutton->FlatStyle = System::Windows::Forms::FlatStyle::System; 167 | this->Cancelbutton->Location = System::Drawing::Point(168, 312); 168 | this->Cancelbutton->Name = L"Cancelbutton"; 169 | this->Cancelbutton->Size = System::Drawing::Size(72, 24); 170 | this->Cancelbutton->TabIndex = 6; 171 | this->Cancelbutton->Text = L"Cancel"; 172 | // 173 | // TDRVFTextBox 174 | // 175 | this->TDRVFTextBox->Location = System::Drawing::Point(200, 160); 176 | this->TDRVFTextBox->Name = L"TDRVFTextBox"; 177 | this->TDRVFTextBox->Size = System::Drawing::Size(80, 20); 178 | this->TDRVFTextBox->TabIndex = 7; 179 | this->TDRVFTextBox->Text = L"0.68"; 180 | // 181 | // label4 182 | // 183 | this->label4->BackColor = System::Drawing::Color::Transparent; 184 | this->label4->Location = System::Drawing::Point(16, 160); 185 | this->label4->Name = L"label4"; 186 | this->label4->Size = System::Drawing::Size(168, 32); 187 | this->label4->TabIndex = 8; 188 | this->label4->Text = L"Enter the Estimated Cable Velocity Factor (0.4 to 0.99)"; 189 | // 190 | // groupBox1 191 | // 192 | this->groupBox1->BackColor = System::Drawing::Color::Transparent; 193 | this->groupBox1->Controls->Add(this->FeetRadioButton); 194 | this->groupBox1->Controls->Add(this->MetersRadioButton); 195 | this->groupBox1->Location = System::Drawing::Point(56, 208); 196 | this->groupBox1->Name = L"groupBox1"; 197 | this->groupBox1->Size = System::Drawing::Size(200, 80); 198 | this->groupBox1->TabIndex = 9; 199 | this->groupBox1->TabStop = false; 200 | this->groupBox1->Text = L"View Distance to marker as:"; 201 | // 202 | // FeetRadioButton 203 | // 204 | this->FeetRadioButton->FlatStyle = System::Windows::Forms::FlatStyle::System; 205 | this->FeetRadioButton->Location = System::Drawing::Point(16, 48); 206 | this->FeetRadioButton->Name = L"FeetRadioButton"; 207 | this->FeetRadioButton->Size = System::Drawing::Size(64, 24); 208 | this->FeetRadioButton->TabIndex = 1; 209 | this->FeetRadioButton->Text = L"Feet"; 210 | // 211 | // MetersRadioButton 212 | // 213 | this->MetersRadioButton->Checked = true; 214 | this->MetersRadioButton->FlatStyle = System::Windows::Forms::FlatStyle::System; 215 | this->MetersRadioButton->Location = System::Drawing::Point(16, 24); 216 | this->MetersRadioButton->Name = L"MetersRadioButton"; 217 | this->MetersRadioButton->Size = System::Drawing::Size(72, 24); 218 | this->MetersRadioButton->TabIndex = 0; 219 | this->MetersRadioButton->TabStop = true; 220 | this->MetersRadioButton->Text = L"Meters"; 221 | // 222 | // TDRSetupDialog 223 | // 224 | this->AcceptButton = this->OKbutton; 225 | this->AutoScaleBaseSize = System::Drawing::Size(5, 13); 226 | this->BackgroundImage = (cli::safe_cast(resources->GetObject(L"$this.BackgroundImage"))); 227 | this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch; 228 | this->ClientSize = System::Drawing::Size(314, 368); 229 | this->Controls->Add(this->groupBox1); 230 | this->Controls->Add(this->label4); 231 | this->Controls->Add(this->TDRVFTextBox); 232 | this->Controls->Add(this->TDRStopTextBox); 233 | this->Controls->Add(this->TDRStartTextBox); 234 | this->Controls->Add(this->Cancelbutton); 235 | this->Controls->Add(this->OKbutton); 236 | this->Controls->Add(this->label3); 237 | this->Controls->Add(this->label2); 238 | this->Controls->Add(this->label1); 239 | this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; 240 | this->Name = L"TDRSetupDialog"; 241 | this->Text = L"TDRSetupDialog"; 242 | this->groupBox1->ResumeLayout(false); 243 | this->ResumeLayout(false); 244 | this->PerformLayout(); 245 | 246 | } 247 | 248 | 249 | 250 | 251 | public: 252 | void set_Start(float number) { TDRStartTextBox->Text = number.ToString(); } 253 | float get_Start() 254 | { 255 | float n; 256 | try 257 | { 258 | n = Convert::ToSingle(TDRStartTextBox->Text); 259 | } 260 | catch (System::FormatException^ pe) 261 | { 262 | MessageBox::Show(pe->Message, "Error"); 263 | } 264 | catch (System::OverflowException^ pe) 265 | { 266 | MessageBox::Show(pe->Message, "Error"); 267 | } 268 | return n; 269 | } 270 | void set_Stop(float number) { TDRStopTextBox->Text = number.ToString(); } 271 | float get_Stop() 272 | { 273 | float n; 274 | try 275 | { 276 | n = Convert::ToSingle(TDRStopTextBox->Text); 277 | } 278 | catch (System::FormatException^ pe) 279 | { 280 | MessageBox::Show(pe->Message, "Error"); 281 | } 282 | catch (System::OverflowException^ pe) 283 | { 284 | MessageBox::Show(pe->Message, "Error"); 285 | } 286 | return n; 287 | } 288 | void set_VF(float number) { TDRVFTextBox->Text = number.ToString(); } 289 | float get_VF() 290 | { 291 | float n; 292 | try 293 | { 294 | n = Convert::ToSingle(TDRVFTextBox->Text); 295 | } 296 | catch (System::FormatException^ pe) 297 | { 298 | MessageBox::Show(pe->Message, "Error"); 299 | } 300 | catch (System::OverflowException^ pe) 301 | { 302 | MessageBox::Show(pe->Message, "Error"); 303 | } 304 | return n; 305 | } 306 | bool get_MetricMode() { return MetersRadioButton->Checked; } 307 | void set_MetricMode(bool mode) 308 | { 309 | if(mode) 310 | { 311 | MetersRadioButton->Checked = true; 312 | FeetRadioButton->Checked = false; 313 | } 314 | else 315 | { 316 | MetersRadioButton->Checked = false; 317 | FeetRadioButton->Checked = true; 318 | } 319 | } 320 | private: System::Void OKbutton_Click(System::Object^ sender, System::EventArgs^ e) 321 | { 322 | try 323 | { 324 | // VNAR3::Form1::TDRStartTime = Convert::ToSingle(TDRStartTextBox->Text); 325 | // VNAR3::Form1::TDRStopTime = Convert::ToSingle(TDRStopTextBox->Text); 326 | } 327 | catch (System::FormatException^ pe) 328 | { 329 | MessageBox::Show(pe->Message, "Error"); 330 | } 331 | catch (System::OverflowException^ pe) 332 | { 333 | MessageBox::Show(pe->Message, "Error"); 334 | } 335 | 336 | } 337 | 338 | }; 339 | } -------------------------------------------------------------------------------- /TextEntry.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "TextEntry.h" 3 | 4 | -------------------------------------------------------------------------------- /TextEntry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | #pragma once 20 | 21 | using namespace System; 22 | using namespace System::ComponentModel; 23 | using namespace System::Collections; 24 | using namespace System::Windows::Forms; 25 | using namespace System::Data; 26 | using namespace System::Drawing; 27 | 28 | 29 | namespace VNAR3 30 | { 31 | /// 32 | /// Summary for TextEntry 33 | /// 34 | /// WARNING: If you change the name of this class, you will need to change the 35 | /// 'Resource File Name' property for the managed resource compiler tool 36 | /// associated with all .resx files this class depends on. Otherwise, 37 | /// the designers will not be able to interact properly with localized 38 | /// resources associated with this form. 39 | /// 40 | 41 | /// Text Entry dialogbox 42 | public ref class TextEntry : public System::Windows::Forms::Form 43 | { 44 | public: 45 | TextEntry(String^ BoxTitle) 46 | { 47 | InitializeComponent(); 48 | label1->Text = BoxTitle; 49 | } 50 | 51 | public: 52 | String^ EnteredText() { return textBox1->Text; }; 53 | void set_DisplayedText(String^ Input) { textBox1->Text = Input; } 54 | 55 | protected: 56 | ~TextEntry() 57 | { 58 | if(components) 59 | delete(components); 60 | } 61 | 62 | private: System::Windows::Forms::Label^ label1; 63 | private: System::Windows::Forms::TextBox^ textBox1; 64 | private: System::Windows::Forms::Button^ OKbutton; 65 | private: System::Windows::Forms::Button^ CancelButton; 66 | 67 | private: 68 | /// 69 | /// Required designer variable. 70 | /// 71 | System::ComponentModel::Container^ components; 72 | 73 | /// 74 | /// Required method for Designer support - do not modify 75 | /// the contents of this method with the code editor. 76 | /// 77 | void InitializeComponent(void) 78 | { 79 | System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(TextEntry::typeid)); 80 | this->label1 = (gcnew System::Windows::Forms::Label()); 81 | this->textBox1 = (gcnew System::Windows::Forms::TextBox()); 82 | this->OKbutton = (gcnew System::Windows::Forms::Button()); 83 | this->CancelButton = (gcnew System::Windows::Forms::Button()); 84 | this->SuspendLayout(); 85 | // 86 | // label1 87 | // 88 | this->label1->BackColor = System::Drawing::Color::Transparent; 89 | this->label1->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 90 | static_cast(0))); 91 | this->label1->Location = System::Drawing::Point(24, 16); 92 | this->label1->Name = L"label1"; 93 | this->label1->Size = System::Drawing::Size(640, 23); 94 | this->label1->TabIndex = 0; 95 | this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; 96 | // 97 | // textBox1 98 | // 99 | this->textBox1->Location = System::Drawing::Point(16, 48); 100 | this->textBox1->Name = L"textBox1"; 101 | this->textBox1->Size = System::Drawing::Size(648, 20); 102 | this->textBox1->TabIndex = 1; 103 | // 104 | // OKbutton 105 | // 106 | this->OKbutton->DialogResult = System::Windows::Forms::DialogResult::OK; 107 | this->OKbutton->FlatStyle = System::Windows::Forms::FlatStyle::System; 108 | this->OKbutton->Location = System::Drawing::Point(248, 88); 109 | this->OKbutton->Name = L"OKbutton"; 110 | this->OKbutton->Size = System::Drawing::Size(72, 24); 111 | this->OKbutton->TabIndex = 2; 112 | this->OKbutton->Text = L"OK"; 113 | // 114 | // CancelButton 115 | // 116 | this->CancelButton->DialogResult = System::Windows::Forms::DialogResult::Cancel; 117 | this->CancelButton->FlatStyle = System::Windows::Forms::FlatStyle::System; 118 | this->CancelButton->Location = System::Drawing::Point(352, 88); 119 | this->CancelButton->Name = L"CancelButton"; 120 | this->CancelButton->Size = System::Drawing::Size(72, 24); 121 | this->CancelButton->TabIndex = 3; 122 | this->CancelButton->Text = L"Cancel"; 123 | // 124 | // TextEntry 125 | // 126 | this->AcceptButton = this->OKbutton; 127 | this->AutoScaleBaseSize = System::Drawing::Size(5, 13); 128 | this->BackgroundImage = (cli::safe_cast(resources->GetObject(L"$this.BackgroundImage"))); 129 | this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch; 130 | this->ClientSize = System::Drawing::Size(680, 126); 131 | this->Controls->Add(this->CancelButton); 132 | this->Controls->Add(this->OKbutton); 133 | this->Controls->Add(this->textBox1); 134 | this->Controls->Add(this->label1); 135 | this->Name = L"TextEntry"; 136 | this->Text = L"TextEntry"; 137 | this->ResumeLayout(false); 138 | this->PerformLayout(); 139 | 140 | } 141 | }; 142 | } -------------------------------------------------------------------------------- /USB_EZ_interface.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004, Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | // Class to encapsulate the EZUSB device interface 22 | 23 | // Only the functions are disclosed here because .NET has a conflict 24 | // with header files. 25 | // #including the "objbase.h" file in the main .NET file causes it not to 26 | // compile due to Interface conflicts. But "objbase.h" is required to access 27 | // DeviceIoControl and USB definitions. So it's in the USB_EZ_interface.cpp 28 | // CPP file, not here in the header. This header gets #included in the main 29 | // program. VNADevice had to be redesigned so that it does not expose any 30 | // variables or functions (private or public) that require the objbase.h 31 | // header to define. All those functions are localized inside the methods 32 | // of VNADevice in the .cpp file only. Yuck. 33 | // Slight improvement: all the messy variables are localized inside a Helper 34 | // function, which only gets mentioned in the .H file via a forward reference 35 | // (thus hiding it's internals). 36 | 37 | 38 | #include "stdafx.h" 39 | #include "DataDisplay.h" 40 | #using 41 | 42 | extern volatile float magSig; 43 | extern volatile float phaseSig; 44 | extern volatile float volSig; 45 | 46 | #define HW_MOCKUP 0 47 | #define HW_NANOVNA 1 48 | #define HW_SI5351 2 49 | #define HW_ADF4351 3 50 | #define HW_NANOV2 4 51 | 52 | #define DIR_TRANS 0 53 | #define DIR_REFL 1 54 | 55 | /// VNA Device wrapper. Holds state and device handle 56 | public ref class VNADevice 57 | { 58 | private: 59 | bool Result; // DeviceIoControl result 60 | int state; // -1=no device +1=device OK 61 | int mode; 62 | //int mp; 63 | long lastFreq; 64 | int lastDir; 65 | int cable_before; 66 | int cable_after; 67 | int resistance; 68 | int capacitance; 69 | int sourcecapacitance; 70 | int inductance; 71 | int hardware; 72 | int hasScanCommand; 73 | float noise; 74 | __int64 minHWFreq; 75 | __int64 maxHWFreq; 76 | array^ S11Real; 77 | array^ S11Imag; 78 | array^ S21Real; 79 | array^ S21Imag; 80 | int index; 81 | int dur; // total duration of one side signal 82 | System::IO::Ports::SerialPort^ serialPort; 83 | 84 | // long int IICErrorCount; // Temporary IIC error counter 85 | 86 | /*__nogc*/ class Helper * d; // holds the USB device state 87 | 88 | void GetHandle(void); 89 | void ReleaseHandle(void); 90 | bool ToggleReset(bool hold); 91 | 92 | public: 93 | VNADevice(System::IO::Ports::SerialPort^ port); // Constructor: open device, set state 94 | ~VNADevice(); // Destructor: release __nogc objects and structs 95 | bool Init(void); // Build descriptors, get pipes 96 | int State(); // -1 = no device +1 = device OK 97 | bool Start(); // Release reset of the 8051 processor on VNA 98 | bool Stop(); // Halt the 8051 processor on VNA 99 | bool Sweep(__int64 startF, __int64 stepF, int numPoints, int duration, System::Windows::Forms::ProgressBar^ SweepProgressBar, int power); 100 | void Sweep(__int64 startF, __int64 stepF, int numPoints, int duration, System::Windows::Forms::ProgressBar^ SweepProgressBar); 101 | void SetFreq(__int64 startF, int direction); 102 | bool Download(array^ Codebuffer, int CodeSize, unsigned short Address ); // download code to 8051 103 | bool Read(VNA_RXBUFFER * readbuf); // Read 64 bytes of data from BULK_IN_EP2 - it blocks the 104 | // calling thread, but the VNA always tries to have a buffer 105 | // ready so it should never actually block. 106 | // If 1st byte is 0xff or 0xfe, it's a dummy return, 107 | // If 1st byte is 0x01, it's a valid data block 108 | // If 2nd byte is not 0x00, there was an I2C error on the 8051 109 | bool Write(VNA_TXBUFFER * writebuf); // Write 64 bytes of data to BULK_OUT_EP2 endpoint 110 | bool WriteRead(VNA_TXBUFFER * TxBuffer, VNA_RXBUFFER * RxBuffer, int direction); // Write data buffer then retrieve Rx buffer 111 | bool FindVNA(); // Check if current serial port and HW selection is connected with the right device 112 | void SetMode(int m); 113 | void SetBefore(int l); 114 | void SetAfter(int l); 115 | void SetResistance(int v); 116 | void SetCapacitance(int v); 117 | void SetSourceCapacitance(int v); 118 | void SetInductance(int v); 119 | void SelectHardware(int h); 120 | int GetHardware(); 121 | void SetAudioRefLevel(double h); 122 | double GetAudioRefLevel(); 123 | void SetNoise(float c); 124 | void SetMaxFreq(__int64 f); 125 | void SetMinFreq(__int64 f); 126 | __int64 GetMinFreq(); 127 | __int64 GetMaxFreq(); 128 | void VNADevice::SetIF(int r); 129 | int VNADevice::GetIF(); 130 | array^ VNADevice::Perform(System::String ^command); 131 | 132 | }; 133 | -------------------------------------------------------------------------------- /VNAR3 Help.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/VNAR3 Help.chm -------------------------------------------------------------------------------- /VNAR3.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VNAR3", "VNAR3.vcxproj", "{490B301C-F977-49BD-97A9-F750517E03E0}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | Template|Win32 = Template|Win32 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {490B301C-F977-49BD-97A9-F750517E03E0}.Debug|Win32.ActiveCfg = Debug|Win32 14 | {490B301C-F977-49BD-97A9-F750517E03E0}.Debug|Win32.Build.0 = Debug|Win32 15 | {490B301C-F977-49BD-97A9-F750517E03E0}.Release|Win32.ActiveCfg = Release|Win32 16 | {490B301C-F977-49BD-97A9-F750517E03E0}.Release|Win32.Build.0 = Release|Win32 17 | {490B301C-F977-49BD-97A9-F750517E03E0}.Template|Win32.ActiveCfg = Template|Win32 18 | {490B301C-F977-49BD-97A9-F750517E03E0}.Template|Win32.Build.0 = Template|Win32 19 | EndGlobalSection 20 | GlobalSection(SolutionProperties) = preSolution 21 | HideSolutionNode = FALSE 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /VNAR3.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Template 14 | Win32 15 | 16 | 17 | 18 | {490B301C-F977-49BD-97A9-F750517E03E0} 19 | VNAR3 20 | ManagedCProj 21 | 22 | 23 | 24 | Application 25 | MultiByte 26 | true 27 | 28 | 29 | Application 30 | Unicode 31 | true 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | <_ProjectFileVersion>10.0.40219.1 47 | $(SolutionDir)$(Configuration)\ 48 | $(Configuration)\ 49 | true 50 | 51 | $(SolutionDir)$(Configuration)\ 52 | $(Configuration)\ 53 | false 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Disabled 62 | WIN32;_DEBUG;%(PreprocessorDefinitions) 63 | false 64 | Default 65 | MultiThreadedDebugDLL 66 | Use 67 | Level3 68 | ProgramDatabase 69 | false 70 | 71 | 72 | /SAFESEH 73 | %(AdditionalOptions) 74 | $(OutDir)$(ProjectName).exe 75 | true 76 | true 77 | Windows 78 | main 79 | false 80 | 81 | 82 | form1.h 83 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies) 84 | 85 | 86 | 87 | 88 | WIN32;NDEBUG;%(PreprocessorDefinitions) 89 | false 90 | MultiThreadedDLL 91 | Use 92 | Level3 93 | ProgramDatabase 94 | 95 | 96 | /SAFESEH 97 | %(AdditionalOptions) 98 | $(OutDir)$(ProjectName).exe 99 | true 100 | Windows 101 | main 102 | false 103 | 104 | 105 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies) 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | copy "$(TargetPath)" "C:\Users\Erik\Google Drive\Arduino_PC" 115 | 116 | 117 | 118 | 119 | true 120 | true 121 | 122 | 123 | true 124 | true 125 | 126 | 127 | true 128 | true 129 | 130 | 131 | true 132 | true 133 | 134 | 135 | true 136 | true 137 | 138 | 139 | 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | Create 163 | Create 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | CppForm 172 | 173 | 174 | 175 | CppForm 176 | 177 | 178 | 179 | CppForm 180 | 181 | 182 | 183 | 184 | 185 | 186 | CppForm 187 | 188 | 189 | 190 | CppForm 191 | 192 | 193 | CppForm 194 | 195 | 196 | CppForm 197 | 198 | 199 | CppForm 200 | 201 | 202 | 203 | CppForm 204 | 205 | 206 | CppForm 207 | 208 | 209 | 210 | CppForm 211 | 212 | 213 | CppForm 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | About.h 229 | Designer 230 | 231 | 232 | Calibration.h 233 | Designer 234 | 235 | 236 | CursorStatus.h 237 | Designer 238 | 239 | 240 | Form1.h 241 | Designer 242 | 243 | 244 | 245 | MarkerEntry.h 246 | Designer 247 | 248 | 249 | Mockup.h 250 | Designer 251 | 252 | 253 | NumEntBox.h 254 | Designer 255 | 256 | 257 | SerialPort.h 258 | Designer 259 | 260 | 261 | SignalGenerator.h 262 | Designer 263 | 264 | 265 | TDRSetupDialog.h 266 | Designer 267 | 268 | 269 | TextEntry.h 270 | Designer 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | -------------------------------------------------------------------------------- /VNAR3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | Source Files 68 | 69 | 70 | Source Files 71 | 72 | 73 | Source Files 74 | 75 | 76 | Source Files 77 | 78 | 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | Header Files 127 | 128 | 129 | Header Files 130 | 131 | 132 | Header Files 133 | 134 | 135 | Header Files 136 | 137 | 138 | Header Files 139 | 140 | 141 | Header Files 142 | 143 | 144 | Header Files 145 | 146 | 147 | 148 | 149 | Resource Files 150 | 151 | 152 | Resource Files 153 | 154 | 155 | Resource Files 156 | 157 | 158 | 159 | 160 | 161 | Resource Files 162 | 163 | 164 | 165 | 166 | Resource Files 167 | 168 | 169 | Resource Files 170 | 171 | 172 | Resource Files 173 | 174 | 175 | Resource Files 176 | 177 | 178 | Resource Files 179 | 180 | 181 | Resource Files 182 | 183 | 184 | Resource Files 185 | 186 | 187 | Resource Files 188 | 189 | 190 | Resource Files 191 | 192 | 193 | Resource Files 194 | 195 | 196 | Resource Files 197 | 198 | 199 | Resource Files 200 | 201 | 202 | -------------------------------------------------------------------------------- /VNAR4.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/VNAR4.4.zip -------------------------------------------------------------------------------- /VNAR4.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/VNAR4.5.zip -------------------------------------------------------------------------------- /VNAR4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/VNAR4.zip -------------------------------------------------------------------------------- /app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/app.ico -------------------------------------------------------------------------------- /app.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | //#include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (U.S.) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | #ifdef _WIN32 20 | //LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | #pragma code_page(1252) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Icon 27 | // 28 | 29 | // Icon with lowest ID value placed first to ensure application icon 30 | // remains consistent on all systems. 31 | 1 ICON "app.ico" 32 | 33 | #ifdef APSTUDIO_INVOKED 34 | ///////////////////////////////////////////////////////////////////////////// 35 | // 36 | // TEXTINCLUDE 37 | // 38 | 39 | 1 TEXTINCLUDE 40 | BEGIN 41 | "resource.h\0" 42 | "\0" 43 | END 44 | 45 | 2 TEXTINCLUDE 46 | BEGIN 47 | "#include ""afxres.h""\r\n" 48 | "\0" 49 | END 50 | 51 | 3 TEXTINCLUDE 52 | BEGIN 53 | "\r\n" 54 | "\0" 55 | END 56 | 57 | #endif // APSTUDIO_INVOKED 58 | 59 | #endif // English (U.S.) resources 60 | ///////////////////////////////////////////////////////////////////////////// 61 | 62 | 63 | 64 | #ifndef APSTUDIO_INVOKED 65 | ///////////////////////////////////////////////////////////////////////////// 66 | // 67 | // Generated from the TEXTINCLUDE 3 resource. 68 | // 69 | 70 | 71 | ///////////////////////////////////////////////////////////////////////////// 72 | #endif // not APSTUDIO_INVOKED 73 | 74 | -------------------------------------------------------------------------------- /delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/delete.png -------------------------------------------------------------------------------- /icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/icon1.ico -------------------------------------------------------------------------------- /icon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/icon2.ico -------------------------------------------------------------------------------- /icon3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/icon3.ico -------------------------------------------------------------------------------- /nanoVNA_1500.cal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/nanoVNA_1500.cal -------------------------------------------------------------------------------- /nanoVNA_2100.cal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/nanoVNA_2100.cal -------------------------------------------------------------------------------- /not_used/5000Hz.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/not_used/5000Hz.mp3 -------------------------------------------------------------------------------- /not_used/500Hz stereo.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/not_used/500Hz stereo.mp3 -------------------------------------------------------------------------------- /not_used/Detector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | // Routines to encapsulate the magnitude/phase detector IC 23 | // Refl and Tran detector routines are starting to diverge. 24 | // 25 | // 09-03-2007 TC McDermott 26 | // 27 | 28 | 29 | #include "stdafx.h" 30 | #using 31 | #using 32 | using namespace System; 33 | using namespace System::IO; 34 | using namespace System::Windows::Forms; 35 | 36 | /// Analog Devices AD8302 device-dependent constants 37 | public ref class Detector 38 | { 39 | public: 40 | int maxMagnitude; ///< maximum magnitude reading 41 | float unitsPerdB; ///< magnitude ADC counts per dB. (~57.0) 42 | array^ pherror; ///< phase error for each degree 43 | array^ MagTable; ///< refl magnitude raw data table 44 | array^ m; ///< y = mx + b from linear regression, by frequency 45 | array^ b; ///< y = mx + b from linear regression, by frequency 46 | array^ r; ///< 'r' is the correlation coefficient for the regression, by frequency 47 | array^ flat; ///< ADC count where amp detector bottoms out 48 | static const int t1 = 110; // twiddle factors for detector floor correction 49 | static const int t2 = 110; 50 | String^ name; // Name of detector (TxDet or RxDet) 51 | 52 | // New 06-09-2007 53 | double diffQDelayNs; ///< differential time delay of Q-reference compared to I-reference 54 | int Iasym, Qasym, IasymLo; ///< Phase detector lead/lag asymmetry 55 | 56 | int Qmin, Qmax, Imin, Imax; /// Phase Detector mins and maxes - New 06-16-2007 57 | int Qmid, Imid, Qmag, Imag; /// derived detector center lines & half-range 58 | 59 | int IminLo, ImaxLo, ImidLo, ImagLo; /// derived I phase detector low ref level mins and maxes - New 09-30-2007 60 | 61 | int beginIndex, endIndex; /// Index of 90-degrees and 90+360 degrees of the shorted cal cable 62 | 63 | bool phaseCalibrated; ///< true if phase values have been calibrated 64 | 65 | Detector(void); // Constructor, allocate default values 66 | bool PhaseCal(array^ Iphase, array^ Qphase, array^ IphaseLo); // construct phase points from raw data 67 | bool AmpCal(array^ Mag); // construct amplitude calibration table from raw data 68 | double IQtoDegrees(int I, int Q, int Freq, double MagDb, int ILo, int QLo); // convert I/Q ADC reading to degrees 69 | double MagTodBRefl(int Freq, int Mag); // convert detector magnitude count to dB. via piecewise linear fit 70 | double MagTodBTran(int Freq, int Mag, int LowMag, int MidMag); // convert detector magnitude count to dB. via table lookup 71 | double CompensateQDelay(double Degrees, int Freq); // compensate phase reading for Q-reference delay 72 | double CompensateAsymmetry(double Degrees); // compensate phase reading for detector assymmetry 73 | }; 74 | 75 | 76 | -------------------------------------------------------------------------------- /not_used/DirectionalCoupler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2004-2010 Thomas C. McDermott, N5EG 3 | // This file is part of VNAR - the Vector Network Analyzer program. 4 | // 5 | // VNAR is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // VNAR is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with VNAR, if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #pragma once 21 | 22 | // Routines to encapsulate directional coupler compensation 23 | 24 | 25 | #include "stdafx.h" 26 | #include "DisplayRoutines.h" 27 | #using 28 | #using 29 | using namespace System; 30 | using namespace System::ComponentModel; 31 | using namespace System::IO; 32 | using namespace System::Windows::Forms; 33 | 34 | ref class InstrumentCalDataSet; //so DirectionalCoupler class can forward-reference InstrumentCalDataSet 35 | 36 | /// Set of coefficients for 6-point periodic error model 37 | public ref struct PerErrModelCoeff { 38 | int freq; ///< frequency where set applies 39 | double offset; ///< offset angle of the correction in degrees 40 | double mag; ///< peak magnitude of the correction 41 | }; 42 | 43 | /// Encapsulate directional coupler error model 44 | public ref class DirectionalCoupler 45 | { 46 | public: 47 | 48 | // double calCableSurgeRealOhms, calCableSurgeImagOhms; // real and imaginary parts of cal cable surge impedance 49 | 50 | array^ DirMag; // Directivity cal raw data 51 | array^ DirIphs; // Directivity cal raw data 52 | array^ DirQphs; // Directivity cal raw data 53 | 54 | array^ PhRipCoeff; // Array of phase ripple coefficients 55 | array^ MagRipCoeff; // Array of mag ripple coefficients 56 | 57 | array^ phaseError; // Array of open-short angle error for LF phase computation 58 | array^ magError; // Array of open-short magnitude for magnitude compensation 59 | array^ openAngle; // Array of open angle for LF phase computation 60 | array^ shortAngle; // Array of short angle for LF phase computation 61 | 62 | bool DirCalibrated; ///< true if Directivity Calibration has been run or values loaded from cal file 63 | bool RippleCalibrated; ///< true if Mag & Phase ripple calibration has been run or values loaded from cal file 64 | 65 | double PhaseDCOffset; ///< Value of phase error offset (sum of all phaseError/numPoints) 66 | double MagDCOffset; ///< Value of mag error offset (sum of magError/numPoints) 67 | 68 | 69 | DirectionalCoupler(void); // constructor 70 | // store coupler directivity calibration raw readings 71 | void DirectivityCal(array^ readings); 72 | // Compensate S11 reading for Coupler Directivity 73 | void CompensateDirectivity(InstrumentCalDataSet^ cal, double& rmagnitudeLin, double& rphase, int Freq); 74 | // Generate table of unit-length ripple compensation vectors 75 | bool GenerateShortOpenComp(InstrumentCalDataSet^ cal, array^ shortedrefl , array^ openrefl); 76 | double PhaseRippleCompensate(double phase, int frequency); 77 | // Compensate coupler magnitude ripple error NEW 09-23-2007 78 | double MagRippleCorrection(double phase, int frequency); 79 | // Update parameter estimates by descending along the gradient NEW 09-23-2007 80 | void DirectionalCoupler::Descend(array^ partialDerivative, array^ weight, array^ coeff); 81 | // Compute error predicted by point-wise periodic error model 82 | double DirectionalCoupler::PeriodicModelCorrection(int frequency, double phase, array^ PerErrModelCoeff, 83 | double DCOffset); 84 | // Compute SumSqErr for model compared to error signature 85 | double DirectionalCoupler::SumSquareError(int startI, int stopI, array^ angle, 86 | array^ errSignature, array^ coeff, double DCOffset); 87 | // Compute gradient of the model parameter set vs. the SumSqError of the fit 88 | void DirectionalCoupler::Gradient(array^ partialDerivative, int startI, int stopI, 89 | array^ angle, array^ errSignature, array^ modelCoeff, 90 | double DCOffset); 91 | 92 | }; 93 | 94 | -------------------------------------------------------------------------------- /not_used/InstrumentCal.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "InstrumentCal.h" 3 | 4 | -------------------------------------------------------------------------------- /not_used/fix_fft.c: -------------------------------------------------------------------------------- 1 | /* fix_fft.c - Fixed-point in-place Fast Fourier Transform */ 2 | /* 3 | All data are fixed-point short integers, in which -32768 4 | to +32768 represent -1.0 to +1.0 respectively. Integer 5 | arithmetic is used for speed, instead of the more natural 6 | floating-point. 7 | 8 | For the forward FFT (time -> freq), fixed scaling is 9 | performed to prevent arithmetic overflow, and to map a 0dB 10 | sine/cosine wave (i.e. amplitude = 32767) to two -6dB freq 11 | coefficients. The return value is always 0. 12 | 13 | For the inverse FFT (freq -> time), fixed scaling cannot be 14 | done, as two 0dB coefficients would sum to a peak amplitude 15 | of 64K, overflowing the 32k range of the fixed-point integers. 16 | Thus, the fix_fft() routine performs variable scaling, and 17 | returns a value which is the number of bits LEFT by which 18 | the output must be shifted to get the actual amplitude 19 | (i.e. if fix_fft() returns 3, each value of fr[] and fi[] 20 | must be multiplied by 8 (2**3) for proper scaling. 21 | Clearly, this cannot be done within fixed-point short 22 | integers. In practice, if the result is to be used as a 23 | filter, the scale_shift can usually be ignored, as the 24 | result will be approximately correctly normalized as is. 25 | 26 | Written by: Tom Roberts 11/8/89 27 | Made portable: Malcolm Slaney 12/15/94 malcolm@interval.com 28 | Enhanced: Dimitrios P. Bouras 14 Jun 2006 dbouras@ieee.org 29 | */ 30 | 31 | #define N_WAVE 1024 /* full length of Sinewave[] */ 32 | #define LOG2_N_WAVE 10 /* log2(N_WAVE) */ 33 | 34 | /* 35 | Henceforth "short" implies 16-bit word. If this is not 36 | the case in your architecture, please replace "short" 37 | with a type definition which *is* a 16-bit word. 38 | */ 39 | 40 | /* 41 | Since we only use 3/4 of N_WAVE, we define only 42 | this many samples, in order to conserve data space. 43 | */ 44 | short Sinewave[N_WAVE-N_WAVE/4] = { 45 | 0, 201, 402, 603, 804, 1005, 1206, 1406, 46 | 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, 47 | 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608, 48 | 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195, 49 | 6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766, 50 | 7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319, 51 | 9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849, 52 | 11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353, 53 | 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827, 54 | 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268, 55 | 15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672, 56 | 16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036, 57 | 18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357, 58 | 19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631, 59 | 20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855, 60 | 22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027, 61 | 23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143, 62 | 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201, 63 | 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198, 64 | 26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132, 65 | 27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001, 66 | 28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802, 67 | 28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534, 68 | 29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195, 69 | 30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783, 70 | 30851, 30918, 30984, 31049, 31113, 31175, 31236, 31297, 71 | 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735, 72 | 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097, 73 | 32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382, 74 | 32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588, 75 | 32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717, 76 | 32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766, 77 | 32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736, 78 | 32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628, 79 | 32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441, 80 | 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176, 81 | 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833, 82 | 31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413, 83 | 31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918, 84 | 30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349, 85 | 30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706, 86 | 29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992, 87 | 28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208, 88 | 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355, 89 | 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437, 90 | 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456, 91 | 25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413, 92 | 24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311, 93 | 23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153, 94 | 22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942, 95 | 20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680, 96 | 19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371, 97 | 18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017, 98 | 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623, 99 | 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, 100 | 14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724, 101 | 12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227, 102 | 11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703, 103 | 9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156, 104 | 7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589, 105 | 6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006, 106 | 4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411, 107 | 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808, 108 | 1607, 1406, 1206, 1005, 804, 603, 402, 201, 109 | 0, -201, -402, -603, -804, -1005, -1206, -1406, 110 | -1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011, 111 | -3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608, 112 | -4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195, 113 | -6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766, 114 | -7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319, 115 | -9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849, 116 | -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353, 117 | -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827, 118 | -14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268, 119 | -15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672, 120 | -16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036, 121 | -18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357, 122 | -19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631, 123 | -20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855, 124 | -22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027, 125 | -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143, 126 | -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201, 127 | -25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198, 128 | -26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132, 129 | -27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001, 130 | -28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802, 131 | -28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534, 132 | -29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195, 133 | -30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783, 134 | -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297, 135 | -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735, 136 | -31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097, 137 | -32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382, 138 | -32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588, 139 | -32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717, 140 | -32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766, 141 | }; 142 | 143 | /* 144 | FIX_MPY() - fixed-point multiplication & scaling. 145 | Substitute inline assembly for hardware-specific 146 | optimization suited to a particluar DSP processor. 147 | Scaling ensures that result remains 16-bit. 148 | */ 149 | short FIX_MPY(short a, short b) 150 | { 151 | /* shift right one less bit (i.e. 15-1) */ 152 | int c = ((int)a * (int)b) >> 14; 153 | /* last bit shifted out = rounding-bit */ 154 | b = c & 0x01; 155 | /* last shift + rounding bit */ 156 | a = (c >> 1) + b; 157 | return a; 158 | } 159 | 160 | /* 161 | fix_fft() - perform forward/inverse fast Fourier transform. 162 | fr[n],fi[n] are real and imaginary arrays, both INPUT AND 163 | RESULT (in-place FFT), with 0 <= n < 2**m; set inverse to 164 | 0 for forward transform (FFT), or 1 for iFFT. 165 | */ 166 | int fix_fft(short fr[], short fi[], short m, short inverse) 167 | { 168 | int mr, nn, i, j, l, k, istep, n, scale, shift; 169 | short qr, qi, tr, ti, wr, wi; 170 | 171 | n = 1 << m; 172 | 173 | /* max FFT size = N_WAVE */ 174 | if (n > N_WAVE) 175 | return -1; 176 | 177 | mr = 0; 178 | nn = n - 1; 179 | scale = 0; 180 | 181 | /* decimation in time - re-order data */ 182 | for (m=1; m<=nn; ++m) { 183 | l = n; 184 | do { 185 | l >>= 1; 186 | } while (mr+l > nn); 187 | mr = (mr & (l-1)) + l; 188 | 189 | if (mr <= m) 190 | continue; 191 | tr = fr[m]; 192 | fr[m] = fr[mr]; 193 | fr[mr] = tr; 194 | ti = fi[m]; 195 | fi[m] = fi[mr]; 196 | fi[mr] = ti; 197 | } 198 | 199 | l = 1; 200 | k = LOG2_N_WAVE-1; 201 | while (l < n) { 202 | if (inverse) { 203 | /* variable scaling, depending upon data */ 204 | shift = 0; 205 | for (i=0; i 16383 || m > 16383) { 213 | shift = 1; 214 | break; 215 | } 216 | } 217 | if (shift) 218 | ++scale; 219 | } else { 220 | /* 221 | fixed scaling, for proper normalization -- 222 | there will be log2(n) passes, so this results 223 | in an overall factor of 1/n, distributed to 224 | maximize arithmetic accuracy. 225 | */ 226 | shift = 1; 227 | } 228 | /* 229 | it may not be obvious, but the shift will be 230 | performed on each data point exactly once, 231 | during this pass. 232 | */ 233 | istep = l << 1; 234 | for (m=0; m>= 1; 243 | wi >>= 1; 244 | } 245 | for (i=m; i>= 1; 253 | qi >>= 1; 254 | } 255 | fr[j] = qr - tr; 256 | fi[j] = qi - ti; 257 | fr[i] = qr + tr; 258 | fi[i] = qi + ti; 259 | } 260 | } 261 | --k; 262 | l = istep; 263 | } 264 | return scale; 265 | } 266 | 267 | /* 268 | fix_fftr() - forward/inverse FFT on array of real numbers. 269 | Real FFT/iFFT using half-size complex FFT by distributing 270 | even/odd samples into real/imaginary arrays respectively. 271 | In order to save data space (i.e. to avoid two arrays, one 272 | for real, one for imaginary samples), we proceed in the 273 | following two steps: a) samples are rearranged in the real 274 | array so that all even samples are in places 0-(N/2-1) and 275 | all imaginary samples in places (N/2)-(N-1), and b) fix_fft 276 | is called with fr and fi pointing to index 0 and index N/2 277 | respectively in the original array. The above guarantees 278 | that fix_fft "sees" consecutive real samples as alternating 279 | real and imaginary samples in the complex array. 280 | */ 281 | int fix_fftr(short f[], int m, int inverse) 282 | { 283 | int i, N = 1<<(m-1), scale = 0; 284 | short tt, *fr=f, *fi=&f[N]; 285 | 286 | if (inverse) 287 | scale = fix_fft(fi, fr, m-1, inverse); 288 | for (i=1; i 10 | #include 11 | #include 12 | #include 13 | //#include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /taprlogo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erikkaashoek/Tapr-VNA/12f7709a91283963ced7401f5d05873eb325ec06/taprlogo.gif --------------------------------------------------------------------------------