InternalPwm

Warning

This is a feature in beta state. Please verify that the function performs as expected in your specific configuration and setup.

Note

This command is only supported on X3x cameras.

When working with the X3x camera the strong led flashes may be distracting for a lot of people. The internal pwm allows the led to be activated at high frequency, so a seemingly constant illumination is produced, which may be less distracting than single flashes.

The internal pwm can trigger both led and cameras, so the cameras will receive a trigger singal during an led flash.

Usage example for constant illumination:

// Call the Open command to open the camera
NxLibCommand open(cmdOpen);
open.parameters()[itmCameras] = "1234"; // Insert the serial number of the camera to be opened into the Cameras parameter of Open
open.execute();

NxLibCommand internalpwm(cmdInternalPwm);
internalpwm.parameters()[itmCameras] = "1234"; // Camera serial
internalpwm.parameters()[itmFrequency] = 75; // Set frequency to 75Hz
internalpwm.parameters()[itmDutyCycle] = 0.09; // Set duty cycle to 9%
internalpwm.parameters()[itmOutput][itmLeft] = true; // Will trigger left camera (which in turn triggers the right camera)
internalpwm.parameters()[itmOutput][itmLED] = true; // Will trigger led
internalpwm.execute();

NxLibItem camera = root[itmCameras][itmBySerialNo]["1234"]; // replace "1234" with your camera's serial number
	
// The internal pwm signal is high active
camera[itmParameters][itmCapture][itmTriggerMode] = valRisingEdge; // Set the camera to trigger on a rising edge on the GPIO port

// The camera will now be constantly triggered through the internal pwm. 
// So we only have to retrieve the images on demand by cmdRetrieve.

for (int imageIndex = 0; imageIndex < 10; imageIndex++) {
    NxLibCommand retrieve(cmdRetrieve);
    while (true) {
        retrieve.parameters()[itmTimeout] = 0;
        retrieve.execute();
        if (retrieve.result()["1234"][itmRetrieved].asBool()) {
            // a new image has been received and copied into the raw image node
            break;
        }
    }
    // Compute the disparity map, point map, and process the data according to your needs
}