Пример #1
0
        public static void MykonosInitArmCheck()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            bool isArmGood = Link.Mykonos.verifyArmChecksum();

            Assert.AreEqual(true, isArmGood, "ARM checksum did not match");

            //Check ARM Version API
            byte[] ver         = new byte[4];
            UInt32 fullVersion = 0;

            Link.Mykonos.readArmMem(0x01000128, 4, 1, ref ver);
            fullVersion = ((UInt32)(ver[0]) | ((UInt32)(ver[1]) << 8) | ((UInt32)(ver[2]) << 16) | ((UInt32)(ver[3]) << 24));


            string version = Link.Mykonos.getArmVersion();

            Console.WriteLine("ARM Version: " + version);

            byte armMajor = 0;
            byte armMinor = 0;
            byte armRc    = 0;

            Link.Mykonos.getArmVersion(ref armMajor, ref armMinor, ref armRc);
            Console.WriteLine("ARM Version: " + armMajor + "." + armMinor + "." + armRc);
            Assert.AreEqual(fullVersion % 100, armRc, "ARM RC version readback not as expected");
            Assert.AreEqual((fullVersion / 100) % 100, armMinor, "ARM minor version readback not as expected");
            Assert.AreEqual(fullVersion / 10000, armMajor, "ARM major version readback not as expected");
            Assert.AreEqual(armMajor + "." + armMinor + "." + armRc, version, "ARM version readback not as expected");

            //Debug - make sure we loaded ARM profile into ARM mem
            byte[] armMemData = new byte[96];
            Link.Mykonos.readArmMem(0x20000000, 96, 1, ref armMemData);
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(settings.resultsPath + @"QABasicSmokeTest\ArmProfile.txt"))
            {
                foreach (byte element in armMemData)
                {
                    file.WriteLine(element.ToString("X"));
                }
            }

            Link.Disconnect();
        }
Пример #2
0
        public static void writeAuxDac()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            Link.hw.ReceiveTimeout = 0;

            Link.Mykonos.writeAuxDac(0, 512);

            Link.hw.ReceiveTimeout = 5000;

            Debug.WriteLine("0xB73: " + Link.spiRead(0xB73).ToString("X"));
            Debug.WriteLine("0xB74: " + Link.spiRead(0xB74).ToString("X"));
            Debug.WriteLine("0xB75: " + Link.spiRead(0xB75).ToString("X"));
            Debug.WriteLine("0xB76: " + Link.spiRead(0xB76).ToString("X"));
            Link.Disconnect();
        }
Пример #3
0
        public static void AD9528ClockStatusCheck()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);



            byte pllStatus = Link.Ad9528.readPllStatus();

            Assert.AreEqual(0x27, (pllStatus & 0x27), "AD9528 PLL not locked or does REFCLK not detected.");

            byte spiData = Link.spiRead(0x403); Console.WriteLine("AD9528: 0x403: " + spiData.ToString("X"));

            Console.WriteLine("AD9528: 9528 PLL Status: " + pllStatus.ToString("X"));

            Link.Disconnect();
        }
Пример #4
0
        public static void ReadRxGainTable()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            byte spiReg1     = 0;
            byte spiReg2     = 0;
            byte index       = 0;
            byte feGain      = 0;
            byte extControl  = 0;
            byte digGain     = 0;
            byte enableAtten = 0;

            Link.setSpiChannel(1);

            Link.spiWrite(0x00A, 0x84);
            spiReg1 = Link.spiRead(0x00A); Console.WriteLine("Scratch Reg Test: " + spiReg1.ToString("X"));
            Assert.AreEqual(0x84, spiReg1, "SPI not working");

            Link.spiWrite(0x516, 0x0C); //Enable Rx1 gain table for readback

            Int16[] coefs = new Int16[128];

            for (byte i = 255; i > 128; i--)
            {
                Link.spiWrite(0x500, i);
                index = Link.spiRead(0x50A);

                feGain = Link.spiRead(0x50B);

                extControl = Link.spiRead(0x50C);

                spiReg2     = Link.spiRead(0x50D);
                digGain     = (byte)(spiReg2 & 0x7F);
                enableAtten = (byte)(spiReg2 >> 7);

                Console.WriteLine(index + ", " + feGain + ", " + extControl + ", " + digGain + ", " + enableAtten);
            }

            Link.spiWrite(0x516, 0x08); //Enable Rx1 gain table for readback

            Link.Disconnect();
        }
Пример #5
0
        //[Test]
        public static void MykonosCheckReset()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            //Check that ENSM status is no longer in Alert State following Reset
            byte spiData1 = 0x0;

            spiData1 = Link.spiRead(0x1B3);
            Console.Write("0x1B3: " + spiData1.ToString("x"));

            Link.Mykonos.resetDevice();

            System.Threading.Thread.Sleep(5000);

            spiData1 = Link.spiRead(0x1B3);
            Console.Write("0x1B3: " + spiData1.ToString("x"));
            Assert.AreEqual(0xFF, spiData1);
            Link.Disconnect();
        }
Пример #6
0
        public static void CheckEnRxQecTrackingCalsFromRadioInit()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.hw.ReceiveTimeout = 0;

            settings.trackCalMask = (UInt32)(Mykonos.TRACKING_CALMASK.RX1_QEC)
                                    | (UInt32)(Mykonos.TRACKING_CALMASK.ORX1_QEC);

            byte spiData1 = 0x0;

            //Test Setup:
            //Run Init Cals
            TestSetup.MykonosInitCals(settings);
            System.Threading.Thread.Sleep(5000);
            spiData1 = Link.spiRead(0xD40);
            Console.WriteLine("SPI Addr: 0xD40:" + spiData1.ToString("X"));
            Assert.AreEqual(0x2, (spiData1 & 0x3),
                            "Myk: Test Setup Failed  Init Cals not completed");

            //Call API Under Test
            //track RX QEC
            Link.Mykonos.enableTrackingCals(settings.trackCalMask);
            Link.hw.ReceiveTimeout = 5000;
            byte[] armData = new byte[] { 0, 0, 0, 0 };
            Link.Mykonos.sendArmCommand(ReadConfigCmd, new byte[] { CalSchedObjId, 0, 0, 2 }, 4);
            Link.Mykonos.readArmMem(0x20000000, 4, 1, ref armData);

            //armData[1] is the calmask [15:8], and armData[0] is calmask[7:0]
            Console.WriteLine("Test tracking calmask:" + settings.trackCalMask.ToString("X"));
            Console.WriteLine("Enabled tracking calmask: " + armData[3].ToString("X") +
                              armData[2].ToString("X") + armData[1].ToString("X") + armData[0].ToString("X"));

            Assert.AreEqual(settings.trackCalMask, (UInt32)(((UInt32)(armData[3]) << 24)
                                                            | ((UInt32)(armData[2]) << 16)
                                                            | ((UInt32)(armData[1]) << 8)
                                                            | ((UInt32)(armData[0]))),
                            "Tracking calmask did not match the mask written to ARM memory");
            Link.Disconnect();
        }
Пример #7
0
        public static void TestMCS()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            byte mcsStatus = 0;

            Link.setSpiChannel(1);
            Link.spiWrite(0x120, 0x00);

            Link.Mykonos.enableMultichipSync(1, ref mcsStatus);

            Link.Ad9528.requestSysref(true);
            Link.Ad9528.requestSysref(true);
            Link.Ad9528.requestSysref(true);
            Link.Ad9528.requestSysref(true);

            Link.Mykonos.enableMultichipSync(0, ref mcsStatus);
            Link.Disconnect();
        }
Пример #8
0
        public static void MykonosInitStatusCheck()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            Link.setSpiChannel(TestSetup.MykonosSpi);
            Console.WriteLine("SPIRead x119: " + Link.spiRead(0x119).ToString("X"));
            Console.WriteLine("SPIRead x157: " + Link.spiRead(0x157).ToString("X"));
            Console.WriteLine("SPIRead x1B3: " + Link.spiRead(0x1B3).ToString("X"));
            UInt32 pllStatus = Link.spiRead(0x157);

            Assert.AreEqual(0x01, pllStatus & 0x01, "CLK PLL not locked");


            UInt32 ensmStatus = Link.spiRead(0x1B3);

            Assert.AreEqual(0x05, ensmStatus & 0x7, "Not in Alert state.");

            Link.Disconnect();
        }
Пример #9
0
        public static void MykonosCheckGetMykonosErrorMessage()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            string errorMsg      = "";
            uint   MAX_ERRORCODE = 277;

            errorMsg = Link.Mykonos.getMykonosErrorMessage(0);
            Console.WriteLine(errorMsg);
            Assert.AreEqual("\n", errorMsg, "Error Message not as expected");

            for (uint i = 1; i < MAX_ERRORCODE; i++)
            {
                errorMsg = Link.Mykonos.getMykonosErrorMessage(i);
                Console.WriteLine(errorMsg);
                Assert.AreNotEqual("", errorMsg, "Error Message not as expected. Error code: " + i);
            }
            Link.Disconnect();
        }
Пример #10
0
        public static void SetArmDebugMode()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            Console.Write(Link.identify());
            Console.Write(Link.version());



            Link.fpgaWrite(0x100, 1); //enable Test mode 0xA for ARM Debug

            byte fpgaReadData = Link.spiRead(0xD00); Console.WriteLine("xD00 = " + fpgaReadData.ToString("X"));

            fpgaReadData = Link.spiRead(0xD08); Console.WriteLine("xD08 = " + fpgaReadData.ToString("X"));
            fpgaReadData = Link.spiRead(0xD09); Console.WriteLine("xD09 = " + fpgaReadData.ToString("X"));
            fpgaReadData = Link.spiRead(0xD14); Console.WriteLine("xD14 = " + fpgaReadData.ToString("X"));


            Link.Disconnect();
        }
Пример #11
0
        public static void SweepTxPllFrequency(TestSetupConfig settings)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.setSpiChannel(1);
            Link.Mykonos.init_clocks(settings.mykSettings.DeviceClock_kHz, 9830400, Mykonos.VCODIV.VCODIV_1, 4);

            double[] freq = { 1.2605E+10, 1.2245E+10, 1.1906E+10, 1.1588E+10, 1.1288E+10, 1.1007E+10, 1.0742E+10, 1.0492E+10, 1.0258E+10, 1.0036E+10, 9.8278E+09, 9.6311E+09, 9.4453E+09, 9.2698E+09, 9.1036E+09, 8.9463E+09, 8.7970E+09, 8.6553E+09, 8.5206E+09, 8.3923E+09, 8.2699E+09, 8.1531E+09, 8.0414E+09, 7.9344E+09, 7.8318E+09, 7.7332E+09, 7.6384E+09, 7.5471E+09, 7.4590E+09, 7.3740E+09, 7.2919E+09, 7.2124E+09, 7.1355E+09, 7.0610E+09, 6.9887E+09, 6.9186E+09, 6.8506E+09, 6.7846E+09, 6.7205E+09, 6.6582E+09, 6.5978E+09, 6.5392E+09, 6.4823E+09, 6.4270E+09, 6.3734E+09, 6.3214E+09, 6.2709E+09, 6.2220E+09, 6.1745E+09, 6.1284E+09, 6.0836E+09, 6.0401E+09, 5.9977E+09 };

            byte pllStatus = 0;

            for (int i = 0; i <= 52; i++)
            {
                Link.Mykonos.setRfPllFrequency(Mykonos.PLLNAME.TX_PLL, (UInt64)(freq[i] / 4));
                System.Threading.Thread.Sleep(100);

                pllStatus = Link.Mykonos.checkPllsLockStatus();
                //Console.WriteLine("Frequency: " + freq[i]/4 + ", PLL Status: 0x" + pllStatus.ToString("X"));


                byte vcoOutLevel  = (byte)(Link.spiRead(0x2BA) & 0x0F);
                byte vcoVar       = (byte)(Link.spiRead(0x2B9) & 0xF);
                byte vcoBiasRef   = (byte)(Link.spiRead(0x2C2) & 0x7);
                byte vcoBiasTcf   = (byte)((Link.spiRead(0x2C2) >> 3) & 0x3);
                byte vcoCalOffset = (byte)((Link.spiRead(0x2B8) >> 3) & 0xF);
                byte vcoVarRef    = (byte)(Link.spiRead(0x2D1) & 0xF);
                byte iCp          = (byte)(Link.spiRead(0x2BB) & 0x3F);
                byte lfC2         = (byte)((Link.spiRead(0x2BE) >> 4) & 0xF);
                byte lfC1         = (byte)(Link.spiRead(0x2BE) & 0xF);
                byte lfR1         = (byte)((Link.spiRead(0x2BF) >> 4) & 0xF);
                byte lfC3         = (byte)(Link.spiRead(0x2BF) & 0xF);
                byte lfR3         = (byte)(Link.spiRead(0x2C0) & 0xF);

                Console.WriteLine(freq[i] + "\t" + vcoOutLevel + "\t" + vcoVar + "\t" + vcoBiasRef + "\t" + vcoBiasTcf + "\t" + vcoCalOffset + "\t" + vcoVarRef + "\t" + iCp + "\t" + lfC2 + "\t" + lfC1 + "\t" + lfR1 + "\t" + lfC3 + "\t" + lfR3);
            }

            Link.Disconnect();
        }
Пример #12
0
        public static void CheckSetRadioOffFromRadioOn()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            UInt32 radioState = 0;
            byte   spiData1   = 0x0;

            //Test Setup:
            //Run Init Cals
            TestSetup.MykonosInitCals(settings);
            System.Threading.Thread.Sleep(5000);
            spiData1 = Link.spiRead(0xD40);
            Console.WriteLine("SPI Addr: 0xD40:" + spiData1.ToString("X"));
            Assert.AreEqual(0x2, (spiData1 & 0x3), "Myk: Test Setup Failed  Init Cals not completed");
            Link.Mykonos.radioOn();
            spiData1 = Link.spiRead(0xD40);
            Console.WriteLine("SPI Addr: 0xD40:" + spiData1.ToString("X"));
            Assert.AreEqual(0x03, (spiData1 & 0x03), "Myk: Test Setup Failed  Radio Satus not RADIO_ON as expected");
            //Call API under test
            Link.Mykonos.radioOff();

            //Check Pass Criteria
            //Radio Status Via Direct Spi Read
            //Radio Status Via API
            spiData1 = Link.spiRead(0xD40);
            Console.WriteLine("SPI Addr: 0xD40:" + spiData1.ToString("X"));
            Assert.AreNotEqual(0x3, (spiData1 & 0x3), "Myk: 1 Radio State is Still Radio ON");
            Assert.AreEqual(0x02, (spiData1 & 0x03), "Myk:  2 Radio Satus not INIT as Expected");

            Link.Mykonos.getRadioState(ref radioState);
            Console.WriteLine("MYKONOS RadioState = " + radioState.ToString("X"));
            Assert.AreNotEqual(0x3, (radioState & 0x3), "Myk: 3 Radio State is Still Radio ON");
            Assert.AreEqual(0x2, (radioState & 0x3), "Myk: 4 Radio State not INIT");
            Console.WriteLine("MYKONOS RadioState = " + radioState.ToString("X"));
            Link.Disconnect();
        }
Пример #13
0
        public static void ReadFirFilter()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);

            byte spiReg1 = 0;
            byte spiReg2 = 0;

            Link.spiWrite(0x00A, 0x84); //Enable readback of RX1 FIR
            spiReg1 = Link.spiRead(0x00A); Console.WriteLine("Scratch Reg Test: " + spiReg1.ToString("X"));
            Link.spiWrite(0xDFF, 0x84); //Enable readback of RX1 FIR
            spiReg1 = Link.spiRead(0xDFF); Console.WriteLine("Filter Select: " + spiReg1.ToString("X"));

            spiReg1 = Link.spiRead(0x410); Console.WriteLine("Rx #taps: " + (spiReg1).ToString("X"));
            spiReg1 = Link.spiRead(0x411); Console.WriteLine("Rx Filter Gain: " + (spiReg1 & 0x03).ToString("X"));
            spiReg1 = Link.spiRead(0x412); Console.WriteLine("DPD Rx Filter Gain: " + (spiReg1 & 0x03).ToString("X"));
            Console.WriteLine("Sniffer Rx Filter Gain: " + ((spiReg1 >> 5) & 0x03).ToString("X"));

            Int16[] coefs = new Int16[128];

            for (int i = 0; i < 128; i++)
            {
                Link.spiWrite(0xE01, (byte)(i * 2));
                spiReg1 = Link.spiRead(0xE00);
                Link.spiWrite(0xE01, (byte)(i * 2 + 1));
                spiReg2 = Link.spiRead(0xE00);

                coefs[i] = (Int16)((UInt16)(spiReg1) | ((UInt16)(spiReg2) << 8));
                Console.WriteLine("Coef[" + i + "]: " + coefs[i]);
            }



            Link.Disconnect();
        }
Пример #14
0
        public static void testReadGpio3v3PinLevel([Values((UInt16)0x01, (UInt16)0x20)] UInt16 gpio3v3PinLevel)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1  = 0x0;
            byte   spiData2  = 0x0;
            UInt16 gpio3v3Oe = 0x3F;
            UInt16 gpio3v3PinLevelReadback = 0x0;

            Mykonos.GPIO3V3_MODE gpio3v3Mode3_0  = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Mykonos.GPIO3V3_MODE gpio3v3Mode7_4  = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Mykonos.GPIO3V3_MODE gpio3v3Mode11_8 = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Link.Mykonos.setupGpio3v3(gpio3v3Oe, gpio3v3Mode3_0, gpio3v3Mode7_4, gpio3v3Mode11_8);
            Link.Mykonos.setGpio3v3PinLevel(gpio3v3PinLevel);
            Link.Mykonos.getGpio3v3PinLevel(ref gpio3v3PinLevelReadback);
            Console.WriteLine(gpio3v3PinLevelReadback);
            spiData1 = Link.spiRead(0xB04); Console.WriteLine("0xB04: " + spiData1.ToString("X"));
            spiData2 = Link.spiRead(0xB05); Console.WriteLine("0xB05: " + spiData2.ToString("X"));
            Assert.AreEqual(gpio3v3PinLevelReadback, ((spiData2 & 0x0F) << 8) | spiData1, "GPIO3v3 readback not as expected");
            switch (gpio3v3PinLevel)
            {
            case 0x01:
                Assert.AreEqual(gpio3v3PinLevelReadback, 2048, "GPIO input read not as expected");
                break;

            case 0x20:
                Assert.AreEqual(gpio3v3PinLevelReadback, 64, "GPIO input read not as expected");
                break;

            default:
                Assert.Fail("output GPIO level not defined in test code");
                break;
            }
            Link.Disconnect();
        }
Пример #15
0
        public static void getPllFrequency([Values(Mykonos.PLLNAME.RX_PLL, Mykonos.PLLNAME.SNIFFER_PLL)] Mykonos.PLLNAME pllName)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.setSpiChannel(MykonosSpi);

            Link.Mykonos.setRfPllFrequency(pllName, 3500000000);
            System.Threading.Thread.Sleep(1000);

            byte spiData1 = 0x0;

            //Check PLL Lock Status
            spiData1 = Link.spiRead(0x157); Console.WriteLine("Myk: Clk Syn Stat:" + spiData1.ToString("X"));
            Assert.AreEqual(0x01, spiData1 & 0x01, "Myk: CLK PLL not locked");
            spiData1 = Link.spiRead(0x257); Console.WriteLine("Myk: Rx Clk Syn Stat:" + spiData1.ToString("X"));
            Assert.AreEqual(0x01, spiData1 & 0x01, "Myk: Rx CLK Syn not locked");
            spiData1 = Link.spiRead(0x2C7); Console.WriteLine("Myk: Tx Clk Syn Stat:" + spiData1.ToString("X"));
            Assert.AreEqual(0x01, spiData1 & 0x01, "Myk: Tx CLK Syn not locked");
            spiData1 = Link.spiRead(0x357); Console.WriteLine("Myk: SnRx Clk Syn Stat:" + spiData1.ToString("X"));
            Assert.AreEqual(0x01, spiData1 & 0x01, "Myk: SnRx CLK Syn not locked");
            spiData1 = Link.spiRead(0x17F); Console.WriteLine("Myk: Cal PLL Stat:" + spiData1.ToString("X"));
            Assert.AreEqual(0x01, spiData1 & 0x01, "Myk: Cal PLL  not locked");

            ulong readBack = 0;

            Link.Mykonos.getRfPllFrequency(Mykonos.PLLNAME.CLK_PLL, ref readBack);
            Console.Write("Test" + settings.rxProfileData.ClkPllFrequency_kHz);
            Assert.AreEqual(settings.rxProfileData.ClkPllFrequency_kHz, (readBack / 1000), "CLKPLL Frequency Readback Not as Expected");
            Console.WriteLine("Clk Pll Frequency: " + readBack);

            Link.Mykonos.getRfPllFrequency(pllName, ref readBack);
            Assert.AreEqual(3500000000, readBack, "PLL Frequency Readback Not as Expected");

            Link.Disconnect();
        }
Пример #16
0
        public static void CheckEnaAllTrackCalsFromInit()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.hw.ReceiveTimeout = 0;
            byte spiData1 = 0x0;

            //Test Setup:
            //Run Init Cals
            //And check INIT
            TestSetup.MykonosInitCals(settings);
            System.Threading.Thread.Sleep(5000);
            spiData1 = Link.spiRead(0xD40);
            Console.WriteLine("SPI Addr: 0xD40:" + spiData1.ToString("X"));
            Assert.AreEqual(0x2, (spiData1 & 0x3), "Myk: Test Setup Failed  Init Cals not completed");


            //Call API Under Test
            Link.Mykonos.enableTrackingCals((UInt32)(0x3FF));
            Link.hw.ReceiveTimeout = 5000;

            byte[] armData = new byte[] { 0, 0, 0, 0 };
            Link.Mykonos.sendArmCommand(0x08, new byte[] { 0x83, 0, 0, 2 }, 4);
            Link.Mykonos.readArmMem(0x20000000, 4, 1, ref armData);

            //armData[1] is the calmask [15:8], and armData[0] is calmask[7:0]
            Debug.WriteLine("Enabled tracking calmask: " + armData[3].ToString("X") +
                            armData[2].ToString("X") + armData[1].ToString("X") + armData[0].ToString("X"));

            Assert.AreEqual(0x3FF, (UInt32)(((UInt32)(armData[3]) << 24) | ((UInt32)(armData[2]) << 16)
                                            | ((UInt32)(armData[1]) << 8) | ((UInt32)(armData[0]))),
                            "Tracking calmask did not match the mask written to ARM memory");

            Link.Disconnect();
        }
Пример #17
0
        public static void OrxCaptureTest([Values(Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO, Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO)] Mykonos.OBSRXCHANNEL channel, [Values(-20)] int amp_dbm,
                                          [Values(10000)] int IQExptVal)
        {
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            profileInfo[0] = settings.rxProfileData.IqRate_kHz;
            profileInfo[1] = settings.rxPllLoFreq_Hz;
            profileInfo[2] = settings.rxProfileData.PrimarySigBw_Hz;

            double samplingFreq_Hz = profileInfo[0] * 1000;
            double profileBW_MHz   = profileInfo[2] / 1000000;

            Console.WriteLine("Rx Sampling Freq (Hz): " + samplingFreq_Hz);
            Console.WriteLine("Rx Profile Bandwdith (MHz): " + profileBW_MHz);
            double freqLo_kHz = profileInfo[1] / 1000;

            Console.WriteLine("Rx LO Frequency (kHz): " + freqLo_kHz);

            //Define Receiver Test Signal to be 10MHz Offset from LO frequency
            double testSigFreq_MHz = (freqLo_kHz / 1000 + 10);
            int    amplitude_dBm   = amp_dbm;

            Console.WriteLine("Rx Test Signal Freq (MHz): " + testSigFreq_MHz);

            //Define DataCapture Parameters
            const int NUM_SAMPLES = 8192;

            short[] rxDataArray = new short[NUM_SAMPLES * 2];
            double[,] timeDomainData = new double[NUM_SAMPLES / 2, 3];


            //Generate Test Signal for Rx Capture with ESG
            SG_AgilentESG esg = new SG_AgilentESG(measEquipment.ESGAddress);

            Console.WriteLine("ESG Info:" + esg.Identify());
            Console.WriteLine("ESG Address :" + measEquipment.ESGAddress);
            Console.WriteLine("ESG Generating Tone Freq:" + testSigFreq_MHz);
            Console.WriteLine("ESG Generating Tone Amp:" + amplitude_dBm);
            esg.SetFrequency(testSigFreq_MHz);
            esg.SetAmplitude(amp_dbm);
            esg.SetRfOutput(true);

            //Enable Mykonos Rx Datapath
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            //Link.Mykonos.setEnsmState(Mykonos.ENSM_STATE.TX_RX);
            //Link.Mykonos.powerUpRxPath(channel);
            Link.Mykonos.radioOn();
            Link.Mykonos.setObsRxPathSource(channel);

            Link.Disconnect();
            System.Threading.Thread.Sleep(1000);

            //Retrieve Rx Data from FPGA
            rxDataArray = Helper.MykonosOrxCapture(channel, NUM_SAMPLES);

            //Frequency Domain Data Processing
            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();
            double samplingFreq_MHz          = samplingFreq_Hz / 1000000;
            byte   sampleBitWidth            = 16;

            double[] data = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

            //Define the 2D array to store frequency bins corresponding to fft data
            double[,] fftFreqAmp = new double[data.Length, 2];
            double binSize = (samplingFreq_MHz / NUM_SAMPLES);
            double minFreq = samplingFreq_MHz / 2 * (-1);

            for (int i = 0; i < data.Length; i++)
            {
                fftFreqAmp[i, 0] = minFreq + (binSize * 2 * i);
                fftFreqAmp[i, 1] = data[i];
            }

            //Time Domain Data Processing
            int numSamplesDiv2 = (int)NUM_SAMPLES / 2;

            for (int i = 0; i < numSamplesDiv2; i++)
            {
                timeDomainData[i, 0] = i;
                timeDomainData[i, 1] = rxDataArray[2 * i];
                timeDomainData[i, 2] = rxDataArray[2 * i + 1];
            }

            var IMin = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => timeDomainData[i, 1]).Min();
            var IMax = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => timeDomainData[i, 1]).Max();
            var QMin = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => timeDomainData[i, 2]).Min();
            var QMax = System.Linq.Enumerable.Range(0, numSamplesDiv2).Select(i => timeDomainData[i, 2]).Max();

            Console.WriteLine("I Max, Min:" + IMax.ToString() + "," + IMin.ToString());
            Console.WriteLine("Q Max, Min:" + QMax.ToString() + "," + QMin.ToString());


#if WR_RES_TO_PDF
            string path = RxRfTests.ResPath + "Rx_FFT_TimeDomain_Plots";
            if (channel == Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO)
            {
                path = path + "ORX1";
            }
            else
            {
                path = path + "ORX2";
            }

            string[] timeLabels = new string[] { "Time Domain Response of " + channel.ToString(), "Sample Number", "ADC Codes", "I data", "Q data" };
            string[] fftLabels  = new string[] { "Frequency Domain Response of " + channel.ToString(), "Frequency (MHz)", "Amplitude (dBFS)", "FFT DATA" };                                                                                       // Should be >=4 long.

            var doc1 = new Document();
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            container[0] = Helper.MakeChartObject(timeDomainData, timeLabels, path);
            container[1] = Helper.MakeChartObject(fftFreqAmp, fftLabels, path);
            string[] pcbInfo;
            pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, "N/A", "N/A");

            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            // open result pdf
            System.Diagnostics.Process.Start(path + ".pdf");
#endif


            // open result pdf
            System.Diagnostics.Process.Start(path + ".pdf");

            /*
             * NUnit.Framework.Assert.Greater(IMin, ((-1) * (IQExptVal + ((IQExptVal * 10) / 100))));
             * NUnit.Framework.Assert.Less(IMin, (IQExptVal * (-1)));
             * NUnit.Framework.Assert.Less(IMax, ((IQExptVal + ((IQExptVal * 10) / 100))));
             * NUnit.Framework.Assert.Greater(IMax, IQExptVal);
             *
             * NUnit.Framework.Assert.Greater(QMin, ((-1) * (IQExptVal + ((IQExptVal * 10) / 100))));
             * NUnit.Framework.Assert.Less(QMin, (IQExptVal * (-1)));
             * NUnit.Framework.Assert.Less(QMax, ((IQExptVal + ((IQExptVal * 10) / 100))));
             * NUnit.Framework.Assert.Greater(QMax, IQExptVal);
             */
            NUnit.Framework.Assert.Greater(IMax, 5000);
            NUnit.Framework.Assert.Greater(QMax, 5000);
        }
        public static void TxLOLInitCalCheck([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)
        {
            //Setup the calibrations
            settings.calMask = (UInt32)(Mykonos.CALMASK.TX_BB_FILTER) |
                               (UInt32)(Mykonos.CALMASK.ADC_TUNER) |
                               (UInt32)(Mykonos.CALMASK.TIA_3DB_CORNER) |
                               (UInt32)(Mykonos.CALMASK.DC_OFFSET) |
                               (UInt32)(Mykonos.CALMASK.TX_ATTENUATION_DELAY) |
                               (UInt32)(Mykonos.CALMASK.RX_GAIN_DELAY) |
                               (UInt32)(Mykonos.CALMASK.FLASH_CAL) |
                               (UInt32)(Mykonos.CALMASK.PATH_DELAY) |
                               //(UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL) |
                               (UInt32)(Mykonos.CALMASK.TX_QEC_INIT) |
                               (UInt32)(Mykonos.CALMASK.LOOPBACK_RX_LO_DELAY) |
                               (UInt32)(Mykonos.CALMASK.LOOPBACK_RX_RX_QEC_INIT) |
                               (UInt32)(Mykonos.CALMASK.RX_LO_DELAY) |
                               (UInt32)(Mykonos.CALMASK.RX_QEC_INIT);
            TestSetup.TestSetupInit(settings);

            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            int      backoff     = 0;
            string   boardfreq   = settings.testBoard;

            profileInfo[0] = settings.txProfileData.IqRate_kHz;
            profileInfo[1] = settings.txPllLoFreq_Hz;
            profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;

            double txIqDataRate_kHz     = profileInfo[0];
            double profileBandwidth_MHz = profileInfo[2] / 1000000;

            Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz);
            Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz);
            double freqTxLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz);

            //Define variables for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
            double[] fundAmp      = new double[2];
            double[] LoLeakageAmp = new double[2];

            //Connect to Signal Analyser
            //The span is fixed to 100MHz
            //Set Marker 2 as LO leakage marker
            //Note: this may need to be set depending on profile.
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 100, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(2, freqTxLo_MHz);

            //Config and Enable Mykonos with Test Specific Settings
            //Use Default Test Constructor
            //Start Calibration

            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);

            System.Threading.Thread.Sleep(500);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            //Generate Tone and Measure Image
            double offsetFreq_Mhz = 10;
            double testFreq_MHz   = freqTxLo_MHz + offsetFreq_Mhz;
            double offsetFreq_Hz  = offsetFreq_Mhz * 1000000;

            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

            //Take Measurements from PXA
            pxa.SetMarker(1, testFreq_MHz);  //Fundamental amplitue marker

            System.Threading.Thread.Sleep(500);
            fundAmp[0]      = Double.Parse(pxa.GetMarker(1), style);
            LoLeakageAmp[0] = Double.Parse(pxa.GetMarker(2), style);
            Console.WriteLine("No Init LO Leakage" + ": FundAmp: " + fundAmp[0] + ", LO Leakage:   " + LoLeakageAmp[0]);


            //Re-Initialise with TX QEC init Cal
            settings.calMask = settings.calMask | (UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL);
            TestSetup.TestSetupInit(settings);
            //Turn Radio Off and
            Link = AdiCommandServerClient.Instance;
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOff();
            System.Threading.Thread.Sleep(500);



            System.Threading.Thread.Sleep(500);
            Link.Disconnect();

            //Config and Enable Mykonos with Test Specific Settings
            Link = AdiCommandServerClient.Instance;
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            //Generate Tone and Measure Image
            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

            //Take Measurements from PXA
            System.Threading.Thread.Sleep(500);
            fundAmp[1]      = Double.Parse(pxa.GetMarker(1), style);
            LoLeakageAmp[1] = Double.Parse(pxa.GetMarker(2), style);
            Console.WriteLine("Init LO Leakage" + ": FundAmp: " + fundAmp[1] + ", LO Leakage:   " + LoLeakageAmp[1] + ",   " + (fundAmp[1] - LoLeakageAmp[1]) + ",   ");
            Console.WriteLine("Lo Leakage Diff:   " + (LoLeakageAmp[0] - LoLeakageAmp[1]));
            // Check that Image has reduced
            NUnit.Framework.Assert.Less(LoLeakageAmp[1], LoLeakageAmp[0]);
        }
Пример #19
0
        public static void SnRxGainSweep([Values(Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A, Mykonos.OBSRXCHANNEL.OBS_SNIFFER_B, Mykonos.OBSRXCHANNEL.OBS_SNIFFER_C)] Mykonos.SNIFFER_CHANNEL channel)
        {
            //Initialize param structure with Hardcoded Values
            //Check why Sniffer test checks OrxProfile
            double[] profileInfo      = Helper.SetOrxProfileInfo(Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A);
            double   samplingFreq_MHz = profileInfo[0] / 1000;
            double   freqLo_MHz       = profileInfo[1] / 1000000;
            double   profileBW_MHz    = profileInfo[2] / 1000000;
            double   testFreq         = 2510;
            double   amplitude_dBm    = -20;


            int numIndices = 58;

            double[,] amplitudeData     = new double[numIndices, 3]; //58
            double[,] amplitudeDiffData = new double[numIndices - 1, 2];
            short[] rxDataArray = new short[16384];
            Console.WriteLine("Detected LO Frequency: " + freqLo_MHz);
            Console.WriteLine("Profile BW: " + profileBW_MHz);

            testFreq      = freqLo_MHz + 5;
            amplitude_dBm = -35;

            ///ESG Setup
            SG_AgilentESG esg = new SG_AgilentESG(measEquipment.ESGAddress);

            Console.WriteLine(measEquipment.ESGAddress);
            Console.WriteLine(esg.Identify());
            esg.SetFrequency(testFreq);
            esg.SetAmplitude(amplitude_dBm);
            esg.SetRfOutput(true);

            // ----- Test Execution ----- //
            byte gainIndex = 255;
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();

            for (int i = 0; i < (numIndices + 1); i++)
            {
                try
                {
                    Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
                    //Link.spiWrite(0x516, 0x84);
                    gainIndex = (byte)(255 - i);


                    //Console.WriteLine("Register 0x512: " + Link.spiRead(0x512));
                    //Console.WriteLine("Register 0x513: " + Link.spiRead(0x513));


                    //Console.WriteLine("Initial gain index = " + Link.Mykonos.getObsRxGain());
                    Link.Mykonos.setObsRxManualGain(Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A, gainIndex);
                    //if (gainIndex <= 237)
                    //{
                    //    Link.spiWrite(0x516, 0xC0);
                    //    Link.spiWrite(0x508, 0x10);
                    //}
                    Console.WriteLine("Set gain index = " + gainIndex);
                    Console.WriteLine("Register 0x508: " + Link.spiRead(0x508).ToString("X"));
                    Console.WriteLine("Register 0x514: " + Link.spiRead(0x514).ToString("X"));
                    Console.WriteLine("Register 0x516: " + Link.spiRead(0x516).ToString("X"));
                    System.Threading.Thread.Sleep(100);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    break;
                }
                finally
                {
                    Link.Disconnect();
                }


                rxDataArray = Helper.MykonosOrxCapture(Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A, 8192);
                byte     sampleBitWidth = 16;
                double[] data           = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                amplitudeData[i, 0] = (double)gainIndex;
                amplitudeData[i, 1] = analysisData.FundamentalPower_dBFS;
                Console.WriteLine("Fundamental Amplitude: " + analysisData.FundamentalPower_dBFS.ToString());
                if (i == 0)
                {
                    amplitudeData[i, 2] = analysisData.FundamentalPower_dBFS;
                }
                else
                {
                    amplitudeData[i, 2]         = amplitudeData[i - 1, 2] - 1;
                    amplitudeDiffData[i - 1, 0] = (double)gainIndex;
                    amplitudeDiffData[i - 1, 1] = amplitudeData[i - 1, 1] - amplitudeData[i, 1];
                }
            }
#if false //Graphing Error - To be fixed
            string path = SnRxRfTest.ResPath + "SnRxGainSweep";
            if (channel == Mykonos.SNIFFER_CHANNEL.SNIFFER_A)
            {
                path = path + "SnA";
            }
            else if (channel == Mykonos.SNIFFER_CHANNEL.SNIFFER_B)
            {
                path = path + "SnB";
            }
            else
            {
                path = path + "SnC";
            }
            var doc1 = new Document();
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            string[] timeLabels = new string[] { "Rx Gain Sweep versus Amplitude for " + channel.ToString(),
                                                 "Gain Index (byte)",
                                                 "Amplitude (dBFS)",
                                                 "Amplitude: " + amplitude_dBm + "dBm",
                                                 "Perfect 1dB Gain Index Steps" };
            string[] timeLabels2 = new string[] { "Difference between consecutive gain entries " + channel.ToString(),
                                                  "Gain Index",
                                                  "Amplitude delta (dB, comparing A(n + 1) - A(n))",
                                                  "Amplitude: " + amplitude_dBm + "dBm" };
            string[] pcbInfo = Helper.PcbInfo();

            container[0] = Helper.MakeChartObject(amplitudeData, timeLabels, path);
            container[1] = Helper.MakeChartObject(amplitudeDiffData, timeLabels2, path + "2");

            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);
            //Console.WriteLine(pcbInfo);
            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
        }
Пример #20
0
        public static void ObsRxDecPwrTest([Values(Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO, Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO)] Mykonos.OBSRXCHANNEL channel,
                                           [Values(-20)] int amp_dbm)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.radioOn();
            Link.Mykonos.setObsRxPathSource(channel);

            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            profileInfo[0] = settings.rxProfileData.IqRate_kHz;
            profileInfo[1] = settings.rxPllLoFreq_Hz;
            profileInfo[2] = settings.rxProfileData.PrimarySigBw_Hz;

            double samplingFreq_Hz = profileInfo[0] * 1000;
            double profileBW_MHz   = profileInfo[2] / 1000000;

            Console.WriteLine("Rx Sampling Freq (Hz): " + samplingFreq_Hz);
            Console.WriteLine("Rx Profile Bandwdith (MHz): " + profileBW_MHz);
            double freqLo_kHz = profileInfo[1] / 1000;

            Console.WriteLine("Rx LO Frequency (kHz): " + freqLo_kHz);

            //Define Receiver Test Signal to be 10MHz Offset from LO frequency
            double testSigFreq_MHz = (freqLo_kHz / 1000 + 10);
            int    amplitude_dBm   = amp_dbm;

            Console.WriteLine("Rx Test Signal Freq (MHz): " + testSigFreq_MHz);

            //Define DataCapture Parameters
            const byte NUM_SAMPLES         = 255;
            ushort     obsRxDecPower_mdBFS = 10;
            byte       spiData             = 0x0;


            //Generate Test Signal for Rx Capture with ESG
            SG_AgilentESG esg = new SG_AgilentESG(measEquipment.ESGAddress);

            Console.WriteLine("ESG Info:" + esg.Identify());
            Console.WriteLine("ESG Address :" + measEquipment.ESGAddress);
            Console.WriteLine("ESG Generating Tone Freq:" + testSigFreq_MHz);
            Console.WriteLine("ESG Generating Tone Amp:" + amplitude_dBm);
            esg.SetFrequency(testSigFreq_MHz);

            esg.SetRfOutput(true);
            esg.SetAmplitude(amplitude_dBm);
            System.Threading.Thread.Sleep(1000);


            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();
            double samplingFreq_MHz          = samplingFreq_Hz / 1000000;
            byte   sampleBitWidth            = 16;


            for (int amp = -20; amp > -40; amp--)
            {
                System.Threading.Thread.Sleep(100);
                esg.SetAmplitude(amp);
                System.Threading.Thread.Sleep(100);
                short[] rxDataArray = Helper.MykonosOrxCapture(channel, 16384);

                double[] data = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                Link.Mykonos.getObsRxDecPower(ref obsRxDecPower_mdBFS);
                spiData = Link.spiRead(0x4E6);


                Console.WriteLine("Received power: " + obsRxDecPower_mdBFS + " calculated power: " + analysisData.FundamentalPower_dBFS + " at " + amp + " dbfs");
                NUnit.Framework.Assert.Less(System.Math.Abs((double)obsRxDecPower_mdBFS / 1000 + analysisData.FundamentalPower_dBFS), 0.50);
                NUnit.Framework.Assert.AreEqual(spiData * 250, obsRxDecPower_mdBFS);
            }


            Link.Disconnect();
        }
Пример #21
0
        public static void ObsRxAGCTest([Values(Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A)] Mykonos.OBSRXCHANNEL channel)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1                         = 0;
            ushort power                            = 0;
            byte   agcRx1MaxGainIndex               = 255;
            byte   agcRx1MinGainIndex               = 195;
            byte   agcRx2MaxGainIndex               = 255;
            byte   agcRx2MinGainIndex               = 195;
            byte   agcObsRxMaxGainIndex             = 255;
            byte   agcObsRxMinGainIndex             = 203;
            byte   agcObsRxSelect                   = 1;
            byte   agcPeakThresholdMode             = 1; // Change for power only mode
            byte   agcLowThsPreventGainIncrease     = 1; // Change for power only mode
            UInt32 agcGainUpdateCounter             = 30720;
            byte   agcSlowLoopSettlingDelay         = 3;
            byte   agcPeakWaitTime                  = 2;
            byte   pmdMeasDuration                  = 0x08;
            byte   pmdMeasConfig                    = 0x2;
            byte   agcResetOnRxEnable               = 1;
            byte   agcEnableSyncPulseForGainCounter = 0;

            // mykonosPowerMeasAgcCfg_t
            byte pmdUpperHighThresh           = 0x01; // Triggered at approx -2dBFS
            byte pmdUpperLowThresh            = 0x03;
            byte pmdLowerHighThresh           = 0x0C;
            byte pmdLowerLowThresh            = 0x04;
            byte pmdUpperHighGainStepAttack   = 0x04;
            byte pmdUpperLowGainStepAttack    = 0x02;
            byte pmdLowerHighGainStepRecovery = 0x02;
            byte pmdLowerLowGainStepRecovery  = 0x04;

            // mykonosPeakDetAgcCfg_t
            byte apdHighThresh               = 0x1F; //Triggered at approx -3dBFS
            byte apdLowThresh                = 0x16; //Triggered at approx -5.5dBFS
            byte hb2HighThresh               = 0xB5; // Triggered at approx -2.18dBFS
            byte hb2LowThresh                = 0x80; // Triggered at approx -5.5dBFS
            byte hb2VeryLowThresh            = 0x40; // Triggered at approx -9dBFS
            byte apdHighThreshExceededCnt    = 0x06;
            byte apdLowThreshExceededCnt     = 0x04;
            byte hb2HighThreshExceededCnt    = 0x06;
            byte hb2LowThreshExceededCnt     = 0x04;
            byte hb2VeryLowThreshExceededCnt = 0x04;
            byte apdHighGainStepAttack       = 0x04;
            byte apdLowGainStepRecovery      = 0x02;
            byte hb2HighGainStepAttack       = 0x04;
            byte hb2LowGainStepRecovery      = 0x02;
            byte hb2VeryLowGainStepRecovery  = 0x04;
            byte apdFastAttack               = 1;
            byte hb2FastAttack               = 1;
            byte hb2OverloadDetectEnable     = 1;
            byte hb2OverloadDurationCnt      = 1;
            byte hb2OverloadThreshCnt        = 0x1;

            // Write some values into the structure
            Link.Mykonos.init_obsRxAgcStructure(1, ref agcRx1MaxGainIndex,
                                                ref agcRx1MinGainIndex,
                                                ref agcRx2MaxGainIndex,
                                                ref agcRx2MinGainIndex,
                                                ref agcObsRxMaxGainIndex,
                                                ref agcObsRxMinGainIndex,
                                                ref agcObsRxSelect,
                                                ref agcPeakThresholdMode,
                                                ref agcLowThsPreventGainIncrease,
                                                ref agcGainUpdateCounter,
                                                ref agcSlowLoopSettlingDelay,
                                                ref agcPeakWaitTime,
                                                ref agcResetOnRxEnable,
                                                ref agcEnableSyncPulseForGainCounter);

            Link.Mykonos.init_obsRxPwrAgcStructure(1, ref pmdUpperHighThresh,
                                                   ref pmdUpperLowThresh,
                                                   ref pmdLowerHighThresh,
                                                   ref pmdLowerLowThresh,
                                                   ref pmdUpperHighGainStepAttack,
                                                   ref pmdUpperLowGainStepAttack,
                                                   ref pmdLowerHighGainStepRecovery,
                                                   ref pmdLowerLowGainStepRecovery, ref pmdMeasDuration,
                                                   ref pmdMeasConfig);

            Link.Mykonos.init_obsRxPeakAgcStructure(1, ref apdHighThresh,
                                                    ref apdLowThresh,
                                                    ref hb2HighThresh,
                                                    ref hb2LowThresh,
                                                    ref hb2VeryLowThresh,
                                                    ref apdHighThreshExceededCnt,
                                                    ref apdLowThreshExceededCnt,
                                                    ref hb2HighThreshExceededCnt,
                                                    ref hb2LowThreshExceededCnt,
                                                    ref hb2VeryLowThreshExceededCnt,
                                                    ref apdHighGainStepAttack,
                                                    ref apdLowGainStepRecovery,
                                                    ref hb2HighGainStepAttack,
                                                    ref hb2LowGainStepRecovery,
                                                    ref hb2VeryLowGainStepRecovery,
                                                    ref apdFastAttack,
                                                    ref hb2FastAttack,
                                                    ref hb2OverloadDetectEnable,
                                                    ref hb2OverloadDurationCnt,
                                                    ref hb2OverloadThreshCnt);


            Link.Mykonos.setupObsRxAgc();

            Link.Mykonos.radioOn();
            Link.Mykonos.setObsRxPathSource(channel);
            Console.WriteLine("gain before: " + Link.Mykonos.getObsRxGain());
            Console.WriteLine(Link.spiRead(0x448));
            //Link.spiWrite(0x448, 0x2);
            Link.Mykonos.setObsRxGainControlMode(Mykonos.GAINMODE.AGC);

            Console.WriteLine("gain after: " + Link.Mykonos.getObsRxGain());
            //Assert.Pass();


            SG_AgilentESG esg = new SG_AgilentESG(measEquipment.ESGAddress);

            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            profileInfo[0] = settings.rxProfileData.IqRate_kHz;
            profileInfo[1] = settings.rxPllLoFreq_Hz;
            profileInfo[2] = settings.rxProfileData.PrimarySigBw_Hz;

            double samplingFreq_Hz = profileInfo[0] * 1000;
            double profileBW_MHz   = profileInfo[2] / 1000000;

            Console.WriteLine("Rx Sampling Freq (Hz): " + samplingFreq_Hz);
            Console.WriteLine("Rx Profile Bandwdith (MHz): " + profileBW_MHz);
            double freqLo_kHz = profileInfo[1] / 1000;

            Console.WriteLine("Rx LO Frequency (kHz): " + freqLo_kHz);

            //Define Receiver Test Signal to be 10MHz Offset from LO frequency
            double testSigFreq_MHz = (freqLo_kHz / 1000 + 15);

            Console.WriteLine("Rx Test Signal Freq (MHz): " + testSigFreq_MHz);
            //Generate Test Signal for Rx Capture with ESG
            Console.WriteLine("ESG Info:" + esg.Identify());
            Console.WriteLine("ESG Address :" + measEquipment.ESGAddress);
            Console.WriteLine("ESG Generating Tone Freq:" + testSigFreq_MHz);
            esg.SetFrequency(testSigFreq_MHz);
            esg.SetRfOutput(true);

            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();
            double samplingFreq_MHz          = samplingFreq_Hz / 1000000;
            byte   sampleBitWidth            = 16;
            string response  = "";
            string initgain  = "";
            string finalgain = "";

            //Sweep from -20 to 10db
            for (int amplitude_dBm = -20; amplitude_dBm < 10; amplitude_dBm++)
            {
                esg.SetAmplitude(amplitude_dBm);
                System.Threading.Thread.Sleep(100);
                Link.Mykonos.getObsRxDecPower(ref power);

                short[]  rxDataArray = Helper.MykonosOrxCapture(channel, 16384);
                double[] data        = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                response = Link.Mykonos.getObsRxGain();
                spiData1 = Link.spiRead(0x4B6);
                Assert.AreEqual(spiData1 + 128, Int32.Parse(response), "Register Readback for Sniffer Gain not as expected");


                if (amplitude_dBm == -20)
                {
                    initgain = response;
                }
                Console.WriteLine("Gain: " + response + "DecPower: " + power + " FFT Power " + analysisData.FundamentalPower_dBFS + " at " + amplitude_dBm + "\n");
            }

            //Sweep from 10 to -20db

            for (int amplitude_dBm = 10; amplitude_dBm >= -20; amplitude_dBm--)
            {
                esg.SetAmplitude(amplitude_dBm);
                System.Threading.Thread.Sleep(100);
                Link.Mykonos.getObsRxDecPower(ref power);

                short[]  rxDataArray = Helper.MykonosOrxCapture(channel, 16384);
                double[] data        = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                response = Link.Mykonos.getObsRxGain();
                spiData1 = Link.spiRead(0x4B6);
                Assert.AreEqual(spiData1 + 128, Int32.Parse(response), "Register Readback for Sniffer Gain not as expected");


                if (amplitude_dBm == -20)
                {
                    finalgain = response;
                }
                Console.WriteLine("Gain: " + response + "DecPower: " + power + " FFT Power " + analysisData.FundamentalPower_dBFS + " at " + amplitude_dBm + "\n");
            }
            Assert.AreEqual(initgain, finalgain, "Initial gain is not equal to the final gain");
            Link.Disconnect();
        }
Пример #22
0
        public static void testsetTx1AttenCtrlPin()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte spiData1           = 0x0;
            int  spiData2           = 0x0;
            int  stepSize           = 0x1f;
            byte readstepSize       = 0;
            uint tx1AttenIncPin     = 0x1000;
            uint readtx1AttenIncPin = 0;
            uint tx1AttenDecPin     = 0x2000;
            uint readtx1AttenDecPin = 0;
            int  useTx1ForTx2       = 1;
            byte readuseTx1ForTx2   = 0;
            int  enable             = 1;
            byte readenable         = 0;
            int  tpcMode            = 0;
            int  tpcMaskTx2         = 0;



            Link.Mykonos.setTx1AttenCtrlPin((byte)stepSize, tx1AttenIncPin, tx1AttenDecPin, (byte)enable, (byte)useTx1ForTx2);
            int wrtPin = (0x00 | 0x04 | 0x01);


            tpcMode = (enable > 0) ? 0x03 : 0x01;
            if (useTx1ForTx2 > 0)
            {
                tpcMode   |= 0x1C;
                tpcMaskTx2 = 0x1F;
            }
            else
            {
                tpcMaskTx2 = 0x13;
            }

            if (enable == 0)
            {
                tpcMode    = 0x05;
                tpcMaskTx2 = 0x1F;
                wrtPin     = 0;
            }


            spiData2 = Link.spiRead(0x96D);
            spiData2 = (spiData2 & ~0x1F) | (stepSize & 0x1F);
            spiData1 = Link.spiRead(0x96D); Console.WriteLine("0x96D: " + spiData1.ToString("X"));
            Assert.AreEqual(spiData2, spiData1, "stepSize not as expected");

            spiData2 = Link.spiRead(0x96E);
            spiData2 = (spiData2 & ~tpcMaskTx2) | (tpcMode & tpcMaskTx2);
            spiData1 = Link.spiRead(0x96E); Console.WriteLine("0x96E: " + spiData1.ToString("X"));
            Assert.AreEqual(spiData2, spiData1, "tpcMode not as expected");

            spiData2 = Link.spiRead(0x96F);
            spiData2 = (spiData2 & ~0x0f) | (wrtPin & 0x0f);
            spiData1 = Link.spiRead(0x96F); Console.WriteLine("0x96F: " + spiData1.ToString("X"));
            Assert.AreEqual(spiData2, spiData1, "wrtPin not as expected");


            Link.Mykonos.getTx1AttenCtrlPin(ref readstepSize, ref readtx1AttenIncPin, ref readtx1AttenDecPin, ref readenable, ref readuseTx1ForTx2);
            Assert.AreEqual(stepSize, readstepSize, "stepSize is not the same");
            if (enable > 0)
            {
                Assert.AreEqual(tx1AttenIncPin, readtx1AttenIncPin, "tx1AttenIncPin is not the same");
                Assert.AreEqual(tx1AttenDecPin, readtx1AttenDecPin, "tx1AttenDecPin is not the same");
                if (useTx1ForTx2 > 0)
                {
                    Assert.Greater(readuseTx1ForTx2, 0, "useTx1ForTx2 is not the same");
                }
                else
                {
                    Assert.AreEqual(readuseTx1ForTx2, 0, "useTx1ForTx2 is not the same");
                }
            }
            Assert.AreEqual(enable, readenable, "enable is not the same");

            Link.Mykonos.setTx1AttenCtrlPin((byte)stepSize, tx1AttenIncPin, tx1AttenDecPin, (byte)0, (byte)useTx1ForTx2);
            Link.Mykonos.getTx1AttenCtrlPin(ref readstepSize, ref readtx1AttenIncPin, ref readtx1AttenDecPin, ref readenable, ref readuseTx1ForTx2);
            Assert.AreEqual(0, readenable, "enable is not 0");

            Link.Disconnect();
        }
Пример #23
0
        public static void testsetTx2AttenCtrlPin()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte spiData1           = 0x0;
            int  spiData2           = 0x0;
            int  stepSize           = 0x1f;
            byte readstepSize       = 0;
            uint tx1AttenIncPin     = 0x4000;
            uint readtx1AttenIncPin = 0;
            uint tx1AttenDecPin     = 0x8000;
            uint readtx1AttenDecPin = 0;
            byte useTx1ForTx2       = 1;
            int  enable             = 1;
            byte readenable         = 0;
            int  tcpmode            = 0;
            byte readuseTx1ForTx2   = 0;



            Link.Mykonos.setTx2AttenCtrlPin((byte)stepSize, tx1AttenIncPin, tx1AttenDecPin, (byte)enable);
            int wrtPin = (0x00 | 0x40 | 0x10);


            tcpmode = (enable > 0) ? 0x0C : 0x01;
            //tcpmode |= (useTx1ForTx2 > 0) ? 0x10 : 0x00;


            if (enable == 0)
            {
                tcpmode = 0x05;
                wrtPin  = 0;
            }
            spiData2 = Link.spiRead(0x96D);
            spiData2 = (spiData2 & ~0x1F) | (stepSize & 0x1F);
            spiData1 = Link.spiRead(0x96D); Console.WriteLine("0x96D: " + spiData1.ToString("X"));
            Assert.AreEqual(spiData2, spiData1, "stepSize not as expected");

            spiData2 = Link.spiRead(0x96E);
            spiData2 = (spiData2 & ~0x1C) | (tcpmode & 0x1C);
            spiData1 = Link.spiRead(0x96E); Console.WriteLine("0x96E: " + spiData1.ToString("X"));
            Assert.AreEqual(spiData2, spiData1, "tcpmode not as expected");

            spiData2 = Link.spiRead(0x96F);
            spiData2 = (spiData2 & ~0xf0) | (wrtPin & 0xf0);
            spiData1 = Link.spiRead(0x96F); Console.WriteLine("0x96F: " + spiData1.ToString("X"));
            Assert.AreEqual(spiData2, spiData1, "wrtPin not as expected");

            Link.Mykonos.getTx2AttenCtrlPin(ref readstepSize, ref readtx1AttenIncPin, ref readtx1AttenDecPin, ref readenable, ref useTx1ForTx2);
            Assert.AreEqual(stepSize, readstepSize, "stepSize is not the same");
            if (enable > 0)
            {
                Assert.AreEqual(tx1AttenIncPin, readtx1AttenIncPin, "tx2AttenIncPin is not the same");
                Assert.AreEqual(tx1AttenDecPin, readtx1AttenDecPin, "tx2AttenDecPin is not the same");
            }
            Assert.AreEqual(enable, readenable, "enable is not the same");


            Link.Mykonos.setTx2AttenCtrlPin((byte)stepSize, tx1AttenIncPin, tx1AttenDecPin, (byte)0);
            Link.Mykonos.getTx2AttenCtrlPin(ref readstepSize, ref readtx1AttenIncPin, ref readtx1AttenDecPin, ref readenable, ref readuseTx1ForTx2);
            Assert.AreEqual(0, readenable, "enable is not 0");

            Link.Disconnect();
        }
Пример #24
0
        public static void testSetupGpio()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte spiData1 = 0x0;
            byte spiData2 = 0x0;
            uint gpioOe   = 0x0;
            int  shift    = 0;
            uint usedMask = 0x7FFFF;

            // foreach (Mykonos.OBSRXCHANNEL channel in Enum.GetValues(typeof(Mykonos.OBSRXCHANNEL)))
            foreach (Mykonos.GPIO_MODE gpioMode3_0 in Enum.GetValues(typeof(Mykonos.GPIO_MODE)))
            {
                foreach (Mykonos.GPIO_MODE gpioMode7_4 in Enum.GetValues(typeof(Mykonos.GPIO_MODE)))
                {
                    foreach (Mykonos.GPIO_MODE gpioMode11_8 in Enum.GetValues(typeof(Mykonos.GPIO_MODE)))
                    {
                        foreach (Mykonos.GPIO_MODE gpioMode15_12 in Enum.GetValues(typeof(Mykonos.GPIO_MODE)))
                        {
                            foreach (Mykonos.GPIO_MODE gpioMode18_16 in new Mykonos.GPIO_MODE[] { Mykonos.GPIO_MODE.GPIO_MONITOR_MODE, Mykonos.GPIO_MODE.GPIO_BITBANG_MODE })
                            {
                                for (gpioOe = 0; gpioOe <= 0x7FFFF; gpioOe = gpioOe + 0x7FFFF)
                                {
                                    uint srcWrite = (uint)gpioMode3_0 + ((uint)gpioMode7_4 << 4) + ((uint)gpioMode11_8 << 8) + ((uint)gpioMode15_12 << 12) + ((uint)gpioMode18_16 << 16);
                                    //Console.WriteLine("srcWrite: " + srcWrite);

                                    //gpioOe = (uint)(0x01 << shift);
                                    Link.Mykonos.setupGpio(gpioOe, gpioMode3_0, gpioMode7_4, gpioMode11_8, gpioMode15_12, gpioMode18_16);

                                    //Check GPIO direction control bit
                                    spiData2 = Link.spiRead(0xB20);
                                    spiData2 = (byte)((spiData2 & ~(usedMask & 0xFF)) | ((gpioOe & 0xFF) & (usedMask & 0xFF)));
                                    spiData1 = Link.spiRead(0xB20); Console.WriteLine("0xB20: " + spiData1.ToString("X"));
                                    Assert.AreEqual(spiData2, spiData1, "GPIO direction control bit 7-0 not as expected");

                                    spiData2 = Link.spiRead(0xB21);
                                    spiData2 = (byte)((spiData2 & ~((usedMask >> 8) & 0xFF)) | (((gpioOe >> 8) & 0xFF) & ((usedMask >> 8) & 0xFF)));
                                    spiData1 = Link.spiRead(0xB21); Console.WriteLine("0xB21: " + spiData1.ToString("X"));
                                    Assert.AreEqual(spiData2, spiData1, "GPIO direction control bit 15-8 not as expected");

                                    spiData2 = Link.spiRead(0xB22);
                                    spiData2 = (byte)((spiData2 & ~((usedMask >> 16) & 0xFF)) | (((gpioOe >> 16) & 0xFF) & ((usedMask >> 16) & 0xFF)));
                                    spiData1 = Link.spiRead(0xB22); Console.WriteLine("0xB22: " + spiData1.ToString("X"));
                                    Assert.AreEqual(spiData2, spiData1, "GPIO direction control bit 18-16 not as expected");


                                    //Check GPIO
                                    spiData1 = Link.spiRead(0xB29); Console.WriteLine("0xB29: " + spiData1.ToString("X"));
                                    Assert.AreEqual((srcWrite & 0xFF), spiData1, "GPIO Lower byte not as expected");

                                    spiData1 = Link.spiRead(0xB2A); Console.WriteLine("0xB2A: " + spiData1.ToString("X"));
                                    Assert.AreEqual(((srcWrite >> 8) & 0xFF), spiData1, "GPIO Upper byte not as expected");

                                    spiData1 = Link.spiRead(0xB2B); Console.WriteLine("0xB2B: " + spiData1.ToString("X"));
                                    Assert.AreEqual(((srcWrite >> 16) & 0x07), spiData1, "GPIO Extra bits not as expected");
                                }
                            }
                        }
                    }
                }
            }
            Link.Disconnect();
        }
Пример #25
0
        public static void TxPassbandSweepTxNCO([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel, [Values(2500, 2500)] double deltaF_kHz)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;

            double spanMhz;
            int    numSteps = 0;

            double txIqDataRate_MHz     = 0;
            double freqTxLo_MHz         = 0;
            double profileBandwidth_MHz = 0;
            double toneOffsetFreq_Mhz   = 0;
            double offsetFreq_Hz        = 0;
            double testRfFreq_MHz       = 0;


            try
            {
                //Enable the Transmitter Path
                Link.Mykonos.radioOn();
                //Profile Information
                txIqDataRate_MHz     = (double)(settings.txProfileData.IqRate_kHz) / 1000;
                freqTxLo_MHz         = (double)(settings.txPllLoFreq_Hz) / 1000000;
                profileBandwidth_MHz = (double)settings.txProfileData.PrimarySigBw_Hz;

                numSteps = (int)(txIqDataRate_MHz / (deltaF_kHz / 1000.0));
                spanMhz  = txIqDataRate_MHz;
                //Define Data Array for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
                double[,] fundAmpXY   = new double[numSteps, 2];
                double[,] loLeakageXY = new double[numSteps, 2];
                double[,] imageAmpXY  = new double[numSteps, 2];

                pxa.SysPreset();
                pxa.SetRBW_VBW(30, 30);
                pxa.SetCenterSpan(freqTxLo_MHz, 200, 0);
                pxa.SetAtten(20);
                pxa.SetMarker(2, freqTxLo_MHz);  //LO leakage marker

                double peakAmp_dBm  = 0;
                double peakFreq_Mhz = 0;
                double deltaF       = txIqDataRate_MHz / numSteps;

                double fundAmp   = 0;
                double loLeakage = 0;
                double imageAmp  = 0;
                Console.Write(numSteps + 1);
                for (int i = 0; (i < numSteps); i++)
                {
                    toneOffsetFreq_Mhz = (-0.5 * txIqDataRate_MHz) + ((deltaF_kHz / 1000.0) * i);

                    offsetFreq_Hz  = toneOffsetFreq_Mhz * 1000000;
                    testRfFreq_MHz = freqTxLo_MHz + offsetFreq_Hz / 1000000;

                    Link.Mykonos.enableTxNco(1, (int)(toneOffsetFreq_Mhz * 1000), (int)(toneOffsetFreq_Mhz * 1000));

                    System.Threading.Thread.Sleep(500);
                    //pxa.HoldAverage(10);
                    pxa.MeasPeakPower(ref peakAmp_dBm, ref peakFreq_Mhz);

                    //Set PXA Markers
                    /* for this to work, NCO freq set must be rastered to its actual frequency in the chip */
                    //pxa.SetMarker(3, freqTxLo_MHz - (freqTxLo_MHz - peakFreq_Mhz)); //Image marker
                    //pxa.SetMarker(1, testRfFreq_MHz); //Fundamental amplitue marker

                    //fundAmp = Double.Parse(pxa.GetMarker(1), style);
                    //loLeakage = Double.Parse(pxa.GetMarker(2), style);
                    //imageAmp = Double.Parse(pxa.GetMarker(3), style);

                    //TODO: Marker 3 does not always sit on the image, sometimes its off a bin or so and measures incorrectly.
                    pxa.SetMarker(3, (freqTxLo_MHz - ((peakFreq_Mhz / 1000000.0) - freqTxLo_MHz)));  //Image marker

                    fundAmp   = peakAmp_dBm;
                    loLeakage = Double.Parse(pxa.GetMarker(2), style);
                    imageAmp  = Double.Parse(pxa.GetMarker(3), style);

                    fundAmpXY[i, 0] = toneOffsetFreq_Mhz;
                    fundAmpXY[i, 1] = fundAmp;

                    loLeakageXY[i, 0] = toneOffsetFreq_Mhz;
                    loLeakageXY[i, 1] = loLeakage;

                    imageAmpXY[i, 0] = toneOffsetFreq_Mhz;
                    imageAmpXY[i, 1] = imageAmp;
                    if ((toneOffsetFreq_Mhz > -1) && (toneOffsetFreq_Mhz < 1))
                    {
                        Console.WriteLine("Bypass:"******"Fundamental Amplitude (dBm)" + i + ": " + toneOffsetFreq_Mhz + ": " + fundAmp);
                    Console.WriteLine("LO Leakage (dBm)" + toneOffsetFreq_Mhz + ": " + loLeakage);
                    Console.WriteLine("Image Amplitude (dBm)" + toneOffsetFreq_Mhz + ": " + imageAmp);
                    Console.WriteLine("Image Amplitude (dBc)" + toneOffsetFreq_Mhz + ": " + (fundAmp - imageAmp));
#endif
                }
                Link.Disconnect();
                //Graph Data and Save in PDF Form
                var      doc1 = new Document();
                string   path = TxRfTests.ResPath + "TxPassbandSweepTxNco";
                string[] pcbInfo;
                iTextSharp.text.Image[] container = new iTextSharp.text.Image[3];
                string[] fundAmpLabels            = new string[] { "Fundamental Amplitude Versus Offset Tone Frequency (from LO)",
                                                                   "Offset Tone Frequency (MHz)",
                                                                   "Amplitude (dBm)",
                                                                   "Trace Amplitude" };
                string[] loLeakageLabels = new string[] { "LO Leakage Versus Offset Tone Frequency",
                                                          "Offset Tone Frequency (MHz)",
                                                          "Amplitude (dBm)",
                                                          "Trace Amplitude" };
                string[] imageAmpLabels = new string[] { "Image Amplitude Versus Offset Tone Frequency",
                                                         "Offset Tone Frequency (MHz)",
                                                         "Amplitude (dBm)",
                                                         "Trace Amplitude" };

                pcbInfo = Helper.PcbInfo();
                Console.Write(fundAmpXY[48, 0]);
                container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
                container[1] = Helper.MakeChartObject(loLeakageXY, loLeakageLabels, path);
                container[2] = Helper.MakeChartObject(imageAmpXY, imageAmpLabels, path);
                Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

                //Open Result PDF
                System.Diagnostics.Process.Start(path + ".pdf");

                //Check Min Max Fund Amplitudes are within +/-0.5db of each other.
                var MinFundAmp = System.Linq.Enumerable.Range(15, 30).Select(i => fundAmpXY[i, 1]).Min();
                var MaxFundAmp = System.Linq.Enumerable.Range(15, 30).Select(i => fundAmpXY[i, 1]).Max();
                Console.WriteLine("MinFundAmp: " + MinFundAmp);
                Console.WriteLine("MaxFundAmp: " + MaxFundAmp);
                Console.WriteLine("MaxDiffFundAmp: " + (MaxFundAmp - MinFundAmp));
                NUnit.Framework.Assert.IsTrue((MaxFundAmp - MinFundAmp) < 1.0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Пример #26
0
        public static void TxAttenuationSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)
        {
            int atten   = 0;
            int backoff = 0;

            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            profileInfo[0] = settings.txProfileData.IqRate_kHz;
            profileInfo[1] = settings.txPllLoFreq_Hz;
            profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;

            double txIqDataRate_kHz     = profileInfo[0];
            double profileBandwidth_MHz = profileInfo[2] / 1000000;

            Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz);
            Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz);
            double freqTxLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz);

            //Configure Tone Generator
            //10MHz offset tone generation
            double offsetFreq_Hz = 10000000;

            double[,] fundAmpXY = new double[42, 2];
            Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

            //Connect to Signal Analyser
            //The span is fixed to 50MHz
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 50, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(1, freqTxLo_MHz + 10);                        //Fundemental Amplitued Marker
            pxa.SetMarker(2, freqTxLo_MHz);                             //LO Leakage Marker
            pxa.SetMarker(3, freqTxLo_MHz - (offsetFreq_Hz / 1000000)); //Image Amplitude marker

            //Config and Enable Mykonos with Test Specific Settings
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.radioOn();

            //Test Sequence
            //Iterate Thru Tx Attenuation Settings
            //Measure Amplitude of the fundamental
            //TODO: 0 to 41950
            int    step          = 0;
            double fundAmp_dB    = 0;
            double minAttnVal_dB = 0;
            double maxAttnVal_dB = 41.95;

            for (double attenVal_dB = minAttnVal_dB; (attenVal_dB < maxAttnVal_dB); attenVal_dB += 1)
            {
                try
                {
                    if (channel == Mykonos.TXCHANNEL.TX1)
                    {
                        Link.Mykonos.setTx1Attenuation(attenVal_dB);
                    }
                    if (channel == Mykonos.TXCHANNEL.TX2)
                    {
                        Link.Mykonos.setTx2Attenuation(attenVal_dB);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    break;
                }

                pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);

                fundAmp_dB         = Double.Parse(pxa.GetMarker(1), style);
                fundAmpXY[step, 1] = fundAmp_dB;
                fundAmpXY[step, 0] = attenVal_dB;
                step++;
#if WR_RES_TO_CONSOLE
                Console.WriteLine("Fundamental Amplitude, Attenuation Value " + attenVal_dB + ": " + fundAmp_dB);
#endif
            }
            Link.Disconnect();
#if WR_RES_TO_PDF
            //Graph Data and Save in PDF Form
            var      doc1 = new Document();
            string   path = TxRfTests.ResPath + "TxAttenuationSweep";
            string[] pcbInfo;
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[1];
            string[] fundAmpLabels            = new string[] { "Fundamental Amplitude Versus Offset Tone Frequency (from LO)",
                                                               "setTxAtten Argument",
                                                               "Amplitude (dBm)",
                                                               "Trace Amplitude" };

            pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, backoff.ToString(), atten.ToString());

            container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
            TxRfTests instance = new TxRfTests();
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
        }
Пример #27
0
        public static void TxPassbandSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)

        {
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            int      atten       = 0;
            int      backoff     = 0;

            profileInfo[0] = settings.txProfileData.IqRate_kHz;
            profileInfo[1] = settings.txPllLoFreq_Hz;
            profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;

            double txIqDataRate_kHz     = profileInfo[0];
            double profileBandwidth_MHz = profileInfo[2] / 1000000;

            Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz);
            Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz);
            double freqTxLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz);

            //Define Test Parameters Based on Profile Info & Lo Frequency
            double         SwpMinFreq  = freqTxLo_MHz - (1.1 * (profileBandwidth_MHz / 2));
            double         SwpMaxFreq  = freqTxLo_MHz + (1.1 * (profileBandwidth_MHz / 2));
            double         SwpSigAmp   = -40;
            int            SwpNumSteps = 50;
            SwpParamStruct param       = new SwpParamStruct(SwpMinFreq, SwpMaxFreq, SwpSigAmp, SwpNumSteps);
            double         SwpStepSz   = (param.freqMax - param.freqMin) / param.numSteps;

            Console.WriteLine("SwpMinFreq (MHz): " + SwpMinFreq);
            Console.WriteLine("SwpMaxMax (MHz): " + SwpMaxFreq);
            Console.WriteLine("SwpSigAmp (MHz): " + SwpSigAmp);

            //Define Data Array for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
            double[,] fundAmpXY   = new double[param.numSteps + 1, 2];
            double[,] loLeakageXY = new double[param.numSteps + 1, 2];
            double[,] imageAmpXY  = new double[param.numSteps + 1, 2];

            //Connect to Signal Analyser
            //The span is fixed to 100MHz
            //Set Marker 2 as LO leakage marker
            //Note: this may need to be set depending on profile.
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 200, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(2, freqTxLo_MHz);

            //Config and Enable Mykonos with Test Specific Settings
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

#if WR_RES_TO_CONSOLE
            Console.WriteLine(" OffSet Frequency input (MHz):" +
                              "Fundamental Amplitude (dBm), " +
                              "LO Leakage (dBm)," +
                              "Image Amplitude (dBm),");
#endif
            //Test Sequence
            //Sweep Thru Passband
            for (int i = 0; (i <= param.numSteps); i++)
            {
                //Calculate Test Tone And Generate
                double offsetFreq_Mhz = param.freqMin + (i * SwpStepSz) - (freqTxLo_MHz);
                double testFreq_MHz = freqTxLo_MHz + offsetFreq_Mhz;
                double fundAmp, loLeakage, imageAmp;
                double offsetFreq_Hz = offsetFreq_Mhz * 1000000;

                if (offsetFreq_Hz == 0)
                {
                    fundAmpXY[i, 0] = offsetFreq_Mhz;
                    fundAmpXY[i, 1] = fundAmpXY[i - 1, 1];

                    loLeakageXY[i, 0] = offsetFreq_Mhz;
                    loLeakageXY[i, 1] = loLeakageXY[i - 1, 1];

                    imageAmpXY[i, 0] = offsetFreq_Mhz;
                    imageAmpXY[i, 1] = imageAmpXY[i - 1, 1];
                    continue;
                }
                Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);
                //Take Measurements from PXA

                pxa.SetMarker(3, freqTxLo_MHz - (offsetFreq_Hz / 1000000)); //Image marker
                pxa.SetMarker(1, testFreq_MHz);                             //Fundamental amplitue marker
                //pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);
                fundAmp   = Double.Parse(pxa.GetMarker(1), style);
                loLeakage = Double.Parse(pxa.GetMarker(2), style);
                imageAmp  = Double.Parse(pxa.GetMarker(3), style);

                fundAmpXY[i, 0] = offsetFreq_Mhz;
                fundAmpXY[i, 1] = fundAmp;

                loLeakageXY[i, 0] = offsetFreq_Mhz;
                loLeakageXY[i, 1] = loLeakage;

                imageAmpXY[i, 0] = offsetFreq_Mhz;
                imageAmpXY[i, 1] = imageAmp;



#if WR_RES_TO_CONSOLE //Optional printout for text based readout in test output window
                Console.WriteLine(offsetFreq_Mhz + ":   " + fundAmp + ",   " + loLeakage + ",   " + imageAmp + ",   " + (fundAmp - imageAmp) + ",   ");
#endif
            }

#if WR_RES_TO_PDF
            //Graph Data and Save in PDF Form
            var       doc1     = new Document();
            string    path     = TxRfTests.ResPath + "TxPassbandSweep";
            TxRfTests instance = new TxRfTests();
            string[]  pcbInfo;
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[3];
            string[] fundAmpLabels            = new string[] { "Fundamental Amplitude Versus Offset Tone Frequency (from LO)",
                                                               "Offset Tone Frequency (MHz)",
                                                               "Amplitude (dBm)",
                                                               "Trace Amplitude" };
            string[] loLeakageLabels = new string[] { "LO Leakage Versus Offset Tone Frequency",
                                                      "Offset Tone Frequency (MHz)",
                                                      "Amplitude (dBm)",
                                                      "Trace Amplitude" };
            string[] imageAmpLabels = new string[] { "Image Amplitude Versus Offset Tone Frequency",
                                                     "Offset Tone Frequency (MHz)",
                                                     "Amplitude (dBm)",
                                                     "Trace Amplitude" };
            pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, backoff.ToString(), atten.ToString());

            // pcbInfo = Helper.PcbInfo();
            container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
            container[1] = Helper.MakeChartObject(loLeakageXY, loLeakageLabels, path);
            container[2] = Helper.MakeChartObject(imageAmpXY, imageAmpLabels, path);
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
#if WR_RES_TO_TXT
            // Write data to txt file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + ".txt"))
            {
                file.WriteLine("Sample,  Frequency MHz, Fundamental Power(dBm),  LOL(dBFS), Image Power(dBFS),");
                for (int i = 0; i < param.numSteps; i++)
                {
                    file.WriteLine(i + "," + fundAmpXY[i, 0].ToString() + "," + fundAmpXY[i, 1].ToString() + "," + loLeakageXY[i, 1].ToString() + "," + imageAmpXY[i, 1].ToString());
                }
            }
#endif

            //Check Min Max Fund Amplitudes are within 0.5db of each other.
            var MinFundAmp = System.Linq.Enumerable.Range(0, param.numSteps).Select(i => fundAmpXY[i, 1]).Min();
            var MaxFundAmp = System.Linq.Enumerable.Range(0, param.numSteps).Select(i => fundAmpXY[i, 1]).Max();
            Console.WriteLine("MinFundAmp: " + MinFundAmp);
            Console.WriteLine("MaxFundAmp: " + MaxFundAmp);
            Console.WriteLine("MaxDiffFundAmp: " + (MaxFundAmp - MinFundAmp));
            NUnit.Framework.Assert.IsTrue((MaxFundAmp - MinFundAmp) < 1.0);
        }
Пример #28
0
        public static void CheckGetInitCalStatus()
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            //Link.Mykonos.setObsRxPathSource(Mykonos.OBSRXCHANNEL.OBS_INTERNALCALS);
            UInt32           calmask     = 0;
            byte             spiData1    = 0x0;
            MykInitCalStatus initcalstat = new MykInitCalStatus();
            //Test Setup:
            //Run Init Cals without TX_LO_LEAKAGE_INTERNAL
            UInt32 calMask = (UInt32)(Mykonos.CALMASK.TX_BB_FILTER) |
                             (UInt32)(Mykonos.CALMASK.ADC_TUNER) |
                             (UInt32)(Mykonos.CALMASK.TIA_3DB_CORNER) |
                             (UInt32)(Mykonos.CALMASK.DC_OFFSET) |
                             (UInt32)(Mykonos.CALMASK.FLASH_CAL) |
                             (UInt32)(Mykonos.CALMASK.PATH_DELAY) |
                             (UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL) |
                             (UInt32)(Mykonos.CALMASK.TX_QEC_INIT) |
                             (UInt32)(Mykonos.CALMASK.LOOPBACK_RX_LO_DELAY) |
                             (UInt32)(Mykonos.CALMASK.LOOPBACK_RX_RX_QEC_INIT) |
                             //(UInt32)(Mykonos.CALMASK.RX_LO_DELAY) |
                             (UInt32)(Mykonos.CALMASK.RX_QEC_INIT);

            settings.calMask = calMask;
            TestSetup.MykonosInitCals(settings);
            System.Threading.Thread.Sleep(5000);
            Link.Mykonos.getPendingTrackingCals(ref calmask);
            Console.WriteLine("calmask: " + calmask);
            spiData1 = Link.spiRead(0xD40);
            Console.WriteLine("SPI Addr: 0xD40:" + spiData1.ToString("X"));
            Assert.AreEqual(0x2, (spiData1 & 0x3),
                            "Myk: Test Setup Failed  Init Cals not completed");


            //Readback the init cal status
            Link.Mykonos.getInitCalStatus(out initcalstat);
            Assert.AreEqual(initcalstat.CalsDoneLastRun, settings.calMask, "Cals done last run not as expected");
            Assert.AreEqual(initcalstat.CalsDoneLifeTime, settings.calMask, "Cals done lifetime not as expected");

            byte[] armData = new byte[14];
            Link.Mykonos.sendArmCommand(GetCmd, new byte[] { IntCalsDoneObjId }, 1);
            Link.Mykonos.readArmMem(0x20000000, 14, 1, ref armData);


            Assert.AreEqual(initcalstat.CalsDoneLifeTime, ((UInt32)(((UInt32)(armData[3]) << 24) | ((UInt32)(armData[2]) << 16) | ((UInt32)(armData[1]) << 8) | ((UInt32)(armData[0])))), "Init done last run readback not as expected");
            Assert.AreEqual(initcalstat.CalsDoneLastRun, ((UInt32)(((UInt32)(armData[7]) << 24) | ((UInt32)(armData[6]) << 16) | ((UInt32)(armData[5]) << 8) | ((UInt32)(armData[4])))), "Init done lifetime readback not as expected");
            Assert.AreEqual(initcalstat.CalsMinimum, ((UInt32)(((UInt32)(armData[11]) << 24) | ((UInt32)(armData[10]) << 16) | ((UInt32)(armData[9]) << 8) | ((UInt32)(armData[8])))), "Min cal readback not as expected");
            Assert.AreEqual(initcalstat.InitErrCal, (UInt32)(armData[12]), "Init Error cal readback not as expected");
            Assert.AreEqual(initcalstat.InitErrCode, (UInt32)(armData[13]), "Init Error code readback not as expected");

            //Run init cals with TX_LO_LEAKAGE_INTERNAL
            Link.Mykonos.runInitCals((UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL));


            System.Threading.Thread.Sleep(5000);

            //Readback the init cals. Last run should only have TX_LO_LEAKAGE_INTERNAL
            Link.Mykonos.getInitCalStatus(out initcalstat);
            Assert.AreEqual(initcalstat.CalsDoneLastRun, (UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL), "Cals done last run not as expected");
            Assert.AreEqual(initcalstat.CalsDoneLifeTime, settings.calMask | (UInt32)(Mykonos.CALMASK.TX_LO_LEAKAGE_INTERNAL), "Cals done lifetime not as expected");

            Link.Mykonos.sendArmCommand(GetCmd, new byte[] { IntCalsDoneObjId }, 1);
            Link.Mykonos.readArmMem(0x20000000, 14, 1, ref armData);


            Assert.AreEqual(initcalstat.CalsDoneLifeTime, ((UInt32)(((UInt32)(armData[3]) << 24) | ((UInt32)(armData[2]) << 16) | ((UInt32)(armData[1]) << 8) | ((UInt32)(armData[0])))), "Init done last run readback not as expected");
            Assert.AreEqual(initcalstat.CalsDoneLastRun, ((UInt32)(((UInt32)(armData[7]) << 24) | ((UInt32)(armData[6]) << 16) | ((UInt32)(armData[5]) << 8) | ((UInt32)(armData[4])))), "Init done lifetime readback not as expected");
            Assert.AreEqual(initcalstat.CalsMinimum, ((UInt32)(((UInt32)(armData[11]) << 24) | ((UInt32)(armData[10]) << 16) | ((UInt32)(armData[9]) << 8) | ((UInt32)(armData[8])))), "Min cal readback not as expected");
            Assert.AreEqual(initcalstat.InitErrCal, (UInt32)(armData[12]), "Init Error cal readback not as expected");
            Assert.AreEqual(initcalstat.InitErrCode, (UInt32)(armData[13]), "Init Error code readback not as expected");
            Link.Disconnect();
        }
Пример #29
0
        public static void QECHarmonicSweep([Values(Mykonos.TXCHANNEL.TX1, Mykonos.TXCHANNEL.TX2)] Mykonos.TXCHANNEL channel)
        {
            InitCalSweepTests obj = new InitCalSweepTests();

            obj.QECTestsInit();
            //Retrieve Profile Information, samplingFreq_Hz,  ProfileBW, LO Frequency Information
            double[] profileInfo = new double[3];
            double   backoff     = -15;
            int      atten       = 0;

            profileInfo[0] = settings.txProfileData.IqRate_kHz;
            profileInfo[1] = settings.txPllLoFreq_Hz;
            profileInfo[2] = settings.txProfileData.PrimarySigBw_Hz;

            double txIqDataRate_kHz     = profileInfo[0];
            double profileBandwidth_MHz = profileInfo[2] / 1000000;

            Console.WriteLine("IQ Data Rate (kHz): " + txIqDataRate_kHz);
            Console.WriteLine("Profile Bandwdith (MHz): " + profileBandwidth_MHz);
            double freqTxLo_MHz = profileInfo[1] / 1000000;

            Console.WriteLine("Tx LO Frequency (MHz): " + freqTxLo_MHz);

            //Define Test Parameters Based on Profile Info & Lo Frequency
            double         SwpMinFreq  = freqTxLo_MHz - (2 * (profileBandwidth_MHz / 2));
            double         SwpMaxFreq  = freqTxLo_MHz + (2 * (profileBandwidth_MHz / 2));
            double         SwpSigAmp   = -40;
            int            SwpNumSteps = 200;
            SwpParamStruct param       = new SwpParamStruct(SwpMinFreq, SwpMaxFreq, SwpSigAmp, SwpNumSteps);
            double         SwpStepSz   = (param.freqMax - param.freqMin) / param.numSteps;

            Console.WriteLine("SwpMinFreq (MHz): " + SwpMinFreq);
            Console.WriteLine("SwpMaxMax (MHz): " + SwpMaxFreq);
            Console.WriteLine("SwpSigAmp (MHz): " + SwpSigAmp);

            //Define Data Array for storing Fundamental Amplitue, LoLeakage and ImageAmplitude
            //double[,] fundAmpXY = new double[param.numSteps, 2];
            double[,] harmonicAmpnoCal = new double[param.numSteps + 1, 4];
            double[,] harmonicAmpCal   = new double[param.numSteps + 1, 4];

            double[,] loLeakageXYcal = new double[param.numSteps + 1, 2];
            double[,] loLeakageXYdif = new double[param.numSteps + 1, 2];

            //double[,] imageAmpXY = new double[param.numSteps, 2];

            //Connect to Signal Generator
            //The span is fixed to 100MHz
            //Set Marker 2 as LO leakage marker
            //Note: this may need to be set depending on profile.
            NumberStyles  style = NumberStyles.AllowExponent | NumberStyles.Number;
            SA_AgilentPXA pxa   = new SA_AgilentPXA(measEquipment.PXAAddress);

            pxa.SetCenterSpan(freqTxLo_MHz, 200, 0);
            pxa.SetAtten(20);
            pxa.SetRefLevel(10);
            pxa.SetMarker(2, freqTxLo_MHz);


            //Config and Enable Mykonos with Test Specific Settings
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

#if WR_RES_TO_CONSOLE
            Console.WriteLine(" OffSet Frequency input (MHz):" +
                              "Image Amplitude (dBm)");
#endif
            //Test Sequence
            //Sweep Thru Passband
            for (int i = 0; (i <= param.numSteps); i++)
            {
                //Calculate Test Tone And Generate
                double offsetFreq_Mhz = param.freqMin + (i * SwpStepSz) - (freqTxLo_MHz);
                double testFreq_MHz   = freqTxLo_MHz + offsetFreq_Mhz;
                double harmonicAmp;
                double offsetFreq_Hz = offsetFreq_Mhz * 1000000;

                if (offsetFreq_Hz == 0)
                {
                    harmonicAmpnoCal[i, 0] = offsetFreq_Mhz;
                    harmonicAmpnoCal[i, 1] = harmonicAmpnoCal[i - 1, 1];
                    harmonicAmpnoCal[i, 2] = harmonicAmpnoCal[i - 1, 2];
                    harmonicAmpnoCal[i, 3] = harmonicAmpnoCal[i - 1, 3];

                    continue;
                }
                Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);
                //Take Measurements from PXA

                pxa.SetMarker(1, freqTxLo_MHz + (offsetFreq_Hz / 1000000));
                pxa.SetMarker(2, freqTxLo_MHz + 2 * (offsetFreq_Hz / 1000000));
                pxa.SetMarker(3, freqTxLo_MHz + 3 * (offsetFreq_Hz / 1000000));
                //pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);
                harmonicAmpnoCal[i, 0] = offsetFreq_Mhz;
                harmonicAmp            = Double.Parse(pxa.GetMarker(1), style);
                harmonicAmpnoCal[i, 1] = harmonicAmp;
                harmonicAmp            = Double.Parse(pxa.GetMarker(2), style);
                harmonicAmpnoCal[i, 2] = harmonicAmp;
                harmonicAmp            = Double.Parse(pxa.GetMarker(3), style);
                harmonicAmpnoCal[i, 3] = harmonicAmp;

#if WR_RES_TO_CONSOLE //Optional printout for text based readout in test output window
                Console.WriteLine(offsetFreq_Mhz + ":   " + harmonicAmp + ",   ");
#endif
            }


            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.radioOff();
            Link.Disconnect();


            obj.AllCalsInit();
            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            Link.Mykonos.setTx1Attenuation(0);
            Link.Mykonos.radioOn();
            Link.Disconnect();

            for (int i = 0; (i <= param.numSteps); i++)
            {
                //Calculate Test Tone And Generate
                double offsetFreq_Mhz = param.freqMin + (i * SwpStepSz) - (freqTxLo_MHz);
                double testFreq_MHz   = freqTxLo_MHz + offsetFreq_Mhz;
                double offsetFreq_Hz  = offsetFreq_Mhz * 1000000;
                double harmonicAmp;

                if (offsetFreq_Hz == 0)
                {
                    harmonicAmpCal[i, 0] = offsetFreq_Mhz;
                    harmonicAmpCal[i, 1] = harmonicAmpCal[i - 1, 1];
                    harmonicAmpCal[i, 2] = harmonicAmpCal[i - 1, 2];
                    harmonicAmpCal[i, 3] = harmonicAmpCal[i - 1, 3];
                    //loLeakageXY[i, 3] = loLeakageXY[i, 1] - loLeakageXY[i, 2];

                    continue;
                }
                Helper.GenerateTxTone(Mykonos.TXCHANNEL.TX1_TX2, profileInfo, offsetFreq_Hz, backoff);

                pxa.SetMarker(1, freqTxLo_MHz + (offsetFreq_Hz / 1000000));
                pxa.SetMarker(2, freqTxLo_MHz + 2 * (offsetFreq_Hz / 1000000));
                pxa.SetMarker(3, freqTxLo_MHz + 3 * (offsetFreq_Hz / 1000000));
                //pxa.HoldAverage();
                System.Threading.Thread.Sleep(500);
                harmonicAmpCal[i, 0] = offsetFreq_Mhz;
                harmonicAmp          = Double.Parse(pxa.GetMarker(1), style);
                harmonicAmpCal[i, 1] = harmonicAmp;
                harmonicAmp          = Double.Parse(pxa.GetMarker(2), style);
                harmonicAmpCal[i, 2] = harmonicAmp;
                harmonicAmp          = Double.Parse(pxa.GetMarker(3), style);
                harmonicAmpCal[i, 3] = harmonicAmp;
            }

#if WR_RES_TO_PDF
            //Graph Data and Save in PDF Form
            var       doc1     = new Document();
            string    path     = TxRfTests.ResPath + "QECInitSweep";
            TxRfTests instance = new TxRfTests();
            string[]  pcbInfo;
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            string[] loLeakageLabels          = new string[] { "Harmonic Amplitude Versus Offset Tone Frequency without Calibrations",
                                                               "Offset Tone Frequency (MHz)",
                                                               "Amplitude (dBm)",
                                                               "1st Harmonic", "2nd Harmonic", "3rd Harmonic" };
            string[] loLeakageLabelscal = new string[] { "Harmonic Amplitude Versus Offset Tone Frequency with Calibrations",
                                                         "Offset Tone Frequency (MHz)",
                                                         "Amplitude (dBm)",
                                                         "1st Harmonic", "2nd Harmonic", "3rd Harmonic" };
            string[] loLeakageLabelsdif = new string[] { "Image Amplitude Versus Offset Tone Frequency Difference",
                                                         "Offset Tone Frequency (MHz)",
                                                         "Amplitude (dBm)",
                                                         "Trace Amplitude" };
            pcbInfo = Helper.PcbInfo((settings.txPllLoFreq_Hz / 1000000000.0).ToString(), (settings.rxPllLoFreq_Hz / 1000000000.0).ToString(), settings.mykSettings.txProfileName, settings.mykSettings.rxProfileName, backoff.ToString(), atten.ToString());
            // pcbInfo = Helper.PcbInfo();
            //container[0] = Helper.MakeChartObject(fundAmpXY, fundAmpLabels, path);
            container[0] = Helper.MakeChartObject(harmonicAmpnoCal, loLeakageLabels, path);
            container[1] = Helper.MakeChartObject(harmonicAmpCal, loLeakageLabelscal, path);
            //container[1] = Helper.MakeChartObject(loLeakageXYcal, loLeakageLabelscal, path);
            //container[2] = Helper.MakeChartObject(loLeakageXYdif, loLeakageLabelsdif, path);

            //container[2] = Helper.MakeChartObject(imageAmpXY, imageAmpLabels, path);
            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);

            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
#endif
#if WR_RES_TO_TXT
            // Write data to txt file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + ".txt"))
            {
                file.WriteLine("Sample,  Frequency MHz, LOL(dBFS) w/o cal, LOL(dBFS) w/ cal");
                for (int i = 0; i <= param.numSteps; i++)
                {
                    file.WriteLine(i + "," + harmonicAmpnoCal[i, 0].ToString() + "," + harmonicAmpnoCal[i, 1].ToString() + "," + harmonicAmpnoCal[i, 2].ToString());
                }
            }
#endif
        }
Пример #30
0
        public static void ORxGainSweep([Values(Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO, Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO)] Mykonos.OBSRXCHANNEL channel)
        {
            //Initialize param structure with Hardcoded Values
            double[] profileInfo      = Helper.SetOrxProfileInfo(channel);
            double   samplingFreq_MHz = profileInfo[0] / 1000;
            double   freqLo_MHz       = profileInfo[1] / 1000000;
            double   profileBW_MHz    = profileInfo[2] / 1000000;
            double   testFreq         = 2510;
            double   amplitude_dBm    = -20;

            string[] pcbInfo;

            //TODO: Hard coded, may want to read the gain tables instead if custom ones are loaded
            //Number of known indicies in the gain index table.
            //Should a customer provide a custom gain table, we should determine the number of valid gain indicies
            // and this array size should correspond to that number.
            int numIndices = 19;

            double[,] amplitudeData     = new double[numIndices, 3];
            double[,] amplitudeDiffData = new double[numIndices - 1, 2];
            short[] rxDataArray = new short[16384];
            Console.WriteLine("Detected LO Frequency: " + freqLo_MHz);
            Console.WriteLine("Profile BW: " + profileBW_MHz);

            switch (channel)
            {
            case Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO:
            case Mykonos.OBSRXCHANNEL.OBS_RX2_TXLO:
                testFreq = freqLo_MHz + 10;
                break;

            case Mykonos.OBSRXCHANNEL.OBS_SNIFFER_A:
            case Mykonos.OBSRXCHANNEL.OBS_SNIFFER_B:
            case Mykonos.OBSRXCHANNEL.OBS_SNIFFER_C:
                testFreq      = freqLo_MHz + 5;
                amplitude_dBm = -30;
                break;
            }

            //ESG Configuration
            SG_AgilentESG esg = new SG_AgilentESG(measEquipment.ESGAddress);

            Console.WriteLine(measEquipment.ESGAddress);
            Console.WriteLine(esg.Identify());
            esg.SetFrequency(testFreq);
            esg.SetAmplitude(amplitude_dBm);
            esg.SetRfOutput(true);

            //Test Sequence
            byte gainIndex = 255;
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            AdiMath.FftAnalysis analysisData = new AdiMath.FftAnalysis();

            for (int i = 0; i < (numIndices + 1); i++)
            {
                try
                {
                    Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
                    Link.spiWrite(0x4F1, 0x80);
                    gainIndex = (byte)(255 - i);
                    Console.WriteLine("Initial gain index = " + Link.Mykonos.getObsRxGain());
                    Link.Mykonos.setObsRxManualGain(channel, gainIndex);    //There is currently an error in the API.
                    Console.WriteLine("Set gain index = " + gainIndex);
                    System.Threading.Thread.Sleep(100);
                }
                catch (Exception e)
                {
                    //Console.WriteLine("Invalid Gain index reached" + i);    //Need to figure out a better way to exit the loop when invalid gain reached
                    Console.WriteLine(e);
                    break;
                }
                finally
                {
                    Link.Disconnect();
                }


                rxDataArray = Helper.MykonosOrxCapture(channel, 8192); //Grab data from the FPGA
                byte     sampleBitWidth = 16;
                double[] data           = AdiMath.complexfftAndScale(rxDataArray, samplingFreq_MHz, sampleBitWidth, true, out analysisData);

                amplitudeData[i, 0] = (double)gainIndex;
                amplitudeData[i, 1] = analysisData.FundamentalPower_dBFS;
                if (i == 0)
                {
                    amplitudeData[i, 2] = analysisData.FundamentalPower_dBFS;
                }
                else
                {
                    amplitudeData[i, 2]         = amplitudeData[i - 1, 2] - 1;
                    amplitudeDiffData[i - 1, 0] = (double)gainIndex;
                    amplitudeDiffData[i - 1, 1] = amplitudeData[i - 1, 1] - amplitudeData[i, 1];
                    Console.WriteLine(" Gain index :" + amplitudeDiffData[i - 1, 0]);
                    Console.WriteLine(" Differential Amplitude" + amplitudeDiffData[i - 1, 1]);
                }
            }


#if WR_RES_TO_PDF
            string path = ObsRxRfTests.ResPath + "ORxGainSweep";
            if (channel == Mykonos.OBSRXCHANNEL.OBS_RX1_TXLO)
            {
                path = path + "OBS_RX1_TXLO";
            }
            else
            {
                path = path + "OBS_RX2_TXLO";
            }
            var doc1 = new Document();
            iTextSharp.text.Image[] container = new iTextSharp.text.Image[2];
            string[] timeLabels = new string[] { "Rx Gain Sweep versus Amplitude for " + channel.ToString(),
                                                 "Gain Index (byte)",
                                                 "Amplitude (dBFS)",
                                                 "Amplitude: " + amplitude_dBm + "dBm",
                                                 "Perfect 1dB Gain Index Steps" };
            string[] timeLabels2 = new string[] { "Difference between consecutive gain entries " + channel.ToString(),
                                                  "Gain Index",
                                                  "Amplitude delta (dB, comparing A(n + 1) - A(n))",
                                                  "Amplitude: " + amplitude_dBm + "dBm" };
            pcbInfo = Helper.PcbInfo();

            container[0] = Helper.MakeChartObject(amplitudeData, timeLabels, path);
            container[1] = Helper.MakeChartObject(amplitudeDiffData, timeLabels2, path + "2");

            Helper.AddAllChartsToPdf(container, path + ".pdf", pcbInfo);
            //Open Result PDF
            System.Diagnostics.Process.Start(path + ".pdf");
            for (int i = 1; i < (numIndices); i++)
            {
                NUnit.Framework.Assert.IsTrue(((amplitudeDiffData[i - 1, 1] < 1) &&
                                               (amplitudeDiffData[i - 1, 1] > 0)));
            }
#endif
        }