Trigger with USB virtual COM port (NEUROSPEC MMBTS) to EEG system

OS: Win11 Home
PsychoPy version (e.g. 1.84.x): 2022.2.5

What are you trying to achieve?:
Hi everybody, I’m Francesco and I’m pretty new in Psychopy and in coding in general; bear me please.
I’m trying to understand how to send trigger to a EEG system using a virtual COM port, the MMBT-S Trigger Interface Box (Neurospec) [MMBT-S Trigger Interface Box | NEUROSPEC AG Research Neurosciences].
I tried to follow both the psychopy instructions (Communicating with external hardware using PsychoPy — Workshops for PsychoPy 2022 2022) and the setup instructions from the MMBTS manual; and in psychopy I tried both the port component and the code component, but still I’m not able to send the trigger to the EEG system (even if everything is working).

In the code component I used the following code:

in first routine; Begin Exp* tab:

import serial
mmbts = serial.Serial()
mmbts.port = ‘COM6’

in trial, Each frame tab

if polygon.status == STARTED and not stimulus_pulse_started: #Change ‘stimulus’ to match the name of the component that you want to send the trigger for
win.callOnFlip(mmbts.write, str.encode(‘1’))
stimulus_pulse_start_time = globalClock.getTime()
stimulus_pulse_started = True

if stimulus_pulse_started and not stimulus_pulse_ended:
if globalClock.getTime() - stimulus_pulse_start_time >= 0.005:
win.callOnFlip(mmbts.write, str.encode(‘0’))
stimulus_pulse_ended = True

in end trial; End Exp* tab:


I tried also to change the code using in the trial_code/each frame tab:

trigger_code = 5 # trigger code must be between 1-255
(which is the code presents in the MMBTS manual)

What specifically went wrong when you tried that?:
It does not matter which code I use, Psychopy does not give any error, but the trigger is not sent to the EEG system.
Is anyone had the same problem? What can be wrong on what I’ve done?

Thanks a lot for the help.