Technical Application Notes
Click an item to read from the list below.

Technical Application Notes


 

 

Using Counter and Timer Control

Using Counter and Timer Control

Technical Application Note TAN2016004

Revised June 17, 2016

Subject

Technical Application Note (TAN2016004): Using Counter and Timer Control

10629

Applicable Products

  • Blackfly S and Spinnaker SDK

Application Note Description

This document provides an overview of the Counter and Timer Control feature in the Blackfly S camera.

Introduction

The Counter and Timer feature allows you to:

  • Create a function generator
  • Keep a count of how many times a signal has fired

Some general applications include:

  • Input to Logic Block
  • Line output for controlling external devices
  • Keep track of how many times the camera has exposed
  • Keep track of how many times an external input signal has triggered
  • Trigger the camera at a predefined period of time

Note: This document uses the SpinView application to demonstrate the configuration and execution of Counter and Timer Control.

Configuring Counter and Timer Control

  1. Select the counter (0 or 1).
  2. Select Event Source to indicate when the counter increments.
  3. When the selected source allows for signal activation, use Counter Event Activation to specify Level Low, Level High, Falling Edge, Rising Edge, or Any Edge.
  4. Set the Counter Delay to indicate the maximum number of counts that need to occur before generating the Counter Start event.
  5. Set the Counter Duration to indicate the maximum number of counts that need to occur before generating the Counter End event.
  6. Select either the Counter Trigger Source to specify the event to start the counter or Counter Reset Source to specify the event to end the counter. Only one can be active at a time. Selecting one disables the other.
    1. Select the Counter Trigger Source.
    2. When the selected source allows for signal activation, use Counter Trigger Activation to specify Level Low, Level High, Falling Edge, Rising Edge, or Any Edge.

    OR

    1. Select the Counter Reset Source.
    2. When the selected source allows for signal activation, use Counter Reset Activation to specify Level Low, Level High, Falling Edge, Rising Edge, or Any Edge.

 

Possible sources for event, trigger, or reset include:

  • MHz Tick
  • Line Inputs
  • User Outputs
  • Counter Starts
  • Counter Ends
  • Logic Block Outputs
  • Exposure Start
  • Exposure End
  • Frame Trigger Wait

Example

The counter increments by 1 on every rising edge at Line0 to a maximum of 4.

A = Counter Delay

B = Counter Duration

C = Line0 Input Signal

D = Counter0 Start

E = Counter0 End

Counter Status

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.

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.

1 MHz / 50 Hz = 20,000 cycles / duration

4. Define Counter Duration and Counter Delay values to create a 70% duty cycle.

Counter Delay = 30% x 20,000 = 6,000
Counter Duration = 70% x 20,000 = 14,000

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.

9. 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:

Missing trigger = Counter0 Value – Counter1 Value
= 3 – 1
= 2