Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Camera sync with scanner problem

Solved!
Go to solution

Hello again,

 

I'm working on a project that I have to sync image acquisition (line camera) with scanner. I think I'm doing it right but image is always randomly delayed, not synced. 

I set the camera to 'no trigger' mode, then move the scanner to the minimum position. Then set the camera to 'trigger' mode, and start the scanner with continuous sawtooth signal. I'm getting 1024 chunk of images at a time so, when I'm out of sync, I'm reading mix of first and second sawtooth signals.

What I see is, sometimes, the image acquisition starts half way up of the first sawtooth signal (it's very random and most of the time it's out of sync). Can someone please see my test VI and suggest if I'm doing anything wrong?

When I see the sequence on O-Scope, I see the DAQ signal goes to min, then starts the sawtooth. And the camera is in 'trigger' mode and waits until the sawtooth starts.

 

Much appreciated.

0 Kudos
Message 1 of 10
(3,403 Views)

Hi dk91,

 

There is a lot of things that you left out that make this hard to troubleshoot.

 

1) What DAQ device are you using?

2) What camera are you using?

3) Can you give us more details about the camera trigger?  (Is it an external trigger?  If it is, what is sourcing the external trigger?)

 

From looking at the block diagram, I am wondering if you are using the ramping signal as the grab trigger.  If that is the case, I'm not surprised that you are seeing odd behavior.

 

Regards,

 

George B.

Applications Engineer 

National Instruments

 

0 Kudos
Message 2 of 10
(3,325 Views)

Hi George,

 

I'm using USB 6211 to generate ramp (1024 samples) signals which drives scanner (XY). At every sample point in the ramp signal (1024), I'm generating a trigger at rising edge (5V TTL) from USB6211 (by exporting sample clock to DO channel) to tell usb line camera to start capturing. 

Please let me know if anything is not clear.

 

Thanks

0 Kudos
Message 3 of 10
(3,321 Views)

Hi dk91, 

 

I rarely work with DAQmx, so I'm willing to admit that I could be missing something here, but it looks like you are routing the Sample Clock to the "DO" line.  I don't see that line listed in the options available when I click the drop down list.  I didn't get an error when I simulated the device to see if that worked, but I'm not convinced that this isn't the problem.  

 

Also, be sure that you are routing that sample clock to a Digital Out pin.  I believe any PFI Line 4-7 will get you where you want to be.

 

 A couple other things to consider:

1) You are using Grab rather than Snap.  I don't know how many images you are grabbing, but I suspect that if you are still grabbing images when a trigger pulse occurs, you'll miss that trigger.  This could be another culprit.

2) You could route the start trigger from the AO task to a PFI line and use that to start grabbing pictures at a given framerate.  If you set the frame rate up correctly, you could capture a finite amount of images.  This could be an alternate approach to what you are doing now.

 

TL;DR Try changing the line selected in DAQmx Export Signal from "DO" to any DI PFI Line.  I don't have "DO" listed in my available lines, but you may have a virtual channel setup that I don't have.

 

Regards,

 

George B.

Applications Engineering

National Instruments

 

PS. Your stop button case is all messed up.  If you hit stop, a false is sent to the stop conditional and no message is sent to the consumer loop to stop.  Or in this case, you aren't destroying the queue, so there isn't any error to stop the loop.  This is why you have to hit the abort button to stop.

0 Kudos
Message 4 of 10
(3,302 Views)

Hi George,

 

Thanks for the response. The one I attached is a test VI that I created from my actual program. The actual program is exporting sample clock to PFI4 correctly. I do see this on O-Scope. Same for the 'stop' function. Also, I'm using "Grab2.vi".

I'm continuously capturing 1024 lines of images at a time - the sawtooth signal to drive scanner has 1024 sample points (sawtooth starts from the minimum point which I move the scanner to minimum position first before starting the sawtooth), and the camera will have 1024 triggers.

What I'm seeing is, I get the 1024 images but it looks like the first image is from somewhere in the middle of the sawtooth and ends at somewhere in the middle next sawtooth signal. I added 'stop' task right after moving scanner to minimum (before the sawtooth starts) but no difference - still having issue with sync.

0 Kudos
Message 5 of 10
(3,299 Views)

Interesting - this sounds like the camera isn't immediately responding to the trigger.

 

I'm wondering if this is happening because you are configuring the camera at the start of each ramp.

 

The typical scenario that we suggest that customers follow is to do all the configuration settings before starting the while loop.  I'm guessing that by adding in the overhead of configuring the camera, some of the triggers are being missed, which is why you are seeing an offset.

 

Regards,

 

George B.

0 Kudos
Message 6 of 10
(3,277 Views)
Solution
Accepted by topic author dk91

Could you send a snapshot of your camera configuration from NI MAX?

0 Kudos
Message 7 of 10
(3,270 Views)

Here is the snapshot of my configuration.

By the way, I added delay after the configuration, before start the sawtooth, but no changes. It still starts at random point (out of sync).

MAX_Spectrometer.PNG

Thanks for the help.

 

 

0 Kudos
Message 8 of 10
(3,255 Views)

Anything of note under the digital IO section?

0 Kudos
Message 9 of 10
(3,246 Views)

Device type was set to "Area Scan" instead of "Line Scan". After setting it to correct type, it all works as expected. Thanks.

0 Kudos
Message 10 of 10
(3,209 Views)