Replace\remove Queued data

6 views (last 30 days)
G van den Noort
G van den Noort on 23 Apr 2019
Edited: Walter Roberson on 2 Oct 2019
Hi all,
I'm trying to make a GUI with which I control signals that i want to send and receive to/from my NI DAQ device.
For now I have a GUI with an axes, a start and a stop button.
There should be a contineous measurement of the analog input channels for as long as i dont quit the operation.
When I press the start button I want a sine wave of 10seconds sent to the analog output.
When I press the stop button I want this signal to be stopped and the analog output should be 0 V.
So the output signal should be 0V for as long as the start button is not pressed, then it should be a wave, when I press the start-button, for 10 seconds or less if the stop button is pressed before the end of the 10seconds.
s1 = daq.createSession('ni'); % create input session
ch1 = addAnalogInputChannel(s1,'Dev1', 0, 'Voltage'); % add analog channel for feedback of stim2 (trigger)
ch1.TerminalConfig = 'SingleEnded'; % ground the channel
addAnalogOutputChannel(s1,'Dev1',0,'Voltage'); % channel for sending stim1
s1.IsContinuous = true; % run till it is explicitely stopped
s1.Rate = inputRate;
I have a listener that makes a 0V signal if no data is queued.
l
h = addlistener(s1,'DataRequired',@(src,event) src.queueOutputData(ZeroSignal));
And a listener that plots the input data in realtime in a figure.
lh1 = addlistener(s1,'DataAvailable',@(src,event) updateFigure(event.TimeStamps, event.Data));
Now my problem is that when I use the function stop(s1); to stop the sine wave, the whole sesion is stopped. And that's not what I want, I just want want the signal to go back to 0V. But I can only let the output signal be 0 after the whole queue is sent to the output.
Is there a way to empty the queue or replace the queue after the function queueOutputData is used?
  1 Comment
Krish Mukesh Chhatbar
Krish Mukesh Chhatbar on 2 Oct 2019
Hey, I'm trying to do something something, where i want to update the queuedata with the change in frequency or amplitude in my GUI. I tried generate a variable from simulink to base workspace and tried to see if It updates the queuedata, but it doesn't.
Another way is what if we send data of a particular time say 0.5 seconds to the queueData, that way we'll have control over it. I'm yet to try this.
Did you find any solution for your issue? If so can you share it?
Thanks

Sign in to comment.

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!