acquisition triggering and flash sync via Triggered Mode MT9V034

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.

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.

@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 :slight_smile:

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.

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
1 Like

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.

1 Like

Indeed! thanks again for your help earlier.