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.
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.
Question
lvogl
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!
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 accountSign in
Already have an account? Sign in here.
Sign In Now