Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%% Initialization Code
% This code must be used to initialize a scope object (a) to work with
% Initialize Scope
scope = KS_DSOX1204G('192.168.0.5');
%% Simple Data Acquisition Example
% Connect to Scope
scope.connect();
% Run Acquisition
% captureChannels(channels, timeRange, channelVoltRange)
% channels - List of the channels to capture on
% timeRange - Length of time, in seconds, to capture data for
% chanVoltRange - Voltage range for each channel, 3 options:
% -- [] (blank) - Use currently set range (from screen)
% -- 'auto' - Scope will auto-range-find
% -- [0, 4] - Range specified by min,max voltages
result1 = scope.captureChannels([1 2],[.005],{[], []});
% Disconnect from Scope
scope.disconnect();
% Plot the data
figure;
subplot(2,1,1);
plot(result1.Time_s, result1.Chan1_V,'-');
title("Channel 1");
ylabel("Volts");
subplot(2,1,2);
plot(result1.Time_s, result1.Chan2_V,':');
title("Channel 2");
xlabel('Time [s]');
ylabel("Volts");
%% Waveform Tests
% Connect to Scope
scope.connect();
% Setup and start sine wave output
% wave_startSine(freq, amplitude, offset)
% freq - Frequency [Hz] to generate the sine wave at
% amplitude- Sine wave amplitude [Volts] peak-to-peak
% offset - DC voltage offset (from sine wave centered at 0) [Volts]
scope.wave_startSine(1e3, 10,0);
% Run Acquisition
result = scope.captureChannels([1 2],[],{'auto', 'auto'});
% Stop the waveform output
scope.wave_stop();
% Disconnect from Scope
scope.disconnect();
% Plot Data
figure;
plot(result.Time_s, result.Chan1_V,':');
hold on;
plot(result.Time_s, result.Chan2_V,'-');
hold off;
legend({"Input", "Output"})
%% Frequency Analysis Test
% Connect to Scope
scope.connect();
% Run the Frequency Response Analysis on the Scope
% fra_run(fRange, points)
% fRange - Minimum and maximum frequency to sweep across
% points - The total number of frequency points (determines resolution)
resp = scope.fra_run([100 200000],20);
% Disconnect from Scope
scope.disconnect();
% Plot the results of the FRA
figure;
ax1 = subplot(2,1,1);
semilogx(resp.Frequency, resp.Gain_DB);
title('Gain Response');
ylabel('Gain [dB]');
grid on;
ax2 = subplot(2,1,2);
semilogx(resp.Frequency, resp.Phase_Deg);
title('Phase Response');
ylabel('Degrees');
xlabel('Frequency [Hz]');
grid on;
linkaxes([ax1, ax2],'x');