Esempio n. 1
0
        public double[] Meas_Current_Trig(Triger_Source Trig_src, double dblTrigLevel_in_Amps, double dblTimeInterval_in_us, int intTotalPoints, int intOffsetPoints)
        {
            double[] dblResult = new double[5];
            double dblTimeInterval_in_Seconds = dblTimeInterval_in_us / 1000000;
            try
            {
                PowerSupply_66332A.Write("SENS:CURR:DET ACDC");
                PowerSupply_66332A.Write("SENS:CURR:RANG MAX");
                PowerSupply_66332A.Write("SENS:FUNC 'CURR'");
                PowerSupply_66332A.Write("SENS:SWE:TINT " + dblTimeInterval_in_Seconds.ToString());
                PowerSupply_66332A.Write("SENS:SWE:POIN " + intTotalPoints.ToString());
                PowerSupply_66332A.Write("SENS:SWE:OFFS:POIN " + intOffsetPoints.ToString());

                if (Trig_src == Triger_Source.Int)
                {
                    PowerSupply_66332A.Write("TRIG:ACQ:SOUR INT");
                    PowerSupply_66332A.Write("TRIG:ACQ:LEV:CURR " + dblTrigLevel_in_Amps.ToString());
                    PowerSupply_66332A.Write("TRIG:ACQ:SLOPE:CURR POS");
                    PowerSupply_66332A.Write("TRIG:ACQ:HYST:CURR 0.05");

                    _Util.Wait(10);
                    PowerSupply_66332A.Write("INIT:NAME ACQ");
                }
                else if (Trig_src == Triger_Source.Bus)
                {
                    PowerSupply_66332A.Write("TRIG:ACQ:SOUR BUS");

                    _Util.Wait(10);
                    PowerSupply_66332A.Write("INIT:NAME ACQ");
                    PowerSupply_66332A.Write("TRIG:ACQ:IMM");
                }
                else
                {
                    throw new Exception();
                }


                PowerSupply_66332A.Write("FETCH:ARRAY:CURR?");

                _Util.Wait(10);
                string strTemp = PowerSupply_66332A.ReadString();
                while (strTemp.Substring(strTemp.Length - 1) != "\n")
                {
                    strTemp += PowerSupply_66332A.ReadString();
                }

                string[] strReturn = strTemp.Split(',');


                PowerSupply_66332A.Write("FETCH:CURR:HIGH?");
                _Util.Wait(10);
                string strHigh = PowerSupply_66332A.ReadString();

                PowerSupply_66332A.Write("FETCH:CURR:LOW?");
                _Util.Wait(10);
                string strLow = PowerSupply_66332A.ReadString();

                PowerSupply_66332A.Write("FETCH:CURR:MIN?");
                _Util.Wait(10);
                string strMin = PowerSupply_66332A.ReadString();

                PowerSupply_66332A.Write("FETCH:CURR:MAX?");
                _Util.Wait(10);
                string strMax = PowerSupply_66332A.ReadString();

                PowerSupply_66332A.Write("FETCH:CURR:DC?");
                _Util.Wait(10);
                string strRms = PowerSupply_66332A.ReadString();

                //RMS Current
                dblResult[0] = double.Parse(strRms);
                //Low Current
                dblResult[1] = double.Parse(strLow);
                //High Current
                dblResult[2] = double.Parse(strHigh);
                //Min Current
                dblResult[3] = double.Parse(strMin);
                //Max Current
                dblResult[4] = double.Parse(strMax);


                double dblTemp = 0.0;
                int intAvgCount = 0;
                double[] dblResult1 = new double[4096];

                for (int i = 0; i < strReturn.Count() - 2; i++)
                {
                    dblResult1[i] = Double.Parse(strReturn[i]);

                    if (i >= 10 + Math.Abs(intOffsetPoints) && i <= strReturn.Count() - 1 - 10)
                    {
                        dblTemp += dblResult1[i];
                        intAvgCount++;
                    }
                }

                dblTemp = dblTemp / intAvgCount;
                if (Trig_src == Triger_Source.Int) dblResult[2] = dblTemp;
            }
            catch (Exception e)
            {
                //throw new Exception(e.Message);

                PowerSupply_66332A.Write("TRIG:ACQ:IMM");
                for (int i = 0; i <= 4; i++)
                {
                    dblResult[i] = -99;
                }
            }

            return dblResult;
        }
Esempio n. 2
0
        public void SetArbTrig(Triger_Type TrigType, Triger_Source Trig_Src, double TrigDelay_in_ms)
        {
            //ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:EXT:SLOP POS");
            if (TrigType == Triger_Type.Continous_Free) // Free Run
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:TYPE CONT");
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:TYPE:CONT FREE");
            }
            else if (TrigType == Triger_Type.Continous_Trig) // External Trig -- Triger and Run
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:TYPE CONT");
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:TYPE:CONT TRIG");
            }
            else if (TrigType == Triger_Type.Continous_Reset) // External Trig -- Reset and Run
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:TYPE CONT");
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:TYPE:CONT RES");
            }
            else
            {
                throw new Exception("Trig type not defined!");
            }

            //Triger Source
            if (Trig_Src == Triger_Source.Ext) // External(Patt 1)
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:SOUR EXT");
            }
            else if (Trig_Src == Triger_Source.Bus) // Bus Trig 
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:SOUR BUS");
            }
            else if (Trig_Src == Triger_Source.Manual) // Trigger Key 
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:SOUR MAN");
            }
            else
            {
                throw new Exception("Trig type not defined!");
            }

            //Trgger Delay
            if (TrigDelay_in_ms == 0)
            {
                //ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:EXT:DEL " + TrigDelay_in_ms + "ms");
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:EXT:DEL:STAT OFF");
            }
            else
            {
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:EXT:DEL " + TrigDelay_in_ms + "ms");
                ESG_E4438C.Write(":SOUR:RAD:ARB:TRIG:EXT:DEL:STAT ON");
            }
        }
Esempio n. 3
0
        private void RegisterWrite(int GPIB_Addr, string arb_name, string strCmd, Triger_Source trigger)
        {
            //int shift_point = (int)Math.Ceiling((double)intPoint / 5) + intShift;

            double SRate = dblFreq * intPoint * 2E6;
            int shift_point = (int)Math.Ceiling((double)(dblShift * 10));
            int total_point = (strCmd.Length + 4) * intPoint;
            int intHigh = Convert.ToInt32(intPoint * 2 * dblDuty);
            int intLow = intPoint * 2 - intHigh;

            #region Build Mipi Array
            StringBuilder sbClock = new StringBuilder();
            StringBuilder sbData = new StringBuilder();

            if (bln_loop)
            {
                string[] strCmdLst = strCmd.Split('#');

                #region //// First cmd
                #region //// Prefix 2*point  一个周期
                for (int i = 1; i <= intPoint * 2; i++)
                {
                    if (shift_point > 0)
                    {
                        if (i > shift_point)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }

                        sbData.Append(",");
                        sbData.Append(0);
                    }
                    else if (shift_point < 0)
                    {
                        if (i > Math.Abs(shift_point))
                        {
                            sbData.Append(",");
                            sbData.Append(0);
                        }

                        sbClock.Append(",");
                        sbClock.Append(0);
                    }

                }
                #endregion

                #region //// Data
                for (int j = 0; j < strCmdLst[0].Length; j++)
                {
                    for (int i = 1; i <= intPoint * 2; i++)
                    {
                        // SSC no clock
                        if (j <= 1)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }
                        else if (i <= intHigh)
                        {
                            sbClock.Append(",");
                            sbClock.Append(1);
                        }
                        else if (i > intHigh)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }

                        sbData.Append(",");
                        sbData.Append(strCmdLst[0][j]);
                    }
                }
                #endregion

                #region //// BP signal
                for (int i = 1; i <= intPoint * 2; i++)
                {
                    if (i <= intHigh)
                    {
                        sbClock.Append(",");
                        sbClock.Append(1);
                    }
                    else if (i > intHigh)
                    {
                        sbClock.Append(",");
                        sbClock.Append(0);
                    }
                    sbData.Append(",");
                    sbData.Append(0);
                }
                #endregion

                #region //// Suffix 2*point
                for (int i = 1; i <= intPoint * 2 + shift_point; i++)
                {
                    sbClock.Append(",");
                    sbClock.Append(0);
                    if (i <= intPoint * 2)
                    {
                        sbData.Append(",");
                        sbData.Append(0);
                    }
                }
                #endregion

                #endregion

                #region //// Burst width
                for (int j = 0; j < strCmdLst[1].Length; j++)
                {
                    for (int i = 1; i <= intPoint * 2; i++)
                    {
                        sbClock.Append(",");
                        sbClock.Append(0);
                        sbData.Append(",");
                        sbData.Append(strCmdLst[1][j]);
                    }
                }
                #endregion

                #region //// 2nd cmd
                #region //// Prefix 2*point  一个周期
                for (int i = 1; i <= intPoint * 2; i++)
                {
                    if (shift_point > 0)
                    {
                        if (i > shift_point)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }

                        sbData.Append(",");
                        sbData.Append(0);
                    }
                    else if (shift_point < 0)
                    {
                        if (i > Math.Abs(shift_point))
                        {
                            sbData.Append(",");
                            sbData.Append(0);
                        }

                        sbClock.Append(",");
                        sbClock.Append(0);
                    }

                }
                #endregion

                #region //// Data
                for (int j = 0; j < strCmdLst[2].Length; j++)
                {
                    for (int i = 1; i <= intPoint * 2; i++)
                    {
                        // SSC no clock
                        if (j <= 1)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }
                        else if (i <= intHigh)
                        {
                            sbClock.Append(",");
                            sbClock.Append(1);
                        }
                        else if (i > intHigh)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }

                        sbData.Append(",");
                        sbData.Append(strCmdLst[2][j]);
                    }
                }
                #endregion

                #region //// BP signal
                for (int i = 1; i <= intPoint * 2; i++)
                {
                    if (i <= intHigh)
                    {
                        sbClock.Append(",");
                        sbClock.Append(1);
                    }
                    else if (i > intHigh)
                    {
                        sbClock.Append(",");
                        sbClock.Append(0);
                    }
                    sbData.Append(",");
                    sbData.Append(0);
                }
                #endregion

                #region //// Suffix 2*point
                for (int i = 1; i <= intPoint * 2 + shift_point; i++)
                {
                    sbClock.Append(",");
                    sbClock.Append(0);
                    if (i <= intPoint * 2)
                    {
                        sbData.Append(",");
                        sbData.Append(0);
                    }
                }
                #endregion

                #endregion

            }

            else
            {
                #region //// Prefix 2*point  一个周期
                for (int i = 1; i <= intPoint * 2; i++)
                {
                    if (shift_point > 0)
                    {
                        if (i > shift_point)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }

                        sbData.Append(",");
                        sbData.Append(0);
                    }
                    else if (shift_point < 0)
                    {
                        if (i > Math.Abs(shift_point))
                        {
                            sbData.Append(",");
                            sbData.Append(0);
                        }

                        sbClock.Append(",");
                        sbClock.Append(0);
                    }

                }
                #endregion

                #region //// Data
                for (int j = 0; j < strCmd.Length; j++)
                {
                    for (int i = 1; i <= intPoint * 2; i++)
                    {
                        // SSC no clock
                        if (j <= 1)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }
                        else if (i <= intHigh)
                        {
                            sbClock.Append(",");
                            sbClock.Append(1);
                        }
                        else if (i > intHigh)
                        {
                            sbClock.Append(",");
                            sbClock.Append(0);
                        }

                        sbData.Append(",");
                        sbData.Append(strCmd[j]);
                    }
                }
                #endregion

                #region //// BP signal
                for (int i = 1; i <= intPoint * 2; i++)
                {
                    if (i <= intHigh)
                    {
                        sbClock.Append(",");
                        sbClock.Append(1);
                    }
                    else if (i > intHigh)
                    {
                        sbClock.Append(",");
                        sbClock.Append(0);
                    }
                    sbData.Append(",");
                    sbData.Append(0);
                }
                #endregion

                #region //// Suffix 2*point
                for (int i = 1; i <= intPoint * 2 + shift_point; i++)
                {
                    sbClock.Append(",");
                    sbClock.Append(0);
                    if (i <= intPoint * 2)
                    {
                        sbData.Append(",");
                        sbData.Append(0);
                    }
                }
                #endregion }
            }
            #endregion Build Mipi Array

            if (!simulated)
            {
                #region Send to Arb
                SendCmd("*CLS");

                SendCmd("SOUR1:FUNC ARB");
                SendCmd("SOUR1:DATA:VOL:CLE");
                SendCmd("SOUR1:DATA:ARB SCLK" + sbClock.ToString());
                SendCmd("SOUR1:FUNC:ARB SCLK");

                SendCmd("SOUR1:FUNC:ARB:SRATE " + SRate.ToString());
                //SendCmd("SOUR1:FUNC:ARB:FILTER OFF");
                SendCmd("SOUR1:FUNC:ARB:FILTER STEP");
                SendCmd("OUTP1:LOAD INF");
                SendCmd("SOUR1:VOLT " + dblVolt.ToString());
                SendCmd("SOUR1:VOLT:OFFS 0");

                SendCmd("SOUR1:BURS:STAT ON");
                SendCmd("SOUR1:BURS:MODE TRIG");
                SendCmd("SOUR1:BURS:NCYC 1");
                SendCmd("TRIG1:SOUR BUS");

                SendCmd("SOUR2:FUNC ARB");
                SendCmd("SOUR2:DATA:VOL:CLE");
                SendCmd("SOUR2:DATA:ARB " + arb_name + sbData.ToString());
                SendCmd("SOUR2:FUNC:ARB " + arb_name);

                SendCmd("SOUR2:FUNC:ARB:SRATE " + SRate.ToString());
                //SendCmd("SOUR2:FUNC:ARB:FILTER OFF");
                SendCmd("SOUR2:FUNC:ARB:FILTER STEP");
                SendCmd("OUTP2:LOAD INF");
                SendCmd("SOUR2:VOLT " + dblVolt.ToString());
                SendCmd("SOUR2:VOLT:OFFS 0");

                SendCmd("SOUR2:BURS:STAT ON");
                SendCmd("SOUR2:BURS:MODE TRIG");
                SendCmd("SOUR2:BURS:NCYC 1");
                SendCmd("TRIG2:SOUR BUS");

                SendCmd("OUTP1 ON");
                SendCmd("OUTP2 ON");

                // set ext trigger
                if (trigger == Triger_Source.Ext)
                {
                    SendCmd("TRIG1:SOUR EXT");
                    SendCmd("TRIG2:SOUR EXT");
                }
                else
                {
                    util.Wait(1000);
                    SendCmd("*TRG");
                }
                #endregion Send to Arb
            }
            //SendCmd("*RST");

        }