Jump to content
  • 0

DT9847-2-2 - Matlab operation


Paolo Neri

Question

I'm testing my DT9847-2-2, I connected analog output 0 to analog input 0 and, by using QuickDaq software, I'm able to produce a sinusoidal wave and to acquire it on the analog input. I'm also checking with an oscilloscope and the operation looks fine.

Now, I'm trying a simple matlab script (attached as .m file and copied at the bottom of the question) which should do exactly the same. If I plot the generated signal (i.e. dout, figure1) I can see the proper sinusoidal function, while if I plot the acquired analog input I see something like this:

image.png.bdc260db096774750417baf878863d6f.png

 

On the oscilloscope, I see the voltage going from 0 to -10 V, and then going back to 0 gradually when the command delete(s) is performed.

I installed version 7.8.9 of the DT software (I also tried version 7.8.2, same result) and I applied the fix to the scripts "AsyncOLChannel" and "ChannelGroupOL", which solved the first Matlab errors. 

Any suggestion? 

Thank you very much

 

 

MATLAB SCRIPT

%% Initialize DT DAQ

clear

close all

clc

dev = daq.getDevices(); % NEEDED to obtain correct Device Name for DT9847

devID = dev.ID; % ID for the DT9847

% Sets up session with the DT-DAQ (Needed to setup the session)

s=daq.createSession('dt');

Rate = 50000;

Duration = 2;

tout = 0:1/Rate:Duration;

fout = 10;

dout = 0.9*sin(2*pi*fout*tout).';

% Set Sampling Rate

s.Rate = Rate;

% Setup output channel as Voltage with the default range

chOut0 = addAnalogOutputChannel(s, devID,'0', 'Voltage');

chIn0 = addAnalogInputChannel(s, devID ,'0', 'Voltage');

% Queue the output to be output to the channel

queueOutputData(s, dout);

figure(1)

plot(dout)

% Transmit the output based on sampling rate and data samples queued

[din, tin] = startForeground(s);

delete (s);

figure(2)

plot(tin, din)

 

DT9847_InOut_Test.m

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

After some browisn on the forum, I followed the instruction provided at the link:

https://forum.digilent.com/topic/26056-data-translation-dt9847-analog-output-error-with-matlab/

 

I removed all the old installation, and installed the software provided in the message from JRis, Posted on June 23.

So far, it looks like I'm able to acquire the signal on analog input correctly, probably I had some old installation interfering with my scripts. Anyway, it is still needed to modify the functions "AsyncOLChannel" and "ChannelGroupOL", as explained by Fausto Soares  in the link:

https://it.mathworks.com/matlabcentral/answers/1693530-error-when-trying-to-start-acquisition-from-data-translation-device

 

 

Link to comment
Share on other sites

  • 0

Hello @Paolo Neri.

You are on the correct track to using the DT9847-2-2 with MATLAB.  

There is a known bug with the analog output when using DT Open Layers v7.8.9, so a user must revert back to DT Open Layers v7.8.2.  The DT DataAcq OMNI software can be downloaded from BOX using this link: https://datatranslation.box.com/s/8mrbkoxzyv8r9fbsadybvj0btxk2qbni

Regards,

Fausto

Link to comment
Share on other sites

  • 0

Thanks. Meanwhile, I tried to generate the output from the analog out and record it on the anolog input with the matalb script attached in my first post. I generate a sine wave and I expected to read it synchronously on the input. But I find that I have a (usually) small time delay in the recorded sine wave, so that the output channel seems to be not synchronized with the input: is there any specific code to synchronize the channels (both analog and digital, if possible)?

 

Thanks 

regards

Paolo 

Link to comment
Share on other sites

  • 0

I thought that the difference between background and foreground was Matlab waiting or not the comletion of the acquisition, isn't it? I whould perform some testing with background operation. Meanwhile, are the digital channels synchronized with respect to the analog? (i.e. digital input with analog input and digital output with analog output)

Link to comment
Share on other sites

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...