globalClock.getTime() produces inaccurate results in EEG trials but core.monotonicClock.getTime() works

Hi all, I apologize for my noob question. I am running my first EEG study with Biosemi using Psychopy. The serial_out component was a giant mess so I used code, and it seemingly works great (all the tiggers are sent where they are supposed to be sent, nothing is duplicated, etc.). The problem is: I first used the code suggested on the official website using the globalClock function (here):


if target_words.status == STARTED and not pulse_started:
    win.callOnFlip(port.write, str.encode(chr(trigger)))
    pulse_start_time = globalClock.getTime()
    thisExp.addData('trigger started', pulse_start_time)
    pulse_started = True
    pulse_ended = False

if pulse_started and not pulse_ended:
        if globalClock.getTime() - pulse_start_time >= 0.005:
            win.callOnFlip(port.write, b'\x00')
            pulse_ended = True

I added “thisExp.addData(‘trigger started’, pulse_start_time)” so that I could test whether the trigger is sent exactly when the target_words routine starts (it’s not at the beggining of a trial but 250 ms later). That’s how I noticed that globalClock.getTime() records a comletely diferent time compared to when the target_words routine starts, and the difference could be anything from 60 to 300 ms. When I replaced it with core.monotonicClock.getTime(), it works like charm, showing that the trigger is sent 0.017 ms after the target_words routine starts, and it’s very consistent.

Can somebody please explain the difference between the clocks to me and why the official website suggests we use globalClock.getTime() instead? I don’t have the photodiode to test the time, and I know it’s not ideal, but it’s something anyway.