Using the Digital Input and Output¶
The camera’s digital output is controlled via the Output node. Please first read about restrictions of controlling the output pin here.
The camera’s digital input state can be read from the Input node. When using a hardware trigger mode the electrical signal is used to trigger the camera exposure in hardware.
Note
The state of the input can be read from the Input node also when using hardware triggering, but the node replicates the electrical state with low frequency of around 5Hz, so you will not be able to safely detect trigger signals of 200ms or shorter by polling this node!
Code Examples¶
Flash Output¶
This example configures the output pin to output a low-active flash signal for 5ms synchronized to the camera’s exposure
NxLibItem root; // References the tree's root item at path "/"
NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/BySerialNo/1234"
// The camera must already be open. see Opening a Camera topic for more information
// Configure the output as a low-active flash
camera[itmParameters][itmIO][itmOutput][itmMode] = valLowActive;
camera[itmParameters][itmIO][itmOutput][itmDuration] = 5.0;
* References the tree's root item at path "/"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/', 0, 0, RootHandle)
* References the camera's item at path "/Cameras/BySerialNo/1234"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/Cameras/BySerialNo/1234', 0, 0, CameraHandle)
* The camera must already be open; see Opening a Camera topic for more information
* Configure the output as a low-active flash
set_framegrabber_param (CameraHandle, 'Parameters/IO/Output/Mode', 'LowActive')
set_framegrabber_param (CameraHandle, 'Parameters/IO/Output/Duration', 5.0)
Statically setting the output state¶
The following example will switch the output on for the duration of 1s.
Note
This example does not work with N20, N30 and N35 cameras as they do not support to set the output statically.
NxLibItem root; // References the tree's root item at path "/"
NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/1234"
// The camera must already be open. see Opening a Camera topic for more information
camera[itmParameters][itmIO][itmOutput][itmMode] = valHigh; // Set the output to 'high'
std::this_thread::sleep_for(std::chrono::seconds(1)); // Wait for 1s
camera[itmParameters][itmIO][itmOutput][itmMode] = valLow; // Set the output to 'low'
* References the tree's root item at path "/"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/', 0, 0, RootHandle)
* References the camera's item at path "/Cameras/BySerialNo/1234"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/Cameras/BySerialNo/1234', 0, 0, CameraHandle)
* The camera must already be open; see Opening a Camera topic for more information
* Set the output to 'high'
set_framegrabber_param (CameraHandle, 'Parameters/IO/Output/Mode', 'High')
wait_seconds (1)
* Set the output to 'low'
set_framegrabber_param (CameraHandle, 'Parameters/IO/Output/Mode', 'Low')
Reading the input state¶
Reads the input state of the camera.
Note
The camera must already be open. See Opening a Camera topic for more information
NxLibItem root; // References the tree's root item at path "/" NxLibItem camera = root[itmCameras]["1234"]; // References the camera's item at path "/Cameras/BySerialNo/1234" // The camera must already be open. see Opening a Camera topic for more information bool inputState = camera[itmParameters][itmIO][itmInput].asBool(); if (inputState) { printf("The camera's input is currently high\n"); } else { printf("The camera's input is currently low\n"); }
* References the tree's root item at path "/"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/', 0, 0, RootHandle)
* References the camera's item at path "/Cameras/BySerialNo/1234"
open_framegrabber ('Ensenso-NxLib', 0, 0, 0, 0, 0, 0, 'default', 0, 'Raw', -1, 'false', 'Item', '/Cameras/BySerialNo/1234', 0, 0, CameraHandle)
* The camera must already be open; see Opening a Camera topic for more information
get_framegrabber_param (CameraHandle, 'Parameters/IO/Input', InputState)