Browse KB Articles
Using Counter and Timer Control
KB Number: 11034
Technical Application Note (TAN2016004): Using Counter and Timer Control
Application Note Description
This document provides an overview of the Counter and Timer Control feature in the Blackfly S and Oryx cameras.
The Counter and Timer feature allows you to:
Some general applications include:
Note: This document uses the SpinView application to demonstrate the configuration and execution of Counter and Timer Control.
Configuring Counter and Timer Control
Possible sources for event, trigger, or reset include:
The counter increments by 1 on every rising edge at Line0 to a maximum of 4.
Counter status can be queried from the nodemap as either Active or Idle.
Pulse Width Modulation Example
The goal of this example is to strobe a 50 Hz pulse with 70% duty cycle.
Step 1 - Set up the GPIO Connection
The first step is to set up the hardware to output the PWM signal from the camera. For this example, we use an oscilloscope to display the signal. The GPIO pins vary depending on the camera family used.
Blackfly S (BFS)
BFS cameras have a 6-pin GPIO. It has both a non-isolated output and an opto-isolated output. If using the opto-isolated output (as in our example) the camera requires a pull-up resistor to strengthen its strobe signal.
To configure the BFS camera's strobe output:
To configure the pull-up resistor needed to strengthen the signal:
Oryx cameras have a 12-pin GPIO. It has two non-opto pins that can be used as either input or output. Non-opto pins do not need a pull-up resistor to strengthen the strobe signal. This example uses the non-opto pins.
To configure the ORX camera's strobe output:
Step 2 - Set up the software (SpinView)
The steps below show how to set up the PWM signal in SpinView.
1. Select a Counter (either 0 or 1).
2. From Counter Event Source, select MHz Tick which is a signal of 1 MHz.
3. To create a 50 Hz clock, we need a counter duration of 20,000.
4. Define Counter Duration and Counter Delay values to create a 70% duty cycle.
5. From Counter Trigger Source, select FrameTriggerWait. Set Counter Trigger Activation to Level High.
6. Disable Exposure Auto and set an Exposure Time of less than 1/50 second.
7. Enable Trigger Mode and select Trigger Source to Counter0 Start.
8. Configure GPIO so that Line 1 is in Output mode and the Line Source is Counter 0 Active. For ORX cameras, use Line 2.
9. For BFS cameras only, enable the 3.3 V line (red wire).
10. Start streaming.
Detect Missing Trigger Example
The goal of this example is to detect missing triggers.
Missing Triggers = Total Number of Triggers – Total Number of Exposures
Counter0 counts the total number of triggers. Counter1 counts the total number of exposures.
1. Disable Exposure Auto and set a long Exposure Time (for example, 3.5 seconds).
2. Enable Trigger Mode and set Trigger Source to line 0 Rising Edge.
3. Connect Line0 (1 Hz TTL signal) to the camera.
4. Configure Counter0 to count the number of triggers.
a. From Counter Event Source, select Line0. Set Counter Event Activation to Rising Edge.
b. From Counter Trigger Source, select Line0. Set Counter Trigger Activation to Rising Edge.
c. Set the Counter Duration to a high value and Counter Delay to 0.
5. Configure Counter1 to count the number of exposures.
a. From Counter Event Source, select ExposureStart. Set Counter Event Activation to Rising Edge.
b. From Counter Trigger Source, select ExposureStart. Set Counter Trigger Activation to Rising Edge.
c. Set the Counter Duration to the same high value as Counter0 and Counter Delay to 0.
6. Enable 1 Hz trigger source. The camera starts capturing images.
7. Right click SpinView GUI to refresh the nodemap and update the Counter Value.
a. Select Counter0 and take note of the Counter Value.
b. Select Counter1 and take note of the Counter Value.
8. Calculate missing triggers: