AnsweredAssumed Answered

C++ controlling Agilent n9010a analyzer and n5182 generator

Question asked by cma21 on Jul 5, 2012
Latest reply on Jul 12, 2012 by connectivity
Hi All, 

I am attempting to automate some scpi commands to control my Agilent instruments as mentioned above. I am currently using Command Expert 1.1 and have had some success using it thus far. However, I am a newbie C++ programmer and am only attempting this control option for ease of use in the lab and to be more time efficient. These are my objectives:

i. I would like to recall from either a saved state in the generator the settings I have made for each type of waveform (ie. WCDMA Center Freq: 1962 MHz Pow: 10 dBm).

ii. From here I would like to either use the "auto tune" softkey or somehow have the analyzer configure itself to be able to view the spectrum/band.

iii. After the screen on the analyzer is configured I would like to save the screen shot as a file in a directory on my PC.

iv. Repeat this process for all different states of waveforms saved in the register on generator.


I am a newbie/beginner level programmer with C++ and I have not found any of the turorials regarding C++ to be very helpful/informative so completing this task seems to be very daunting.Today I threw together a program of random bits and functions and will display it below. Also I have found the win32 console GUI to not be very appealing so if anyone can reccomend a GUI developer to make this more user friendly that would also be very beneficial.

*Thanks in advance and I hope someone can point me in the right direction!*

*Here is my code:*
/////////////////////////////////////////////////////////

#include "stdafx.h"
#include "visa.h"
#include
#include
using namespace std;



int print_Freq()
{
     
     ViSession rm;
     viOpenDefaultRM(&rm);
     
     ViSession v5182_signal_generator;
     viOpen(rm, "TCPIP0::10.208.211.33::5025::SOCKET", VI_NULL, VI_NULL, &v5182_signal_generator);

     char z;
     z = viPrintf(v5182_signal_generator, ":Freq 1.0GHz\n");
     return z;
}

int print_Amp()
{
     ViSession rm;
     viOpenDefaultRM(&rm);
     
     ViSession v5182_signal_generator;
     viOpen(rm, "TCPIP0::10.208.211.33::5025::SOCKET", VI_NULL, VI_NULL, &v5182_signal_generator);
     

     int z;
     z = viPrintf(v5182_signal_generator, ":POW 0dBm\n");
     return z;
}

int Save_Image()
{
     ViSession rm;
     viOpenDefaultRM(&rm);

     ViSession n9010a_exa_signal_analyzer;
     viOpen(rm, "TCPIP0::10.208.211.153::5025::SOCKET", VI_NULL, VI_NULL, &n9010a_exa_signal_analyzer);


     return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
     
     
     ViSession rm;
     viOpenDefaultRM(&rm);
     ViSession n9010a_exa_signal_analyzer;
     ViSession v5182_signal_generator;
     viOpen(rm, "TCPIP0::10.208.211.153::5025::SOCKET", VI_NULL, VI_NULL, &n9010a_exa_signal_analyzer);
     viOpen(rm, "TCPIP0::10.208.211.33::5025::SOCKET", VI_NULL, VI_NULL, &v5182_signal_generator);
     
     viPrintf(v5182_signal_generator, "*RCL 1\n");
     viPrintf(n9010a_exa_signal_analyzer, "*RCL 1\n");
     

     printf("You are currently viewing State 01 via v5182 Signal Generator\n");
     printf("     \n");
     printf("Generator Frequency: \n", print_Freq);
     printf("     \n");
     printf("Generator Power: \n", print_Amp);
     printf("     \n");
     printf("Press any key to continue:\n");
     getchar();
     return 0;

     
          
     viClose(n9010a_exa_signal_analyzer);
     viClose(v5182_signal_generator);

     return 0;
     

}

Edited by: CMA21 on Jul 10, 2012 3:18 PM

Outcomes