Analog Outputs stops (without reason) ?!
显示 更早的评论
Hey everybody!
I hope one of you can help me!
I am working on a Programm using DAQ-Toolbox and a National Instruments I/O USB Card. I am trying to output data continuously by using an analog outputobject. It got a Samplerate of 100 and 100 Values get enqueued before the object is started. After start a timerfunction enqueues new Data by using "putdata". The first 100 Samples are output fine but than the object stops though there are still 400 Values in the queue. It stops without any error message.
Why does the object stop?
In my opinion the object should run until no more data is left in the queue... .
If you need further information for an answer just let me know!
回答(3 个)
Walter Roberson
2011-12-14
0 个投票
Usually USB buffers data until the USB packet size (close to 1000 bytes) is met. If your data is 2 bytes per sample, your buffer is getting drained until less than ~1000 bytes is left.
USB is not suitable for continual output of short packets -- at least not without getting in to details of USB that Mathworks has never exposed the user to.
Chirag Gupta
2011-12-14
0 个投票
Can you post bit of the code? Also are you using the new Session based interface (R2011b) or the legacy interface ?
If you are using the legacy interface (analogoutput object) then you might need to set this property:
Chirag Gupta
2011-12-14
0 个投票
Looking at the documentation, it states that all the data must be queued using putdata before starting the analogoutput object.
So the TimerFcn will not work, unless you do the following: a) Change the TriggerType to Manual, b) and retrigger after putting more data.
A more convenient solution would be offered by Session based architecture which is perfect for this:
I am assuming you are doing both input and output simultaneoulsy! You can use Background operations to continuously queue data to to be output (using a DataRequired callback), example: http://www.mathworks.com/help/toolbox/daq/bsob84e-1.html#bsovlz7-1
You can also do both Input and Output simultaneously and do a live plot using 'DataAvailable' for inputs! http://www.mathworks.com/help/toolbox/daq/bsotkz_-1.html (You might want to use startBackground(), if you want the output data to happen in the background)
7 个评论
Tobias
2011-12-15
Chirag Gupta
2011-12-15
http://www.mathworks.com/help/toolbox/daq/f10-11338.html
This comments that Data should be queued before starting the object, but then also continues to say what you have quoted.
It is possible that: You initially queued data, started the object and before new data could be finished being queued, the object stopped.
I would try Initially queuing more data, and then queuing smaller chunks. Also to check whether the object is still running after you have added more data!
But, I would still recommend moving over to Session based interface as it will allow for more flexibility and ease
Tobias
2011-12-15
Chirag Gupta
2011-12-15
Hey Tobias,
I would just pass the handles object to the callback function for DataAvailable.
Something like:
lh = s.addlistener('DataAvailable', {@plotData,handles});
then
function plotData(src,evt,handles)
...
http://www.mathworks.com/matlabcentral/answers/6258-thread-subject-nidaq-continuous-and-background-acquisition
Tobias
2011-12-16
Chirag Gupta
2011-12-16
I am a little surprised at that! src and event are always inputs.
@(src,evn) Functioname (src,evnt, additionalargs) is one of the many ways to define a callback!
Tobias
2011-12-20
类别
在 帮助中心 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!