alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

Hardware trigger #21

Closed marciojersey closed 4 years ago

marciojersey commented 4 years ago

Under Ubuntu 20.0.4 with the Alvium 1800 U-500m camera, how do I go about setting up a hardware trigger for Line0 with the Python API?

NiklasKroeger-AlliedVision commented 4 years ago

The easiest way to figure out the correct settings for your triggering setup is usually with the Vimba Viewer. Here you have a widget, that allows you to try out different settings to see, which best fits your use case: image

With the shown settings you should be seeing a new frame for every rising edge in your Line0 signal.

To set these feature values with VimbaPython you would simply have to set the same feature values you decided on with the Vimba Viewer. You can find the feature names you have to adjust by taking another look in the Vimba Viewer widget where all settings are shown: image

Here you see the feature name which lets you access the feature in VimbaPython. You would then just go through all those features and set the values you need.

You code might look something like this (untested! Please adjust for your use case)

with vimba:
    with cam:
        cam.LineSelector.set('Line0')
        cam.LineMode.set('Input')
        cam.TriggerSource.set('Line0')
        cam.TriggerSelector.set('FrameStart')
        cam.TriggerMode.set('On')
        cam.TriggerActivation.set('RisingEdge')
        # Other features might be necessary

Generally the process of setting up triggering is independent of the used Vimba API. You simply have to set the correct feature values. Therefore the VimbaCPP or VimbaC documentation might include further informations for triggering that can be helpful to you. You would simply have to "translate" the feature access from the respective language to python as shown above.

marciojersey commented 4 years ago

I've modified the asynchronous_grab.py example in an attempt to test the triggering but I'm still not having any success. Not even with the Vimba Viewer can I get the hardware triggering to work. I've modified the example so that the main method is as follows:

def main(): print_preamble() cam_id = parse_args()

with Vimba.get_instance():
    with get_camera(cam_id) as cam:

        setup_camera(cam)

        cam.LineSelector.set('Line0')
        cam.LineMode.set('Input')
        cam.TriggerSource.set('Line0')
        cam.TriggerSelector.set('FrameStart')
        cam.TriggerActivation.set('RisingEdge');
        cam.TriggerMode.set('On')
        cam.AcquisitionMode.set('SingleFrame')
        try:
            cam.start_streaming(handler=frame_handler)

            print("waiting for triggers...")
            input()
        finally :
            cam.stop_streaming ()

I am using a JST 7 pin I/O cable (product number 12322) in my setup. I grounded pin 6 (black wire) and sending a 5.35 VDC signal to pin 2 (brown wire). I've confirmed with a multimeter that the electrical setup is not the issue. What am I missing?

NiklasKroeger-AlliedVision commented 4 years ago

Not even with the Vimba Viewer can I get the hardware triggering to work.

This sounds like you might not have the correct settings figured out yet. If the triggering does not work in the Vimba Viewer, VimbaPython will also not be able to receive any triggered images as the camera is not recording anything.

I am using a JST 7 pin I/O cable (product number 12322) in my setup. I grounded pin 6 (black wire) and sending a 5.35 VDC signal to pin 2 (brown wire). I've confirmed with a multimeter that the electrical setup is not the issue. What am I missing?

Triggering usually happens on a rising edge for the chosen input line (can be configured to happen at falling edge as well). Your description makes it sound like you are providing a constant 5.35V signal to the input line. Is that the case? If so there is no trigger being fired because the camera never detects a rising edge in the trigger signal.

This sounds to me like this is not really a problem with VimbaPython (which these Github issues are meant to cover) but rather a general usage question our support team is better equipped to handle. I would therefore suggest that you contact them via the form on our website. They have much more experience with these general usage questions and troubleshooting than I do and can probably help you better. Feel free to put a link to this Github issue into the description so they can easily follow our discussion so far.

marciojersey commented 4 years ago

Not even with the Vimba Viewer can I get the hardware triggering to work.

This sounds like you might not have the correct settings figured out yet. If the triggering does not work in the Vimba Viewer, VimbaPython will also not be able to receive any triggered images as the camera is not recording anything.

I am using a JST 7 pin I/O cable (product number 12322) in my setup. I grounded pin 6 (black wire) and sending a 5.35 VDC signal to pin 2 (brown wire). I've confirmed with a multimeter that the electrical setup is not the issue. What am I missing?

Triggering usually happens on a rising edge for the chosen input line (can be configured to happen at falling edge as well). Your description makes it sound like you are providing a constant 5.35V signal to the input line. Is that the case? If so there is no trigger being fired because the camera never detects a rising edge in the trigger signal.

This sounds to me like this is not really a problem with VimbaPython (which these Github issues are meant to cover) but rather a general usage question our support team is better equipped to handle. I would therefore suggest that you contact them via the form on our website. They have much more experience with these general usage questions and troubleshooting than I do and can probably help you better. Feel free to put a link to this Github issue into the description so they can easily follow our discussion so far.

I've figured out the issue. It came down to electrical wiring. I had the trigger activation set to RisingEdge and my logic was that if I touched pin 2 with a 5.25 VDC live wire, I would activate the trigger but I wasn't having any success with that method. So I tried leaving pins 2 and 6 connected but with the 5.25 VDC power source off. By turning the power source on and off I've been able to successfully activate the trigger. Thanks for your feedback.

NiklasKroeger-AlliedVision commented 4 years ago

Glad you got it working! I will go ahead and close this issue. If you do run into further problems feel free to contact our support, of if they are related to VimbaPython create an issue here directly.