Using write function of Data Acquisition Toolbox won't generate a continuous wave.

1 visualización (últimos 30 días)
Hello everyone, I'm trying to build a GUI in matlab that enables me to read a signal from an input channel of my DAQ device (Rogadaq2) which I managed to do already. Additionally, I'm trying to write a desired sin wave to the output channel using the "write" function, however, the signal written is not really continuous. This is a big problem, especially because I need to compute the FFT of this signal. The figure with the signal should corresponde to a a sine wave with Amplitude = 1 and Frequency = 10Hz. I am quite new to this toolbox and haven't found usefull information in the package's documentation. I would appreciate if anyone knows what is causing this and how I can make it a perfect continuous sine wave. Thanks in advance!
function GeneratingStartButtonPushed(app, event)
% Disable DAQ device, channel properties, and start acquisition UI components
setAppViewState(app, 'Outputacquisition');
t = linspace(0,1,app.DAQoutput.Rate);
frequency = app.GeneratingSignalFrequency.Value;
Amplitude = app.GeneratingSignalAmplitude.Value;
output = Amplitude*sin(2*pi*frequency*t);
try
%Create and start DAQouput object
start(app.DAQoutput,"RepeatOutput")
% write(app.DAQoutput, [output' ; ones(1*size(output))']);
write(app.DAQoutput, [ones(1*size(output))' ; output']);
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, 'Start error');
setAppViewState(app, 'OutputConfiguration');
end
% Clear Log status text
app.LogStatusText.Text = '';app.AcquiringStartButton
plot(app.LiveAxes_2, t, output);
end
  4 comentarios
Ivo Bastos
Ivo Bastos el 11 de Abr. de 2023
@Mario Malic Thank you so much! Actually preloading solved my problem. I'm looking forward to seeing that app, best of luck working on that
Mario Malic
Mario Malic el 21 de Abr. de 2023
I have posted my app here, unfortunately it is not yet applicable for the output, but it shouldn't be an issue to add that functionality. https://uk.mathworks.com/matlabcentral/fileexchange/128118-daqx

Iniciar sesión para comentar.

Respuesta aceptada

Vanshika Vaishnav
Vanshika Vaishnav el 13 de Abr. de 2023
Preloading the function solves the problem.
Also check Rate property of https://uk.mathworks.com/help/daq/daq.interfaces.dataacquisition.html object, as the Rate is set to be minimum when the object is initialised.

Más respuestas (0)

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by