Exemple #1
0
        public static double IBM_PBM(SweepData sweepData, double P_Test)
        {
            double PBM = sweepData.powers.Aggregate((cur, next) => Math.Abs(P_Test - cur) < Math.Abs(P_Test - next) ? cur : next);
            int    i   = sweepData.powers.IndexOf(PBM);

            return(sweepData.ibms.ElementAt(i));
        }
Exemple #2
0
        public static double IBM_Track(SweepData sweepData, double I_OP_Min, double I_OP_Max)
        {
            int    min   = sweepData.setcurrents.IndexOf(I_OP_Min);
            int    max   = sweepData.setcurrents.IndexOf(I_OP_Max);
            double num   = sweepData.ibms.ElementAt(min) / sweepData.powers.ElementAt(min);
            double denom = sweepData.ibms.ElementAt(max) / sweepData.powers.ElementAt(max);

            return(num / denom);
        }
Exemple #3
0
        public async static Task <SweepData> SweepTest(double I_Start, double I_Stop, double I_Step, ProgressBar pb)
        {
            var progress = new Progress <double>(value => pb.Value = value);

            Instruments.Instance.TOSALimits();

            Instruments.Instance.ChannelPower(1, true);
            Instruments.Instance.ChannelPower(2, true);
            Instruments.Instance.ChannelPower(3, true);
            SweepData sweepData = new SweepData();

            int count = (int)((I_Stop - I_Start) / I_Step);

            double current_Iterator = I_Start;

            await Task.Run(() =>
            {
                for (int i = 0; i <= count; i++)
                {
                    ((IProgress <double>)progress).Report(100 * ((double)i / (double)count));
                    Instruments.Instance.SourceCurrent(1, current_Iterator);
                    Instruments.Instance.SourceVoltage(2, 0);
                    Instruments.Instance.SourceVoltage(3, 0);
                    //Debug.WriteLine("Source Current: " + current_Iterator);

                    double c = Instruments.Instance.GetCurrent(1);
                    //Debug.Print("Source Current: {0}", c);
                    double v = Instruments.Instance.GetVoltage(1);
                    //Debug.Print("Voltage: {0}", v);

                    sweepData.setcurrents.Add(Math.Round(current_Iterator, 3));
                    sweepData.currents.Add(c * 1000);
                    sweepData.voltages.Add(v);

                    double p = Instruments.Instance.GetCurrent(3) / RESPONSIVITY;
                    //Debug.Print("Power: {0}", p);
                    double ibm = Instruments.Instance.GetCurrent(2);
                    //Debug.Print("ibm: {0}", ibm);

                    //Debug.Print("{0}, {1}, {2}, {3}, {4},", current_Iterator, c, v, p, ibm);

                    sweepData.powers.Add(p * 1000);
                    sweepData.ibms.Add(ibm * 1000);

                    //Debug.Print("");

                    current_Iterator += I_Step;
                }
            });

            Instruments.Instance.ChannelPower(1, false);
            Instruments.Instance.ChannelPower(2, false);
            Instruments.Instance.ChannelPower(3, false);

            return(sweepData);
        }
Exemple #4
0
        public static double ThresholdCurrent(SweepData sweepData, double I_OP_Min, double I_OP_Max)
        {
            List <double> currents = sweepData.currents;
            List <double> powers   = sweepData.powers;

            double b;

            double m = FindSlope(currents, powers, I_OP_Min, I_OP_Max, out b);

            return(-b / m);
        }
Exemple #5
0
        private async void Sweep()
        {
            TOSADevice device = d as TOSADevice;
            TOSAOutput output = o as TOSAOutput;

            bool sweepResult = true;

            SweepData sweepData = await TestCalculations.SweepTest(device.I_Start, device.I_Stop, device.I_Step, sweepProgress);

            sd = sweepData;

            double r = TestCalculations.FindSlope(sweepData.currents, sweepData.voltages, device.I_OP_Min, device.I_OP_Max) * 1000;

            resistance.Text = r.ToString("F") + " Ω";
            bool R_Pass = (r >= device.RS_Min && r <= device.RS_Max);

            output.RS      = r;
            output.RS_Pass = R_Pass;

            if (!R_Pass)
            {
                resistance.Foreground = Brushes.OrangeRed;
                sweepResult           = false;
            }

            double se = TestCalculations.FindSlope(sweepData.currents, sweepData.powers, device.I_OP_Min, device.I_OP_Max);

            slopeEfficiency.Text = se.ToString("F");

            bool SE_Pass = (se >= device.SE_Min && se <= device.SE_Max);

            output.SE      = se;
            output.SE_Pass = SE_Pass;

            if (!SE_Pass)
            {
                slopeEfficiency.Foreground = Brushes.OrangeRed;
                sweepResult = false;
            }

            double ith = TestCalculations.ThresholdCurrent(sweepData, device.I_OP_Min, device.I_OP_Max);

            thresholdCurrent.Text = ith.ToString("F") + " mA";
            bool ITH_Pass = (ith >= device.Ith_Min && ith <= device.Ith_Max);

            output.Ith      = ith;
            output.Ith_Pass = ITH_Pass;

            measurementPanel.Visibility = Visibility.Visible;

            if (!ITH_Pass)
            {
                thresholdCurrent.Foreground = Brushes.OrangeRed;
                sweepResult = false;
            }

            double p_test = sweepData.powers.ElementAt(sweepData.setcurrents.IndexOf(device.I_Test));

            testPower.Text = p_test.ToString("F") + " mW";
            bool P_Test_Pass = (p_test >= device.P_Test_FC_Min && p_test <= device.P_Test_FC_Max);

            output.P_Test_FC      = p_test;
            output.P_Test_FC_Pass = P_Test_Pass;

            if (!P_Test_Pass)
            {
                testPower.Foreground = Brushes.OrangeRed;
                sweepResult          = false;
            }

            double popct = p_test / output.P_Test_OB;

            POPCT.Text = (100 * popct).ToString("F") + " %";
            bool POPCT_Pass = (popct >= device.POPCT_Min);

            output.POPCT      = popct;
            output.POPCT_Pass = POPCT_Pass;

            if (!POPCT_Pass)
            {
                testPower.Foreground = Brushes.OrangeRed;
                sweepResult          = false;
            }

            double ibm = TestCalculations.IBM_PBM(sweepData, device.P_BM_Test);

            monitorCurrent.Text = ibm.ToString("F") + " mA";
            bool IBM_Pass = (ibm >= device.IBM_Min && ibm <= device.IBM_Max);

            output.I_BM_P_BM_Test      = ibm;
            output.I_BM_P_BM_Test_Pass = IBM_Pass;

            if (!IBM_Pass)
            {
                monitorCurrent.Foreground = Brushes.OrangeRed;
                sweepResult = false;
            }

            double pmin = sweepData.powers.ElementAt(sweepData.setcurrents.IndexOf(device.I_OP_Min));
            double pmax = sweepData.powers.ElementAt(sweepData.setcurrents.IndexOf(device.I_OP_Max));


            double ibmslope = TestCalculations.FindSlope(sweepData.powers, sweepData.ibms, pmin, pmax);

            ibmSlope.Text     = ibmslope.ToString("F") + " A/W";
            output.I_BM_Slope = ibmslope;

            double ibmtrack = TestCalculations.IBM_Track(sweepData, device.I_OP_Min, device.I_OP_Max);

            ibmTrack.Text = ibmtrack.ToString("F");
            bool IBM_Track_Pass = (ibmtrack >= device.IBM_Tracking_Min && ibmtrack <= device.IBM_Tracking_Max);

            output.IBM_Track       = ibmtrack;
            output.I_BM_Track_Pass = IBM_Track_Pass;

            if (!IBM_Track_Pass)
            {
                ibmTrack.Foreground = Brushes.OrangeRed;
                sweepResult         = false;
            }

            measurementPanel.Visibility = Visibility.Visible;
            var w = Window.GetWindow(this) as MainWindow;

            if (sweepResult)
            {
                passed                  = true;
                testMessage.Text        = "Test Passed";
                testMessage.Foreground  = Brushes.ForestGreen;
                StartTestButton.Content = "Next step";
                d        = device;
                o        = output;
                w.device = d;
                w.output = o;
            }
            else
            {
                testMessage.Text       = "Test Failed";
                testMessage.Foreground = Brushes.OrangeRed;
                if (numTries >= 3)
                {
                    StartTestButton.Content = "Go home";
                    output.Result           = false;
                    MainWindow.Conn.SaveTOSAOutput(output);
                }
                else
                {
                    StartTestButton.Content = "Retry test";
                }
            }

            SaveLIButton.Visibility = Visibility.Visible;
        }