This article applies to:
E-Prime 3.0
E-Prime 2.0
E-Prime 1.x
Detail
Support for sending a signal to an external device (e.g., another machine, EEG) is available in E-Prime via port communications or through writing your own Windows DLLs.
For port communications, a small amount of script must be used in an InLine Object. To send a signal to the port, you should use the WritePort command in an Inline in your experiment. The parameters for WritePort are as follows:
WritePort address, value
The address of your port can be found by navigating to the Device Manager, 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.
In the WritePort command, the port address may be specified in decimal or hexadecimal notation. Please refer to the Val function in the E-Prime Command Reference further explanation. When using hexadecimal notation, E-Basic requires "&H" to be inserted prior to the address:
WritePort &Haddress, value
The most common parallel port address is (in decimal) 888, which translates in hexadecimal notation to 378. However, we strongly recommend that you refer to your own System properties to find the available port address on your own machine.
You must also remember that, when writing to the parallel port, you are sending 8 bits of data at once. For the WritePort command, the value parameter is translated into binary notation to determine the bit pattern. Since this binary representation corresponds to a specific bit representation, you must send a value which translates (in binary) to send the appropriate bit representation. Essentially, you should 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". If you were to send all "0"'s to the port, the binary notation for this would be 000000000. To send a signal to bit number '2', the binary notation would translate to 00000010.
The bit pattern then corresponds to the pin connections. Bits are either 0-based or 1-based. Pins are always 1-based
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 one.
Therefore, if you wanted to turn on bit number one an 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 your port address were (in hexadecimal) 378, the Write Port syntax for this would be:
WritePort &H378, 1
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.
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. With the WritePort command, E-Prime may be used to trigger an event (e.g., signal an external device to begin data acquisition) or notify an external device of an event (e.g., in order to mark the event in the data collected by the external device).
When sending more than a TTL pulse to the port, you must write your own Windows DLLs. The only information and/or support PST can offer is to direct you to the Declare statement in the E-Prime Command Reference. Essentially, you can bring the library of calls from into E-Prime by copying and pasting them into the User Script of your experiment. In doing so, you will likely no longer use E-Prime's "WritePort" command for port communications, but will rather use the specific commands you have imported. Writing Windows DLLs is best done by a professional programmer, and is beyond the scope of PST's support for E-Prime.
Comments
0 comments
Please sign in to leave a comment.