Laser plug-in

Hi Yasmine,

Regarding display update timing, here’s what I said last June:

On the MWorks side, your experiment is deciding when to send the digital code signaling on/off. Most likely, you’re sending it immediately after an update_stimulus_display action. As noted in the docs, completion of this action indicates that the display update has been submitted, but not that it has completed. MWorks can’t know, via software means alone, when the display update has completed — that’s why you have a photodiode on your display. If you want your experiment to wait until when the OS expects the display update to complete, you can use the predicted_output_time parameter and explicitly wait until that time.

Also:

If you want there to be any consistent correlation between when you send an on/off signal to Blackrock and when a display update appears on screen, then you must use predicted_output_time. If you don’t, then your signals will be sent at arbitrary points in the display update cycle.

I recommended replacing all instances of update_display with invocations of the macro update_display_and_wait (included below), which executes update_display then waits until the predicted output time:

var predicted_display_update_time = 0

%define update_display_and_wait ()
    update_display (predicted_output_time = predicted_display_update_time)
    assert (
        condition = predicted_display_update_time > now()
        message = 'Predicted display update time is in the past'
        )
    wait (duration = predicted_display_update_time - now())
%end

In your current experiment, if the goal is for the photodiode stimulus to appear on screen as close as possible to the time when the laser turns on, then you should turn the laser on immediately after executing update_display_and_wait, e.g.

update_display_and_wait ()
vpixx_dout_laser_gate = true

Cheers,
Chris