Writing an Instrument Driver
- Updated2023-02-21
- 3 minute(s) read
You can develop the pieces of an instrument driver in several different sequences. For more information about how to perform the individual steps in the procedure, refer to the Function Tree Editor, Function Panel Editor, and Help Editor Window topics of the LabWindows/CVI Help. You can use the Instrument Driver Development Wizard and the Attribute Editor to automate developing the instrument driver.
When you use the wizard to build a driver for instruments including oscilloscopes, digital multimeters, function generators, switches, or power supplies, you can select a predefined template that defines common functions and attributes for these types of instruments. The wizard generates a function panel (.fp) file, a source (.c) file, an include (.h) file, and a .sub file for you.
To write the driver for your specific instrument, complete the following steps:
- Name the instrument driver.
- Define the attributes. The wizard automates this task when you use a template.
- Define the instrument functions and function classes. The wizard automates this task when you use a template.
- Create a function tree for the instrument driver, adding help information to the top level of the tree. The wizard automates this task when you use a template.
- For each function in the driver, complete the following steps:
- Define the parameters to the function, including variable types and limits, and error codes. The wizard automates this task when you use a template.
- Create the function panel for the function. Include help information for the panel and for each control. The wizard automates this task when you use a template.
- Write the code to perform the function.
- Test the source code.
- Create the include file for the final instrument source code, including function declarations and constant definitions. The wizard automates this task when you use a template.
- Operate the completed driver using function panels.
- Document the driver.
Naming the Driver
The instrument drivers you create join the large set of LabWindows/CVI instrument drivers. Give unique and meaningful names to the driver and its routines to avoid conflicts with the other instrument drivers and routines. Create a descriptive name and assign an instrument prefix. Insert the prefix before each function name in the driver and use the prefix to name the component files (.c, .h, .fp, and .sub) of the driver.
The descriptive name should be a short description of the driver. This name appears in the Instrument menu and in the Instruments folder in the Library Tree. Examples of such descriptive names are Tektronix 3000 Series Oscilloscopes and HPE1411B Digital Multimeter.
Create the instrument prefix by using a two-character vendor code followed by characters that uniquely identify the driver. Vendors register their two-character codes with the VXIplug&play Alliance. The VXIplug&play specification, VPP-9: Instrument Vendor Abbreviations, contains a list of the two-character codes. For example, suppose you write an instrument driver for the Agilent 34401A digital multimeter. Since AG is the vendor code for Agilent, a unique prefix is ag34401a. The files that comprise the instrument driver would be ag34401a.c, ag34401a.h, ag34401a.fp, ag34401a.sub, and ag34401a.doc. Furthermore, the driver function names each have the prefix ag34401a added to them, for example, ag34401a_ConfigureTrigger. Because the prefix is appended to all functions, attribute IDs, and value definitions, the prefix should be relatively short.
![]() |
Note The instrument prefix must have 31 characters or fewer. LabWindows/CVI adds an underscore ( _ ) separator to the 31-character prefix before appending the function name to the prefix. |