I am facing the same problem as you, did you find any solution as how to continuosly change the output signal without stopping it?
"Mike" wrote in message <jh29ai$7jj$1@newscl01ah.mathworks.com>...
> I have an NI USB DAQ and I can continuously generate a signal. I need to be able to continuously generate a signal and change the frequency from when desired, while still generating a signal. I have not been able to figure out how to change the frequency without shutting down the output first. This is the code I use to continuously generate the data:
>
> function [source, lh] = daqWvformControl(freq, signalVoltPk, squareWv, sampleRate, Dur)
> source = daq.createSession('ni');
> source.IsContinuous = true;
> source.addAnalogOutputChannel('Dev1', 0, 'Voltage');
>
> source.Rate = sampleRate; %in Hz
>
> Npts = round(Dur*source.Rate);
>
> x = (0:(Npts1))/source.Rate;
>
> data = signalVoltPk*sin(freq*2*pi*x); data=data(:);
>
> if squareWv == 1;
> data(data < 0) =  signalVoltPk; % Convert sin wave to square wave
> data(data > 0) = signalVoltPk;
> end
> source.queueOutputData(data);
> lh = source.addlistener('DataRequired', @(src, event)src.queueOutputData(data));
> source.startBackground();
>
> I know it is possible to continously generate the sine wave and also change the frequency of the output signal from the forums, but I have not found the method with matlab... I'd think it is something in changing the queueOutputData, but I can't seem to get that to work... I also need to do it with amplitude, but I imagine the methods will be related.
>
> Thanks for the help
