Sending Desired Signal to DAQ Device with Data Acquisition Toolbox
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey everyone, I am working on controlling current sent to a pair of Helmholtz coils through Matlab with Data Acquisition Toolbox. Looking at related documentation, I was able to generate code that would queue desired signal to NI DAQ device and sustain it but what I want to do is the flexibility of changing the current I send to the device whenever desired. When the data queued with queueOutputData() is finished, the program seems to queue back whatever is in the listener. I actually want it to continue with whatever I queued until I change it and if I change it I want to continue with that. Do I have to update the listener and if so how can I do that? Also, I understand that when I queue a certain signal, I can't cancel it and replace with another signal before it's processed. Is there any way I can overcome it? Below I share the part of the code that generates desired signal, initiates a listener and queues some output data.
s=daq.createSession('ni');
out1=addAnalogOutputChannel(s,'Dev1',0,'Voltage');
s.Rate = 20000; %Device initialization
f=5;
w=2*pi*f;
out1_amp=0.8;
out2_amp=out1_amp;
out1_signal=out1_amp*sin(linspace(0,2*pi*f,s.Rate+1)');
out1_signal(end)=[]; %Signal generation
lh=addlistener(s,'DataRequired', @(src, event) src.queueOutputData([out1_signal]));
s.IsContinuous=true;
queueOutputData(s,repmat([out1_signal],5,1));
s.startBackground();
6 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre National Instruments Frame Grabbers en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!