Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5340

Power spectral density measurement in CVI with GPIB and Agilent N9020A Signal Analyzer

$
0
0

I'm trying to measure power spectral density (PSD - dBm/Hz) in CVI through GPIB with the Agilent N9020A spectrum analyzer and have my GUI display its value in a numeric box.  On my GUI, a "Get PSD" button calls the CVI callback GetPSDCallback (code below) which then calls the function AnalyzerGetDensity (code below).  AnalyzerGetDensity then tells the N9020A to measure PSD, return its value, and store that value in a numeric box on the GUI panel with variable name PRESENTP.

 

When I run the program I get a "QUERY INTERRUPTED" error on the N9020A display and the PSD value isn't recorded. Could someone tell me why this is happening and how I can fix it to make my program work?

 

Thanks for your help.

 

===CVI Callback: ====

 

int CVICALLBACK GetPSDCallback (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:     
        AnalyzerGetDensity(panel);
            break;
    }
    return 0;
}

 

=== PSD Measurement Function: ===

 

float AnalyzerGetDensity (int panel)         

{                                              
    char *stringinput;
    float *floatoutput;
    
    stringinput = (char *)calloc(sizeof(char),256);
    floatoutput = (float *)malloc(sizeof(float)*2);
    strcpy(stringinput,":INIT:CHP;");   
    ibwrt(N9020A, stringinput, strlen(stringinput));
    strcpy(stringinput,":FETC:CHPSmiley Very HappyENS?;");             
    ibwrt(N9020A, stringinput, strlen(stringinput));
    ibrd(N9020A, floatoutput, sizeof(floatoutput));;    
    free(stringinput);
    
    SetCtrlVal (panel, PANEL_PRESENTP, *floatoutput);
    return *floatoutput;    
}


Viewing all articles
Browse latest Browse all 5340

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>