Can you synchronize the data acquisition panel and Matlab image acquisition panel?

I would like to simultaneously receive data from the camera (i.e. images) and analog voltage using matlab. For the camera, I use the imaq toolbar, for voltage reading I use the daq toolbar (read NI-USB device) with the following code:

clear all % Prepare camera vid = videoinput('gentl', 1, 'Mono8'); src = getselectedsource(vid); vid.FramesPerTrigger = 1; vid.TriggerRepeat = Inf; triggerconfig(vid, 'hardware', 'DeviceSpecific', 'DeviceSpecific'); src.FrameStartTriggerMode = 'On'; src.FrameStartTriggerActivation = 'RisingEdge'; % prepare DAQ s=daq.createSession('ni'); s.addAnalogInputChannel('Dev1','ai1','Voltage'); fid = fopen('log.txt','w'); lh = s.addlistener('DataAvailable',@(src,event)SaveData(fid,event)); s.IsContinuous = true; % Take data s.startBackground(); start(vid) N=10; for ii=1:N im(:,:,ii)=getsnapshot(vid); end % end code delete(lh ); fclose('all'); stop(vid) delete(vid) 

where the SaveData function is:

 function SaveData(fid,event) time = event.TimeStamps; data = event.Data; fprintf(fid, '%f,%f\n ', [time data]); end 

I get images and a log.txt file with daq trace (time and data), but how can I use an external trigger (which starts the camera) or some other clock to synchronize the two? In this example, daq reads the camera that triggers the TTL signal (@ 50 Hz), so I want to assign each TTL pulse to the image.

Addendum: I searched and found several discussions (for example, one ) on this question and read examples that are on the Mathworks website but did not find an answer. The documentation shows how to start a multi-charge acquisition at an external event , but the acquisition in question is only applicable for DAQ-based entry, and not for (it also works in the foreground).

+4
source share
3 answers

This will not completely solve your problem, but it may be good enough. After you synchronize the signal with a frequency of 50 Hz, you can use clock to create time stamps for both types of data (camera image and analog voltage). Since the clock function takes almost no time (i.e., below 1e-7s), you can try to edit your SaveData function accordingly:

 fprintf(fid, '%f,%f\n ', [clock time data]); 

And in the for loop add:

 timestamp(i,:)=clock; 
+1
source

Can you use synchronization to start the AD board? From the USB-6009 manual ...

Using PFI 0 as a Digital Trigger - When an analog input task is specified, you can configure PFI 0 as a digital trigger input. When the digital trigger is activated, the AI ​​task expects a rising or falling edge at PFI 0 before collecting. To use AI Start Trigger (ai / StartTrigger) with a digital source, specify PFI 0 as the source and select a rising or falling edge.

My experience is that the delay between the trigger and AQ is very short

I'm sorry that I use Python or C for this, so I can't give you MatLab code, but you want to look at features like.

 /* Select trigger source */ Select_Signal(deviceNumber, ND_IN_START_TRIGGER, ND_PFI_0, ND_HIGH_TO_LOW); /* specify that a start trigger is to be used */ DAQ_Config(deviceNumber, startTrig, extConv); // set startTrig = 1 /* start the acquisition */ DAQ_Start(deviceNumber, …) 

If you want to go this route, you can get more ideas from: http://www.ni.com/white-paper/4326/en

Hope this helps, Carl

+1
source

This is not a complete solution, but some thoughts that may be helpful.

I get images and a log.txt file with daq trace (time and data), but how can I use an external trigger (which starts the camera) or some other clock to synchronize the two?

Can you think of a way to calibrate your setup? That is, to change your experiment and create a distinct event both in your image stream and in the voltage measurement that can be used for synchronization? Just like that ...

0
source

All Articles