📄 fl45.c
字号:
checkErr( Ivi_LockSession (vi, VI_NULL)); /* Set attributes: */ viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_FUNCTION, 0, measFunction), 2, "Measurement Function"); viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_SECONDARY_FUNCTION, 0, secondMeasFunction), 4, "Secondary Measurement Function"); /* For the FL45, the resolution needs to be set before the range since the range is dependent on the resolution. */ viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_RESOLUTION, 0, resolution), 4, "Resolution"); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_RANGE, 0, range), 3, "Range"); /* Set the AC min/max frequencies only if configuring an AC measurement */ switch (measFunction) { case FL45_VAL_AC_VOLTS: case FL45_VAL_AC_CURRENT: case FL45_VAL_AC_PLUS_DC_VOLTS: case FL45_VAL_AC_PLUS_DC_CURRENT: viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_AC_MIN_FREQ, 0, acMinFreq), 5, "AC Min Frequency"); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_AC_MAX_FREQ, 0, acMaxFreq), 6, "AC Max Frequency"); break; } checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession(vi, VI_NULL); return error;}/***************************************************************************** * Function: FL45_ConfigureTrigger * Purpose: Configures the common DMM trigger attributes. These attributes * are FL45_ATTR_TRIGGER_SOURCE and * FL45_ATTR_TRIGGER_DELAY. *****************************************************************************/ViStatus _VI_FUNC FL45_ConfigureTrigger (ViSession vi, ViInt32 triggerSource, ViReal64 triggerDelay){ ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); /* Set attributes: */ viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_TRIGGER_SOURCE, 0, triggerSource), 2, "Trigger Source"); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_TRIGGER_DELAY, 0, triggerDelay), 3, "Trigger Delay"); checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession(vi, VI_NULL); return error;}/**************************************************************************** * Function: FL45_ConfigureCompare * Purpose: Uses the value passed as the compare high and low values,then activates * Compare mode ****************************************************************************/ViStatus _VI_FUNC FL45_ConfigureCompare (ViSession vi, ViBoolean compareEnable, ViReal64 low, ViReal64 high) { ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); checkErr( Ivi_SetAttributeViBoolean (vi, VI_NULL, FL45_ATTR_COMPARE_ENABLE, 0, compareEnable)); /* Only set these attributes if the compare modifier is enabled. Else setting these would be a waste of I/O time. */ if (compareEnable) { viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_COMPARE_LOW, 0, low), 3, "Compare Low Value"); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_COMPARE_HIGH, 0, high), 2, "Compare High Value"); } checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession (vi, VI_NULL); return error; }/**************************************************************************** * Function: FL45_ConfigureDecibel * Purpose: Sets DMM to a decibel mode and sets the reference impedance. ****************************************************************************/ViStatus _VI_FUNC FL45_ConfigureDecibel (ViSession vi, ViInt32 dbMode, ViInt32 impedance) { ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); if (dbMode == FL45_VAL_DB_OFF) checkErr( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_DB_MODE, 0, FL45_VAL_DB_OFF)); else { /* First set the dB Reference to the lowest value possible so that no error is generated when changing dB mode to a mode that has a smaller reference range. */ checkErr( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_DB_REF, 0, FL45_VAL_2_OHMS)); viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_DB_MODE, 0, dbMode), 2, "Decibel Mode Type"); viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_DB_REF, 0, impedance), 3, "Decibel Reference Impedance"); } checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession (vi, VI_NULL); return error; }/**************************************************************************** * Function: FL45_ConfigureHold * Purpose: Configures the DMM's hold capability. ****************************************************************************/ViStatus _VI_FUNC FL45_ConfigureHold (ViSession vi, ViBoolean holdEnable, ViInt32 holdThreshold) { ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); viCheckParm( Ivi_SetAttributeViBoolean (vi, VI_NULL, FL45_ATTR_HOLD_ENABLE, 0, holdEnable), 2, "Hold Enable"); if (holdEnable) viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_HOLD_THRESHOLD, 0, holdThreshold), 3, "Hold Threshold"); checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession (vi, VI_NULL); return error; }/**************************************************************************** * Function: FL45_ConfigureMinMax * Purpose: Sets the DMM to min or max mode and set the appropriate value. ****************************************************************************/ViStatus _VI_FUNC FL45_ConfigureMinMax (ViSession vi, ViInt32 minMax, ViReal64 minValue, ViReal64 maxValue) { ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); if (minMax == FL45_VAL_MAX_MODE) { /* Since we want to set both the minimum and the maximum attribute. We first have to set the min-max modifier to min, set the initial minimum, reset the min-max modifier to max, and then set the initial maximum value. Any other way would cause configuration errors. */ checkErr( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MODE, 0, FL45_VAL_MIN_MODE)); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MIN, 0, minValue), 3, "Minumum Value"); viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MAX, 0, minMax), 2, "Min-Max Mode"); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MAX, 0, maxValue), 4, "Maximum Value"); } else if (minMax == FL45_VAL_MIN_MODE) { /* Same comment as the "if" case in reverse other. */ checkErr( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MODE, 0, FL45_VAL_MAX_MODE)); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MAX, 0, maxValue), 4, "Maximum Value"); viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MAX, 0, minMax), 2, "Min-Max Mode"); viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MIN, 0, minValue), 3, "Minumum Value"); } else viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_MIN_MAX_MODE, 0, minMax), 2, "Min-Max Mode"); checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession (vi, VI_NULL); return error; }/**************************************************************************** * Function: FL45_ConfigureRelative * Purpose: Uses the value passed as the relative base value,then activates * Relative mode ****************************************************************************/ViStatus _VI_FUNC FL45_ConfigureRelative (ViSession vi, ViBoolean relEnable, ViReal64 value) { ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); checkErr( Ivi_SetAttributeViBoolean (vi, VI_NULL, FL45_ATTR_RELATIVE_ENABLE, 0, relEnable)); if (relEnable) viCheckParm( Ivi_SetAttributeViReal64 (vi, VI_NULL, FL45_ATTR_RELATIVE_BASE, 0, value), 2, "Relative Base Value"); checkErr( FL45_CheckStatus (vi)); Error: Ivi_UnlockSession (vi, VI_NULL); return error; } /***************************************************************************** * Function: FL45_Measure * Purpose: Configures the specified measurement function, and reads the result. *****************************************************************************/ViStatus _VI_FUNC FL45_Measure (ViSession vi, ViInt32 measFunction, ViInt32 maxTime, ViReal64 *reading){ ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); if (reading == VI_NULL) viCheckParm( IVI_ERROR_INVALID_PARAMETER, 4, "Null address for Reading."); viCheckParm( Ivi_SetAttributeViInt32 (vi, VI_NULL, FL45_ATTR_FUNCTION, 0, measFunction), 3, "Measurement Function"); checkWarn (FL45_Read (vi, maxTime, reading)); /* Do not invoke the FL45_CheckStatus function here. It is invoked by the FL45_Read function. */ Error: Ivi_UnlockSession(vi, VI_NULL); return error; }/***************************************************************************** * Function: FL45_Read * Purpose: Initiates a measurement and fetches the result. *****************************************************************************/ViStatus _VI_FUNC FL45_Read (ViSession vi, ViInt32 maxTime, ViReal64 *reading)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -