Timer (ace 2, boost)#
For a description of the Timer feature for ace classic/U/L cameras, click here.
Using the Feature#
How It Works#
Two timers are available, Timer 1 and Timer 2.
This is how a timer works:
- A trigger source event that starts the internal timer occurs.
- A delay begins to expire.
- An arm delay begins to expire.
- When the delay has expired, the timer output signal goes high and stays high for the duration that you have configured.
- When the duration has expired, the timer output signal goes low.
- When the arm delay has expired, the camera can receive the next trigger source event.
Configuring a Timer#
To configure a timer:
- Set the
TimerSelector
parameter to the desired timer, e.g.,Timer1
. - Set the
TimerDuration
parameter to the desired timer duration in microseconds. - Set the
TimerDelay
parameter to the desired timer delay in microseconds. - Set the
TimerTriggerArmDelay
parameter to the desired arm delay in microseconds. - Set the
LineSelector
parameter to the output line that you want to use for the timer signal.
If the line is a GPIO line, the line must be configured as output. - If you selected Timer 1 in step 1, set the
LineSource
parameter toTimer1Active
. - If you selected Timer 2 in step 1, set the
LineSource
parameter toTimer2Active
.
Starting a Timer#
Timer Trigger Source#
The TimerTriggerSource
parameter allows you to specify which source starts the timer.
To specify the trigger source:
- Set the
TimerSelector
parameter to the desired timer, e.g.,Timer1
. - Set the
TimerTriggerSource
parameter to the source that you want to use to start the timer.
Now, the timer starts whenever the camera detects a signal on the selected source.
When started, the timer's status immediately changes from TimerTriggerWait
to TimerActive
, regardless of the delay set. However, the timer output signal will only go high after the delay has expired.
Example 1: You set the TimerTriggerSource
parameter to Line2
. Now, the timer starts when the input or output signal on Line 2 changes.
Example 2: You set the TimerTriggerSource
parameter to SoftwareSignal1
. Now, the timer starts whenever you execute a SoftwareSignalPulse
command via channel 1.
Timer Trigger Activation#
By default, a timer 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 TimerTriggerActivation
parameter to one of the following values:
RisingEdge
(default): The timer starts when the signal rises, i.e., when the signal status changes from low to high.FallingEdge
: The timer starts when the signal falls, i.e., when the signal status changes from high to low.AnyEdge
: The timer starts when the signal falls or rises.LevelHigh
: The timer starts when the signal is high. When the signal changes to low, the timer stops and must be started again.LevelLow
: The timer starts when the signal is low. When the signal changes to high, the timer stops and must be started again.
Info
The TimerTriggerActivation
parameter is only available for timer trigger sources that can be high (0) or low (1), i.e., an I/O signal or an "Active" signal like ExposureActive
.
Resetting a Timer#
To reset a timer, execute the TimerReset
command.
The timer's status changes from TimerActive
to TimerTriggerWait
.
The timer can now be restarted immediately regardless of the arm delay set.
Getting the Status of a Timer#
To get the current status of a timer, get the value of the TimerStatus
parameter. This parameter is read-only.
Possible values are:
TimerTriggerWait
: The timer is waiting to be started.TimerActive
: The timer has been started. A timer immediately switches to this state when the trigger source event occurs, regardless of the delay set. If an arm delay is set, the timer remains in theTimerActive
state until the arm delay has expired.TimerIdle
: The timer is idle. A timer is in this state whenever theTimerTriggerSource
parameter is set oOff
, i.e., the timer can't be started.
Sample Code#
// Select Timer 1
camera.TimerSelector.SetValue(TimerSelector_Timer1);
// Set the timer duration to 1000 microseconds
camera.TimerDuration.SetValue(1000.0);
// Set the timer delay to 500 microseconds
camera.TimerDelay.SetValue(500.0);
// Set the timer trigger arm delay to 5000 microseconds
camera.TimerTriggerArmDelay.SetValue(5000.0);
// Select Line 2 and configure the line as output
camera.LineSelector.SetValue(LineSelector_Line2);
camera.LineMode.SetValue(LineMode_Output);
// Specify that the timer signal is output on Line 2
camera.LineSource.SetValue(LineSource_Timer1Active);
// Specify that the timer starts whenever a rising signal is detected on Line 1
camera.TimerTriggerSource.SetValue(TimerTriggerSource_Line1);
camera.TimerTriggerActivation.SetValue(TimerTriggerActivation_RisingEdge);
// Reset the timer
camera.TimerReset.Execute();
// Get the current status of the timer
TimerStatusEnums timerStatus = camera.TimerStatus.GetValue();
INodeMap& nodemap = camera.GetNodeMap();
// Select Timer 1
CEnumerationPtr(nodemap.GetNode("TimerSelector"))->FromString("Timer1");
// Set the timer duration to 1000 microseconds
CFloatPtr(nodemap.GetNode("TimerDuration"))->SetValue(1000.0);
// Set the timer delay to 500 microseconds
CFloatPtr(nodemap.GetNode("TimerDelay"))->SetValue(500.0);
// Set the timer trigger arm delay to 5000 microseconds
CFloatPtr(nodemap.GetNode("TimerTriggerArmDelay"))->SetValue(5000.0);
// Select Line 2 and configure the line as output
CEnumerationPtr(nodemap.GetNode("LineSelector"))->FromString("Line2");
CEnumerationPtr(nodemap.GetNode("LineMode"))->FromString("Output");
// Specify that the timer signal is output on Line 2
CEnumerationPtr(nodemap.GetNode("LineSource"))->FromString("Timer1Active");
// Specify that the timer starts whenever a rising signal is detected on Line 1
CEnumerationPtr(nodemap.GetNode("TimerTriggerSource"))->FromString("Line1");
CEnumerationPtr(nodemap.GetNode("TimerTriggerActivation"))->FromString("RisingEdge");
// Reset the timer
CCommandPtr(nodemap.GetNode("TimerReset"))->Execute();
// Get the current status of the timer
String_t timerStatus = CEnumerationPtr(nodemap.GetNode("TimerStatus"))->ToString();
INodeMap& nodemap = camera.GetNodeMap();
// Select Timer 1
CEnumParameter(nodemap, "TimerSelector").SetValue("Timer1");
// Set the timer duration to 1000 microseconds
CFloatParameter(nodemap, "TimerDuration").SetValue(1000.0);
// Set the timer delay to 500 microseconds
CFloatParameter(nodemap, "TimerDelay").SetValue(500.0);
// Set the timer trigger arm delay to 5000 microseconds
CFloatParameter(nodemap, "TimerTriggerArmDelay").SetValue(5000.0);
// Select Line 2 and configure the line as output
CEnumParameter(nodemap, "LineSelector").SetValue("Line2");
CEnumParameter(nodemap, "LineMode").SetValue("Output");
// Specify that the timer signal is output on Line 2
CEnumParameter(nodemap, "LineSource").SetValue("Timer1Active");
// Specify that the timer starts whenever a rising signal is detected on Line 1
CEnumParameter(nodemap, "TimerTriggerSource").SetValue("Line1");
CEnumParameter(nodemap, "TimerTriggerActivation").SetValue("RisingEdge");
// Reset the timer
CCommandParameter(nodemap, "TimerReset").Execute();
// Get the current status of the timer
String_t timerStatus = CEnumParameter(nodemap, "TimerStatus").GetValue();
// Select Timer 1
camera.Parameters[PLCamera.TimerSelector].SetValue(PLCamera.TimerSelector.Timer1);
// Set the timer duration to 1000 microseconds
camera.Parameters[PLCamera.TimerDuration].SetValue(1000.0);
// Set the timer delay to 500 microseconds
camera.Parameters[PLCamera.TimerDelay].SetValue(500.0);
// Set the timer trigger arm delay to 5000 microseconds
camera.Parameters[PLCamera.TimerTriggerArmDelay].SetValue(5000.0);
// Select Line 2 and configure the line as output
camera.Parameters[PLCamera.LineSelector].SetValue(PLCamera.LineSelector.Line2);
camera.Parameters[PLCamera.LineMode].SetValue(PLCamera.LineMode.Output);
// Specify that the timer signal is output on Line 2
camera.Parameters[PLCamera.LineSource].SetValue(PLCamera.LineSource.Timer1Active);
// Specify that the timer starts whenever a rising signal is detected on Line 1
camera.Parameters[PLCamera.TimerTriggerSource].SetValue(PLCamera.TimerTriggerSource.Line1);
camera.Parameters[PLCamera.TimerTriggerActivation].SetValue(PLCamera.TimerTriggerActivation.RisingEdge);
// Reset the timer
camera.Parameters[PLCamera.TimerReset].Execute();
// Get the current status of the timer
string timerStatus = camera.Parameters[PLCamera.TimerStatus].GetValue();
// Select Timer 1
Pylon.DeviceFeatureFromString(hdev, "TimerSelector", "Timer1");
// Set the timer duration to 1000 microseconds
Pylon.DeviceSetFloatFeature(hdev, "TimerDuration", 1000.0);
// Set the timer delay to 500 microseconds
Pylon.DeviceSetFloatFeature(hdev, "TimerDelay", 500.0);
// Set the timer trigger arm delay to 5000 microseconds
Pylon.DeviceSetFloatFeature(hdev, "TimerTriggerArmDelay", 5000.0);
// Select Line 2 and configure the line as output
Pylon.DeviceFeatureFromString(hdev, "LineSelector", "Line2");
Pylon.DeviceFeatureFromString(hdev, "LineMode", "Output");
// Specify that the timer signal is output on Line 2
Pylon.DeviceFeatureFromString(hdev, "LineSource", "Timer1Active");
// Specify that the timer starts whenever a rising signal is detected on Line 1
Pylon.DeviceFeatureFromString(hdev, "TimerTriggerSource", "Line1");
Pylon.DeviceFeatureFromString(hdev, "TimerTriggerActivation", "RisingEdge");
// Reset the timer
Pylon.DeviceExecuteCommandFeature(hdev, "TimerReset");
// Get the current status of the timer
string timerStatus = Pylon.DeviceFeatureToString(hdev, "TimerStatus");
/* 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 timerStatus_str[64] = {0};
/* Select Timer 1 */
errRes = PylonDeviceFeatureFromString(hdev, "TimerSelector", "Timer1");
CHECK(errRes);
/* Set the timer duration to 1000 microseconds */
errRes = PylonDeviceSetFloatFeature(hdev, "TimerDuration", 1000.0);
CHECK(errRes);
/* Set the timer delay to 500 microseconds */
errRes = PylonDeviceSetFloatFeature(hdev, "TimerDelay", 500.0);
CHECK(errRes);
/* Set the timer trigger arm delay to 5000 microseconds */
errRes = PylonDeviceSetFloatFeature(hdev, "TimerTriggerArmDelay", 5000.0);
CHECK(errRes);
/* Select Line 2 and configure the line as output */
errRes = PylonDeviceFeatureFromString(hdev, "LineSelector", "Line2");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "LineMode", "Output");
CHECK(errRes);
/* Specify that the timer signal is output on Line 2 */
errRes = PylonDeviceFeatureFromString(hdev, "LineSource", "Timer1Active");
CHECK(errRes);
/* Specify that the timer starts whenever a rising signal is detected on Line 1 */
errRes = PylonDeviceFeatureFromString(hdev, "TimerTriggerSource", "Line1");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "TimerTriggerActivation", "RisingEdge");
CHECK(errRes);
/* Reset the timer */
errRes = PylonDeviceExecuteCommandFeature(hdev, "TimerReset");
CHECK(errRes);
/* Get the current status of the timer */
len = sizeof(timerStatus_str);
errRes = PylonDeviceFeatureToString(hdev, "TimerStatus", timerStatus_str, &len);
CHECK(errRes);
You can also use the pylon Viewer to easily set the parameters.