# Output trigger signal from camera to PLC using CVBpy

**URL:** <https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565>\
**Category:** Python API\
**Created:** [October 8, 2018, 8:43am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565 "2018-10-08T08:43:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![GTG](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GTG](https://forum.commonvisionblox.com/u/GTG)\
**Post date:** [October 8, 2018, 8:43am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/1 "2018-10-08T08:43:32Z")

</div>

Hi Everyone  
I am using a Teledyne Dalsa Genie Nano- M1920 (GigE, POE) to develop an inspection system that requires a trigger to be sent from the camera to a PLC, to stop a line, when the incorrect part is detected. I have been using successfully CVBPy for the image acquisition and some of the processing. What i need now is to know how to set up a stop trigger signal (e.g 5V) from the camera to a PLC or anything else, I have second I/O cable attached to the camera but do not know where to start, I am using CVBpy… Any help is very much appreciated.  
Thank you

---

<div class="post-metadata">

**Author:** ![piotrM](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@piotrM](https://forum.commonvisionblox.com/u/piotrM)\
**Post date:** [October 8, 2018, 9:02am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/2 "2018-10-08T09:02:09Z")

</div>

Hi,  
I have not yet done that but you can enable a trigger mode through Common Vision Blox Management Console on your PC - “Device configuration” section. I am sure you can figure out what to set to fit your needs.

 ![teledyneTrigger](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/1e7fda07e49e5d242c97b58e078f9b47aaf448da.png)  
Than you can find the I/O connection diagram in the Genie Nano Manual (download from teledyne web page )and connect it to PLC.

I might be wrong because I have planned how to do it but not yet tested.  
Good luck  
Piotr

---

<div class="post-metadata">

**Author:** ![CvK](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/cvk/32/112_2.png) [@CvK](https://forum.commonvisionblox.com/u/CvK)\
**Post date:** [October 8, 2018, 10:44am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/3 "2018-10-08T10:44:04Z")

</div>

The following setting in the camera ought to get you the functionality you need 🙂

You might run into trouble if you want to toggle this very fast though, but setting this node to do some outputs should be fine if you are not so concerned about real-time.

> Output Line Software Command (Cust::outputLineSoftwareCmd)  
> Writing a value of 1 in the bit field applies the Latch value of the outputLineSoftwareLatchControl and/or executes the PulseOnSoftwareCmd for any output line programmed for software control. The feature outputLineSoftwareCmd can take any binary value and each bit set to 1 corresponds to a Icommand for an Output. Note that Outputs are numbered from 1 to N, therefore Bit 1 of outputLineSoftwareCmd corresponds to Output1. This is applicable to OutputLineSource = Pulse On: where Software Cmd (for Pulse mode) or OutputLineSource = SoftwareControlled and OutputLineSoftwareLatchControl = Latch (for static states).
> 
> | Full Name: | Cust::outputLineSoftwareCmd |
> | --- | --- |
> | Type: | Integer |
> | Access Mode: | Read/Write |
> | Visibility: | Expert |
> | Caching Mode: | Write Through |
> | Streamable: | False |

---

<div class="post-metadata">

**Author:** ![GTG](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GTG](https://forum.commonvisionblox.com/u/GTG)\
**Post date:** [October 17, 2018, 1:38pm UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/4 "2018-10-17T13:38:39Z")

</div>

Thank you very much for the replies so far. So I can set a trigger signal using the CVB management console. I have set it to accept a “Pulse on: Software Command” and using “output Line Software Command =1” genereates the voltage pulse, the pulse duration can be preset. So far so good, I have measured the output signal with a multimeter. My question is, how can the command be set/send using CVBpy since all my development is in python?

I have tried :  
vin\_device= cvb.DeviceFactory.open(cvb\_driver\_path)  
vin\_device.software\_trigger.send\_trigger(1)

get a RuntimeError: failed to send software trigger

Again any help is appreciated, thanks

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [October 17, 2018, 5:58pm UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/5 "2018-10-17T17:58:32Z")

</div>

The camera doesn’t look like its using the standard features for software triggering.

You first need to get the node map from the device as shown here:

[https://forum.commonvisionblox.com/t/cvb-py-set-node/294/2?u=parsd](https://forum.commonvisionblox.com/t/cvb-py-set-node/294/2)

Also the feature nodes are mapped by their actual name and are not made pythonic. Try something like:

```auto
device_node_map = vin_device.node_maps['Device']
sw_trigger = device_node_map.outputLineSoftwareCmd
sw_trigger.execute()

```

---

<div class="post-metadata">

**Author:** ![GTG](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GTG](https://forum.commonvisionblox.com/u/GTG)\
**Post date:** [October 17, 2018, 6:29pm UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/6 "2018-10-17T18:29:07Z")

</div>

Hi thanks, I’ve tried that and get:

AttributeError: ‘cvb.IntegerNode’ object has no attribute ‘execute’

Also it seems that the CVB management console resets the line to line 1 (the PoE camera) instead of line 3 (a different cable leaving the camera) that I set for trigger output.

Thank you for your time,  
GTG

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [October 17, 2018, 6:38pm UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/7 "2018-10-17T18:38:32Z")

</div>

Really interesting node naming…

Ok, then do:

```auto
sw_trigger.value = 1

```

and maybe after a delay

```auto
sw_trigger.value = 0

```

The Management Console doesn’t change anything about these kind of nodes automatically. It just displays updates automatically issued by the camera XML/GenApi.

---

<div class="post-metadata">

**Author:** ![GTG](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GTG](https://forum.commonvisionblox.com/u/GTG)\
**Post date:** [October 18, 2018, 8:54am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/8 "2018-10-18T08:54:50Z")

</div>

That did the trick. Thank you very much!

Other notes:  
In regard to the pulse duration, I could only set it in the CVB management console (in expert/guru mode).  
When i tried:

```auto
sw_trigger_duration = device_nodes.outputLinePulseDuration
sw_trigger_duration.value = 1000000 # 1 second

```

I get a `RuntimeError: Node[Cust::outputLinePulseDuration]: Node is not writable.`

Also, if you want to check the status change you can do a:

```auto
print(device_nodes.LineStatusAll)

```

before and after setting the trigger value with sw\_trigger.value = 1

Again thank you for your help,

GTG

---

<div class="post-metadata">

**Author:** ![GTG](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GTG](https://forum.commonvisionblox.com/u/GTG)\
**Post date:** [December 13, 2018, 3:07pm UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/9 "2018-12-13T15:07:36Z")

</div>

For reference (to software trigger an output voltage from the camera):  
CVB v13.01.003, using a JAI GO 5000 PGE camera

```auto
device_node_map = vin_device.node_maps['Device']
sw_trigger = device_node_map.UserOutputValue
sw_trigger.value = True
sw_trigger.value = False

```

---

<div class="post-metadata">

**Author:** ![jolewen](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jolewen](https://forum.commonvisionblox.com/u/jolewen)\
**Post date:** [December 15, 2020, 9:13am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/10 "2020-12-15T09:13:14Z")

</div>

Could you maybe elaborate on how to execute the trigger?

```auto
img_stream.start()
sw_trigger.value = True
software_trigger.execute()
img, status = img_stream.wait()

```

(or other combinations of wait() and setting the value)

does not work for me …

---

<div class="post-metadata">

**Author:** ![GTG](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GTG](https://forum.commonvisionblox.com/u/GTG)\
**Post date:** [December 17, 2020, 9:06am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/11 "2020-12-17T09:06:46Z")

</div>

Hi  
I use a function e.g:

```auto
     def plc_stop_trigger(self):
            device_node_map = self.vin_device.node_maps["Device"]
            self.sw_trigger = device_node_map.outputLineSoftwareCmd
            self.sw_trigger.value = 1

```

and call it when need to send the signal.

But probably the problem you have comes from not setting in the CVB management application the correct IO, i.e output1 or output2 and set it to be controlled by software command. Your camera manual can guide you on this.  
If you find a different working implementation, don’t forget to leave it here for the benefit of all.

---

<div class="post-metadata">

**Author:** ![jolewen](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jolewen](https://forum.commonvisionblox.com/u/jolewen)\
**Post date:** [December 17, 2020, 10:02am UTC](https://forum.commonvisionblox.com/t/output-trigger-signal-from-camera-to-plc-using-cvbpy/565/12 "2020-12-17T10:02:47Z")

</div>

Thank you!  
your remark brought be onto the right track.  
the nodes were set correctly but  
`dev_node_map.save_settings(save_file)`  
for some reason overwrites the IO and some other nodes.
