- Home /
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: http://answers.unity3d.com/questions/134463/communicate-with-parallel-port.html
Thanks for any help!
Hadar
Dear Hadar, I am more or less in the same situation and i was wondering if you can share any help/advice or code.
Best Regards. Yannis
Answer by Socapex · Dec 30, 2016 at 07:35 PM
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.
Answer by tony_torok · Jan 03, 2017 at 01:49 PM
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
Answer by Link0n3 · May 31, 2018 at 05:15 PM
Has been there any improvement in this? I am trying to have the inpout32 working in Unity 2017 but no luck so far.
Your answer
Follow this Question
Related Questions
How do I get triggers to work at a pixel perfect level? 0 Answers
Communicate with parallel port 4 Answers
how to keep texture animations in sync 0 Answers
Photon synchronization 1 Answer