#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# [open] Send triggers to parallel port with OpenSesame

edited March 2016

Hi,

I want to send trigger pulses to a parallel port with OpenSesame.
I downloaded the pulgin for parallel port triggers and saved it in the plugin folder.
Then I added my trigger pulse. I know the address from presentation (0x378).
The field for putting in these information looks different than in the documentation, though.
(I don't have a field to put in the time, only value and adress.)
So I put in the value (1 or 255) and the adress (0x378) and run the experiment.
But it gives the following error:

  File "dist\libqtopensesame\misc\process.py", line 140, in run
File "dist\libopensesame\experiment.py", line 397, in run
File "dist\libopensesame\item_store.py", line 95, in execute
File "dist\libopensesame\item_store.py", line 110, in run
File "dist\libopensesame\sequence.py", line 50, in run
File "dist\libopensesame\item_store.py", line 110, in run
File "dist\libopensesame\loop.py", line 144, in run
File "dist\libopensesame\item_store.py", line 94, in execute
File "dist\libopensesame\item_store.py", line 126, in prepare
File "dist\libopensesame\sequence.py", line 121, in prepare
File "dist\libopensesame\item_store.py", line 126, in prepare
File "C:\Program Files\OpenSesame\plugins\parallel_port_trigger\parallel_port_trigger.py", line 99, in prepare
NameError: global name 'osexception' is not defined


What can I do about that?
I tried to download the dlportio.dll as descripted here: http://forum.cogsci.nl/index.php?p=/discussion/177/solved-sending-trigger/p1 and it worked until near the end but despite a lot of trials I could not execute the DLPortIO_install.bat . The error-message said the file is broken (in the terminal itself it said it could not find the file.)

I have Windows 7, 64 bit and downloaded the newest version of OpenSesame. In presentation the sending of triggers works.

Thank you very much for your help!

• edited March 2016

This is what my experiment and the parallel port plugin looks like:

Does anyone have any idea?
Thank you!

• edited 9:33PM

I'm sorry to ask again, but I have no idea what to do... so do any of you have any? Also if it may not work I can try if I know what to try...
Thank you!

• edited 9:33PM

Hi Pia,

This is definitely a bug in the plug-in, so I forwarded this problem to @Bob, the developer.

Cheers,
Sebastiaan

There's much bigger issues in the world, I know. But I first have to take care of the world I know.
cogsci.nl/smathot

• edited March 2016

Hi Pia,

In the meantime, you might wanna try sending the triggers from within an inline_script. I ran an EEG experiment in this way and it worked quite nicely.
So, here you go:

In a first inline_script in the beginning of your script, you have to initialize the port connection.

"""
establish connection to EEG port and set some general eeg related variables
"""
try:
from ctypes import windll
global io
io = windll.dlportio # requires dlportio.dll !!!
except:
print 'The parallel port couldn\'t be opened'

port=0x378


Once set up, you can send triggers with io.DlPortWritePortUchar(port,trigger). However, I prefer doing it from within a little function.

def sendTrigger(trigger,port=0x378):
global io
try:
io.DlPortWritePortUchar(port,trigger)
except:
print 'Failed to send trigger %s!'% trigger


So, every time you want to send a trigger, you have to call sendTrigger(trigger) from within an inline_script. And also, don't forget to send the zero triggers in the same way.

I don't know the exact structure of your experiment. Maybe it is necessary to change it to make the triggers being sent at the exact right time. But if you keep the prepare-run-phase in mind (send triggers during run, I suppose), you should be fine if you replace the parallel port plugin with an inline_script.

I hope this helped.

Good luck,

Eduard

• edited March 2016

Hi all,

I am back and actively working on this plugin again.

Sorry for the unreported changes. I removed the time dimension: duration because it occurred to me it has no real use and forces a wait. Duration could become handy when it can run in parallel within the experiment. Also did not have the time for updating documentation. Done now! If there is a need to get the duration variable back, please let me know and I will put it back in.

Did some bug fixes (untested) so it should work now. Gonna try to the test the changes tomorrow.

In the future I will be more involved in the forum. The fastest way to get the bug reports is through github.

Cheers, Bob

• edited 9:33PM

Seems additionally, dummy mode was always enabled and did not work when there was no pport and/or driver. All fixed in v3.1.

• hi! I tried to use parallel port plugin and also check the serial plugin, but both of them did not give any response to my trigger. Even when I tried to disconnect the trigger box, the parallel port did not give any error message..