psychopy.org | Reference | Downloads | Github

Triggers not appearing on actiview serial port

OS (e.g. Win10): Win10
PsychoPy version: 3.1.5
Standard Standalone? (y/n): y
What are you trying to achieve?:
Trying to send triggers via serial port from psychopy to actiview biosemi software at the beginning of loop every time a image is presented.

What did you try to make it work?:
Based on others posts, this is what I coded into my builder:



What specifically went wrong when you tried that?:
The script runs with out any problems and error messages, but no triggers are appearing in the actiview EEG software. I’ve been tinkering, but can’t get a trigger of any kind. This cable works for a matlab script and actiview receives a decimal trigger of 239 and 255. Here is what I’ve tried to get the triggers to work:

  • port.write(bytes(‘1’)), port.write(bytes(1)), port.write(bytes(‘255’)), port.write(bytes(255)), port.write(1), port.write(‘1’).
  • Checked and changed baud rate.
  • Updated drivers for COM3.
  • Matlab script used serialbreak(obj,time) to send triggers so I tried to use the python equivalent of port.send_break(duration=0.25), script runs but still no triggers.
  • port = serial.Serial("COM3, baudrate = 9600, bytesize=serial.EIGHTBITS)

Any ideas about what I’m missing?

What does the receiving end actually expect? You seem to be trying to send the number 1 but also mention “decimal” values of 239 and 255. e.g. The binary number 1 is quite different from the binary representation of the ASCII/UTF-8 encoding of the character '1' (which is 49 in decimal).

Would be best to see what the manual specifies, and perhaps show the successful relevant line(s) of MATLAB code (I’m not sure what relevance the send_break() functions have here: aren’t they about pausing communications rather than sending data?)

Lastly, communications testing is greatly eased by using a dedicated communications testing software on the receiving end to see exactly what if anything is sent. There are free serial port tester applications out there. Check that you are sending anything in the first instance, and then move on to what the content should be, and then lastly test with the intended client software.

I’ll be sure to look into the communications testing software.

Here is some info from the biosemi website on the trigger 1 through 8 which is acted upon during the EEG data acquisition. My .cfg file matches what is displayed in the figure.

Here is the matlab code that successfully leaves triggers from a mac:

%% Open serial port and set breaking parameter
double_BreakTime = 1;
string_Port = '/dev/tty.usbserial-FTSI85RJ';
obj_Port = serial(string_Port);
fopen(obj_Port);

% send trigger
try
   stopasync(obj_Port);
   serialbreak(obj_Port, double_BreakTime);
   catch ME
   display(ME);
end

From this info and after more reading, I think it leaves a trigger by switching from sending 0000000 to 11111111 which in decimal is 255. Do you think this can be replicated in psychopy?

This seems much more like a parallel port protocol rather than serial so I’m a bit confused (even though the MATLAB code refers to a serial port, I wonder if that is just some sort of hardware port emulation thing through USB).

Have you tried using Builder’s parallel port component, rather than creating a serial port in code?

Yes we are sending triggers to a parallel port via a USB port. I thought we were using a biosemi cable like this. But apparently this is a custom cable we made a few years ago that operates similarly. That is why I thought I could replicate the design in this post.

I did initially try using parallel port i/o. I tried it with port address 0x0378 and 0x03BC. Start data was set to 1 and stop data was set to 0. I received the following error:
Error message of : psychopy.parallel has been imported but no parallel port driver found. Install either inpout32, inpoutx64, or dlportio

I also get this error message when I tried to send a trigger via the setData() function like this post.

This error message makes it sound like a just need to update the driver like this. But this is a solution for a parallel port not a usb to parallel port, so it probably won’t work and I’m afraid it’ll break my computer. I think we’ll order the official biosemi cable and try again.

If you have any suggestions I’d be happy to hear your opinion.

That post was for a serial communications protocol, not parallel.

You won’t know until you try.

You don’t need to worry.

The error message tells you what the problem is - the lack of a driver. A new cable won’t fix this in itself: you need the appropriate driver to be able to communicate over the cable.

Haha I have broken a computer before. I installed the new drivers and placed the relevant files in the folder. I tried various serial port commands and parallel port functions. I’m not getting any error messages, but no triggers. We just can’t really depend on our current cable. I’ll be trying with old versions of psychopy and a new cable in the future. I’ll come back to this thread when I get one of the solutions to work.

I got the triggers working. Once we got the official biosemi cord I was able to send triggers with the serial port commands. Importantly I had to change port setting to a baud rate of 115200:
image
image
Thank you for all your help!