Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Read voltage through NI-DMM MATLAB Instrument Driver in Simulation Mode

This example shows how to read voltage from a National Instruments® NI-DMM driver in the simulation mode.

Introduction

Instrument Control Toolbox™ supports communication with instruments through high-level drivers. In this example you can read voltage from a National Instruments® NI-DMM driver in the simulation mode.

Requirements

This example requires a Microsoft® Windows® system and NI-DMM package 3.06 or higher. Make sure the Measurement & Automation Explorer recognizes the NI-DMM device before you use this example.

Verify NI-DMM Installation

Use the instrhwinfo command to check if the NI-DMM software package is installed correctly. If installed correctly, NI-DMM is listed as one of the modules installed on the Windows machine. This example uses libraries installed with it.

driversInfo = instrhwinfo ('ivi');
disp(driversInfo.Modules');
    'AgNA'
    'nidcpower'
    'nidmm'
    'niFgen'
    'nisACPwr'
    'niScope'
    'nisCounter'
    'nisDCPwr'
    'nisDigitizer'
    'nisDmm'
    'nisDownconverter'
    'nisFGen'
    'nisPwrMeter'
    'nisRFSigGen'
    'nisScope'
    'nisSpecAn'
    'nisSwtch'
    'nisUpconverter'
    'niSwitch'
    'Tkdpo2k3k4k'

Create a MATLAB Instrument object

Use the icdevice function to create an instrument object from the MDD which was part of the NI-DMM support package, and establish a connection to the DMM using that object.

The icdevice function takes two or more input arguments. The MDD file name, the resource name for the DMM, and optionally, device-specific parameters that can be set.

You can get the resource name for the DMM from NI Measurement and Automation Explorer. For example: A resource name of PXI1Slot6 in NI MAX would be DAQ::PXI1Slot6 and Device 1 would be DAQ::Dev1. You can remove the optionstring argument and the corresponding string parameter if you have the actual hardware.

You can establish a connection to the DMM using the connect command.

ictObj = icdevice('niDMM.mdd', 'DAQ::Dev1', 'optionstring','simulate=true');
connect(ictObj);
disp(ictObj);
   Instrument Device Object Using Driver : niDMM
 
   Instrument Information
      Type:               IVIInstrument
      Manufacturer:       National Instruments Corp.
      Model:              National Instruments Digital Multimeters
 
   Driver Information
      DriverType:         MATLAB IVI
      DriverName:         niDMM
      DriverVersion:      1.0
 
   Communication State
      Status:             open

Configure the DMM

For the purpose of this example, the DMM is configured as

* Measurement Function: DC Voltage
* Range: 10V
* Resolution: 5.5 Digits

Use the MATLAB Instrument Driver Editor (midedit) to view other properties and functions that allow you to configure a device. The tool shows all the properties and functions that the NI-DMM software package supports.

measurementFunction = 1;
range = 10;
resolution = 5.5;

configuration = get(ictObj, 'configuration');
invoke(configuration, 'configuremeasurementdigits', measurementFunction, range, resolution);

Read and display the voltage

Once you configure the DMM with the required settings, use an appropriate function call to read the voltage.

% Configure DMM to calculate the timeout automatically
AutoTimeLimit = -1;

acquisition = get(ictObj, 'acquisition');
volts =  invoke(acquisition, 'read', AutoTimeLimit);

Display the read voltage

voltageDisplay = sprintf('Voltage : %d v', volts);
disp(voltageDisplay);
Voltage : 5.000032e+00 v

Clean up

Delete the MATLAB Instrument Object.

disconnect(ictObj);
delete(ictObj);
clear ictObj;