Example 2 - Editing the Instrument Driver Attributes
- Updated2023-02-21
- 6 minute(s) read
You can launch the Attribute Editor at any time by selecting Tools»IVI Development»Edit IVI Specific Driver Attributes. The following figure shows the attributes that the Instrument Driver Development Wizard created for the Fluke 45 instrument driver.
The Fluke 45 driver you created using the Instrument Driver Development Wizard has attributes that are common to most DMMs. These attributes include basic instrument operations such as setting the measurement function, range, and resolution. The wizard also generates attributes for advanced DMM features such as configuring the trigger count and sample count. The attributes have example implementations for the help information, range tables, and callbacks. Much of the driver design is already done for you.
This example shows how to edit the attributes that the Instrument Driver Development Wizard creates. To complete the attributes for the Fluke 45, you must customize each attribute's example implementation for the Fluke 45, and delete the attributes that the Fluke 45 does not use.
Complete the following steps to customize the measurement function attribute and delete the attributes that the Fluke 45 does not use.
Customizing the Measurement Function Attribute
- In the Edit Driver Attributes dialog box, double-click the FUNCTION attribute. The Edit Attribute dialog box appears, as shown in the following figure.
Notice that the Instrument Driver Development Wizard has already filled in the attribute information. - Click Edit to edit the range table for the attribute.
The Edit Range Table dialog box appears, as shown in the following figure.
- Complete the following steps to modify the range table.
- Delete the following range table entries:
FL45_VAL_4_WIRE_RES
FL45_VAL_PERIOD
FL45_VAL_TEMPERATURE
These entries correspond to measurement functions that the Fluke 45 does not support. - Change the contents of the Command String control for the remaining entries as listed in the following table.
After you enter this information, the dialog box appears, as shown in the following figure.Original Contents New Contents FL45_VAL_DC_VOLTS "VDC" FL45_VAL_AC_VOLTS "VAC" FL45_VAL_DC_CURRENT "ADC" FL45_VAL_AC_CURRENT "AAC" FL45_VAL_2_WIRE_RES "OHMS" FL45_VAL_FREQ "FREQ" FL45_VAL_AC_PLUS_DC_VOLTS "VACDC" FL45_VAL_AC_PLUS_DC_CURRENT "AACDC"
- Delete the following range table entries:
- Click OK to return to the Edit Attribute dialog box.
- Click OK to return to the Edit Driver Attributes dialog box.
- Click Apply to apply the changes to the range table.
- Click Close in the Edit Driver Attributes dialog box to close the Attribute Editor.
For each range table entry you delete, you also must delete the corresponding value that the fl45.h header file defines. - Complete the following steps to delete the unused measurement function values that the fl45.h header file defines.
- Open the fl45.h file.
- Delete the following lines in the header file:
#define FL45_VAL_PERIOD IVIDMM_VAL_PERIOD
#define FL45_VAL_4_WIRE_RES IVIDMM_VAL_4_WIRE_RES
#define FL45_VAL_TEMPERATURE IVIDMM_VAL_TEMPERATURE - Save the header file.
Modifying the Write and Read Callbacks for the Measurement Function Attribute
- Select Tools»IVI Development»Edit IVI Specific Driver Attributes to return to the Edit Driver Attributes dialog box.
- Right-click the FUNCTION attribute and select Go to Write Callback.
The Write Callback for the FUNCTION attribute sends a command string to the instrument to set the measurement function to a specific value. The callback performs the following operations:
- Uses the range table to look up the instrument specific command that corresponds to the measurement function the callback receives in the value parameter.
- Writes the command string to the DMM.
- Enter the following code for the FL45AttrFunction_WriteCallback function.
static ViStatus _VI_FUNC FL45AttrFunction_WriteCallback (ViSession vi, ViSession io, ViConstString channelName, ViAttr attribute, ViInt32 value)
{ViStatus error = VI_SUCCESS;
ViString cmd;
checkErr (Ivi_GetViInt32EntryFromValue (value, &attrFunctionRangeTable, VI_NULL, VI_NULL, VI_NULL, VI_NULL, &cmd, VI_NULL));
viCheckErr (viPrintf (io, "%s;", cmd));Error:
return error;
}
- Select Tools»IVI Development»Edit IVI Specific Driver Attributes to return to the Edit Driver Attributes dialog box.
- Right-click the FUNCTION attribute and select Go To Read Callback.
The Read Callback for the FUNCTION attribute queries the instrument for the present measurement function setting. The callback performs the following operations:
- Sends the FUNC1? query to the DMM. This command instructs the Fluke 45 to return the measurement function it is currently using.
- Reads the response from the instrument.
- Uses the range table to look up the value that corresponds to the string the instrument returns.
Enter the following code for the FL45AttrFunction_ReadCallback function.
static ViStatus _VI_FUNC FL45AttrFunction_ReadCallback (ViSession vi, ViSession io, ViConstString channelName, ViAttr attribute, ViInt32 *value)
{ViStatus error = VI_SUCCESS;
ViChar rdBuffer[BUFFER_SIZE];
ViInt32 rdBufferSize = sizeof(rdBuffer);/* Read measurement function from instrument */
viCheckErr (viPrintf (io, "FUNC1?;"));
viCheckErr (viScanf (io, "%#s", &rdBufferSize, rdBuffer));
checkErr (Ivi_GetViInt32EntryFromString (rdBuffer, &attrFunctionRangeTable, value, VI_NULL, VI_NULL, VI_NULL, VI_NULL));Error:
return error;
}
- Save the source file.
Deleting Unused Attributes
The Fluke 45 is a simple DMM. It does not use all the attributes that the Instrument Driver Development Wizard creates for DMM instrument drivers. You must delete the attributes that the instrument does not use, the range tables that correspond to the attributes, and the values that the fl45.h header file defines for the range tables.
Complete the following steps to delete the attributes that the Fluke 45 does not use.
- Select Tools»IVI Development»Edit Instrument Attributes to invoke the Attribute Editor.
- For each of the following attributes, select the attribute and click Cut.
SAMPLE_COUNT
SAMPLE_TRIGGER
SAMPLE_INTERVAL
TRIGGER_COUNT
TRIGGER_SLOPE
MEAS_COMPLETE_DEST
AUTO_ZERO
POWERLINE_FREQ - Select Multipoint Acquisition and click Cut.
- Click Apply to apply these changes in the instrument driver files.
The Attribute Editor asks whether you want to delete the callbacks for each attribute. For each callback, the Generate Code dialog box appears, as shown in the following figure.
- Click Delete for each callback.
Complete the following steps to delete the range tables that correspond to the attributes.
- From the Edit Driver Attributes dialog box, click Range Tables.
- In the Range Tables dialog box, delete each of the following range tables by selecting it in the list box and clicking Cut.
attrAutoZeroRangeTable
attrMeasCompleteDestRangeTable
attrPowerlineFreqRangeTable
attrSampleCountRangeTable
attrSampleIntervalRangeTable
attrSampleTriggerRangeTable
attrTriggerCountRangeTable
attrTriggerSlopeRangeTable - Click OK to return to the Edit Driver Attributes dialog box.
- Click Apply to apply the range tables changes in the instrument driver files.
- Click Close on the Edit Driver Attributes dialog box to close the Attribute Editor.
Complete the following steps to delete the defined constants for values that the Fluke 45 does not use.
- Open the fl45.h file.
- Delete the following sections of defined constants from the header file.
Section 1:
/*- Defined values for attribute FL45_ATTR_AUTO_ZER0 -*/
#define FL45_VAL_AUTO_ZERO_OFF IVIDMM_VAL_AUTO_ZERO_OFF
#define FL45_VAL_AUTO_ZERO_ON IVIDMM_VAL_AUTO_ZERO_ON
#define FL45_VAL_AUTO_ZERO_ONCE IVIDMM_VAL_AUTO_ZERO_ONCE
Section 2:
/*- Defined values for attribute FL45_ATTR_POWERLINE_FREQ -*/
#define FL45_VAL_50_HERTZ IVIDMM_VAL_50_HERTZ
#define FL45_VAL_60_HERTZ IVIDMM_VAL_60_HERTZ
#define FL45_VAL_400_HERTZ IVIDMM_VAL_400_HERTZ
Section 3:
/*- Defined value for attribute FL45_ATTR_SAMPLE_TRIGGER -*/
/* #define FL45_VAL_IMMEDIATE DEFINED ABOVE */
/* #define FL45_VAL_EXTERNAL DEFINED ABOVE */
/* #define FL45_VAL_GPIB_GET DEFINED ABOVE */
#define FL45_VAL_INTERVAL IVIDMM_VAL_INTERVAL
/* #define FL45_VAL_TTL0 DEFINED ABOVE */
/* #define FL45_VAL_TTL1 DEFINED ABOVE */
/* #define FL45_VAL_TTL2 DEFINED ABOVE */
/* #define FL45_VAL_TTL3 DEFINED ABOVE */
/* #define FL45_VAL_TTL4 DEFINED ABOVE */
/* #define FL45_VAL_TTL5 DEFINED ABOVE */
/* #define FL45_VAL_TTL6 DEFINED ABOVE */
/* #define FL45_VAL_TTL7 DEFINED ABOVE */
/* #define FL45_VAL_ECL0 DEFINED ABOVE */
/* #define FL45_VAL_ECL1 DEFINED ABOVE */
/* #define FL45_VAL_PXI_STAR DEFINED ABOVE */
Section 4:
/*- Defined values for attribute FL45_ATTR_TRIGGER_SLOPE -*/
#define FL45_VAL_POS IVIDMM_VAL_POS
#define FL45_VAL_NEG IVIDMM_VAL_NEG
Section 5:
/*- Defined values for attribute FL45_ATTR_MEAS_COMPLETE_DEST -*/
#define FL45_VAL_NONE IVIDMM_VAL_NONE
/* #define FL45_VAL_TTL0 DEFINED ABOVE */
/* #define FL45_VAL_TTL1 DEFINED ABOVE */
/* #define FL45_VAL_TTL2 DEFINED ABOVE */
/* #define FL45_VAL_TTL3 DEFINED ABOVE */
/* #define FL45_VAL_TTL4 DEFINED ABOVE */
/* #define FL45_VAL_TTL5 DEFINED ABOVE */
/* #define FL45_VAL_TTL6 DEFINED ABOVE */
/* #define FL45_VAL_TTL7 DEFINED ABOVE */
/* #define FL45_VAL_ECL0 DEFINED ABOVE */
/* #define FL45_VAL_ECL1 DEFINED ABOVE */
/* #define FL45_VAL_PXI_STAR DEFINED ABOVE */ - Save the source file.