E-Prime Knowledge Base

1320 - INFO: General Parallel Port Information

E-Prime is capable of sending a signal to the port for interfacing with an external device. The receipt and handling of the signal by the other machine is the responsibility of the user.

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. The port address may be specified in decimal or hexadecimal notation. When using hexadecimal notation, E-Basic requires "&H" to be inserted prior to the address. For example, the most common parallel port address is (in decimal) 888, which translates in hexadecimal notation to 378. This would, therefore, be written as &H378 in E-Prime.

Note: Make sure parallel port mode is set correctly in the BIOS (common terms are 'Output only' or 'Standard'). To avoid modifying your BIOS settings, please see SAMPLE:Parallel Port Configure which can use E-Basic script to configure your parallel port. (see below)

The value parameter can also be written in decimal or hexadecimal notation. The value is translated into binary notation which represents a specific bit pattern. The bit pattern then corresponds to the pin connections. Bits are either 0-based or 1-based. Pins are always 1-based.

You must remember that, when writing to the parallel port, you are sending 8 bits of data at once. You will write a "1" to any bit whose corresponding pin you wish to turn "on." A "0" is written to any bit whose corresponding pin you wish to turn "off". Bit to pin mapping is relatively standard for the parallel port. Please refer to documentation for your hardware and/or port address for a mapping of bits to pins. Note: The first available bit to pin connection begins at bit number 1 and at pin number 2. You cannot send a signal to pin number 1.

With a standard parallel port, you can assume that pins 9 through 2 correspond to the number 0000000 when all pins are off, and match up the number values with that notation. Using the binary system, the number values of the pins (9 to 2) are 128, 64, 32, 16, 8, 4, 2, 1 respectively. 10000000 represents a "1" to 9 and a "0" to the other pins; if you want to turn on pin 9, you must send a value of 128 to the port. 00000001 represents a "1" to pin 2 and a "0" to the other pins; if you want to turn on pin 2, you must send a value of 1 to the port. The following table illustrates standard pin mappings and corresponding decimal values.


For example, if you wanted to turn on bit number one on a 1-based bit pattern, and leave the rest off, you would send a signal of "1" to pin 2, and a signal of 0 to pins 3-9. In binary notation, this would be written as 00000001. In decimal or hexadecimal notation, this would translate to "1". Assuming that you have connected the external equipment to the pin associated with bit 0, the external hardware would see +5V (approximate) or a logical "1" on the pin. You could verify this with an o-scope or hand held multi-meter by connecting the signal lead to the pin representing bit 0 and the ground lead to a ground pin (typically pins 18-25).

If your port address were (in hexadecimal) 378, the WritePort syntax for this would be:

WritePort &H378, 1

If using OnsetSignals, the proper syntax would be:

ObjectName.OnsetSignalEnabled = True
ObjectName.OnsetSignalPort = &H378
ObjectName.OnsetSignalData = 1

NOTE: The OnsetSignal/OffsetSignal properties prepare the object for signaling. Unlike WritePort where the value is sent immediately to the port, the actual signal when using OnsetSignal/OffsetSignal properties does not occur until the actual onset or offset of the object when it is run on the Procedure timeline.
INFO: How do I notify external equipment at the exact time that an event occurs in E-Prime?

Interfacing with the Parallel Port
The original IBM-PC's Parallel Printer Port had a total of 12 digital outputs and 5 digital inputs accessed via 3 consecutive 8-bit ports in the processor's I/O space. E-Prime supports the standard printer port (Output Only, Standard, SPP, AT) in the wiring configuration below. Note that other configurations such as PS/2, Bi-Directional, EPP, ECP, etc. are not supported in E-Prime at this time.

8 output pins accessed via the DATA Port
5 input pins (one inverted) accessed via the STATUS Port
4 output pins (three inverted) accessed via the CONTROL Port
The remaining 8 pins are grounded

25-way Female D-Type Connector

Configuring the Parallel Port
To avoid modifying your BIOS settings, please see SAMPLE:Parallel Port Configure which can use E-Basic full script to configure your parallel port. You can then call ConfigurePortForOutput which will allow for the DATA port (pins 2-9) to accept WritePort and OnsetSignalXXX calls. You can also call ConfigurePortForInput which would allow for the DATA port (pins 2-9) to be set up for input responses and also avoid using the BASE ADDRESS + 1 when setting up the Port device. That is, you would specify &H378 instead of &H379.

This topic was created on:
Updated on 7/10/2002 3:44:00 PM (GMT)

This topic was last updated on:
Updated on 2/22/2013 8:45:00 PM (GMT)

End User Comments:    Add... (login required)

Click here to log into Web Support.
Privacy | Terms of Use | Terms and Conditions | Legal Trademarks | Authorized Use | Quality Policy
Copyright 2014 Psychology Software Tools, Inc. All Rights Reserved
Email: Info@pstnet.com | Telephone: 412.449.0078 | Fax: 412.449.0079