You might want to access an API associated with hardware you have purchased. In this example, you call a hypothetical interface card for a databus called X-bus.

メモ You do not need to use the Call Library Function Node to gain access to the APIs of National Instruments hardware. All National Instruments products come with LabVIEW interfaces.

Configure the Call Library Function Node

The X-bus interface card comes with a software driver for your operating system. The X-bus documentation provides the following standard information:

  • A listing of all functions you can use to access the hardware
  • Description of the shared library file xbus.dll that contains these functions
  • Instructions on including a header file xbus.h
    メモ Although LabVIEW does not permit you to include such header files, you can open header files and extract information about function prototypes and constants.
  • (Windows) A statement about the Standard __stdcall calling convention that the X-bus library uses

One of the functions you want to use with this hypothetical hardware is XBusRead16, which reads a 16-bit integer from a certain address. The documentation describes XBusRead16 as follows:

long XBusRead16(unsigned long offset, short*data); Puts 16 bits from the register at "offset" into the memory location pointed to by "data." Returns 1 if successful, or 0 if it fails.

Given the preceding information from the X-bus documentation, complete the following steps to configure the LabVIEW Call Library Function Node.

  1. Open a new, blank VI and save the VI as Read Data.
  2. Place a Call Library Function Node on the block diagram.
  3. Right-click the Call Library Function Node object and select Configure from the shortcut menu.
  4. Make the following settings in the Call Library Function dialog box:
    1. Enter XbusRead16 in the Function name control.
    2. Select the stdcall (WINAPI) control from the Calling Convention field.
    3. Navigate to the Parameters page of the Call Library Function dialog box. Select Numeric from the Type pull-down menu for return type.
    4. Select Signed 32-bit Integer from the Data Type pull-down menu for return type.
    5. Add a parameter and name it offset.
    6. Select Numeric from the Type pull-down menu.
    7. Select Unsigned 32-bit Integer from the Data Type pull-down menu.
    8. Add a parameter and name it data.
    9. Select Numeric from the Type pull-down menu.
    10. Select Signed 16-bit Integer from the Data Type pull-down menu.
    11. Select Pointer to Value from the Pass pull-down menu.
  5. Inspect the function prototype that appears in the Function Prototype field. If the prototype you see does not match the definition of the function in the API you are calling, you must change your settings in the Call Library Function dialog box.

Place a numeric control, numeric indicator, and round LED indicator on the front panel window. Label the control and indicators and complete the block diagram as shown in the following block diagram and front panel.