private void RunCrosstalk_vs_VBATVoltage_APx() { //Not finished //Signal generated from APx //APx must be ready in FFT mode to capture the FFT //This part steps the frequency on the AP2700, taking an FFT of each step using the APx. Typically 1M FFT w/ 8 avg is used. NativeMethods.PreventSleep(); // Prevent computer from sleeping and disconnecting from APx System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); startRunTimeString = DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss"); textBox_Status.Text = "Running automation...\r\n"; textBox_Status.Text += "Start Time: " + startRunTimeString + Environment.NewLine; List<double> voltageToSweep = new List<double>() { 1.7, 1.75, 1.8, 1.85, 1.9, 1.95 }; PowerSupply.E3631A PSU = new PowerSupply.E3631A(); double oneFreq = 1000; //Sweep voltage at 1kHz List<Tuple<double, double>> xTalk_voltage_dBV = new List<Tuple<double, double>>(); //Parse and update frequencies to sweep //parse_FreqToSweep(); //Begin xTalk test APx.BenchMode.Measurements.Fft.Append = false; foreach (double v in voltageToSweep) { //Change AP2700 frequency PSU.setVoltage(v, "P6V"); textBox_Status.Text += v.ToString() + "V" + Environment.NewLine; try { //Run APx FFT APx.BenchMode.Measurements.Fft.Start(); while (APx.BenchMode.Measurements.Fft.IsStarted) //! Wait for FFT to finish { System.Threading.Thread.Sleep(100); // Sleep 100ms } //APx.BenchMode.Measurements.Fft.Append = true; //Grab FFT data double[] xValues = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetXValues(InputChannelIndex.Ch1); double[] yValues = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetYValues(InputChannelIndex.Ch1); double[] xValues_input = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetXValues(InputChannelIndex.Ch2); double[] yValues_input = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetYValues(InputChannelIndex.Ch2); //Grab desired point from data double xTalkVal = findCrosstalkValue(oneFreq, xValues, yValues, xValues_input, yValues_input); //Append data to xTalk data xTalk_voltage_dBV.Add(new Tuple<double, double>(v, xTalkVal)); } catch (Exception ex) { MessageBox.Show(ex.Message); } //Export FFT data System.IO.Directory.CreateDirectory(savePath + dataFolder); string filename = savePath + dataFolder + "\\xTalkAutomation_" + "rawFFTData" + startRunTimeString + "Voltage" + v.ToString() + ".csv"; //Currently doesn't work correctly. Modify to output correct data. Currently outputs the same data over and over from the first sweep. APx.BenchMode.Measurements.Fft.ExportData(filename); } //Export APx file - bad idea file is huge 1.5GB! //string filename_APx = savePath + dataFolder + "\\xTalkAutomation_" + "rawFFTData" + startRunTimeString + ".approjx"; //APx.SaveProject(filename_APx); //Export xTalk data exportXtalkDatatoFile(xTalk_voltage_dBV); //Report test time sw.Stop(); textBox_Status.Text += "Automation finished. Automation Time: " + sw.Elapsed.ToString() + Environment.NewLine + "Absolute time Ended: " + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + Environment.NewLine; NativeMethods.AllowSleep(); }
private void RunCrosstalk_vs_VBATVoltage_APx() { //Not finished //Signal generated from APx //APx must be ready in FFT mode to capture the FFT //This part steps the frequency on the AP2700, taking an FFT of each step using the APx. Typically 1M FFT w/ 8 avg is used. NativeMethods.PreventSleep(); // Prevent computer from sleeping and disconnecting from APx System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); startRunTimeString = DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss"); textBox_Status.Text = "Running automation...\r\n"; textBox_Status.Text += "Start Time: " + startRunTimeString + Environment.NewLine; List <double> voltageToSweep = new List <double>() { 1.7, 1.75, 1.8, 1.85, 1.9, 1.95 }; PowerSupply.E3631A PSU = new PowerSupply.E3631A(); double oneFreq = 1000; //Sweep voltage at 1kHz List <Tuple <double, double> > xTalk_voltage_dBV = new List <Tuple <double, double> >(); //Parse and update frequencies to sweep //parse_FreqToSweep(); //Begin xTalk test APx.BenchMode.Measurements.Fft.Append = false; foreach (double v in voltageToSweep) { //Change AP2700 frequency PSU.setVoltage(v, "P6V"); textBox_Status.Text += v.ToString() + "V" + Environment.NewLine; try { //Run APx FFT APx.BenchMode.Measurements.Fft.Start(); while (APx.BenchMode.Measurements.Fft.IsStarted) //! Wait for FFT to finish { System.Threading.Thread.Sleep(100); // Sleep 100ms } //APx.BenchMode.Measurements.Fft.Append = true; //Grab FFT data double[] xValues = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetXValues(InputChannelIndex.Ch1); double[] yValues = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetYValues(InputChannelIndex.Ch1); double[] xValues_input = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetXValues(InputChannelIndex.Ch2); double[] yValues_input = APx.BenchMode.Measurements.Fft.FFTSpectrum.GetYValues(InputChannelIndex.Ch2); //Grab desired point from data double xTalkVal = findCrosstalkValue(oneFreq, xValues, yValues, xValues_input, yValues_input); //Append data to xTalk data xTalk_voltage_dBV.Add(new Tuple <double, double>(v, xTalkVal)); } catch (Exception ex) { MessageBox.Show(ex.Message); } //Export FFT data System.IO.Directory.CreateDirectory(savePath + dataFolder); string filename = savePath + dataFolder + "\\xTalkAutomation_" + "rawFFTData" + startRunTimeString + "Voltage" + v.ToString() + ".csv"; //Currently doesn't work correctly. Modify to output correct data. Currently outputs the same data over and over from the first sweep. APx.BenchMode.Measurements.Fft.ExportData(filename); } //Export APx file - bad idea file is huge 1.5GB! //string filename_APx = savePath + dataFolder + "\\xTalkAutomation_" + "rawFFTData" + startRunTimeString + ".approjx"; //APx.SaveProject(filename_APx); //Export xTalk data exportXtalkDatatoFile(xTalk_voltage_dBV); //Report test time sw.Stop(); textBox_Status.Text += "Automation finished. Automation Time: " + sw.Elapsed.ToString() + Environment.NewLine + "Absolute time Ended: " + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + Environment.NewLine; NativeMethods.AllowSleep(); }