communicating with parallel port

Hello

We’re using unity for psychophysical experiments and we need to know an exact timing of things occurring in the game. The preferred solution is to communicate with an LPT port connected to the experimental equipment and send a message every time a specific event occurs in the game or a key is pressed.
My question is whether it is possible to send these triggers to the parallel port from within Unity?
Since this will be used to synchronize between the Unity and the data (EEG) collected from the subject, we need to make sure that these messages to the LPT are really sent with a precise timing. We can tolerate a delay in the trigger sending if it is a constant delay, but the noise in this delay shouldn’t be much more than ~30 milliseconds.

This questions was actually already asked in the past @Agoston Torok, @Bunny83, @aldonaletto, but it was 5 years ago and I understand these features in Unity changed meanwhile. See the post here:

Thanks for any help!

Hadar

You will want to use C# features for that, it seems very easy. Here is a tutorial and here is another code example. You will basically dllimport the correct library and work with that. It is trivial.

If latency is an issue, than you can make a C dll and use sockets (I imagine, never done LTP per say). Note that native dlls are now part of unity free. I’d stick to C# for the first prototype.

Dear Hadar,

@Socapex is right, you’ll need to communicate with the port using a c# script and inpout32.dll or similar (depending on your OS). From the latency point of view: we used a light diode to check for sync in our setup (attached it to the screen and check the latency between trigger and diode signal), I suggest you to do the same. Note that FPS may change during a game, your screen has a refresh rate too, and the physics in the game is not tied to refresh rate. Also, note that delay is not much of a problem, uncertainty on the other hand is. If you have other questions pls don’t hesitate to contact torok.agoston@ttk.mta.hu

Regards,

Tony

Has been there any improvement in this? I am trying to have the inpout32 working in Unity 2017 but no luck so far.