MATLAB Answers

daq problems in 'FramesAcquiredFcn' imaq callback

4 views (last 30 days)
Patrick on 16 May 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;
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);
%daqtest.outFcn = zeros(1000, 4);
daqtest.outFcn(2:100:1000, 3) = 5;
daqtest.outFcn(100, 3) = 5;
disp('starting in background');
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
daqObj = daqtest.daqObj;
wait(daqObj, 2);
disp('starting in background');
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]
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.


Sign in to comment.

Answers (0)

Sign in to answer this question.