Jump to content
  • 0

Different Results in measurement seconds apart


lvogl

Question

I wanted to do a basic function check with the Discovery 2 and with help of a Matlab script generate a sine wave and then read that wave with the ociloscope. 

The Matlab code used is the same as given in the tutorial: Acquiring and Generating Data at the Same Time with Digilent Analog Discovery 

daqlist("digilent")

dq = daq("digilent")

addoutput(dq, "AD1", "1", "Voltage");
addoutput(dq, "AD1", "2", "Voltage");
ch_out = dq.Channels(1:2);
ch_out(1).Name = "AD1_1_out";
ch_out(2).Name = "AD1_2_out"

addinput(dq, "AD1", "1", "Voltage");
addinput(dq, "AD1", "2", "Voltage");
ch_in = dq.Channels(3:4);
ch_in(1).Name = "AD1_1_in";
ch_in(2).Name = "AD1_2_in"

rate = 300e3;
dq.Rate = rate;

f = 10;
totalduration = 0.5;
n = totalduration * rate;
t = (1:n)/rate;
output = sin(2*pi*f*t)';

[data, startTime] = readwrite(dq, [output output]);

plot(data.Time, data.AD1_1_in, data.Time, data.AD1_2_in);

xlabel('Time (s)');
ylabel('Voltage (V)');
title(['Clocked Data Triggered at: ' datestr(startTime)])

When the results represent the wanted sine wave they have an offset and seconds after running the script the results change entierly to something wrong. Below I added screenshots of the different results. All the jumpercables are solidly connected on a bread board.

Thank you for any help!

image.png.4027aadaf1e31ef2cb57041d27ee9fee.pngimage.png.c93b245f202d9deae6618c111073347b.pngimage.png.82cc32a06fd0fdf3fd1ab1c796d3cb8e.png

image.png.f7eee300b1b84f7e910257bd9fcc807f.png

image.png.085d770c376bb7419ae644bc5fc43313.png

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...