⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minst.c

📁 atheros ar5001 5002 driver
💻 C
📖 第 1 页 / 共 5 页
字号:
    gpibWrite(ud, ":FREQ:STOP 2E9;");                    // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max0) {
       pwr_max0 = pwr;
       freq_max0 = freq;
    }

    // Search between 2 GHz and 2.8 GHz
    gpibWrite(ud, ":FREQ:STAR 2E9;");                    // start freq
    gpibWrite(ud, ":FREQ:STOP 2.8E9;");                  // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max0) {
       pwr_max0 = pwr;
       freq_max0 = freq;
    }

    // Search between 2.8 GHz and 3 GHz
    gpibWrite(ud, ":FREQ:STAR 2.8E9;");                  // start freq
    gpibWrite(ud, ":FREQ:STOP 3E9;");                    // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max0) {
       pwr_max0 = pwr;
       freq_max0 = freq;
    }

    // Search between 3 GHz and 4 GHz
    gpibWrite(ud, ":FREQ:STAR 3E9;");                    // start freq
    gpibWrite(ud, ":FREQ:STOP 4E9;");                    // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max0) {
       pwr_max0 = pwr;
       freq_max0 = freq;
    }

    // Search between 4 GHz and 5 GHz
    gpibWrite(ud, ":FREQ:CENT UP;");                     // increment center freq 1 GHz
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max0) {
       pwr_max0 = pwr;
       freq_max0 = freq;
    }

    // Search between 5 and 5.13 GHz
    gpibWrite(ud, ":FREQ:STAR 5E9;");                    // start freq
    gpibWrite(ud, ":FREQ:STOP 5.13E9;");                 // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max0) {
       pwr_max0 = pwr;
       freq_max0 = freq;
    }

    // Search between 5.27 and 5.342 GHz
    gpibWrite(ud, ":FREQ:STAR 5.27E9;");                      // start freq
    gpibWrite(ud, ":FREQ:STOP 5.342E9;");                     // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                         // trigger sweep
    pwr_max1 = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq_max1 = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak

    // Search between 5.342 and 6 GHz
    gpibWrite(ud, ":FREQ:STAR 5.342E9;");                     // start freq
    gpibWrite(ud, ":FREQ:STOP 6E9;");                         // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                         // trigger sweep
    pwr_max2 = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq_max2 = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak

    // Search between 6 and 6.7 GHz
    gpibWrite(ud, ":FREQ:STAR 6E9;");                    // start freq
    gpibWrite(ud, ":FREQ:STOP 6.7E9;");                  // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max2) {
       pwr_max2 = pwr;
       freq_max2 = freq;
    }

    n = sprintf(emissions, "%07.2f, %10.3E, %07.2f, %10.3E, %07.2f, %10.3E",
                            pwr_max0, freq_max0, pwr_max1, freq_max1, pwr_max2, freq_max2);
    emissions[n] = '\0';

    return emissions;
}

MANLIB_API double spaMeasTxPwrDev(const int ud, 
                                  const double center, 
                                  const double ref_level,
                                  const int reset) {

    int rsp = 0;
    double pwr_dev = 0;

    // reset prior to setting the center frequency
    if (reset) rsp = atoi(gpibQuery(ud, "*RST;*OPC?", 5L));

    // change to channel frequency
    gpibWrite(ud, qq(":FREQ:CENT %f;", center));

    if (reset) {
       gpibWrite(ud, ":FREQ:SPAN 25E6;");                          // span
       gpibWrite(ud, ":BAND:RES 1E6;VID 3E6;");                    // resolution / video bandwidth
       gpibWrite(ud, qq(":DISP:WIND:TRAC:Y:RLEV %f;", ref_level)); // reference level
       gpibWrite(ud, ":DISP:WIND:TRAC:Y:PDIV 5;");                 // scale
       gpibWrite(ud, ":AVER 0;");                                  // averaging off
       gpibWrite(ud, ":DET POS;");                                 // detector mode (peak) 
       gpibWrite(ud, ":TRAC:MODE WRIT;");                          // max hold off
    }

    // Make Power Measurement
    gpibWrite(ud, ":INIT:CONT 0;");                      // single sweep
    gpibWrite(ud, ":FREQ:SPAN 25E6;");                   // span
    gpibWrite(ud, ":BAND:VID 3E6;");                     // video bandwidth
    gpibWrite(ud, ":DET POS;");                          // detector mode (peak) 
    gpibWrite(ud, ":TRAC:MODE MAXH;");                   // max hold on
    gpibWrite(ud, ":INIT:CONT 1;");                      // continuous sweep
    sleep(10000);
    gpibWrite(ud, ":CALC:MARK:MAX;");                    // find peak
    gpibWrite(ud, ":CALC:MARK:CENT;");                   // center peak
    gpibWrite(ud, ":INIT:CONT 0;");                      // single sweep
    gpibWrite(ud, ":TRAC:MODE WRIT;");                   // max hold off
    gpibWrite(ud, ":FREQ:SPAN 0;");                      // span
    gpibWrite(ud, ":BAND:VID 1E6;");                     // video bandwidth
    gpibWrite(ud, ":DET SAMP;");                         // detector mode (sample) 
    gpibWrite(ud, ":TRAC:MODE MAXH;");                   // max hold on
    gpibWrite(ud, ":INIT:CONT 1;");                      // continuous sweep
    sleep(10000);
    gpibWrite(ud, ":CALC:MARK:MAX;");                    // find peak
    pwr_dev = atof(gpibQuery(ud, ":CALC:MARK:Y?", 55L)); // measure power
    gpibWrite(ud, ":TRAC:MODE WRIT;");                   // max hold off
    return pwr_dev;
}

MANLIB_API char *spaMeasRxSpuriousEm(const int ud, 
                                     const double ref_level,
                                     const int reset) {

    int rsp = 0, n, cf_index;
    double pwr, freq, pwr_max0, pwr_max1, freq_max0, freq_max1;
    static char emissions[41] = "-120.00, 0.000E+000, -120.00, 0.000E+000";

    if (reset) {
       rsp = atoi(gpibQuery(ud, "IP;DONE?", 5L));   // reset
       gpibWrite(ud, "SNGLS;");                     // single sweep
       gpibWrite(ud, "AT AUTO;");                   // auto attenuation
       gpibWrite(ud, qq("RL %fDB;", ref_level));    // reference level
       gpibWrite(ud, "LG 5DB;");                    // scale
       gpibWrite(ud, "FA 10MHZ;");                  // start freq
       gpibWrite(ud, "FB 1GHZ;");                   // stop freq
       gpibWrite(ud, "RB 100KHZ;");                 // resolution bandwidth
       gpibWrite(ud, "VB 100KHZ;");                 // video bandwidth
       gpibWrite(ud, "DET POS;");                   // detector mode (peak)
       gpibWrite(ud, "SS MAN;");                    // freq step size manual
       gpibWrite(ud, "SS 1GHZ;");                   // freq step size 1 GHz
    }

    // Make measurement
    // Search between 10 MHz and 1 GHz
    gpibWrite(ud, "FA 10MHZ;");
    gpibWrite(ud, "FB 1GHZ;");
    gpibWrite(ud, "RB 100KHZ;");                 // resolution bandwidth
    gpibWrite(ud, "VB 100KHZ;");                 // video bandwidth
    gpibWrite(ud, "TS;");
    gpibQuery(ud, "DONE?",5L);
    gpibWrite(ud, "MKPK HI;");
    pwr_max0 = atof(gpibQuery(ud, "MKA?",55L));
    freq_max0 = atof(gpibQuery(ud, "MKF?",55L));

    // Search between 1 and 2 GHz
    gpibWrite(ud, "FA 1GHZ;");
    gpibWrite(ud, "FB 2GHZ;");
    gpibWrite(ud, "RB 1MHZ;");                 // resolution bandwidth
    gpibWrite(ud, "VB 1MHZ;");                 // video bandwidth
    gpibWrite(ud, "TS;");
    gpibQuery(ud, "DONE?",5L);
    gpibWrite(ud, "MKPK HI;");
    pwr_max1 = atof(gpibQuery(ud, "MKA?",55L));
    freq_max1 = atof(gpibQuery(ud, "MKF?",55L));

    // Search between 2 and 2.8 GHz
    gpibWrite(ud, "FA 2GHZ;");
    gpibWrite(ud, "FB 2.8GHZ;");
    gpibWrite(ud, "TS;");
    gpibQuery(ud, "DONE?",5L);
    gpibWrite(ud, "MKPK HI;");
    pwr = atof(gpibQuery(ud, "MKA?",55L));
    freq = atof(gpibQuery(ud, "MKF?",55L));
    if (pwr > pwr_max1) {
       pwr_max1 = pwr;
       freq_max1 = freq;
    }

    // Search between 2.8 and 3 GHz
    gpibWrite(ud, "FA 2.8GHZ;");
    gpibWrite(ud, "FB 3GHZ;");
    gpibWrite(ud, "TS;");
    gpibQuery(ud, "DONE?",5L);
    gpibWrite(ud, "MKPK HI;");
    pwr = atof(gpibQuery(ud, "MKA?",55L));
    freq = atof(gpibQuery(ud, "MKF?",55L));
    if (pwr > pwr_max1) {
       pwr_max1 = pwr;
       freq_max1 = freq;
    }

    // Search between 3 and 4 GHz
    gpibWrite(ud, "FA 3GHZ;");
    gpibWrite(ud, "FB 4GHZ;");
    gpibWrite(ud, "TS;");
    gpibQuery(ud, "DONE?",5L);
    gpibWrite(ud, "MKPK HI;");
    pwr = atof(gpibQuery(ud, "MKA?",55L));
    freq = atof(gpibQuery(ud, "MKF?",55L));
    if (pwr > pwr_max1) {
       pwr_max1 = pwr;
       freq_max1 = freq;
    }

    // Search between 4 and 6 GHz
    for (cf_index=0;cf_index<2;cf_index++) {
       gpibWrite(ud, "CF UP;");
       gpibWrite(ud, "TS;");
       gpibQuery(ud, "DONE?",5L);
       gpibWrite(ud, "MKPK HI;");
       pwr = atof(gpibQuery(ud, "MKA?",55L));
       freq = atof(gpibQuery(ud, "MKF?",55L));
       if (pwr > pwr_max1) {
          pwr_max1 = pwr;
          freq_max1 = freq;
       }
    }

    // Search between 6 and 13 GHz
    for (cf_index=0;cf_index<7;cf_index++) {
       gpibWrite(ud, "CF UP;");
       gpibWrite(ud, "TS;");
       gpibQuery(ud, "DONE?",5L);
       gpibWrite(ud, "MKPK HI;");
       pwr = atof(gpibQuery(ud, "MKA?",55L));
       freq = atof(gpibQuery(ud, "MKF?",55L));
       if (pwr > pwr_max1) {
          pwr_max1 = pwr;
          freq_max1 = freq;
       }
    }

    // Search between 13 and 16 GHz
    for (cf_index=0;cf_index<3;cf_index++) {
       gpibWrite(ud, "CF UP;");
       gpibWrite(ud, "TS;");
       gpibQuery(ud, "DONE?",5L);
       gpibWrite(ud, "MKPK HI;");
       pwr = atof(gpibQuery(ud, "MKA?",55L));
       freq = atof(gpibQuery(ud, "MKF?",55L));
       if (pwr > pwr_max1) {
          pwr_max1 = pwr;
          freq_max1 = freq;
       }
    }

    n = sprintf(emissions, "%07.2f, %10.3E, %07.2f, %10.3E", pwr_max0, freq_max0, pwr_max1, freq_max1);
    emissions[n] = '\0';

    return emissions;
}

MANLIB_API char *spaMeasRxSpuriousEmLite(const int ud, 
                                         const double ref_level,
                                         const int reset) {

    int rsp = 0, n, cf_index;
    double pwr, freq, pwr_max0, pwr_max1, freq_max0, freq_max1;
    static char emissions[41] = "-120.00, 0.000E+000, -120.00, 0.000E+000";

    if (reset) {
       rsp = atoi(gpibQuery(ud, "*RST;*OPC?", 5L));                // reset
       gpibWrite(ud, ":INIT:CONT 0;");                             // single sweep
       gpibWrite(ud, qq(":DISP:WIND:TRAC:Y:RLEV %f;", ref_level)); // reference level
       gpibWrite(ud, ":DISP:WIND:TRAC:Y:PDIV 5;");                 // scale
       gpibWrite(ud, ":BAND:RES 1E5;VID 1E5;");                    // resolution / video bandwidth
       gpibWrite(ud, ":FREQ:STAR 1E7;");                           // start freq
       gpibWrite(ud, ":FREQ:STOP 1E9;");                           // stop freq
       gpibWrite(ud, ":DET POS;");                                 // detector mode (peak)
       gpibWrite(ud, ":CALC:MARK:PEAK:SEAR:MODE MAX");             // set peak search mode
       gpibWrite(ud, ":FREQ:CENT:STEP:AUTO 0;");                   // freq step auto off
       gpibWrite(ud, ":FREQ:CENT:STEP 1E9;");                      // freq step 1 GHz
    }

    // Make measurement
    // Search between 10 MHz and 1 GHz
    gpibWrite(ud, ":FREQ:STAR 1E7;");                         // start freq
    gpibWrite(ud, ":FREQ:STOP 1E9;");                         // stop freq
    gpibWrite(ud, ":BAND:RES 1E5;VID 1E5;");                  // resolution / video bandwidth
    gpibWrite(ud, ":INIT:IMM;*WAI;");                         // trigger sweep
    pwr_max0 = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq_max0 = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak

    // Search between 1 and 2 GHz
    gpibWrite(ud, ":FREQ:STAR 1E9;");                         // start freq
    gpibWrite(ud, ":FREQ:STOP 2E9;");                         // stop freq
    gpibWrite(ud, ":BAND:RES 1E6;VID 1E6;");                  // resolution / video bandwidth
    gpibWrite(ud, ":INIT:IMM;*WAI;");                         // trigger sweep
    pwr_max1 = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq_max1 = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak

    // Search between 2 and 2.8 GHz
    gpibWrite(ud, ":FREQ:STAR 2E9;");                    // start freq
    gpibWrite(ud, ":FREQ:STOP 2.8E9;");                  // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max1) {
       pwr_max1 = pwr;
       freq_max1 = freq;
    }

    // Search between 2.8 and 3 GHz
    gpibWrite(ud, ":FREQ:STAR 2.8E9;");                  // start freq
    gpibWrite(ud, ":FREQ:STOP 3E9;");                    // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max1) {
       pwr_max1 = pwr;
       freq_max1 = freq;
    }

    // Search between 3 and 4 GHz
    gpibWrite(ud, ":FREQ:STAR 3E9;");                    // start freq
    gpibWrite(ud, ":FREQ:STOP 4E9;");                    // stop freq
    gpibWrite(ud, ":INIT:IMM;*WAI;");                    // trigger sweep
    pwr = atof(gpibQuery(ud, ":CALC:MARK:MAX;Y?", 55L)); // find max peak and measure amplitude
    freq = atof(gpibQuery(ud, ":CALC:MARK:X?",55L));     // measure frequency of peak
    if (pwr > pwr_max1) {
       pwr_max1 = pwr;
       freq_max1 = freq;
    }

    // Search between 4 and 6 GHz
    for (cf_index=0;cf_index<2;cf_index++) {
       gpibWrite(ud, ":FREQ:CENT UP;");                     // increment center freq

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -