| Reference | Downloads | Github

Sending triggers to brain vision trigger box

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): 2021.1.1.4
Standard Standalone? (y/n) If not then what?:


I am trying to send triggers to my EEG system. I am using the brain vision achiChamp amplifier and the goal is to send triggers whenever an auditory stimulus started playing. As I must use the serial port to send triggers to the trigger box I have used this code which I found here in Psychopy forum:

#Python Example
import serial
import time
import threading
Connected = True
PulseWidth = 0.01
def ReadThread(port):
while Connected:
if port.inWaiting() > 0:
print “0x%X”%ord(

Open the Windows device manager, search for the “TriggerBox VirtualSerial Port (COM6)”

in “Ports /COM & LPT)” and enter the COM port number in the constructor.

port = serial.Serial(“COM6”)

Start the read thread

thread = threading.Thread(target=ReadThread, args=(port,))

Set the port to an initial state


Set Bit 0, Pin 2 of the Output(to Amp) connector


Reset Bit 0, Pin 2 of the Output(to Amp) connector


Reset the port to its default state


Terminate the read thread

Connected = False

Close the serial port


However, when I use port.write() command nothing is sent to the EEG system. I tried to just set the port high and low by using port.setDTR(True) and it works. But by using this command, I am not able to send different triggers, and the only way to differentiate triggers for different stimuli is the time interval between setting high and low.
Now I am wondering why in my system the serial port.write() command is not working but port.setDTR() works. I should also mention that the computer which is used for sending triggers is connected through a USB port and a USB to serial converter to the trigger box. I am not sure if that is the problem.
I would be more than happy if anyone can help me.

Hi There,

Could you try encoding a string when you use the port.write() command - something like this?

Hope this helps,

Thanks @ Becca, but it didn’t work! I think something is wrong with how the trigger box (the box that gets triggers from psychopy and sends them to the EEG system) is connected to the stimulus computer. I know that the brain vision trigger box uses a serial connection and in our lab it is connected via a USB and a USB to serial adaptor to the stimulus computer. This means that when I write port.write (str.encode(‘1’)) the code is sent through a USB cable to the USB to serial adaptor and then to the trigger box. Could this be the problem that it does not show up in my EEG system?