How To: Two Cameras, One on Software and One on Hardware Trigger

This guide sets up one installation of LumiScan Cam Driver with two cameras:

  • camera1 is triggered by software: each capture fires the camera and takes its image.

  • camera2 is triggered by a hardware signal on one of its input lines: a capture takes the next image the camera delivers after a pulse.

Both store their images in the same storage folder, each in a sub-folder of its own. All five files are complete: copy them, then change the serial numbers.

Files

All five files of this guide, to download:

Before you start

  • LumiScan Cam Driver installed, with one licence per camera, see Requirements

  • Two GigE Vision cameras in the camera network, with their serial numbers

  • The trigger signal wired to an input line of camera2; the name of that line (Line0, Line1, …​) is in the camera’s documentation

The files below use the settings format from v2.3.0: the cameras, with their serial numbers and feature files, are listed in lumiscan-cam-driver.json, and each module names its camera by cameraId. Before, each module file carried serial, driverId and initialFeatureFile itself. The Cam Driver converts files of the older format at start, keeping a copy of each file it changes.

How it fits together

File What it holds

lumiscan-cam-driver.json

The application settings: both module files, both cameras with their feature files, the storage

camera1.json

The module of the software-triggered camera

camera2.json

The module of the hardware-triggered camera

camera1-features.txt

The trigger settings of camera1: software trigger

camera2-features.txt

The trigger settings of camera2: hardware trigger on Line0, rising edge

When it connects a camera, the Cam Driver first sets it up for its own use - software trigger, packet size, pixel format - and then applies the camera’s feature files in order. A feature file can therefore change what the Cam Driver has set, as camera2-features.txt does with the trigger source. A feature the camera does not take is logged and skipped; the connection goes on.

Put all five files into the folder the Cam Driver reads its settings from, see Creating New Camera Settings Files. A relative path in featureFiles is resolved against this folder.

Step 1 - Application settings

lumiscan-cam-driver.json
{
    "$schema": "schemas/lumiscan-cam-driver.schema.json",
    "meta": {
        "inputFileType": "LumiScan-CtrlX-Cam-Driver",
        "inputFileVersion": "1.0.0",
        "targetMachine": "CtrlX7",
        "programName": "lumiscan-cam-driver",
        "programVersion": "2.3.0"
    },
    "modules": [
        "camera1.json",
        "camera2.json"
    ],
    "cameras": [
        {
            "cameraId": "camera1",
            "serial": "LX123456",
            "driverId": "default",
            "featureFiles": [
                "camera1-features.txt"
            ]
        },
        {
            "cameraId": "camera2",
            "serial": "LX654321",
            "driverId": "default",
            "featureFiles": [
                "camera2-features.txt"
            ]
        }
    ],
    "system": {
        "debug": false,
        "logLevel": "INFO",
        "unifiedStorage": false,
        "storage": {
            "type": "Internal",
            "parameters": {
                "rootPath": "images"
            }
        }
    }
}

Change:

  • serial of both cameras: the serial numbers of your cameras.

The images go to the folder images of the application’s settings folder. To store them elsewhere, change storage/parameters/rootPath, see Saving Image Files.

With unifiedStorage set to false, camera1 saves into <rootPath>/camera1 and camera2 into <rootPath>/camera2. One storage serves all modules: the storage cannot be set per module.

Step 2 - Module files

camera1.json
{
    "$schema": "schemas/lumiscan-cam-driver-module.schema.json",
    "meta": {
        "inputFileType": "LumiScan-Ctrlx-Camera-Configuration",
        "inputFileVersion": "0.0.1",
        "targetMachine": "CtrlX7",
        "programName": "lumiscan-cam-driver",
        "programVersion": "2.3.0"
    },
    "id": "camera1",
    "cameraId": "camera1",
    "exposureTimeUS": 10000,
    "pixelFormat": "Mono8",
    "exportPixelFormat": "Mono8",
    "packetSize": 1500,
    "packetDelay_us": 0,
    "timeout_ms": 2000,
    "timestampSource": "Camera",
    "clearBufferBeforeCapture": false,
    "triggerBeforeAcquire": true
}

triggerBeforeAcquire is true: each capture fires the software trigger and then takes the image. The client calls only control/capture/execute, or runs the capture handshake.

camera2.json
{
    "$schema": "schemas/lumiscan-cam-driver-module.schema.json",
    "meta": {
        "inputFileType": "LumiScan-Ctrlx-Camera-Configuration",
        "inputFileVersion": "0.0.1",
        "targetMachine": "CtrlX7",
        "programName": "lumiscan-cam-driver",
        "programVersion": "2.3.0"
    },
    "id": "camera2",
    "cameraId": "camera2",
    "exposureTimeUS": 10000,
    "pixelFormat": "Mono8",
    "exportPixelFormat": "Mono8",
    "packetSize": 1500,
    "packetDelay_us": 0,
    "timeout_ms": 10000,
    "timestampSource": "Camera",
    "clearBufferBeforeCapture": false,
    "triggerBeforeAcquire": false
}

triggerBeforeAcquire is false: a capture fires no trigger, it takes the next image the camera delivers. One pulse, one capture: images not yet captured wait in the camera’s queue (device-info/number-of-images-in-queue). timeout_ms is how long a capture waits for the pulse; when none comes, the capture fails with -10004 and the fault is latched until reset and connect-camera, see Recovering from a Failed Capture. Choose a timeout longer than the longest time between two pulses in your process.

Step 3 - Feature files

One feature per line, its name and its value. The names are GenICam (SFNC) names; a camera that names its trigger features differently needs a feature mapping, see Custom GenICam Feature Names.

camera1-features.txt
TriggerSelector FrameStart
TriggerMode On
TriggerSource Software
camera2-features.txt
TriggerSelector FrameStart
TriggerMode On
TriggerSource Line0
TriggerActivation RisingEdge

Change Line0 to the input line the trigger signal is wired to, and RisingEdge to the edge of your signal. Use an edge, not a level (LevelHigh, LevelLow).

Step 4 - Restart and check

  1. Restart LumiScan Cam Driver. It reads its settings files only at start.

  2. Connect both cameras with the handshake on <camera>/control/connect-camera.

  3. Check under hdvisionsystems/lumiscan-cam-driver/camera2/features that TriggerMode is On and TriggerSource is Line0. If not, the log names the feature the camera did not take.

  4. Capture with camera1/control/capture/execute: camera1/control/status/code is 0.

  5. Send a trigger pulse to camera2, then capture with camera2/control/capture/execute - or start the capture first and send the pulse within timeout_ms: camera2/control/status/code is 0.

  6. Save both images with <camera>/control/save/execute and check the two sub-folders of the storage folder.

Keep the cameras from transmitting at once

camera2 transmits as soon as its pulse comes, whatever camera1 is doing. If a pulse falls into a capture of camera1, both cameras send at the same time and images arrive incomplete (-10004). Either let the PLC keep the pulse of camera2 and the captures of camera1 apart, or interleave the packets of both cameras with GevSCPD and GevSCFTD, see Using Multiple Cameras. The packet delay of a camera is packetDelay_us in its module file; GevSCFTD can be added to its feature file.

Result

  • camera1 takes an image with every capture.

  • camera2 takes the image of each hardware pulse.

  • Both save into their own sub-folder of the same storage folder.

JSON Schemas

The application keeps the JSON Schemas of its settings files in its schemas folder; those copies always match the installed version. The schemas of LumiScan Cam Driver 2.3.0 can also be downloaded: JSON Schemas of LumiScan Cam Driver 2.3.0.

To have an editor such as Visual Studio Code check a copy of a settings file that you edit on your PC, point its $schema entry at the published schema:

{
  "$schema": "https://docs.hdvisionsystems.com/schemas/lumiscan-cam-driver/2.3.0/lumiscan-cam-driver.schema.json",
  ...
}

Leave the $schema entry of the files on the device as the application wrote it.