Read Waveforms from a Keysight® M9210A Digitizer using the IVI-C Driver
This example shows how to acquire a waveform from both channels of a Keysight technologies M9210A digitizer using an IVI-C driver, and display it in MATLAB. Instrument Control Toolbox™ software supports communication with instruments through IVI drivers. For a complete list of hardware supported, visit the Instrument Control Toolbox™ supported hardware page.
- Get Identification Information about the Instrument
- Verify the Driver is Installed
- Import the IVI-C Driver into MATLAB
- Initialize the Driver Object and Connect to the Digitizer
- Set Up the Digitizer to Acquire Waveforms on Channel 1 and Channel 2
- Acquire Data
- Plot the acquired signals
- Clean Up - Delete the MD1 Device Object
- Additional Information:
This example has been tested on Microsoft® Windows 7 and Windows XP Systems. Agilent IO Suite and MD1 IVI driver version 126.96.36.199 need to be installed.
Ensure that the instrument has been configured in the VISA utility (such as Agilent Connection Expert) before you execute this example.
Use INSTRHWINFO to find the instrument resource string
% Get the resource string from the Agilent VISA ObjectConstructorName and % verify it is the one used to communicate with the instrument agilentVisaInfo = instrhwinfo('visa', 'agilent'); resourceInfo = agilentVisaInfo.ObjectConstructorName
resourceInfo = 
If the AgMD1 driver is installed, it will show up in the list of installedDrivers
IviInfo = instrhwinfo('ivi'); installedDrivers = IviInfo.Modules
installedDrivers = Columns 1 through 6 'Ag33220' 'Ag3352x' 'Ag34410' 'Ag34970' 'Ag532xx' 'AgAC6800' Columns 7 through 11 'AgE36xx' 'AgInfiniiVision' 'AgMD1' 'AgRfSigGen' 'AgXSAn' Columns 12 through 13 'KtRFPowerMeter' 'rsspecan'
To use the installed IVI-C driver from MATLAB, a MATLAB driver needs to be created. The MATLAB driver needs to be created only once, and should exist on the MATLAB path
% Create the MATLAB driver makemid('AgMD1', 'AgMD1.mdd', 'ivi-c');
Using the MATLAB driver, a device object must be created first. Using the device object, a connection is established to the digitizer from MATLAB. In this example the driver is used in simulate mode. Set Simulate=false in the initOptions variable below to run this example with an actual instrument
initOptions = 'Simulate=true, DriverSetup= Cal=0, Trace=false, model=M9210A'; visaAddress = 'PXI17::10::0::INSTR'; myDigitizer = icdevice('AgMD1.mdd', visaAddress, 'optionstring', initOptions); % Connect to the digitizer using the device object created above connect(myDigitizer);
After the connection is established, properties such as input impedance, number of points per record, and sampling rate need to be set, prior to acquiring the waveforms on the digitizer. The values of the enumerated datatypes used can be found in the MD1 driver documentation
% Abort present acquisition if any invoke(myDigitizer.Waveformacquisitionlowlevelacquisition, 'abort'); % Set the input impedance values of the individual channels myDigitizer.RepCapIdentifier = 'Channel1'; myDigitizer.Channel.Input_Impedance = 50; % (Ohms) myDigitizer.RepCapIdentifier = 'Channel2'; myDigitizer.Channel.Input_Impedance = 50; % (Ohms) % Set the acquisition parameters numberOfRecords = 1; ptsPerRecord = 1e4; samplingRate = 2e9; invoke(myDigitizer.Configurationacquisition, 'configureacquisition',... numberOfRecords, ptsPerRecord, samplingRate); % Set the individual channel parameters Range = 0.2; Offset = 0.0; Coupling = 1; Enabled = true; invoke(myDigitizer.Configurationchannel, 'configurechannel', 'Channel1',... Range, Offset, Coupling, Enabled); invoke(myDigitizer.Configurationchannel, 'configurechannel', 'Channel2',... Range, Offset, Coupling, Enabled); % Set the trigger source, and trigger type myDigitizer.RepCapIdentifier = 'Channel1'; myDigitizer.Trigger.Active_Trigger_Source = 'External1'; % The hex value can be found in the MD1 driver documentation AGMD1_VAL_IMMEDIATE_TRIGGER = hex2dec('000003E9'); myDigitizer.Trigger.Trigger_Type = AGMD1_VAL_IMMEDIATE_TRIGGER; % Determine the minimum amount of memory needed to fetch or read data from % the digitizer for maximum performance dataWidth = 64; numRecords = 1; offsetWithinRecord = 0; numPointsPerRecord = ptsPerRecord; arrayElements = invoke(myDigitizer.Waveformacquisitionlowlevelacquisition,... 'queryminwaveformmemory', dataWidth, numRecords,... offsetWithinRecord, numPointsPerRecord); WaveformArray = zeros(arrayElements, 1);
To acquire data from channel 1 the READWAVEFORMREAL64 method is used. The READWAVEFORMREAL64 method initiates acquisition of a signal on both channel 1 and channel 2, but returns the waveform for channel 1 only. Following this, to read the already acquired waveform from channel 2, the FETCHWAVEFORMREAL64 method is used
maxTimeMilliseconds = 50; % Initiate an acquisition on all enabled channels, wait (up to % |maxTimeMilliseconds|) for the acquisition to complete, and return the % waveform for this channel [sig1, ActualPoints, FirstValidPoint, ~, ~, ~, XIncrement] = ... invoke(myDigitizer.Waveformacquisition, 'readwaveformreal64', ... 'Channel1', maxTimeMilliseconds, arrayElements, WaveformArray); sig1 = sig1(FirstValidPoint+1:FirstValidPoint+ActualPoints); % |FETCHWAVEFORMREAL64| returns a previously acquired waveform for the selected % channel. An acquisition must be made prior to calling this method. For % this case the previous call to |READWAVEFORMREAL64| has performed the waveform % acquisition already. Call this method separately for each channel [sig2, ActualPoints, FirstValidPoint, ~, ~, ~, ~] = ... invoke(myDigitizer.Waveformacquisitionlowlevelacquisition, ... 'fetchwaveformreal64', 'Channel2', arrayElements, WaveformArray); sig2 = sig2(FirstValidPoint+1:FirstValidPoint+ActualPoints);
The SUBPLOT feature of MATLAB is used to plot the waveforms read from channel 1 and channel 2 of the digitizer
% Create the time vector using the XIncrement value returned by the % |READWAVEFORMREAL64| method t = 0:XIncrement:(length(sig1)-1)*XIncrement; figure; % Plot the channel 1 waveform subplot(2, 1, 1); plot(t, sig1); xlabel('Time (s)'); ylabel('Voltage (V)'); ylim([-.2 0.2]); title('Digitizer Channel 1'); % Plot the channel 2 waveform subplot(2, 1, 2); plot(t, sig2); xlabel('Time (s)'); ylabel('Voltage (V)'); ylim([-.2 0.2]); title('Digitizer Channel 2');
After configuring the digitizer, and fetching/reading data from it, the device object needs to be closed and removed from the workspace
disconnect(myDigitizer); delete(myDigitizer); clear myDigitizer;
This example shows the setup and acquisition of data from a Digitizer using the IVI driver. Once the measured waveform is retrieved from the instrument, MATLAB can be used to visualize and perform analyses on the data using the rich library of functions in the Signal Processing Toolbox™ and Communications Systems Toolbox™. Using Instrument Control Toolbox™, it is possible to automate control of instruments, and, build test systems that use MATLAB to perform analyses that may not be possible using the built-in capability of the hardware.