Instrument Control Toolbox
This example shows how to acquire digital waveform from a National Instruments NI-SCOPE driver in the simulation mode.
Instrument Control Toolbox™ supports communication with instruments through high-level drivers. In this example you can acquire digital waveforms from a National Instruments NI-SCOPE driver in the simulation mode.
This example requires a Microsoft Windows system and NI-SCOPE package 3.6 or higher. Make sure the Measurement & Automation Explorer recognizes the NI-SCOPE driver before you use this example.
Use the instrhwinfo command to check if the NI-SCOPE software package is installed correctly. This example uses libraries installed with it.
NI-SCOPE is an IVI-C compliant driver, and is listed as one of the modules installed on the Windows machine.
driversInfo = instrhwinfo ('ivi'); disp(driversInfo.Modules');
'niScope' 'nisDCPwr' 'nisDmm' 'nisFGen' 'nisScope' 'nisSwtch'
Before you use an IVI-C driver, create a MATLAB Instrument Driver (MDD) for it, using the makemid function.
makemid takes the IVI-C module name as the input and outputs the MDD file in the present working directory (pwd).
Use the icdevice function to create an instrument object from the MDD you generated, and establish a connection to the scope using that object.
icdevice function takes two or more input arguments. The MDD file name, the resource name for the scope and optionally, device-specific parameters that can be set.
You can get the resource name for the scope 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 arugment and the corresponding string parameter if you have the actual hardware.
You can establish a connection to the scope using the connect command.
ictObj = icdevice('niScope.mdd', 'DAQ::Dev1', 'optionstring','simulate=true'); connect(ictObj); disp(ictObj);
Instrument Device Object Using Driver : niScope Instrument Information Type: IVIInstrument Manufacturer: National Instruments Corp. Model: NI Digitizers Driver Information DriverType: MATLAB IVI DriverName: niScope DriverVersion: 1.0 Communication State Status: open
For the purpose of this example, the scope is configured using auto setup which automatically sets the vertical range, sample rate, trigger level and few other settings.
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-SCOPE software package supports.
configuration = get(ictObj, 'configuration'); invoke(configuration, 'autosetup');
Waveform information is a structure containing the timing information, number of samples, gain, and offset scaling factors for acquiring a waveform from the scope. For the purpose of this example, we are acquiring 1024 samples at a sampling rate of 0.1 seconds.
waveformInfo.absoluteInitialX = 0; waveformInfo.relativeInitialX = 0; waveformInfo.xIncrement = 0.1; waveformInfo.actualSamples = 1024; waveformInfo.gain = 1; waveformInfo.reserved1 = 0; waveformInfo.reserved2 = 0;
Once you configure the scope with the required settings, use an appropriate function call to acquire the waveform from channel 0.
waveformArray = zeros(1, 1024); acquisition = get(ictObj, 'Acquisition'); channelList ='0'; [waveformArray , waveformInfo] = invoke(acquisition, 'fetchbinary16',channelList, 10, 1024, waveformArray, waveformInfo);
Delete the MATLAB Instrument Object.
disconnect(ictObj); delete (ictObj); clear ictObj;