Example Code

Synchronising a camera snap on the peaks of an input wave

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Other

    Software

  • LabVIEW

    Driver

  • NI Vision Acquistion Software

Code and Documents

Attachment

Download All

Overview

This example syncronize your camera with an external input signal.

Description

Sometimes in a vision application, you will want to synchronise camera snaps off an external synchronisation signal. In the most simplest of cases, the sync. signal is a sinusoidal wave, and you'd want the camera to snap an image every time a there is a peak on the synchronisation signal.

A good way to achieve this is to use a producer-consumer architecture. In this way, a camera snap can be placed in a loop that will only execute when triggered to by an another loop.

So, in this example, a top loop runs continuously looking for the peak in the synchronisation signal. When it detects a peak, it sends a value into a notifier (basically just a single element queue), allowing the bottom loop to run.

ds.PNG

In this example, a simulated signal is used. You can easily replace this with a real signal using DAQmx to actually acquire that real signal. Note, you will need to know before-hand the amplitude of your input signal.

Capture.PNG

Requirements

LabVIEW 2009 "or compatible"

Vision Acquisition Software 2009 "or compatbile"

USB or GIGe Camera

Steps to Implement or Execute Code

1.) Make sure the required software is installed and activated

2.) Test out your camera using Measurement & Automation Explorer (MAX)

3.) Close MAX

4.) Download the attached example code and open it in LabVIEW

5.) Choose the desired frequency and amplitude on the right

6.) Copy the IMAQdx shipping example into the second while loop (see Additional Information below).

7.) Select the tested camera using the IMAQdx reference input

8.) Run the LabVIEW example

Additional Information or References

You will need to add IMAQdx snap code in the second while loop.

Select Help/Find Examples directly in LabVIEW to open the shipping IMAQdx snap example.

It's located under "Hardware Input and Output\Vision Acquisition\NI-IMAQdx\Low-Level\Low-Level Snap.vi"

**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit thisdiscussion thread**

Josh E
Applications Engineer
National Instruments UK & Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors