# acquisition triggering and flash sync via Triggered Mode MT9V034

**URL:** <https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829>\
**Category:** OpenMV Boards\
**Created:** [July 18, 2020, 12:53pm UTC](https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829 "2020-07-18T12:53:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mourr](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@mourr](https://forums.openmv.io/u/mourr)\
**Post date:** [July 18, 2020, 12:53pm UTC](https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829/1 "2020-07-18T12:53:06Z")

</div>

Hi there,

Can anybody shed some light on purpose of sensor.ioctl(sensor.IOCTL\_SET\_TRIGGERED\_MODE, True)

I have an H7 board with MT9V034. When running the Global Shutter Triggered Mode example script, it yields to the camera capturing regardless whether there is a trigger pulse or not. furthermore, when i tried to probe the boards P pins (all the of them) , I couldn’t detect any output signal while the camera is acquiring.

Actually, I am not sure what this IOCTL\_SET\_TRIGGERED\_MOD does?  
1- does the cam waits for a trigger for a snapshot to be taken?  
2- does it input a pulse with a pulse with equal to the integration time. In this case on which pin the signal is on?

Thank you all.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [July 18, 2020, 4:06pm UTC](https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829/2 "2020-07-18T16:06:16Z")

</div>

Triggered mode causes the camera to take a picture when you call snapshot. Normally the camera generates images whenever and you are just reading them asynchronously. In triggered mode the images are synced to when snapshot is called.

So, you are free to in your code develope any mechanism via looking for a I/O pin rising edge or waiting on serial data to trigger the camera snapshot.

Typically, you’d code your main loop to look for a rising edge on an I/O pin. Once seen you’d snapshot then to capture the picture in response to an external event. E.g. a product moving down a production line.

The camera will expose the image for whatever time you set in the exposure function.

---

<div class="post-metadata">

**Author:** ![mourr](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@mourr](https://forums.openmv.io/u/mourr)\
**Post date:** [July 19, 2020, 10:10am UTC](https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829/3 "2020-07-19T10:10:27Z")

</div>

@kwagyeman : Fantastic - that’s clear, thanks.

So I think - I got it to work. Although this might no be the most elegant way - any suggestion(s) are welcome 🙂

Picking up on some the code that was already posted in this forum:

Essentially what I am trying to achieve is - External event → trigger pulse → turn on illumination/acquire → turn off illumination → next pulse → repeat

Tested the code using a 1Hz trigger pulse connected to input pin7 and a small led connected to the output pin0 → the triggered output image stream shows a static lit led ( no flickering or intensity fluctuation from one image to the next ). Not sure if I am capturing on the THE trigger pulse or the the following one though. I don’t have a spare probe to check the timing between P0/P7.

```python
import sensor, image, time, pyb
from pyb import Pin, ExtInt

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 2000)

# sensor acquisition trigger when calling snapshot()
sensor.ioctl(sensor.IOCTL_SET_TRIGGERED_MODE, True)

# Create a clock object to track the FPS.
clock = time.clock() 

# set ext. trigger input pulse
sync = 0
def syncline (line):
    global sync
    sync = 1
ext = ExtInt(Pin('P7'), ExtInt.IRQ_RISING, Pin.PULL_DOWN, syncline)
ext.enable()

# set illumination source pin objects 
pin0 = Pin('P0', Pin.OUT_PP, Pin.PULL_NONE)
pin7 = Pin('P7', Pin.IN)

# Acquire

while(True):
    if (sync == 1):
        clock.tick() # Update the FPS clock.
        pin0.value(pin7.value()) # turn on illumination source 
        img = sensor.snapshot()
        pin0.low() # turn off illumination source 
        print(clock.fps())
        sync = 0

```

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [July 19, 2020, 5:04pm UTC](https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829/4 "2020-07-19T17:04:44Z")

</div>

Yeah, that code is fine. Good job on it. That’s exactly what you want to do.

The LED is statically on because that’s the point of the global shutter camera! Things appear static because you control the exposure.

---

<div class="post-metadata">

**Author:** ![mourr](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@mourr](https://forums.openmv.io/u/mourr)\
**Post date:** [July 19, 2020, 5:56pm UTC](https://forums.openmv.io/t/acquisition-triggering-and-flash-sync-via-triggered-mode-mt9v034/1829/5 "2020-07-19T17:56:06Z")

</div>

Indeed! thanks again for your help earlier.
