daq problems in 'FramesAcquiredFcn' imaq callback

2 visualizaciones (últimos 30 días)
Patrick
Patrick el 16 de Mayo de 2012
I am using R2011b 64-bit version. We have an NI-1429 frame grabber that is hardware triggered by an analog output channel of an NI-6259 DAQ. What I want to be able to do is have a callback that will grab the frames once they are available, and then continue the acquistion by queueing more data to the DAQ (which should be finished outputing all data that has been queued).
This works with the 32-bit R2009b (the old DAQ interface). But this doesn't seem to work with the new session interface. Namely, the DAQ appears to be stop, even though 'isRunning' and 'isLogging' are true, the 'ScansQueued' property stays the same. Calling a wait() will cause it to timeout.
Relevant code snippets follow. There is some initialization code prior to this but I don't think its that important.
function testDAQ_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to testDAQ_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global daqtest
daqObj = daqtest.daqObj;
stop(daqtest.vidObj);
triggerconfig(daqtest.vidObj, 'hardware', 'fallingEdge', 'external0');
set(daqtest.vidObj, 'ROIPosition', [0 0 2048 10]);
set(daqtest.vidObj, 'FramesAcquiredFcn', @vidFrameAvailable);
set(daqtest.vidObj, 'FramesAcquiredFcnCount', 1);
set(daqtest.vidObj, 'FramesPerTrigger', 1);
set(daqtest.vidObj, 'TriggerRepeat', inf);
start(daqtest.vidObj);
%daqtest.outFcn = zeros(1000, 4);
daqtest.outFcn(2:100:1000, 3) = 5;
daqtest.outFcn(100, 3) = 5;
daqObj.queueOutputData(daqtest.outFcn);
disp('starting in background');
daqObj.startBackground();
There the 'vidFrameAvailable' is in a seperate file :
function vidFrameAvailable(src, evnt)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
global daqtest
disp('vidFrameAvailable');
daqObj = daqtest.daqObj;
wait(daqObj, 2);
daqObj.queueOutputData(daqtest.outFcn);
disp('starting in background');
daqObj.startBackground();
end
The vid timer callback executes once. Then I get a timeout at the 'wait()'. If I put a breakpoint right before that, and type 'get(daqtest.daqObj)' at the command line. I get the following:
NumberOfScans: 1000
DurationInSeconds: 1
Rate: 1000
IsContinuous: false
NotifyWhenDataAvailableExceeds: 100
IsNotifyWhenDataAvailableExceedsAuto: true
NotifyWhenScansQueuedBelow: 500
IsNotifyWhenScansQueuedBelowAuto: true
Vendor: National Instruments
Channels: [1x4 daq.ni.AnalogOutputVoltageChannel]
IsRunning: true
IsLogging: true
IsDone: false
RateLimit: 0.1 to 1000000.0
ScansQueued: 903
ScansOutputByHardware: 97
ScansAcquired: 0
'ScansQueued' never goes down, which it should if the the board is indeed running. It seems like the DAQ is somehow 'suspended', so it won't output anymore once the callback is called.
This seems to work OK without a callback mechanism, in other words, in a loop. But thats a pretty kludgy solution... I should be able to use callbacks.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by