[solved] Sending different triggers via serial port
Dear community,
thanks again for helping me with my other problem. I now want to send two different triggers via serial port to our EEG. I therefore prepared two inline scripts:
exp.serial_port.write(chr(1))
and
exp.serial_port.write(chr(2))
This should send two different triggers to the EEG, right? Unfortunately neither BioTrace (our recording software) nor Brain Vision Analyzer (for analysis) show two different triggers. I'm not sure whether the python code is wrong or our software is unable to recognize different triggers.
Best wishes,
Daniel

Comments
Hi Daniel,
Indeed it should.
The Python code is correct, but there could be a lot of different reasons for why you don't see the trigger in the BioTrace. The most obvious one is that the code, although valid, is not actually executed. You can find this out by printing something to the debug window after sending the trigger:
Another possibility is that you are sending triggers to the wrong port. When setting up a connection, you have to specify whether you want to use
COM1,COM2, etc. If you choose the incorrect port, your triggers will go nowhere.Could it be either of those two things?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
A rather nasty error we've encountered in our labs, is that sometimes triggers are sent, but not recognized by the system you're sending them to. In our case, we tried sending parallel port triggers to a BioPac system. The system did not seem to respond. After measuring the parallel port voltage directly from the pins, we discovered that a signal was being transferred. Also, the BioPac did respond to the same type of triggers in a different setup. We concluded that the parallel port output of our computer was simply too weak to be recognized as a trigger by the BioPac (< 3.5 V).
I have to admit that serial ports are a somewhat different system, but it still might be a good idea to manually check (using a voltmeter on the pins of your cable) whether your computer might actually be giving an output, when you can't find any problems in your code.
Thanks for your replies! I forgot to mention (shame on me) that I can see the triggers in both programes. So sorry for sending you into the wrong direction :-(
The actual problem is that the programes can't differentiate between trigger 1 and trigger 2. According to sebastiaan my code is right, so probably BioTrace is just unable to recognize two different triggers.
Instead of
or
it shows
I'll have a chat about this with the BioTrace developers. Maybe they have a solution.
Today I managed to send several different triggers to our EEG by using the port output test of Presentation (trigger 2, trigger 3...):
however, with OpenSesame different triggers aren't recognized (trigger 0, trigger 0...):
Do you guys have any idea how I can fix it?
Best wishes,
Daniel
Hi Daniel,
The following code ...
... will send byte
1via the serial port toCOM1.pyserialexpects a character, which is why you need to sendchr(1)rather than simply1. But that's not important: Characters and bytes are equivalent, just different interpretations of the same 8 bits.Since this code snippet is pretty straight-forward and serial port communication has been extensively tested and used, I think the source of the problem might be that the BioTrace simply expects something different than what you are sending.
For example, the constructor (the
serial.Serial()part) takes many optional parameters, such as the baudrate, etc. If the BioTrace expects a specific configuration, this is a property of the system that you simply have to know.Similarly, the BioTrace might expect a specific type of data, and not just a byte-value. Again, this is a property of the system that you have to know.
I would first check the Presentation settings to see whether and how they have specified properties of the connection: What is the baudrate, etc.? If you can't figure it out, I would ask the BioTrace developers for an example Python snippet.
Cheers,
Sebastiaan
PS. A quick test would be to send all possible values and see how the BioTrace responds:
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi!
Thanks again for your reply. The required values are (according to the Nexus Trigger Interface user manual):
Where do I have to insert these values? Sorry to ask but I'm really not a professional python programmer ;-)
Thanks for your help!
Daniel
You can pass these as keywords to the constructor, like so:
baudrateis a keyword, and you can find a full list of keywords here:Some things may not be entirely clear, so you may have to try out a few settings. Also, it's probably a good idea to also familiarize yourself a bit with Python:
Cheers!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
I added a small modification and it works just perfect now:
Again: many thanks to you!
Great! Glad to hear you got it resolved.
Check out SigmundAI.eu for our OpenSesame AI assistant!