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

📄 aumg369xb.c

📁 介绍了GPIB在开发mg369*仪器的自动控制方面的技巧和注意事项
💻 C
📖 第 1 页 / 共 5 页
字号:
	}
	else
	{
		CHECKERR (viPrintf (vi, "CM%d;", selectedFrequency - 10));
	}

	CHECKERR (viPrintf (vi, "PS%d;", phaseOffsetEnabled ? 1 : 0));

	if (phaseOffsetEnabled)
	{
		CHECKERR (viPrintf (vi, "PSO %f DG;", phaseOffset));
	}

	CHECKERR (viPrintf (vi, "CS%d;", CWRampEnabled ? 1 : 0));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;	
}


/*=====================================================================================*/
/* Function: Configure Fast Frequency Switching										   */
/*																			           */
/* Purpose:  This function configures the fast-frequency-switching parameters,         */
/*           including the table location, the frequency list, and the table pointer.  */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureFastFrequencySwitching (ViSession vi,
					ViInt32 tableLocation, ViInt32 numberOfFrequency,
					ViReal64 frequencyList[], ViInt32 pointerLocation)
{
	ViStatus	status = VI_SUCCESS;

	ViChar		command_str[100000] = "";
	ViInt32		i;

	/*- Check input parameter ranges --------------------------------------------------*/	
	CHECKPARAM (aumg369xb_invalidPointer (frequencyList), VI_ERROR_PARAMETER3);
	/*---------------------------------------------------------------------------------*/

	sprintf(command_str, "ZL%03d", tableLocation);

	for (i = 0; i < numberOfFrequency; i++)
	{
		sprintf(command_str, "%s %Lf HZ", command_str, frequencyList[i]);
	}

	sprintf(command_str + strlen(command_str), "ZEL");

	CHECKERR (viPrintf (vi, command_str));

	CHECKERR (viPrintf (vi, "ZS%03d", pointerLocation));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;	
}


/*=====================================================================================*/
/* Function: Configure Analog Sweep Frequency										   */
/*																			           */
/* Purpose:  This function sets up the MG369XB for a analog frequency sweep and        */
/*			 configures the analog sweep frequency parameters, including the sweep     */
/*			 range, the sweep time and the trigger source.					           */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureAnalogSweepFrequency (ViSession vi, 
					ViInt32 sweepRange, ViReal64 sweepTime, ViInt32 triggerSource)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "SWP, %s, SWT %f SEC, %s;", sweepRangeTable[sweepRange], 
				sweepTime, triggerSourceTable[triggerSource]));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;	
}


/*=====================================================================================*/
/* Function: Configure Step Sweep Frequency											   */
/*																			           */
/* Purpose:  This function sets up the MG369XB for a step frequency sweep and          */
/*			 configures the step sweep frequency parameters, including the step sweep  */
/*           range, the sweep mode, the dwell-time-per-step, the number of steps and   */
/*           the trigger source.                                                       */        
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureStepSweepFrequency (ViSession vi,  
					ViInt32 sweepRange, ViInt32 stepSweepMode, ViReal64 dwellTime, 
					ViInt32 numberOfSteps, ViInt32 triggerSource)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf(vi, "%s, %s, SDT %f SEC, SNS %d SPS, %s;", stepSweepModeTable[stepSweepMode], 
				sweepRangeTable[sweepRange], dwellTime, numberOfSteps, 
				triggerSourceTable[triggerSource]));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;	
}


/*=====================================================================================*/
/* Function: Configure Step Sweep Sweep Time										   */
/*																			           */
/* Purpose:  This function configures the time for the step sweep.					   */								                   
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureStepSweepSweepTime (ViSession vi,
					ViReal64 sweepTime)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "SWT %f SEC;", sweepTime));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;	
}


/*=====================================================================================*/
/* Function: Configure Alternate Sweep Frequency									   */
/*																			           */
/* Purpose:  This function configures the alternate sweep frequency parameters,        */
/*			 including the sweep range and the power level.						       */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureAlternateSweepFrequency (ViSession vi, 
					ViInt32 sweepRange, ViInt32 powerLevel)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "%s, AL%d;", alternateSweepRangeTable[sweepRange], powerLevel));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure Dual Step Sweep Enabled										   */
/*																			           */
/* Purpose:  This function enables or disables the dual step sweep mode.               */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureDualStepSweepEnabled (ViSession vi,
					ViBoolean enabled)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "DU%d;", enabled ? 1 : 0));
	
	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure Non Equally Spaced Step Sweep Enabled						   */
/*																			           */
/* Purpose:  This function enables or disables the non-equally spaced step sweep.      */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureNonEquallySpacedStepSweepEnabled (ViSession vi,
					ViBoolean enabled)

{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "SP%d;", enabled ? 1 : 0));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure Manual Sweep Frequency										   */
/*																			           */
/* Purpose:  This function sets up the MG369XB for a manual sweep frequency and        */
/*           configures the manual sweep parameters, including the sweep range and the */
/*           number of steps.                                                          */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureManualSweepFrequency (ViSession vi,
					ViInt32 sweepRange, ViInt32 numberOfSteps)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "MAN, %s, SNS %d SPS, RL;", sweepRangeTable[sweepRange], 
				numberOfSteps));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure List Sweep Frequency											   */
/*																			           */
/* Purpose:  This function places the MG369XB in list sweep mode and configures the    */
/*           list sweep parameters, including the list number, the start index, the    */ 
/*           stop index, the dwell time and the trigger source.						   */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureListSweepFrequency (ViSession vi, 
					ViInt32 listNumber, ViInt32 startIndex, ViInt32 stopIndex, 
					ViReal64 dwellTime, ViInt32 triggerSource)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "LST, ELN%d, LIB%04d, LIE%04d, LDT %f SEC, %s;", listNumber, 
				startIndex, stopIndex, dwellTime, triggerSourceTable[triggerSource]));

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure Sweep List											           */
/*																			           */
/* Purpose:  This function sets the frequencies and power levels of the selected list  */
/*			 starting at the list index.                                               */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureSweepList (ViSession vi, 
					ViInt32 listNumber, ViInt32 listIndex, 
					ViInt32 numberOfFrequency, ViReal64 frequencyList[], 
					ViInt32 numberOfPowerLevel, ViReal64 powerLevelList[])
{
	ViStatus	status = VI_SUCCESS;
	ViInt32		i;

	/*- Check input parameter ranges --------------------------------------------------*/	
	CHECKPARAM (aumg369xb_invalidPointer (frequencyList), VI_ERROR_PARAMETER4);
	CHECKPARAM (aumg369xb_invalidPointer (powerLevelList), VI_ERROR_PARAMETER6);
	/*---------------------------------------------------------------------------------*/

	CHECKERR (viPrintf (vi, "LST, ELN%d, ELI%04d;", listNumber, listIndex));

	CHECKERR (viPrintf (vi, "LF"));
	for (i = 0; i < numberOfFrequency; i++)
	{
		CHECKERR (viPrintf (vi, "%Lf HZ", frequencyList[i]));
	}

	CHECKERR (viPrintf (vi, "LP"));
	for (i = 0; i < numberOfPowerLevel; i++)
	{
		CHECKERR (viPrintf (vi, "%f DM", powerLevelList[i]));
	}

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*- Master Slave Configuration --------------------------------------------------------*/

/*=====================================================================================*/
/* Function: Configure Master Slave Operation								           */
/*																			           */
/* Purpose:  This function turns on or turns off the master-slave mode of operation.   */
/*           If the master-slave mode is turned on, this function configures the slave */
/*           delta frequency, the slave main power level and the slave alternate sweep */
/*           power level.															   */
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureMasterSlaveOperation (ViSession vi,
					ViBoolean masterSlaveEnabled, ViReal64 slaveDeltaFrequency, 
					ViReal64 slaveMainPowerLevel, ViReal64 slaveAlternateSweepPowerLevel)
{
	ViStatus	status = VI_SUCCESS;

	CHECKERR (viPrintf (vi, "S%d;", masterSlaveEnabled ? 1 : 0));

	if (masterSlaveEnabled)
	{
		CHECKERR (viPrintf (vi, "SLDF %Lf HZ;", slaveDeltaFrequency));

		if (gPowerLevelUnit == AUMG369XB_UNIT_LINEAR_MV)
		{
			CHECKERR (viPrintf (vi, "SLL1 %f VT, SLL2 %f VT;", slaveMainPowerLevel,
						slaveAlternateSweepPowerLevel));
		}
		else
		{
			CHECKERR (viPrintf (vi, "SLL1 %f DM, SLL2 %f DM;", slaveMainPowerLevel,
						slaveAlternateSweepPowerLevel));
		}
	}

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure Slave Frequency List									           */
/*																			           */
/* Purpose:  This function configures the frequency list of the slave unit.			   */                                               
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureSlaveFrequencyList (ViSession vi,
					ViReal64 frequencyList[20])
{
	ViStatus	status = VI_SUCCESS;
	ViInt32		i;

	/*- Check input parameter ranges --------------------------------------------------*/	
	CHECKPARAM (aumg369xb_invalidPointer (frequencyList), VI_ERROR_PARAMETER2);
	/*---------------------------------------------------------------------------------*/

	for (i = 0; i < 10; i++)
	{
		CHECKERR (viPrintf (vi, "SLF%d %Lf HZ;", i, frequencyList[i]));
		CHECKERR (viPrintf (vi, "SLM%d %Lf HZ;", i, frequencyList[i + 10]));
	}

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;
}


/*=====================================================================================*/
/* Function: Configure Slave Frequency Entry								           */
/*																			           */
/* Purpose:  This function configures the selected slave frequency.			           */                                               
/*=====================================================================================*/
ViStatus _VI_FUNC aumg369xb_configureSlaveFrequencyEntry (ViSession vi,
					ViInt32 selectedFrequency, ViReal64 frequency)
{
	ViStatus	status = VI_SUCCESS;

	if (selectedFrequency < 10)
	{
		CHECKERR (viPrintf (vi, "SLF%d %Lf HZ;", selectedFrequency, frequency));
	}
	else
	{
		CHECKERR (viPrintf (vi, "SLM%d %Lf HZ;", selectedFrequency - 10, frequency));
	}

	CHECKERR (aumg369xb_checkStatus (vi));

Error:
	return status;

⌨️ 快捷键说明

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