Counter (ace 2, boost)

The Counter camera feature allows you to count certain camera events, e.g., the number of images acquired.

For a description of the Counter feature for ace classic/U/L cameras, click here.

In this topic Hide

Using the Feature

How It Works

Two counters are available: Counter 1 and Counter 2.

Every counter has the following characteristics:

Getting the Value of a Counter

To determine the current value of a counter, get the value of the CounterValue parameter. This parameter is read-only.

Starting a Counter

Before a counter can count, it must be started.

If you start a counter, it will not necessarily start counting. If and when the counter counts depends on the event source set.

Counter Trigger Source

The CounterTriggerSource parameter allows you to specify which source starts the counter.

To specify the trigger source:

  1. Set the CounterSelector parameter to the desired counter, e.g., Counter2.
  2. Set the CounterTriggerSource parameter to the source that you want to use to start the counter.

Now, the counter starts whenever the camera detects a signal on the selected source. When started, the counter's status changes from CounterTriggerWait to CounterActive.

Example 1: You set the CounterTriggerSource parameter to Line2. Now, the counter starts when the input or output signal on Line 2 changes.

Example 2: You set the CounterTriggerSource parameter to SoftwareSignal1. Now, the counter starts whenever you execute a SoftwareSignalPulse command via channel 1.

Counter Trigger Activation

By default, a counter only starts when a signal on the selected trigger source rises, i.e., when the signal status changes from low to high.

To change this behavior, set the CounterTriggerActivation parameter to one of the following values:

The CounterEventActivation parameter is only available for event sources that can be high (0) or low (1), i.e., an I/O signal or an "Active" signal like ExposureActive.

Increasing a Counter

Once a counter is started, it can be increased, i.e., it can count.

Counter Event Source

The CounterEventSource parameter allows you to specify which source increases the counter.

To specify the event source:

  1. Set the CounterSelector parameter to the desired counter, e.g., Counter2.
  2. Set the CounterEventSource parameter to the source that you want to use to increase the counter.

Now, the counter increases whenever the camera detects a signal on the selected source.

Example 1: You set the CounterEventSource parameter to Line2. Now, the counter increases whenever the input or output signal on Line 2 changes as specified by the CounterEventActivation parameter.

Example 2: You set the CounterEventSource parameter to SoftwareSignal1. Now, the counter increases whenever you execute a SoftwareSignalPulse command via channel 1.

Counter Event Activation

By default, a counter only counts when a signal on the selected event source rises, i.e., when the signal status changes from low to high.

To change this behavior, set the CounterEventActivation parameter to one of the following values:

The CounterEventActivation parameter is only available for event sources that can be high (0) or low (1), i.e., an I/O signal or an "Active" signal like ExposureActive.

Resetting a Counter

You can reset the counter to 0 at any time.

You must reset the counter if it has reached its maximum value (defined by the CounterDuration parameter value) and you want to reuse it.

After the counter has been reset, you must start it again.

Reset by Software

To reset a counter by software, execute the CounterReset command.

Alternatively, you can set a software signal as the reset source (see below).

Reset Using a Reset Source

The CounterResetSource parameter allows you to specify which source resets the counter.

To specify the reset source:

  1. Set the CounterSelector parameter to the desired counter, e.g., Counter2.
  2. Set the CounterResetSource parameter to the source that you want to use to reset the counter.

Now, the counter resets whenever the camera detects a signal on the selected source. When reset, the counter's status changes to CounterTriggerWait and must be started again.

Example 1: You set the CounterResetSource parameter to Line2. Now, the counter resets whenever the input or output signal on Line 2 changes as specified by the CounterResetActivation parameter.

Example 2: You set the CounterResetSource parameter to SoftwareSignal1. Now, the counter resets whenever you execute a SoftwareSignalPulse command via channel 1.

Counter Reset Activation

By default, a counter only resets when a signal on the selected reset source rises, i.e., when the signal status changes from low to high.

To change this behavior, set the CounterResetActivation parameter to one of the following values:

The CounterResetActivation parameter is only available for event sources that can be high (0) or low (1), i.e., an I/O signal or an "Active" signal like ExposureActive.

Stopping a Counter

To stop a counter, do any of the following:

Getting the Status of a Counter

To get the current status of a counter, get the value of the CounterStatus parameter. This parameter is read-only.

Possible values are:

Sample Code

// Select Counter 1
camera.CounterSelector.SetValue(CounterSelector_Counter1);
// Specify that the counter starts when a software signal is sent via channel 1
camera.CounterTriggerSource.SetValue(CounterTriggerSource_SoftwareSignal1);
// Specify that the counter increases whenever a rising signal is detected on Line 1
camera.CounterEventSource.SetValue(CounterEventSource_Line1);
camera.CounterEventActivation.SetValue(CounterEventActivation_RisingEdge);
// Specify that the counter is reset whenever a falling signal is detected on Line 2
camera.CounterResetSource.SetValue(CounterResetSource_Line2);
camera.CounterResetActivation.SetValue(CounterEventActivation_FallingEdge);
// Set the maximum value of the counter to 1000
camera.CounterDuration.SetValue(1000);
// Manually reset the counter
camera.CounterReset.Execute();
// Get the current status of the counter
CounterStatusEnums counterStatus = camera.CounterStatus.GetValue();
// Get the current value of the counter
int64_t i = camera.CounterValue.GetValue();
INodeMap& nodemap = camera.GetNodeMap();
// Select Counter 1
CEnumerationPtr(nodemap.GetNode("CounterSelector"))->FromString("Counter1");
// Specify that the counter starts when a software signal is sent via channel 1
CEnumerationPtr(nodemap.GetNode("CounterTriggerSource"))->FromString("SoftwareSignal1");
// Specify that the counter increases whenever a rising signal is detected on Line 1
CEnumerationPtr(nodemap.GetNode("CounterEventSource"))->FromString("Line1");
CEnumerationPtr(nodemap.GetNode("CounterEventActivation"))->FromString("RisingEdge");
// Specify that the counter is reset whenever a falling signal is detected on Line 2
CEnumerationPtr(nodemap.GetNode("CounterResetSource"))->FromString("Line2");
CEnumerationPtr(nodemap.GetNode("CounterResetActivation"))->FromString("FallingEdge");
// Set the maximum value of the counter to 1000
CIntegerPtr(nodemap.GetNode("CounterDuration"))->SetValue(1000);
// Manually reset the counter
CCommandPtr(nodemap.GetNode("CounterReset"))->Execute();
// Get the current status of the counter
String_t counterStatus = CEnumerationPtr(nodemap.GetNode("CounterStatus"))->ToString();
// Get the current value of the counter
int64_t i = CIntegerPtr(nodemap.GetNode("CounterValue"))->GetValue();
// Select Counter 1
camera.Parameters[PLCamera.CounterSelector].SetValue(PLCamera.CounterSelector.Counter1);
// Specify that the counter starts when a software signal is sent via channel 1
camera.Parameters[PLCamera.CounterTriggerSource].SetValue(PLCamera.CounterTriggerSource.SoftwareSignal1);
// Specify that the counter increases whenever a rising signal is detected on Line 1
camera.Parameters[PLCamera.CounterEventSource].SetValue(PLCamera.CounterEventSource.Line1);
camera.Parameters[PLCamera.CounterEventActivation].SetValue(PLCamera.CounterEventActivation.RisingEdge);
// Specify that the counter is reset whenever a falling signal is detected on Line 2
camera.Parameters[PLCamera.CounterResetSource].SetValue(PLCamera.CounterResetSource.Line2);
camera.Parameters[PLCamera.CounterResetActivation].SetValue(PLCamera.CounterEventActivation.FallingEdge);
// Set the maximum value of the counter to 1000
camera.Parameters[PLCamera.CounterDuration].SetValue(1000);
// Manually reset the counter
camera.Parameters[PLCamera.CounterReset].Execute();
// Get the current status of the counter
string counterStatus = camera.Parameters[PLCamera.CounterStatus].GetValue();
// Get the current value of the counter
Int64 i = camera.Parameters[PLCamera.CounterValue].GetValue();
// Select Counter 1
Pylon.DeviceFeatureFromString(hdev, "CounterSelector", "Counter1");
// Specify that the counter starts when a software signal is sent via channel 1
Pylon.DeviceFeatureFromString(hdev, "CounterTriggerSource", "SoftwareSignal1");
// Specify that the counter increases whenever a rising signal is detected on Line 1
Pylon.DeviceFeatureFromString(hdev, "CounterEventSource", "Line1");
Pylon.DeviceFeatureFromString(hdev, "CounterEventActivation", "RisingEdge");
// Specify that the counter is reset whenever a falling signal is detected on Line 2
Pylon.DeviceFeatureFromString(hdev, "CounterResetSource", "Line2");
Pylon.DeviceFeatureFromString(hdev, "CounterResetActivation", "FallingEdge");
// Set the maximum value of the counter to 1000
Pylon.DeviceSetIntegerFeature(hdev, "CounterDuration", 1000);
// Manually reset the counter
Pylon.DeviceExecuteCommandFeature(hdev, "CounterReset");
// Get the current status of the counter
string counterStatus = Pylon.DeviceFeatureToString(hdev, "CounterStatus");
// Get the current value of the counter
Int64 i = Pylon.DeviceGetIntegerFeature(hdev, "CounterValue");
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
size_t len = 0;
char counterStatus_str[64] = {0};
int64_t i = 0;
/* Select Counter 1 */
errRes = PylonDeviceFeatureFromString(hdev, "CounterSelector", "Counter1");
CHECK(errRes);
/* Specify that the counter starts when a software signal is sent via channel 1 */
errRes = PylonDeviceFeatureFromString(hdev, "CounterTriggerSource", "SoftwareSignal1");
CHECK(errRes);
/* Specify that the counter increases whenever a rising signal is detected on Line 1 */
errRes = PylonDeviceFeatureFromString(hdev, "CounterEventSource", "Line1");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "CounterEventActivation", "RisingEdge");
CHECK(errRes);
/* Specify that the counter is reset whenever a falling signal is detected on Line 2 */
errRes = PylonDeviceFeatureFromString(hdev, "CounterResetSource", "Line2");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "CounterResetActivation", "FallingEdge");
CHECK(errRes);
/* Set the maximum value of the counter to 1000 */
errRes = PylonDeviceSetIntegerFeature(hdev, "CounterDuration", 1000);
CHECK(errRes);
/* Manually reset the counter */
errRes = PylonDeviceExecuteCommandFeature(hdev, "CounterReset");
CHECK(errRes);
/* Get the current status of the counter */
len = sizeof(counterStatus_str);
errRes = PylonDeviceFeatureToString(hdev, "CounterStatus", counterStatus_str, &len);
CHECK(errRes);
/* Get the current value of the counter */
errRes = PylonDeviceGetIntegerFeature(hdev, "CounterValue", &i);
CHECK(errRes);

You can also use the pylon Viewer to easily set the parameters.