📄 calibration.h
字号:
this->statTerm->TabIndex = 18;
this->statTerm->Visible = false;
//
// statThru
//
this->statThru->BackColor = System::Drawing::Color::Transparent;
this->statThru->Image = (__try_cast<System::Drawing::Image* >(resources->GetObject(S"statThru.Image")));
this->statThru->Location = System::Drawing::Point(32, 256);
this->statThru->Name = S"statThru";
this->statThru->Size = System::Drawing::Size(32, 32);
this->statThru->TabIndex = 19;
this->statThru->Visible = false;
//
// calProgressBar
//
this->calProgressBar->Location = System::Drawing::Point(112, 368);
this->calProgressBar->Maximum = 1024;
this->calProgressBar->Name = S"calProgressBar";
this->calProgressBar->Size = System::Drawing::Size(472, 16);
this->calProgressBar->TabIndex = 20;
//
// Calibration
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->BackgroundImage = (__try_cast<System::Drawing::Image* >(resources->GetObject(S"$this.BackgroundImage")));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(640, 412);
this->Controls->Add(this->calProgressBar);
this->Controls->Add(this->statThru);
this->Controls->Add(this->statTerm);
this->Controls->Add(this->statOpen);
this->Controls->Add(this->label6);
this->Controls->Add(this->calSave);
this->Controls->Add(this->statShort);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->CancelButton);
this->Controls->Add(this->label1);
this->Controls->Add(this->thruCal);
this->Controls->Add(this->termCal);
this->Controls->Add(this->openCal);
this->Controls->Add(this->shortCal);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->Name = S"Calibration";
this->Text = S"Calibration";
this->ResumeLayout(false);
}
private: VNADevice* VNA; ///< Vector Network Analyzer hardware object
private: FrequencyGrid* FG; ///< Our Frequency Grid
private: CalDataSet* Cal; ///< Calibration Data Set
public: SaveFileDialog* outfile; ///< Saved File Structure
private: int BufferI __gc[], BufferQ __gc[], BufferM __gc[], BufferN __gc[], BufferP __gc[]; // hold raw readings
/// Fixture SHORTed Load Calibration button click handler
private: System::Void shortCal_Click(System::Object * sender, System::EventArgs * e)
{
VNA_RXBUFFER *RxBuf = new VNA_RXBUFFER;
VNA_TXBUFFER *TxBuf = new VNA_TXBUFFER;
double fmagnitude; // 0 to 1
double fphase; // -180 to +180
double& rmag = fmagnitude;
double& rphs = fphase;
for (long i=0; i<1024; i++)
{
// Compute spot frequency
int Fdesired;
Fdesired = Convert::ToInt32(200000.0+( i*(120000000.0-200000.0)/1024.0));
TxBuf->TxAccum = FG->DDS(Fdesired);
TxBuf->IDAClevelHi = MAX_DDS_LEVEL; // Max transmit level
TxBuf->ReplyType = 0;
TxBuf->MeasureDelay = 0;
TxBuf->QDAClevel = QDAC_ZERODBM; // Reference level
for (int k=0; k<7; k++)
{
VNA->WriteRead(TxBuf, RxBuf);
BufferI[k] = RxBuf->ReflPI;
BufferQ[k] = RxBuf->ReflPQ;
BufferM[k] = RxBuf->ReflMQ;
}
int ReflPI = Median7i(BufferI); // filter the raw readings
int ReflPQ = Median7i(BufferQ);
int ReflMQ = Median7i(BufferM);
Cal->ResolveReflPolar(ReflPI, ReflPQ, ReflMQ, (int)Fdesired, rmag, rphs, true);
// convert it to rectangular
double fx = fmagnitude * cos(fphase * DEGR2RAD);
double fy = fmagnitude * sin(fphase * DEGR2RAD);
// save it as S11-meas-short
Cal->S11shortReal[i] = fx; Cal->S11shortImag[i] = fy;
calProgressBar->Value = i;
if(i%20 == 0)
calProgressBar->Update();
}
statShort->Visible = true;
}
/// Fixture OPEN Load Calibration button click handler
private: System::Void openCal_Click(System::Object * sender, System::EventArgs * e)
{
VNA_RXBUFFER *RxBuf = new VNA_RXBUFFER;
VNA_TXBUFFER *TxBuf = new VNA_TXBUFFER;
double fmagnitude; // 0 to 1
double fphase; // -180 to +180
double& rmag = fmagnitude;
double& rphs = fphase;
// run a sweep of 1024 points, collecting S11 data 'short'
for (long i=0; i<1024; i++)
{
// Compute spot frequency
int Fdesired;
Fdesired = Convert::ToInt32(200000.0+( i*(120000000.0-200000.0)/1024.0));
TxBuf->TxAccum = FG->DDS(Fdesired);
TxBuf->IDAClevelHi = MAX_DDS_LEVEL; // Max transmit level
TxBuf->ReplyType = 0;
TxBuf->MeasureDelay = 0;
TxBuf->QDAClevel = QDAC_ZERODBM; // Reference level
for (int k=0; k<7; k++)
{
VNA->WriteRead(TxBuf, RxBuf);
BufferI[k] = RxBuf->ReflPI;
BufferQ[k] = RxBuf->ReflPQ;
BufferM[k] = RxBuf->ReflMQ;
}
int ReflPI = Median7i(BufferI); // filter the raw readings
int ReflPQ = Median7i(BufferQ);
int ReflMQ = Median7i(BufferM);
Cal->ResolveReflPolar(ReflPI, ReflPQ, ReflMQ, (int)Fdesired, rmag, rphs, true);
// convert it to rectangular
double fx = fmagnitude * cos(fphase * DEGR2RAD);
double fy = fmagnitude * sin(fphase * DEGR2RAD);
// save it as S11-meas-short
Cal->S11openReal[i] = fx; Cal->S11openImag[i] = fy;
calProgressBar->Value = i;
if(i%20 == 0)
calProgressBar->Update();
}
statOpen->Visible = true;
}
/// Fixture TERMINATED Load Calibration button click handler
private: System::Void termCal_Click(System::Object * sender, System::EventArgs * e)
{
VNA_RXBUFFER *RxBuf = new VNA_RXBUFFER;
VNA_TXBUFFER *TxBuf = new VNA_TXBUFFER;
double fmagnitude; // 0 to 1
double fphase; // -180 to +180
double& rmag = fmagnitude;
double& rphs = fphase;
// run a sweep of 1024 points, collecting S11 data 'short'
for (long i=0; i<1024; i++)
{
// Compute spot frequency
int Fdesired;
Fdesired = Convert::ToInt32(200000.0+( i*(120000000.0-200000.0)/1024.0));
TxBuf->TxAccum = FG->DDS(Fdesired);
TxBuf->IDAClevelHi = MAX_DDS_LEVEL; // Max transmit level
TxBuf->ReplyType = 0;
TxBuf->MeasureDelay = 0;
TxBuf->QDAClevel = QDAC_ZERODBM; // Reference level
for (int k=0; k<7; k++)
{
VNA->WriteRead(TxBuf, RxBuf);
BufferI[k] = RxBuf->ReflPI;
BufferQ[k] = RxBuf->ReflPQ;
BufferM[k] = RxBuf->ReflMQ;
}
int ReflPI = Median7i(BufferI); // filter the raw readings
int ReflPQ = Median7i(BufferQ);
int ReflMQ = Median7i(BufferM);
VNA->WriteRead(TxBuf, RxBuf);
Cal->ResolveReflPolar(ReflPI, ReflPQ, ReflMQ, (int)Fdesired, rmag, rphs, true);
// convert it to rectangular
double fx = fmagnitude * cos(fphase * DEGR2RAD);
double fy = fmagnitude * sin(fphase * DEGR2RAD);
// save it as S11-meas-short
Cal->S11termReal[i] = fx; Cal->S11termImag[i] = fy;
calProgressBar->Value = i;
if(i%20 == 0)
calProgressBar->Update();
}
statTerm->Visible = true;
}
/// Fixture Through Calibration button click handler
private: System::Void thruCal_Click(System::Object * sender, System::EventArgs * e)
{
VNA_RXBUFFER *RxBuf = new VNA_RXBUFFER;
VNA_TXBUFFER *TxBuf = new VNA_TXBUFFER;
double fmagnitude; // 0 to 1
double fphase; // -180 to +180
double& rmag = fmagnitude;
double& rphs = fphase;
// run a sweep of 1024 points, collecting S21 data 'thru'
for (long i=0; i<1024; i++)
{
// Compute spot frequency
int Fdesired;
Fdesired = Convert::ToInt32(200000.0+( i*(120000000.0-200000.0)/1024.0));
TxBuf->TxAccum = FG->DDS(Fdesired);
TxBuf->IDAClevelHi = TxLevLinear(0); // Set High Tx Level
TxBuf->IDAClevelLo = TxLevLinear(0 - TARGETLOMAG); // Set Low TX Level
TxBuf->IDAClevelMid = TxLevLinear(0 - TARGETMIDMAG); // Set Mid TX Level
TxBuf->ReplyType = 0;
TxBuf->MeasureDelay = 0;
TxBuf->QDAClevel = QDAC_ZERODBM; // Reference level
for (int k=0; k<7; k++)
{
VNA->WriteRead(TxBuf, RxBuf);
BufferI[k] = RxBuf->TranPI;
BufferQ[k] = RxBuf->TranPQ;
BufferM[k] = RxBuf->TranMQHi;
BufferN[k] = RxBuf->TranMQLo;
BufferP[k] = RxBuf->TranMQMid;
}
int TranPI = Median7i(BufferI); // filter the raw readings
int TranPQ = Median7i(BufferQ);
int TranMQHi = Median7i(BufferM);
int TranMQLo = Median7i(BufferN);
int TranMQMid = Median7i(BufferP);
Cal->ResolveTranPolar(TranPI, TranPQ, TranMQHi, TranMQLo, TranMQMid, (int)Fdesired, rmag, rphs);
// convert it to rectangular
double fx = fmagnitude * cos(fphase * DEGR2RAD);
double fy = fmagnitude * sin(fphase * DEGR2RAD);
// save it as S21-meas-through
Cal->ThReal[i] = fx; Cal->ThImag[i] = fy;
calProgressBar->Value = i;
if(i%20 == 0)
calProgressBar->Update();
}
statThru->Visible = true;
}
/// Fixture Save Calibration button click handler
private: System::Void calSave_Click(System::Object * sender, System::EventArgs * e)
{
// Compute Error Terms
CalToErrorTerms(Cal);
// Save results to file
outfile = new SaveFileDialog();
outfile->Filter = "calibration files (*.cal)|*.cal";
outfile->AddExtension = true;
if (outfile->ShowDialog() == DialogResult::OK)
{
SaveCalDataSet(outfile, Cal);
DialogResult = DialogResult::OK; // Let caller know that Fixture Cal saved a valid file
}
else
DialogResult = DialogResult::Cancel;
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -