How to generate the sine function for the DataAcquisition Digilent Analog Discovery tutorial?

2 views (last 30 days)
I'm trying to create a sine function to use in the DataAcquisition toolbox tutorial for the Digilent Analog Discovery 2. My plot does not resemble the plot in the tutorial so I think the issue is in how I am defining the sine function. Below is the link to the daq tutorial I am following and my code.
daqlist("digilent")
dq = daq("digilent");
% Create sine function
ch_fgen = addoutput(dq,"AD1","1","Sine");
ch_fgen.Name = "AD1_1_fgen";
gain = 5; % set channel gain to 5 (sets amp of sine wave to 5 volts)
ch_fgen.Gain = gain; % assign gain to a variable
ch_fgen.Frequency = 1000; % set signal frequency to 1kHz
% Add an analog input channel
ch_in = addinput(dq, "AD1", "1", "Voltage");
% Set data acquisition and channel properties
ch_in.Name = "AD1_1_in";
rate = 300e3;
dq.Rate = rate;
ch_in.Range = [-2.5 2.5];
% Acquire a single sample
[singleReading, startTime] = read(dq);
% Acquire timestamped data
[data, startTime] = read(dq, seconds(1));
% Plot acquired data
plot(data.Time, data.AD1_1_in)
xlabel('Time (s)')
ylabel('Voltage (V)')
title(['Clocked Data Triggered on: ' datestr(startTime)])

Answers (0)

Categories

Find more on Analog Input and Output in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!