SPRING :: NOTE

[Agilent] N9320B Spectrum Analizer Source (Sample) 본문

Development Tools/Keysight · National Instruments

[Agilent] N9320B Spectrum Analizer Source (Sample)

RAYZIE 2016. 2. 29. 19:21
반응형
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#include <windows.h>
ViSession defaultRM, viN9320B;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
	viQueryf(viN9320B, "*IDN?\n", "%t", &cIdBuff);
	/* prompt the user*/
	/* to connect the amplitude reference output to the input*/
	printf ("Connect CAL OUT to the RF IN \n");
	printf ("......Press Return to continue \n");
	scanf( "%c",&cEnter);
	/*Externally route the 50MHz Signal*/
	viPrintf(viN9320B,"CAL:SOUR:STAT ON \n");
}
void main()
{
	/*Program Variables*/
	ViStatus viStatus = 0;
	double dMarkerFreq = 0;
	double dMarkerAmpl = 0;
	float fPeakExcursion =0;
	/*Open a USB session.*/
	viStatus=viOpenDefaultRM(&defaultRM);
	viStatus=viOpen(defaultRM,"USB0::0x0957::0xFFEF::CN03229432::0::INSTR",VI_NULL,VI_NULL,&viN9320B);
	if(viStatus)
	{
		printf("Could not open a session to USB device\n");
		exit(0);
	}
	while (true)
	{
		viPrintf(viN9320B,"CALC:MARK:PEAK:EXC %1fDB \n",50);
		viPrintf(viN9320B,"CALC:MARK:PEAK:EXC %1fDB \n",fPeakExcursion);
		/*Set the peak thresold */
		viPrintf(viN9320B,"CALC:MARK:PEAK:THR -90 \n");
		/*Trigger a sweep and wait for completion*/
		viPrintf(viN9320B,"INIT:IMM \n");
		/*Set the marker to the maximum peak*/
		viPrintf(viN9320B,"CALC:MARK:MAX \n");
		/*Query and read the marker frequency*/
		viQueryf(viN9320B,"CALC:MARK:X? \n","%lf",&dMarkerFreq);
		printf("\n\t RESULT: Marker Frequency is: %lf MHZ \n\n",dMarkerFreq/10e5);
		/*Query and read the marker amplitude*/
		viQueryf(viN9320B,"CALC:MARK:Y?\n","%lf",&dMarkerAmpl);
		printf("\t RESULT: Marker Amplitude is: %lf dBm \n\n",dMarkerAmpl);
		Sleep(1000);
		system("cls");
	}
	
	/*Close the session*/
	viClose(viN9320B);
	viClose(defaultRM);
}


반응형
Comments