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

📄 aumg369xb_example (step sweep).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 step sweep frequency with fixed power level.
 *
 *            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

int main (int argc, char *argv[])
{
    ViSession	vi = NULL;
    ViStatus	status = VI_SUCCESS;

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

	/*- 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 F1 parameter ------------------------------------------*/ 
	CHECKERR (aumg369xb_configureFrequencyEntry (vi, AUMG369XB_FREQUENCY_F1, 1e9));

	/*- Configure the F2 parameter ------------------------------------------*/
	CHECKERR (aumg369xb_configureFrequencyEntry (vi, AUMG369XB_FREQUENCY_F2, 3e9));

	/*- Configure the L1 parameter ------------------------------------------*/
	CHECKERR (aumg369xb_configurePowerLevelEntry (vi, AUMG369XB_POWER_LEVEL_L1, -20));

	CHECKERR (aumg369xb_configureFixedPowerLevel (vi, AUMG369XB_POWER_LEVEL_L1, VI_FALSE, 0));

	/*- Configure  -----------------------------------------------*/
	CHECKERR (aumg369xb_configureStepSweepFrequency (vi, AUMG369XB_STEP_SWEEP_MODE_LINEAR, 
				AUMG369XB_SWEEP_RANGE_F1_F2, 0.5, 50, AUMG369XB_TRIGGER_SOURCE_AUTO));

	/*- Turn on the RF output -----------------------------------------------*/
	CHECKERR (aumg369xb_configureOutputEnabled (vi, VI_TRUE));
	
	/*- Enable the output for 25 seconds ------------------------------------*/
	Delay (25);

	/*- 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 + -