How can I perform data acquisition with Analog Discovery from Digilent?

I want to record square wave signals from a seperate waveform generator with Analog Discovery (Portable Analog Circuit Design Kit) from Digilent.
The official code for recording with an Analog Discovery does not work ( http://se.mathworks.com/help/daq/examples/getting-started-acquiring-data-with-digilent-analog-discovery.html?searchHighlight=analog%2520discovery ). Instead, the program is continuously busy when executing startForeground(s) and does not produce results.
The official code for waveform generation and acquisition at the same time ( http://se.mathworks.com/help/daq/examples/acquiring-and-generating-data-at-the-same-time-with-digilent-analog-discovery.html?searchHighlight=analog%25252520discovery ) works but allows only for a lower sample rate and takes too long to start measuring for my experiment. Which is why I would prefer to only record rather than outputting zero and recording the actual target signal simultaneously.
How can I fix this code?
s = daq.createSession('digilent');
ch = s.addAnalogInputChannel('ad1', 1, 'Voltage');
s.Rate = 1e6;
s.Channels.Range = [-2.5 2.5];
s.DurationInSeconds = 2;
[data, timestamps, triggerTime] = startForeground(s);
figure
plot(timestamps, data);
xlabel('Time (seconds)')
ylabel('Voltage (Volts)')
title(['Clocked Data Triggered on: ' datestr(triggerTime)])
Additional Info: I use the 1+ and 1- pins of the Analog discovery, the support package Digilent Analog Discovery 15.2.0 is installed, MATLAB version R2015b.

Réponses (1)

I had the same problem as you, using a script I made in January that previously had worked for me. The only thing that had changed for me was downloading the new support package version (15.2.0). Assuming the problem was the new support package, I tried to find a way to revert to the old version. I could not revert, so at minimum I tried uninstalling the package and reinstalling. Oddly enough, that worked for me. I don't think it matters, but I did the reinstall through MATLAB rather than mathworks.com. Also, not sure if it helps, but here is my test script:
clear all;
close all;
duration=3;
sRate=10000;
s=daq.createSession('digilent');
ch1=addAnalogInputChannel(s,'AD1',1,'Voltage');
s.Rate = sRate;
s.DurationInSeconds=duration;
s
disp('Single sample:');
pause;
inputSingleScan(s)
disp('Press enter to start acquisition...');
pause;
[data,timestamps] = s.startForeground;
disp('Acquisition complete...');
plot(timestamps,data);
ylim([-0.5 5.5 ]);
s.removeChannel(1);
clear ch1;
When testing with this script, the inputSingleScan(s) never failed, but before the reinstall the code would remain 'busy' during the s.startForeground.

1 commentaire

Ironically, it worked for me as well after reinstalling the software package. However, one other difference was I uninstalled Waveform 2015 as well.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simultaneous and Synchronized Operations dans Centre d'aide et File Exchange

Question posée :

le 17 Juil 2016

Commenté :

le 21 Juil 2017

Community Treasure Hunt

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

Start Hunting!

Translated by