Reading Parallel Port as Response Device


Author
Message
DrLand
DrLand
Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)
Group: Forum Members
Posts: 14, Visits: 38
Hi,
I'm a new user of Inquisit 4, and I have been searching for an answer to a question, but haven't been able to find a clear answer.
I am trying to use Pin 2 of an LPT port as the valid response to a trial. I have looked at the Port Monitor, and I can see the check on Pin 2 change as the signal goes from high to low or low to high. My question is, what code/element allows me to read in a particular pin on an lpt port (Pin 2 in my case), and look for a change in voltage (either going high, or going low). 
Thanks!

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 100K
First you need to define the respective LPT port as /inputdevice for your <trial>(s), e.g.

<trial mytrial>
/ inputdevice = lpt1
/ validresponse = ("00000010")
...
</trial>

for LPT1. Then you can use the /validresponse and/or /inputmask attributes to define the signal you are looking for.

DrLand
DrLand
Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)
Group: Forum Members
Posts: 14, Visits: 38
Thank you for your quick feedback. I have setup my trial as follows:

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ validresponse = ("00000010")
/ correctresponse = ("00000010")
</trial>

However, when I try and run the experiment, I get the following Error.
ERROR /validresponse: '00000010' is not a valid setting.

ERROR /correctresponse: '00000010' is not a valid setting.

ERROR /validresponse: 'No response' can not be specified unless the trial has a timeout.



Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 100K
Two things to try, please:

#1: When you specify

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ validresponse = (anyresponse)
</trial>

what's recorded in the data file's 'response' column? Same for

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ inputmask = "00000010"
/ validresponse = (anyresponse)
</trial>

?

#2: How does the trial behave when specifying

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ validresponse = (00000010)
/ correctresponse = (00000010)
</trial>

?

Thanks.

Edited 10 Years Ago by Dave
DrLand
DrLand
Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)
Group: Forum Members
Posts: 14, Visits: 38

Dave (8/15/2014)
Two things to try, please:

#1: When you specify

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ validresponse = (anyresponse)
</trial>

what's recorded in the data file's 'response' column? Same for

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ inputmask = "00000010"
/ validresponse = (anyresponse)
</trial>

?

Ok, both the above two codes produce a response indicating value 127

#2: How does the trial behave when specifying

<trial numbers>
/stimulusframes = [1=trials]
/ inputdevice = lpt3
/ validresponse = (00000010)
/ correctresponse = (00000010)
</trial>

?

There is no response with the above code, although it doesn't produce an error message

Thanks.

So I can make the /correctresponse = (127), however, the problem that I am seeing is that it instantly runs through all the trials.
Let me explain exactly what I'm doing. I'm trying to write a simple code that displays the trial number (e.g., 1, 2....). Every time an event happens, pin 2 goes high and stays high until the end of the trial when the pin is set back to low...
So I would like my code to see the change from low to high on pin 2, and then change the trial number.
When I'm running the code now, it immediately cycles through all of my trial numbers without me even sending the event trigger. I'm wondering if when pin 2 is high and staying high...the code is acting like it's a continuous valid response and thus cycles to the next trial.




Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 100K
Whether the pin remains high would be something that your device has to do -- if it never lowers the pin or doesn't do it quickly enough, trials will cycle rapidly. Several things you can do:

#1: Work with /pre- and /posttrialpauses and/or

#2: Require a /pre- and/or /postrrialsignal from the lpt3 port (to ensure the pin is low again).

DrLand
DrLand
Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)
Group: Forum Members
Posts: 14, Visits: 38
I still can't seem to get it to work without immediately cycling through all of the trials.
First, on the parallel port monitor, does the check mean that the pin is high or low? (regardless of whether pin 2 is checked or not (based on my device), the program still immediately cycles through all of the trials. So i'm not sure the input I'm getting is associated with pin 2).
Although I am only interested on the activity on pin two, a number of the other pins have checkmarks in their box.
My understanding is that I can use the inputmask = "00000010" to make the system only look at pin 2, however, no matter what value I put in for the inputmask (e.g., 11111111) this doesn't change how the program behaviors. I am now thinking that the (127) value that I identified in the previous post may belong to a pin other than pin 2 (one of the other pins that have a checkmark in the box according to parallel port monitor, and one that never changes, thus cycles my program).
So I need a way to figure out exactly what value is associated with pin 2 (and pin 3 eventually).
Since pin 2 goes high and stays high for a matter of seconds before going back low, I will try and incorporate the posttrialsignal to wait for a change from pin 3 (at which time pin 2 will go back low again). However, I have to identify exactly how to make the system watch for pin 2 and pin 3




Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 100K
Just to clarify: The check mark sets a pin to high when you want to *send* a signal *to* your device via the parallel monitor -- check the pin(s) and hit 'send'.

You don't need to check any when you want to *receive* signals *from* the device -- hit receive, (push button on the device or the like if necessary) and the parallel port monitor should tell you what it received. A check mark means the respective pin is high. For some more details, see the "How to Use the Parallel Port Monitor Tool" topic in the documentation.

About the '127', this would indicate as many as 7 bits set to high (127 -> 01111111 in binary).

Another thing to consider is that there's a difference between

/inputdevice = lpt<n>

which will read from the port's *status* register and

/inputdevice = lptdata<n>

which will read from the *data* register. Based on your last description, I assume you want the latter.

Given that your device apparently keeps the pin(s) high for several seconds, you should definitely work with either /pre- or /posttrialpause and/or /pre- or /posttrialsignal to allow for the pin(s) to go low between trials. Otherwise the rapid cycling through all trials is exactly what should be expected with pins remaining high for so long.

DrLand
DrLand
Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)
Group: Forum Members
Posts: 14, Visits: 38
Ok, now we are starting to get somewhere. You are right, I needed to use /inputdevice = lptdata3
From using the parallel port monitor, I also figured out that the port value goes from 240 to 241 when pin two is activated. So my code is

<trial checkportsignal>
/ stimulusframes = [1=button]
/ inputdevice = lptdata3
/ validresponse = (241)
</trial>
This now doesn't immediately cycle through the trials, but waits until the first event (pin 2 goes high). However, after that, it then cycles through the trials. This is were I need to setup a posttrialsignal
So I made my device send a signal to pin 3, and turn pin 2 to low at the end of the trial. According to the parallel port monitor, my port value is registered at 242 when pin 2 is low and pin 3 is high. I would therefore use this as the signal to stop the trial. My code is as follows:

<trial checkportsignal>
/ stimulusframes = [1=button]
/ inputdevice = lptdata3
/ validresponse = (241)
/posttrialsignal = (lptdata3, 242)
</trial>

The trial now starts on the correct event, but it is not stopping, so the posttrialsignal isn't working to end the trial. Any ideas.

Thanks for all the help.



DrLand
DrLand
Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)Esteemed Member (2.5K reputation)
Group: Forum Members
Posts: 14, Visits: 38
Just a little more information about the posttrialsignal issue, the error message says "unknown" "Unable to obtain the address for parallel port -1"
Just as a test, I made the posttrialsignal a button press from the keyboard, and that worked. So I just need to get it working off the parallel port.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search