1

im working on a transmitter with a Ni Daq and i have a little problem. I generate a period of my signal and i get it out with a queue output and i put a listener to call again the queue output, but this process take 0.1 seconds (call again the queue), so this is a big delay for a 1KHz signal for example, so how can i reduce this delay.

Here is my code :

clc;
clear all;
clc;

s = daq.createSession('ni');
s.addAnalogOutputChannel('Dev1',0,'Voltage');
s.IsContinuous = true;
fs=1000;
quality= 15;
fd=48000;
fs= fd * quality;
s.Rate = fs;
n=1;
A= 2;
y1=0;
y2=0;
wo= 2*pi*(fd/fs);
x=A*sin(wo);
pcos= 2*cos(wo);
out = [];
tic();
while(n<=quality),
    y= ((x)+(pcos*y1)-(y2));
    y2=y1;
    y1=y;
    out(n,1) = y+2.1;
    x=0;
    n=n+1;
end
toc()
plot(out,'*r');
grid on;
s.NotifyWhenScansQueuedBelow = lim;
lh = addlistener(s,'DataRequired', ...
        @(src,event) src.queueOutputData(out)); % Here is the delay
queueOutputData(s,out) 
startBackground(s);
  • 1
    From my experience, that should not take significant time. What is the value of lim? Your actual sampling rate is not 1khz, it’s 720khz and you are queuing 1sec of signal each time so 0.1 delay should not be a problem anyway – ThP Oct 02 '18 at 03:37

0 Answers0