Machine Vision

Showing results for 
Search instead for 
Did you mean: 

How to always read from the first signal of a regenerated DAQmx output in a for loop?

Hi all,

I have an imaging system controlled by LabVIEW. The camera needs to take two images at each XY position -- one when the blue light on, and the other when the red light on. After taking two pictures, the XY stage moves to the next postion, then the camera image twice again. These modules are put in a for loop. The camera trigger and blue/red control signals are synchronized and generated continuously by DAQmx write in regeneration mode.


The problem is, each time when it loops and the camera receives a trigger, it could be either trigger 1 or trigger 2 (see attached schema), so LabVIEW could not know whether it is blue light or red light and save the data to its corresponding folder. It is not possible to sort the saved images manually since there will be hundreds and thousands of them. Is there a way to tell the camera to read trigger 1 first, then trigger 2?




0 Kudos
Message 1 of 8

I think I would have an external signal that triggers the DAQ output when the part is in place.  The DAQ output would turn on one light, trigger the camera, other light, camera, then stop and wait for the next start trigger.  I am pretty sure you can get it to rearm automatically, so you just start the whole sequence going and then grab two images at a time.  Would this do what you want?



Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 8

Hi Bruce,

Using another signal to trigger the DAQ output sounds like a good plan. But I am not sure how to achieve that. It is basically two questions: 1) how to trigger the DAQ output 2) how to synchronize this external signal with the image acquisition. Do you have any idea?




0 Kudos
Message 3 of 8

Ellie, does the DAQ output signal have to be running continuously?  Can the DAQ output be put inside the for loop so that you only see two triggers after the camera is in place and then no DAQ output until the camera is in the next XY position?  In this way, you can always be sure that your first image is blue and your second image is red (based on your diagram).  With this configuration, your red light will be on during the move to the next XY location.  It also sounds like you already have a method of knowing when the camera has moved to the correct XY position, so the only change would be in the acquisition/light trigger.

0 Kudos
Message 4 of 8

Thank you for the idea. From my point of view, putting the DAQ output signal in N samples mode inside the for loop would still have problems if the output signal not synchronized with the camera acquisition - if output signal goes before the camera acquisition, the camera would miss triggers; if the camera is in place then staring output signal, then the camera would be timeout. Also, initializing and generating DAQ outputs in each for loop is not very time-efficient. If only there is a way to hold the DAQ output signal until the camera reads the trigger...

0 Kudos
Message 5 of 8

I would have three digital output signals.  Red light, blue light, and camera trigger.  The timing on these would be adjusted so you get good images for each light.  The camera would be hardware triggered.  These signal could be generated using a buffered digital waveform output.


The digital output sequence would be started by another trigger, that is sent by an external system when everything is in place for pictures.  The tricky part is automatically rearming this signal sequence after the sequence is done.  I am 99% sure it is possible, but I don't know how to do it without doing some research.  There might be an example somewhere in the NI archives.  If you have plenty of time, you could manually rearm it at the end of the acquisition loop so it is ready for the next iteration of the loop.


Your video acquisition would need to be setup to use a hardware trigger for each image, and to acquire into a multi-image buffer.  At the end of your acquisition loop, you will have two images in your buffer ready to process and in the correct order.



Bruce Ammons
Ammons Engineering
0 Kudos
Message 6 of 8

Thanks Bruce! I haven't found any easier way to solve this problem yet. It seems that I have to use another external signal to trigger the original signal sequence, just like you said. But I haven't figured out how either. The camera can output a trigger when it starts to readout, but that output would be too late for any synchronization. Also, even though I could start all the signals and camera acquisition at the same time somehow, rearming the signal sequence for each loop is not time-efficient. I still need to do more research on this problem. Any further suggestions are also welcomed! Thanks!


0 Kudos
Message 7 of 8

I did a quick search, and it looks like you need to use a retrigger property so that it will automatically rearm after each trigger.


You can do the output using a digital waveform output, but that depends on your hardware.  You might be able to do it with counters, also.  How are you currently doing it?  What hardware are you using?


Generating the external signal is outside of LabVIEW, so I can't help you much there.


How does LabVIEW know there is a part in place and to grab the next two images?



Bruce Ammons
Ammons Engineering
Message 8 of 8