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

📄 aumg369xb_example (fast-frequency-switching).c

📁 介绍了GPIB在开发mg369*仪器的自动控制方面的技巧和注意事项
💻 C
字号:
/***************************************************************************** 
 * (c) 2007, National Instruments, Corporation. All Rights Reserved.	     * 
 *****************************************************************************/

/*****************************************************************************
 *  ANRITSU, MG369XB Synthesized Signal Generator  
 *  Instrument Driver Sample Program                              
 *  Developed with LabWindows/CVI 8.1                                     
 *  Original Release: 10/20/2007                                  
 *
 *  Purpose:  This sample program initializes the synthesized signal generator and
 *            configures it for fast-frequency-switching.
 *
 *            To run this sample program, do the following:
 *            1) Create a new project in LabWindows/CVI.
 *            2) Add this file to the project.  To add files to the project,
 *               select the Add Files To Project from the Edit menu of the 
 *               Project window.
 *            3) Add one of the following files to the project:
 *               aumg369xb.fp, aumg369xb.c, or aumg369xb.lib.
 *            4) Check that the resource name used in aumg369xb_init ()
 *               function is correct.
 *			  5) Run the project.
 *
 *            VCC or Borland Users:
 *            This example uses CVI's MessagePopup() to display the error
 *            message. You will need to replace this function with a 
 *            printf() or similar display function.  You will then need to 
 *            remove the #include <userint.h> statement.  You can then follow 
 *            the above directions for CVI users.
******************************************************************************/
#include <cvirte.h>  
#include <ansi_c.h>
#include <userint.h>
#include <utility.h> 
#include <visa.h> 
#include "aumg369xb.h"

/*= Macro ===================================================================*/ 
#ifndef CHECKERR
#define CHECKERR(fCall) \
	if (status = (fCall), (status = (status < 0) ? status : VI_SUCCESS)) \
		{ \
		goto Error; \
		} \
		else
#endif

#define  SWITCHING_NUMBER 10

int main (int argc, char *argv[])
{
    ViSession	vi = NULL;
    ViStatus	status = VI_SUCCESS;
	ViInt32		i;
	ViReal64	frequencyList[SWITCHING_NUMBER];
	ViReal64	powerOffsetList[SWITCHING_NUMBER];

	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;    /* out of memory */

	/*- Set frequency list and power offset list ----------------------------*/ 
	for (i = 0; i < SWITCHING_NUMBER; i++)
	{
		frequencyList[i] = 1e9 + 1e8 * i;
		powerOffsetList[i] = -20 + 3 * i;
	}

	/*- Initialize MG369XB synthesized signal generator ---------------------*/ 
    CHECKERR (aumg369xb_init ("GPIB0::5::INSTR", VI_TRUE, VI_TRUE, &vi));

	/*- Turn off the RF output ----------------------------------------------*/ 
	CHECKERR (aumg369xb_configureOutputEnabled(vi, VI_FALSE));

	/*- Configure the MG369XB to execute a fast-frequency-switching step each
	    time a GET message is received---------------------------------------*/
	CHECKERR (aumg369xb_configureGroupExecuteTrigger (vi, AUMG369XB_EXECUTE_COMMAND_FFSS));

	/*- Load frequency table ------------------------------------------------*/
	CHECKERR (aumg369xb_configureFastFrequencySwitching (vi, 0, SWITCHING_NUMBER, frequencyList, 0));

	/*- Load power offset table ---------------------------------------------*/
	CHECKERR (aumg369xb_configurePowerOffsetTable(vi, VI_TRUE, SWITCHING_NUMBER, powerOffsetList));

	/*- Turn on the RF output -----------------------------------------------*/
	CHECKERR (aumg369xb_configureOutputEnabled (vi, VI_TRUE));
	
	for (i = 0; i < SWITCHING_NUMBER; i++)
	{
		/*- Execute a fast-frequency-switching step on receipt of a GET -----*/
		CHECKERR (aumg369xb_sendGETBusMessage (vi));
		Delay(2);
	}

	/*- Turn off the RF output ----------------------------------------------*/
	CHECKERR (aumg369xb_configureOutputEnabled(vi, VI_FALSE));
	
Error:

    if (status != VI_SUCCESS)
	{
		ViChar   errorString[256];

		aumg369xb_errorMessage (vi, status, errorString);
		MessagePopup ("Error!", errorString);
	}
    
    if (vi)
        aumg369xb_close (vi);

	return 0;
}

⌨️ 快捷键说明

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