need help with getting input from parallel port device

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
K_uwpsych
Newbie
Posts: 2
Joined: Thu Oct 27, 2005 10:14 am

need help with getting input from parallel port device

Post by K_uwpsych »

I use quickbasic to run Psychology experiments, and we often record vocal response times (RT). Our old equipment involved a voice key that was wired into the "-" key of the keyboard, so we could easily present a stimulus (e.g., a word) UNTIL INKEY$ = "-" and record the RT from there.

However, our old equipment is failing, and we've had new voice keys built that plug into the parallel port. These voice keys are compatible with E-Prime and work well with that program, but we don't yet know how to use them in quickbasic.

We would like to be able to present a word on a the screen and have it stay there until a vocal response is detected on the voice key. Presumably, this is something like looking for a change in the signal from the parallel port?? I really don't know very much about this, and have tried some of the stuff I've found by googling, with no success. I realize this may be difficult without knowing the nature of the device we're plugging in, but all I really know is that it plugs into the parallel port and has a microphone that plugs into the voice key- when it detects a response, there is a light signal on the box itself, and it must be sending some kind of signal to the port because E-Prime can detect it.

Can anyone help me with this?

Thank you.
User avatar
matt2jones
Veteran
Posts: 80
Joined: Sat Feb 19, 2005 8:29 am
Location: elsewhere
Contact:

Post by matt2jones »

Yeah, this does sound difficult without knowing what the equipment is.

I've had very little experiance with communicating with hardware in QB, all I've done is sending information to the modem, which is on the serial port, which is used with the OPEN "COM:" statement, and I don't know if the printer port can be rigged up to a com port in bios.


Going to the e-prime FAQ I found the following information:
The address of your port can be found by selecting "System" from the Windows Control Panel, clicking on the Device Manager tab, and navigating to Ports. Select the parallel (LPT or printer) port, click the Properties button, and select the Resources tab. The address of the currently accessible port will be shown.

*Please note: In order to designate an input address you must add "1" to the output address, so that if your port address, in hexadecimal notation is 378, you would enter "379" in the Port Devices "address" field.
if all you need to do is detect a CHANGE in the information being sent to the parrallel port from the device, you could try something like

Code: Select all

OldPortValue = inp(&H379)
print "Word"
do   
    NewPortValue = inp(&H379)
    if OldPortValue<>NewPortValue then  exit do
    OldPortValue = NewPortValue
loop
cls
But I have no idea of what kind of syncronisation (if any) you need to make with the port, or how many addresses the parallel port outputs to.
microphone that plugs into the voice key-
This line is confusing, are you saying that the microphone is still connected to the '-' key (because if it is then the old program should still work) or is the '-' just a typo?

Hopefully, someone else here will be a bit more familiar with port communications then i am...

matt
Do not mistake Apathy for feeling Content.

http://www.disjointed.cjb.net - Short Storys
http://matt2jones.deviantart.com - Random Art
http://www.freewebs.com/matt2jones - WebComic
Guest

Post by Guest »

I tried the code that you mentioned and it doesn't seem to do anything (i.e., "word" just stays up on the screen unless I ctrl-break to stop).


Quote:
microphone that plugs into the voice key-


This line is confusing, are you saying that the microphone is still connected to the '-' key (because if it is then the old program should still work) or is the '-' just a typo?
Yeah, I just meant the '-' in that case to be just a dash. The microphone plugs into the voice key box, and when you speak into the microphone, the voice key "fires".

I know of someone else who I think uses these same devices in MEL- would any of that code be useful to anyone??
User avatar
matt2jones
Veteran
Posts: 80
Joined: Sat Feb 19, 2005 8:29 am
Location: elsewhere
Contact:

Post by matt2jones »

Yeah, put up as much code as can.

As I've said, I've never use the LPT port through Qbasic before.

matt
Do not mistake Apathy for feeling Content.

http://www.disjointed.cjb.net - Short Storys
http://matt2jones.deviantart.com - Random Art
http://www.freewebs.com/matt2jones - WebComic
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Well, I am at school right now but later I might check my QB book, it said how to open the LPT ports through the OPEN statement...

Im not sure if this is it, but it might be...

Code: Select all

OPEN "LPT1" FOR INPUT AS #1
and ectera. I know you can also do that with KYBD, SCRN, and some others. Open the KYBD for output... it doesnt crash, its just kinda funny...
Image
K_uwpsych
Newbie
Posts: 2
Joined: Thu Oct 27, 2005 10:14 am

MEL Code for device

Post by K_uwpsych »

So this is what someone has told me is the code used to work with the device in MEL. I would need to do the same thing only using QuickBasic. I don't know if this will help or not....

PORT_IN( bit_id, port_data, bit_mask, options, port_address )


where
bit_id (string) = variable assigned to the bit which changed state
*can be anything - records the bit that changed
port_data (integer) = variable assigned to last byte value read
from the port
*can be any name - records the value that the changed bit returned
(this can be used if there are 2 buttons and you need to asses
which was pressed - but not needed for vocal response)
bit_mask (string) = bits to be examined for a change in state
*like "allowable keys" I always set it to all (01234567)
options (string) = various processing options
*usually W to terminte current WAIT after bit has changed
port_address (integer) = address of the port which is polled
for a change in state
*usually 889


you need to dimension variable
CONSTANT( port_address = 889, bit_mask = '01234567' )
INTEGER( return_value )
STRING( changed_bit(1) )


then at response time in the code do
PORT_IN ( changed_bit, return_value, bit_mask, "W", port_address )
WAIT
Post Reply