This article applies to:
E-Prime 3.0
E-Prime 2.0
E-Prime 1.x
Detail
How can I tell if I can use parallel port communication?
Check the manual of your external device to see if it can use parallel port communication and what values it may require. Also, check that your computer has an appropriate port installed.
The parallel port can send and receive data through a cable that connects the devices. Inside each port is a “pin” that corresponds to one of the wires in the cable. Parallel ports have 25 pins. Each pin in the cable is designated for a specific purpose but typically only pins 2 through 9 are used to send data.
The software on the sending side will turn each pin on or off according to the value you wish to send. Then, on the receiving side, software can read the state of the pins (on or off) and interpret the value you sent. Depending on your communication method within E-Prime, as well as the requirements of your external device, you may choose to manipulate individual pins, or always send data on all 8 pins at once (see “How do I send a signal?” below). The receipt and handling of the signal by the other device or machine is the responsibility of the user.
How do I initially configure my cables, Windows settings, and E-Prime settings?
Make sure that your parallel cable is securely connected between your computer and device. Note that at this time, there are no USB-to-Parallel cables compatible with E-Prime. Please see this article for more details: INFO: Recommended Parallel Port Adapters for Machines without a Parallel Port [18031]. For assistance with configuring your external device, please consult your user manual or your IT department.
Once your hardware is set up, you need to make sure that E-Prime knows which port you would like to use for parallel port communication. The address of this port, as well as an LPT port number, is assigned by Windows automatically. You need to get this information from Windows so that it can be put into E-Prime were appropriate. There are several ways to communicate within E-Prime. Task Events are only available in E-Prime Professional 2.0.10.242 and later. The parallel port device is available in both E-Prime 2.0.10.242 Professional and Standard or later. The OnsetSignal/OffSetSignal and WritePort commands are available in all versions of E-Prime. These topics are covered below in “How do I send a signal?”.
How to get needed port information from Windows
1. Click Start - Control Panel - System
2. Click the Hardware tab on the System Properties page
3. Click Device Manager
4. Click on the "+" next to "Ports (COM & LPT)" to view the listing of ports used by your machine. If an LPT port does not appear and you know you have the necessary hardware, you may need to install a driver through Windows Update or from the manufacturer’s website. For more information on hardware driver installation, please consult your IT department.
For Task Events/Parallel Port Device (in 2.0.10.242 or later): LPT number only, e.g. ‘1’
For OnsetSignal/OffSetSignal or WritePort (all E-Prime versions): Port Address only, e.g. ‘&H378’
Select the parallel (LPT or printer) port, right click and select Properties, then 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. For further assistance finding a port address, please consult your parallel port manual or your IT department.
How to put this information into E-Prime
For Task Events/Parallel Port Device (in 2.0.10.242 or later): LPT number only, e.g. ‘1’
Open E-Studio and double click on the purple Experiment Object to open its properties. Click on the Devices tab, Add…, then Parallel Port.
Select the new Parallel Port and click ‘Edit…’ to change its properties. Ensure that the LPT number here matches the one from Windows Device Manager. Configure other settings as needed. This eliminates the need for user script for configuring and initializing parallel port communications. The ParallelPort device is recommended over using the Port device because of its flexibility and ability to use the LPT number instead of a base address. In addition, the ParallelPort device can be used to send digital triggers via Task Events.
For OnsetSignal/OffSetSignal or WritePort (all E-Prime versions): Port Address only, e.g. ‘&H378’
Open E-Studio and double click on the purple Experiment Object to open its properties. Click on the Devices tab, Add…, then Port. Put the appropriate port address in the Address field. Configure other settings as needed.
How to send a signal using a parallel port
NOTE: Parallel ports retain their past state until changed, even after a reboot. That is, you should always ‘clear’ (write all pins to zero) at the start of any experiment.
Task Events
E-STUDIO: Using Task Events [22862]
Parallel Port Device
Send commands using ParallelPortDevice.WriteByte in an InLine script. For further information on using this command, please refer to the E-Prime Command Reference (https://pstnet.com/ecr).
OnsetSignal/OffSetSignal
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.
These properties will allow triggers to be sent at the exact time of an object's onset/offset and will greatly improve your ability to keep timing consistent with stimuli. The properties include (where "X" is the actual name of the object on which the property is being set):
- X.OnsetSignalEnabled
- X.OnsetSignalPort
- X.OnsetSignalData
- X.OffsetSignalEnabled
- X.OffsetSignalPort
- X.OffsetSignalData
You can find these properties fully documented under the general RteRunnableInputObject topic in the E-Prime Command Reference. Note that you will need to specify the address of your port via the xxxSignalPort property, and the value you are sending via the xxxSignalData.
In the following example, assume objects named "Prime" and "Probe", and a parallel port address of &H378. If you wanted each object to send a signal to the parallel port upon its onset, you would create an Inline object at the beginning of the experiment and type in the following script:
- Prime.OnsetSignalEnabled = True
- Prime.OnsetSignalPort = &H378
- Prime.OnsetSignalData = &H01
- Probe.OnsetSignalEnabled = True
- Probe.OnsetSignalPort = &H378
- Probe.OnsetSignalData = &H02
In this example, "Prime" sends a signal to bit 0, and "Probe" sends a signal to bit 1, each time the object is run in the script.
It is typically only necessary to set these properties once, at the beginning of the experiment. If the OnsetSignalData value changes under some conditions, however, you will need to change the value of the property in an InLine that runs prior to the the object that sends the signal.
By default, sending an OnsetSignal from an object keeps the bit high until it is shut off by the next object that runs. If you want to do a toggle, there are two options:
- Use a WritePort command in an InLine, following this object. Write a "0" to all bits.
- Use the corresponding OffsetSignalEnabled/Port/Data properties to reset the bits all back to 0s at the offset of the object.
If you need to control the duration of the pulse, you will also need to manipulate the Duration and PreRelease properties of the object that sends it, until the desired pulse width is achieved (i.e. by adjusting the time between the object’s onset and offset). Refer to the timing diagrams in “Appendix E: Timing of Object Execution” in the E-Prime User’s Guide for a description of the different timing intervals within the execution of an object in E-Prime.
WritePort
You can alternatively intersperse script between each object in the trial sequence and use either the WritePort command its associated methods to communicate with the external device. However, using this method will NOT guarantee that the signals are precisely synchronized with the stimulus. With this method, the signal should occur within one refresh, and this refresh will be specific to the refresh rate of your own monitor.
To enable a WritePort pulse that is synchronized within one refresh of the next event, you should insert an InLine directly preceding the event object on the procedure. You will then use the following script in the InLine (where your WritePort information is customized to your experiment):
Display.WaitForVerticalBlank
WritePort nAddress, nValue
How to receive a signal using a Parallel Port
Task Events
E-STUDIO: Using Task Events [22862]
Parallel Port Device
Use the Parallel port device as an InputMask or receive commands using ParallelPortDevice.ReadCurrentByte in an InLine script. For further information on using this command, please refer to the E-Prime Command Reference (https://pstnet.com/ecr). The Parallel Port input can also be registered as an Input Mask on an E-Object.
Port Device
Use the Port device as an InputMask. In most cases, if you are simply looking for any bit to change and trigger E-Prime, you may enter "any" in the Allowable Input field for the input object. Addtionally, you can receive commands using ReadPort() in an InLine script (https://pstnet.com/ecr).
Special Considerations when using a Parallel Port
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 Parallel Port Configure [30031] which can use E-Basic script to configure your parallel port. Note that this is generally not necessary if using a PCI Parallel Port card.
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.
Pin | Value |
2 | 1 |
3 | 2 |
4 | 4 |
5 | 8 |
6 | 16 |
7 | 32 |
8 | 64 |
9 | 128 |
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". If 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).
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
To avoid modifying your BIOS settings, please see Parallel Port Configure [30031] 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.
If you are not able to add a Parallel Port to your machine or would like a USB alternative, you can use our Chronos device.
Ability for ParallelPortDevice to ToggleBit, SetBit, ResetBit
The ParallelPortDevice as well as the ParallelPort in Task Events offers the ability to utilze the ToggleBit, SetBit, and ResetBit functions.
- SetBit - Specify a zero based bit number to set high. The value remains high if previously high.
- ResetBit - Specify a zero based bit number to set low. The value remains low if previously low.
- ToggleBit - Specify a zero based bit number to toggle. If the value was previously high, then it is set low. If the value was previously low, it will be set high.
Comments
1 comment
Thank you. We appreciate you voting and writing feedback. We will do our best to improve your experience
You wrote:
“fix the links in it ”
Please sign in to leave a comment.