Triggering a FireWire Camera Using Vision Builder AI on a Compact Vision System
Overview
This tutorial introduces basic triggering concepts, but focuses on triggering with IEEE 1394 cameras. In addition to triggering IEEE 1394 cameras this document also discusses some of the particulars of using Vision Builder AI and a Compact Vision System (CVS) along with an IEEE 1394 camera for different triggering applications.
Table of Contents
General Triggering Concepts
In any data acquisition, including image acquisition, there is often a need to synchronize data to actions or events. Triggering is one method used to fulfill this need. A trigger signal is commonly a digital pulse that has a distinct transition. This transition should be clear and deterministic to ensure that our actions occur at the desired time. If image acquisition is being used to examine parts on an assembly line, a signal is needed to ensure that the parts appear in the same location in each image. Without triggering we would acquire many images that may either not contain the item of interest or maybe even multiple images of the same item. Later in this paper we will discuss specific use cases for triggering as well as triggering methods, but first, we will discuss the normal operating mode of a camera.
Free Run Mode
Free run mode is the default operation mode for most cameras. In free run mode a camera uses its internal timing circuitry to acquire and output images on a regular basis. How often a camera outputs an image is referred to as the frame rate, commonly stated in frames per second (fps). When a camera is powered on, it immediately begins acquiring and sending data. When connected with a framegrabber, the framegrabber will lock onto the camera’s pixel clock and acquire pixels based on the camera’s timing signals. In the case of IEEE 1394 cameras, the IEEE 1394 interface will acquire packets of data as they are sent from the camera. In this operation the camera acquires data in its own time and is not synchronized with any outside source.
Software Trigger
In cases where a camera does not have the capability of being triggered, or synchronization is not critical, a software trigger can be used to “begin” acquisition. In this mode, the camera still operates in free run mode, but the software trigger simply determines when our interface will begin paying attention to the data being sent by the camera. The term “software trigger” is used loosely as this method does not actually start the image acquisition. If a camera is in the middle of acquiring a frame, the interface will wait until the next full frame is available and consequently there can be a large time variance between when the software trigger is seen and when the associated image is actually acquired. Due to its non-deterministic nature the “software trigger” is not considered an actual trigger for the purposes of this paper.
Hardware Trigger
As described above, the delays and non-deterministic behavior of the “software trigger” means that synchronization using this method is poor at best and will not be considered as a trigger for this paper. In order to achieve synchronization with an external signal a camera must have triggering capabilities. The camera must be capable of being set in trigger mode and accepting a trigger signal. When the camera receives the trigger signal it will begin acquiring an image immediately. Since these signals and timing are all strictly hardware based this acquisition is deterministic and immediate for most practical purposes (trigger latency will be discussed at a later time). Different trigger modes exist where each frame (or even each line in the case of line scan cameras) can be triggered or the start of acquisition can be triggered and the camera will acquire at its own speed after the initial trigger.
Every camera interface has its own triggering abilities. Since most analog cameras use a BNC cable to send data this means that a second cable is required for the trigger signal. The CameraLink standard specifies multiple data lines and camera control lines that are all contained in a single cable. Trigger signals can be sent along these camera control lines eliminating the need for extra cabling.
This paper is concerned with triggering IEEE 1394 compliant cameras, which, like analog cameras, requires a second line for triggering. Like analog and CameraLink cameras, for true triggering, an IEEE 1394 camera must have circuitry that makes triggering possible. We will first provide a background on the IEEE 1394 technology and how it relates to cameras and then we will discuss triggering modes with these cameras.
IEEE 1394 Camera Standard
IEEE 1394, also known as FireWire or I-Link, is a high-performance serial bus interface that offers high-speed communications and isochronous real-time data services. Devices which use this technology are hot-pluggable, eliminating the need for shutting down a PC to add and remove hardware.
The IEEE 1394 bus provides both asynchronous and isochronous data transfer contingent on if the user wants guaranteed delivery or guaranteed bandwidth, respectively. Asynchronous mode uses a data acknowledge packet from the recipient to verify that all data is transferred correctly. If the device does not get this acknowledgement after sending data, it will retry the command; therefore there is no guarantee of bandwidth. For isochronous data transfer, the data transmission is divided into 125 microsecond cycles and each cycle begins with an asynchronous cycle start packet for commands. Each device requests a partition of the 125 microsecond cycle depending on its packet size (KB/packet). Since the recipient does not acknowledge data transfer, there is no guarantee that transfer has been successfully made. Devices, such as cameras, that request isochronous bandwidth are guaranteed a single packet per cycle. Also note that the total bandwidth of the IEEE 1394 bus is shared among all devices connected which is limited to 400 MB/s and 800MB/s for 1394 a and b respectively.
The IEEE 1394-based Digital Camera (DCAM) Specification is owned by the IEEE 1394 Trade Association and provides a means of standardizing image formats, triggering methods, frame rates, and control of FireWire-based devices. When these settings are chosen, the camera automatically assigns the packet size that will be transferred with each isochronous transfer. Users can typically change the packet size by changing the frame rate or the image size. The smaller the packet size, the longer the transfer time, but bandwidth will free up to allow more devices to send their packets within the 125 microsecond time slice.
More information regarding IEEE 1394 technology can be found at:
Acquiring from FireWire Cameras with National Instruments NI-IMAQdx and Legacy NI-IMAQ for IEEE 1394
Triggering IEEE 1394 Cameras
The 1394 bus does not have the ability to directly send a trigger signal to the camera; therefore, a separate line is needed. Also, the camera must have triggering capabilities. The following are the various trigger modes available on the IEEE 1394 bus.
Trigger Modes
Six triggering modes (0-5) are defined by the DCAM spec with two additional modes (14, 15) reserved in v1.31 for vendor-defined triggering methods.
Mode 0 – Programmable Trigger - The camera starts integration of the incoming light from the external trigger input falling edge. The integration time is specified by defining the “Shutter” attribute; therefore, no parameter is needed.
Mode 1 - Pulse Width Control - Similar to Mode 0, the camera starts integration from an external trigger input falling edge; however, the integration time is equal to the low state of the external trigger. Again, no parameter is required.
Mode 2 – Trigger Pulses Control - The camera starts integration of incoming light from the FIRST external trigger input falling edge. At the Nth (parameter) external trigger input falling edge, integration is stopped. This N control parameter is required to be 2 or more (N >= 2)
Mode 3 – Internal Trigger - The camera issues a trigger internally and cycles N (control parameter) times of the cycle time of the fastest frame rate. The integration time is specified by defining the “Shutter” attribute.
Mode 4 (DCAM 1.31+) – N Frames, Programmable Shutter – The camera starts frame integration when the external trigger input changes to an active value. Each frame is exposed for a duration specified by the shutter attribute. The sequence is repeated N time for every external trigger input falling edge then finishes integration. This parameter N is required to be 1 or more.
Mode 5 (DCAM 1.31+) – N Frames, Pulse Width Control - Similar to Mode 4, the camera starts frame integration when the external trigger input changes to an active value, but exposes incoming light while the external trigger is active. The number of frames is specified by the optional parameter, N, which must have a value of 1 or more.
Not all cameras support every mode listed above. When designing a system for external triggering it is important to understand the specifications of the particular camera and which modes are available. It is also necessary to take into account trigger latency, which is the amount of time between physically triggering the image and acquiring it in computer memory. The total time is the summation of the trigger response time, exposure time, sensor readout, IEEE 1394 bus transfer time, and host response time as presented in the equation:
Ttotal = Ttrig + Texp + Tsensor + Ttrans + Thost
Hardware trigger (Ttrig) response times typically ranges from .02 - .07 milliseconds depending on the camera model. Exposure time (Texp) is the amount of time the camera is acquiring light which can be user-defined usually from 20 microseconds and up to several seconds. Sensor readout (Tsensor) is the time needed to empty the pixel data to the camera’s on-board image buffer. The amount of time (Ttrans) to transfer the image from the camera to the PC, via the IEEE-1394 bus can be calculated using the following equation.
Ttrans = [{(AOI Height x AOI Width)/ (Bytes/packet)}*125]/1000
The time (Thost) it takes for Windows to place the video data into a buffer for further image processing is dependent on both the host processor speed and the thread priority. Now that we have covered the trigger modes available for IEEE 1394 cameras we will present system configuration options and applications using the Compact Vision System (CVS).
Trigger Camera Directly
The first and most simple configuration is to trigger your camera directly and use the CVS for acquisition of the image data only.
Hardware Setup
In this configuration wire the sensor output directly to the camera. This method is straightforward as long as the signal from the sensor is compatible with the trigger circuitry of the camera. Many cameras have optically isolated trigger inputs which may require some additional circuitry from your sensor signal for proper functionality. When the camera is triggered it will send the image data to the CVS where it can be acquired/processed as needed.

Figure 1. Hardware setup to trigger camera directly from sensor and then send acquisition data to CVS
Software Setup
Since the camera is triggered directly by the sensor, there is no I/O configuration required on the CVS. To configure the correct trigger mode for your camera, go to the Trigger tab located in the Acquire Image (IEEE 1394) Setup step. With the Triggered Acquisition box checked, you can select the appropriate trigger mode as described in Section I. Vision Builder for AI automatically populates this list according to the available modes for that particular camera. You can also configure the polarity and timeout for the trigger. If you select modes 2 through 5, you can set the optional control parameter accordingly.
Figure 2. Configurations on the Trigger tab in the Acquire Image (IEEE 1394) Setup step
Use Cases
This is the simplest trigger configuration and should be used when no other timing requirements exist. This use case will minimize cabling necessary compared to other possible configurations, but will give no control over timing delays or synchronization with other devices. The camera will acquire when it sees the trigger source and then the CVS will process the image as soon as it is received. For more advanced synchronization methods, use IMAQ I/O functions to program the Field Programmable Gate Array (FPGA) on the CVS.
Advanced IMAQ I/O
The CVS has a 44-pin DSUB connector, shown in Figure 3-8, that provides access to the general-purpose digital inputs and outputs. This connector is described in detail in the user manual for the CVS. The general-purpose digital I/O available on this connector includes 2 TTL inputs, 8 TTL outputs, 12 isolated inputs, and 4 isolated outputs. The TTL inputs and outputs are most commonly used for triggering applications. The IMAQ I/O driver can be used to access these lines and achieve a variety of more advanced triggering applications. Using these functions the CVS can send multiple triggers to different devices as well as accepting trigger signals. The software configuration will be discussed in more detail in the corresponding sections describing different triggering applications.

Figure 3. 44-Pin DSUB Connector
Figure 4. Communicate Inspection Steps palette: IMAQ I/O Steps for sending static digital inputs/outputs or creating digital pulses
Trigger Camera from CVS
Hardware Setup
In this configuration, the sensor is connected to the Compact Vision System on the 44-Pin DSUB on either TTL Input pins 0/16 or Trig0 on SMB connectors. The FPGA is then programmed to initiate a timed pulse when a trigger is received. Once the camera is triggered, the image data is received by the CVS for inspection and image processing.

Figure 5. Hardware setup to 1) Sensor triggers CVS, 2) CVS sends trigger pulse to camera, and 3) Camera sends image to CVS.
Software Setup
The trigger mode for the camera still needs to be configured as described in the Trigger Camera Directly section in order to correctly communicate with the CVS.
You must configure the CVS I/O to both read the trigger from the sensor and to generate a pulse train to the camera. View the Complete Inspection Setup either by toggling the Main Window View or going to View in the toolbar as shown below:
[+] Enlarge Image
Figure 6. Changing between inspection state diagram view to complete inspection setup view
When in the Complete Inspection Setup View, choose the Inspection Setup state. Use the Inspection Setup state to add and configure steps to perform tasks that you want to complete before the main inspection runs, such as hardware initialization. Steps in the Inspection Setup state are executed only once when the associated inspection is opened in Vision Builder AI.
Figure 7. Inspection state diagram. Setup occurs before the main inspection and only executes once when the inspection runs.
In order to initialize hardware triggering, you must configure the FPGA I/O of the CVS accordingly. In the Communicate Inspection Steps tab, use the NI-IMAQ I/O Pulse to create a digital pulse to the camera based on the external trigger from the sensor. The camera can be connected to any of the listed outputs for triggering. The Pulse Properties define the pulse that will be generated on the selected digital output line. You can set the action to either send a single pulse or start/stop a generated pulse train. Other parameters that can be configured are polarity, delay, width, and time base of the pulse.
When starting a pulse train, you can determine if the pulse is generated immediately on the output line when this step runs or if it is triggered from an external input. Since a sensor will be triggering the output to the camera, you must configure the corresponding input line to detect a rising or falling edge. The following figure sets up the FPGA to output a pulse on TTL Output 1 (driven low with a .01ms delay and 10ms width) when a rising edge is detected on ISO Input 8. In this case the camera trigger pin is connected to TTL Output 1 and the sensor is connected to ISO Input 8.
[+] Enlarge Image
Figure 8. This step configures the FPGA I/O to output a pulse on TTL Output 1 whenever a rising edge on ISO Input 8 is detected.
Once the I/O has been configured, click OK to return to the Inspection Setup window. You can now return to the Complete Inspection Setup View to reopen the State Diagram. Inspection steps that are included in the State Diagram will run in a loop continuously until the inspection completes.
Use Cases
This setup allows you to control the trigger signal going to the camera. Depending on the application, the generated pulse can occur from a falling or rising edge of an input trigger and can be configured for high or low active polarity. You can configure both the pulse width (time between first assertion and deassertion edges) and pulse delay (time between a trigger and first assertion edge) in microseconds from 10 μs to 4,294,967,295 μs. With this configuration, you can also access the isolated voltage line either through an isolated input to source an output device or as a digital output to source currents to an external load. In order to prevent damaging the CVS-1450 device, do not apply voltages greater than 30 VDC to the isolated inputs and do not draw more than 100 mA from 24V or 30V isolated outputs or 50mA from 5V isolated outputs. Further information including circuit diagrams can be found in the CVS User Manual.
Trigger Camera and Strobe Light from CVS
Hardware Setup
The configuration is similar to that described previously, however now you can also connect another TTL or Viso output line to a light source. As shown in the figure, another of these output lines is used to strobe a light.

Figure 9. Hardware setup to 1) Senor triggers CVS, 2) CVS sends trigger pulse to camera and light source, and 3) Camera sends image to CVS.
Software Setup
In order to incorporate a second output line for a light source, you will need to configure another pulse line in the NI-IMAQ I/O Pulse step. In the example configuration that follows, the CVS sends pulse trains to both the camera on TTL Output 1 and the light source on TTL Output 2 which are both triggered from ISO Input 8 (the sensor).
[+] Enlarge Image
Figure 10. Triggering both a camera (on TTL Output 1) and a light source (TTL Output 2) from a sensor (ISO Input 8). The camera is delayed by 0.05 ms with a pulse width of 10ms while the light source is delayed 0.01ms and has a pulse with of 25ms.
In order to compensate for underexposure, trigger latency, and ramp up required for full illumination, it is suggested to trigger the light source earlier and for a longer duration (i.e. shorter delay and larger pulse width). By keeping the light source on for longer than the time of exposure, you guarantee that the image is properly exposed. In the example above, the camera is delayed .04 ms after the light source is turned on. This allows for ramp up to full illumination. Also, the light source is kept on 15 ms longer to prevent underexposure.
Use Cases
Besides being applicable to the previous cases, this setup ensures that the light source will be on during the duration of exposure time. If the inspected object is moving quickly, the strobe light will reduce blurring effects by shortening the exposure time. To ensure that the light is on during the entire exposure time; it is important to also account for light ramp-up time.
Conclusion
Since the IEEE 1394 bus does not have the capabilities to directly trigger a camera, the signal must be sent through hardware either directly to the camera or through the Compact Vision System. Based on the camera specifications, you must select the correct trigger mode in Vision Builder for AI as well as configure the FPGA I/O to detect input/output signals. It is important to also compensate for delay due to trigger latency and under-exposure effects when using a light source.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
