Generate and Measure Signals with Analog Devices ADALM1000
Updated Function Syntax
To accommodate the ADALM1000, the following Data Acquisition Toolbox™ functions allow vendor-specific argument options:
Source Voltage and Measure Current
This example shows how to source a voltage while measuring current on the same channel, to calculate load resistance. First program the ADALM1000 to provide a constant 5 V supply to the load, and then measure the current on the same device channel.
Discover your ADALM device and view its information.
dev = daqlist("adi")
dev = 1×4 table DeviceID Description Model DeviceInfo ________ _______________________________ ___________ ________________________ "SMU1" "Analog Devices Inc. ADALM1000" "ADALM1000" [1×1 daq.adi.DeviceInfo]
dev{1,"DeviceInfo"}
adi: Analog Devices Inc. ADALM1000 (Device ID: 'SMU1') Analog input supports: 0 to +5.0 Volts,-0.20 to +0.20 A ranges Rates from 100000.0 to 100000.0 scans/sec 2 channels ('A','B') 'Voltage','Current' measurement types Analog output supports: 0 to +5.0 Volts,-0.20 to +0.20 A ranges Rates from 100000.0 to 100000.0 scans/sec 2 channels ('A','B') 'Voltage','Current' measurement types
Set up a Data Acquisition Toolbox DataAcquisition to operate the ADALM100.
d = daq("adi")
d = DataAcquisition using Analog Devices Inc. hardware: Running: 0 Rate: 100000 NumScansAvailable: 0 NumScansAcquired: 0 NumScansQueued: 0 NumScansOutputByHardware: 0 RateLimit: [100000 100000]
Add an analog output channel to source voltage from device channel
A
.
addoutput(d,"SMU1","A","Voltage");
Add an analog input channel to measure current on the same device channel
A
.
addinput(d,"SMU1","A","Current");
View the channel configuration.
d.Channels
ans = Index Type Device Channel Measurement Type Range Name _____ ____ ______ _______ _____________________ __________________ __________ 1 "ao" "SMU1" "A" "Voltage (SingleEnd)" "0 to +5.0 Volts" "SMU1_A" 2 "ai" "SMU1" "A" "Current" "-0.20 to +0.20 A" "SMU1_A_1"
Generate an output voltage, and measure the current.
V_load = 5; write(d,V_load); I_load = read(d,"OutputFormat","Matrix"); write(d,0); % Reset device output. R_load = V_load/I_load
R_load = 50.3005
Tip
The ADALM1000 continues to generate the last value programmed until you release the hardware. When you are finished with your signals, reset the device to output 0 volts.
Generate a Pulse
This example shows how to generate a 1-millisecond, 5-volt pulse, surrounded on either side by 10 milliseconds at 0 volts.
pdata = zeros(2100,1); % Column vector of 2100 samples. pdata (1001:1100) = 5; % Pulse in middle of vector. d = daq("adi"); addoutput(d,"SMU1","B","Voltage");
write(d,pdata)
Generate Waveforms
This example shows how to simultaneously generate a 1-kHz square wave on channel A, and a 100 Hz sine wave on channel B. Each output lasts for 5 seconds.
The example requires two DataAcquisition channels for device channels A and B, both as output channels for voltage.
d = daq("adi"); addoutput(d,"SMU1","A","Voltage"); addoutput(d,"SMU1","B","Voltage");
Define the two waveforms.
Sq = zeros(500000,1); % Column vectors of 500k scans. Sw = zeros(500000,1); % Define square wave: for r = 1:100:499900; Sq(r:r+49) = 5; % Set first 50 of each 100 samples to 5 v. end % Define sine wave: Sw = sin(linspace(1,500000,500000)'*2*pi/1000); Sw = Sw + 1; % Shift for positive voltage output
View channel configuration.
d.Channels
ans = Index Type Device Channel Measurement Type Range Name _____ ____ ______ _______ _____________________ _________________ ________ 1 "ai" "SMU1" "A" "Voltage (SingleEnd)" "0 to +5.0 Volts" "SMU1_A" 2 "ai" "SMU1" "B" "Voltage (SingleEnd)" "0 to +5.0 Volts" "SMU1_B"
Start the output signal generation. The 500000 scans at 100000 scans per second lasts for 5 seconds.
write(d,[Sq Sw])