Trigger Ximea using external trigger

Issue #177 resolved
ibrahim created an issue

Hello,

I am trying to trigger a Ximea camera using a hardware trigger, by means of a Quantum Composer (trigger box). However it seems Itom only acknowledges software triggers.

I was wondering if there was a way to trigger the camera externally and then read and plot the file using Itom.

Thank You

Comments (10)

  1. M. Gronle

    Hello Ibrahim,
    usually the hardware trigger worked a while ago. However, if I remember it right, Ximea switched somewhen from a 5V TTL trigger input to a 24V input.

    In general you have to set the appropriate parameters of the camera via ``myCam.setParam(“paramName”, paramValue)`` in order to enable the hardware trigger.
    Then, you need to prepare the camera for the image acquisition by ``myCam.startDevice()``. Although you want to trigger an image acquisition by the hardware trigger,
    you need to prepare this acquisition by ``myCam.acquire()``. Then the camera is ready to wait for the hardware trigger.

    Could you please paste a minimal code snippet and the output of the command line with a possible error message? This would potentially simplify detecting the problem.
    A screenshot of the script and / or command line would also help.

    Ximea also supports the GenICam interface, therefore you could also try to connect to your camera via the genicam plugin. You need to indicate the absolute path to the corresponding cti-file in the Ximea application directory (e.g. C:\XIMEA\GenTL Producer\x64\ximea.gentl.64.cti). However, the general approach (configuring the camera, startDevice, acquire, trigger, getVal / copyVal…) remains the same.

    Cheers

    Marc

  2. ibrahim reporter

    Thanks for the response Marc

    I am eventually planning to take roughly 20 images in a 10ms time period (one image every 0.5ms), yet sometimes when trying to take single shots I get a timeout error as shown below.

    The script I am using is short. the line “qc.run()” initiates the triggers and causes 1 pulse every 0.5ms

    cam.setParam("trigger_mode", 1) #1 is ext. rising edge
    
    
    #Create store for data
    img = dataObject()
    
    #Start device + acquire
    cam.startDevice()
    cam.acquire()
    
    qc.run()
    for i in range (1,4):
        #Get image
        cam.copyVal(img)
        print(img)
        print(i)
    

    When running this code, I get either one of two errors.

    One error is this

    Traceback (most recent call last):
      File "\\icnas4.cc.ic.ac.uk\wqt17\desktop\ibrahim files\ximea camera trigger testing\trigger test 1.py", line 61, in <module>
        cam.copyVal(img)
    RuntimeError: Error invoking function copyVal with error message: 
    ximea m3api error 'Timeout' (pxiGetImage)
    

    which I’m not sure why as the trigger is being sent correctly. This does not get past even the first loop.

    The second output I get is

    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1) 
    1
    Traceback (most recent call last):
      File "\\icnas4.cc.ic.ac.uk\wqt17\desktop\ibrahim files\ximea camera trigger testing\trigger test 1.py", line 61, in <module>
        cam.copyVal(img)
    RuntimeError: Error invoking function copyVal with error message: 
    Tried to get picture without triggering exposure
    

    Lines 1 and 2 show that the code goes through the first loop yet stops at the second.

  3. ibrahim reporter

    After much pain, I have solved the second error with the lack of exposure triggering by putting cam.acquire() inside the loop. 🙂

    However it seems that when trying to take 20 images at 10ms apart, itom seems to display the timeout error at 9 shots every time. Any ideas why?

  4. ibrahim reporter

    The command qc.run() is sending 20 triggers at 10ms apart.

    #Set params
    cam.setParam("trigger_mode", 1) #1 is ext. rising edge
    
    
    #Create store for data
    img = dataObject()
    
    #Start device + acquire
    cam.startDevice()
    cam.acquire()
    
    qc.run()
    for i in range (1,20):
        cam.acquire()
        #Get image
        cam.copyVal(img)
        print(img)
        print(i)
    

    which results in the output

    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    1
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    2
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    3
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    4
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    5
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    6
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    7
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    8
    dataObject('uint16', [2048 x 2048], continuous: 1, owndata: 1)
    9
    Traceback (most recent call last):
      File "\\icnas4.cc.ic.ac.uk\wqt17\desktop\ibrahim files\ximea camera trigger testing\trigger test 1.py", line 65, in <module>
        cam.copyVal(img)
    RuntimeError: Error invoking function copyVal with error message: 
    ximea m3api error 'Timeout' (pxiGetImage)
    

    The code completes between 6-9 loops each time I run it.

    Also, note that when I set my trigger box up so that it sends the 20 triggers 100ms apart, it completes all the shots with no error. I feel this could be due to a limitation of the camera?

  5. Johann Krauter

    When ist works with slower Trigger interval then it can be some camera limitation. What is the maximum fps? Calculate the fps when using software trigger.

  6. M. Gronle

    I also think, that the 10ms interval is quite fast. It might be that the camera itself comes to its limit or the you reached a certain software limit. Please try to measure some timings within your code in order to verify, that the repeated call to acquire is faster than the 10ms trigger interval. It might be, that from time to time, the code in the loop runs a little bit longer than 10ms, such that the next trigger comes earlier than your next acquire command.

    However, the Timeout error of pxiGetImage is somehow strange and might come from a hardware limit of your camera (by the way which model do you use? What is your current integration / exposure time?). The timeout can be set by the plugin parameter timeout, which is set to 3secs per default. That means that the trigger should come within 3secs after the previous acquire command.

    If you only want to acquire a limited series of images you could also think about using the burst mode of the Ximea camera (see https://itom.bitbucket.io/plugindoc/plugins/grabber/ximea.html#image-acquisition-and-frame-burst and the documentation of Ximea). It might also be interesting to see what is your highest framerate using a software trigger only.

  7. Bernd Bertschinger

    What is the status of this issue? I would like to assign a person responsible for this issue.

  8. Log in to comment