Main Content

Fetch Waveform Through NI-SCOPE MATLAB Instrument Driver in Simulation Mode

This example shows how to acquire digital waveforms from two channels of a National Instruments® NI-SCOPE driver in the simulation mode and display the waveforms in MATLAB®.

Requirements

To run this example, you must have the following installed on your computer:

  • NI-SCOPE Instrument driver version 21.0

  • LabWindows™/CVI software version 2020 (Make sure that you also additionally install NI-SCOPE Support for LabWindows/CVI option listed under additional items using LabWindows™/CVI installer)

Make sure the Measurement & Automation Explorer recognizes the NI-SCOPE driver before you use this example.

Verify NI-SCOPE Installation

Use the ividriverlist command to check if the NI-SCOPE software package is installed correctly. If installed correctly, NI-SCOPE is listed as one of the modules installed on the Windows machine.

list = ividriverlist
list=14×4 table
             VendorDriver          MATLABDriver            IVIClass                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        SupportedModels                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
          __________________    __________________    __________________    _____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

    1     "IviACPwr"            "IviACPwr"            "IVIACPwr"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    2     "IviCounter"          "IviCounter"          "IVICounter"          {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    3     "IviDCPwr"            "IviDCPwr"            "IVIDCPwr"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    4     "IviDigitizer"        "IviDigitizer"        "IVIDigitizer"        {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    5     "IviDmm"              "IviDmm"              "IVIDmm"              {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    6     "IviDownconverter"    "IviDownconverter"    "IVIDownconverter"    {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    7     "IviFgen"             "IviFgen"             "IVIFgen"             {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    8     "IviPwrMeter"         "IviPwrMeter"         "IVIPwrMeter"         {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    9     "IviRfSigGen"         "IviRfSigGen"         "IVIRfSigGen"         {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    10    "IviScope"            "IviScope"            "IVIScope"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    11    "IviSpecAn"           "IviSpecAn"           "IVISpecAn"           {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    12    "IviSwtch"            "IviSwtch"            "IVISwtch"            {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    13    "IviUpconverter"      "IviUpconverter"      "IVIUpconverter"      {[""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ]}
    14    "niScope"             "niScope"             "IVIScope"            {["NI PCI-5105"    "NI PCI-5114"    "NI PCI-5122"    "NI PCI-5124"    "NI PCI-5142"    "NI PCI-5152"    "NI PCI-5153"    "NI PCI-5154"    "NI PCI-5922"    "NI PCIe-5155"    "NI PXI-5105"    "NI PXI-5114"    "NI PXI-5122"    "NI PXI-5124"    "NI PXI-5124EX"    "NI PXI-5142"    "NI PXI-5152"    "NI PXI-5153"    "NI PXI-5154"    "NI PXI-5900"    "NI PXI-5922"    "NI PXI-5922EX"    "NI PXIe-5105"    "NI PXIe-5110"    "NI PXIe-5111"    "NI PXIe-5113"    "NI PXIe-5114"    "NI PXIe-5122"    "NI PXIe-5160"    "NI PXIe-5160 (2CH)"    "NI PXIe-5160 (4CH)"    "NI PXIe-5162"    "NI PXIe-5162 (2CH)"    "NI PXIe-5162 (4CH)"    "NI PXIe-5163"    "NI PXIe-5164"    "NI PXIe-5170R (4CH)"    "NI PXIe-5170R (8CH)"    "NI PXIe-5171R (8CH)"    "NI PXIe-5172 (4CH - 325T)"    "NI PXIe-5172 (8CH - 325T)"    "NI PXIe-5172 (8CH - 410T)"    "NI PXIe-5185"    "NI PXIe-5186"    "NI PXIe-5622"    "NI PXIe-5622 (25MHz DDC)"    "NI USB-5132"    "NI USB-5133"]}

Connect to Instrument

Connect to a simulated NI scope using ividev with the instrument's MATLAB driver name and resource name. This example uses the niScope driver's simulation mode to run without physically connecting any hardware. Since simulation mode is enabled, the resource name can be specified as empty.

dev = ividev("niScope","",Simulate=true)
dev = 
  niScope with properties:

                     Model: "NI PXI-5122" 
              Manufacturer: "National Instruments" 
              SerialNumber: "" 
              ResourceName: "" 
              VendorDriver: "niScope" 
                  Simulate: 1 

                ChannelIDs: ["0", "1"] 
           FIFOEndpointIDs: [] 

               Acquisition: [1x1 Acquisition] 
                  Vertical: [1x1 Vertical] 
                Horizontal: [1x1 Horizontal] 
                Triggering: [1x1 Triggering] 
                    Device: [1x1 Device] 
                  Clocking: [1x1 Clocking] 
           Synchronization: [1x1 Synchronization] 
      WaveformMeasurements: [1x1 WaveformMeasurements] 
    InstrumentCapabilities: [1x1 InstrumentCapabilities] 
            DeviceSpecific: [1x1 DeviceSpecific] 
     InherentIVIAttributes: [1x1 InherentIVIAttributes] 
    OnboardSignalProcesing: [1x1 OnboardSignalProcesing] 
                PeerToPeer: [] 

Show all functions

Configure Measurement Parameters

Reset the instrument to a known state and automatically configure the measurement parameters. The scope is configured using auto setup which automatically sets the vertical range, sample rate, trigger level, and a few other settings.

reset(dev);
autoSetup(dev);

Configure Vertical Range

configureVertical function configures the most commonly configured attributes of the digitizer vertical subsystem, such as the range, offset, coupling, probe attenuation, and the channel. We will be fetching data from channels '0' and '1' and therefore configuring these channels. Refer to the NI-Scope documentation for further information.

Range = 10;
Offset = 0;
ProbeAttenuation = 1;

Configure Channel 0.

configureVertical(dev,"0",Range,Offset,"DC",ProbeAttenuation,true); 

Configure Channel 1.

configureVertical(dev,"1",Range,Offset,"DC",ProbeAttenuation,true);

Fetch Waveform

Once you configure the scope with the required settings, use an appropriate function call to acquire the waveform from channels 0 and 1. Prior to fetching data, a waveform acquisition has to be initiated.

Specify number of samples and timeout duration.

numSamples = 1024;
TimeOut = 1000; % millisec

Initiate acquisition.

initiateAcquisition(dev);

Fetch waveforms from Channel 0 and Channel 1.

[waveformArrayCh0, waveformInfoCh0] = fetch(dev,"0",TimeOut,numSamples);
[waveformArrayCh1, waveformInfoCh1] = fetch(dev,"1",TimeOut,numSamples);

Visualize Data

Create a time vector.

t = (0:waveformInfoCh0.actualSamples-1)*waveformInfoCh0.xIncrement;

Plot the waveforms.

plot(t,waveformArrayCh0,t,waveformArrayCh1);
grid on;
xlabel("Time (s)");
ylabel("Volts (V)");
legend("Channel 0","Channel 1");

Clean Up

Disconnect and clear the ividev object from the workspace.

clear dev

See Also

| |

Related Topics