This article applies to:
E-Prime 3.0
E-Prime 2.0
E-Prime 1.x
Detail
NOTE: This article is the same as article numbers 17851 and 17214.
This article describes deprecated methods to send markers from E-Prime to an external device. This information is provided for legacy purposes only; these methods should not be used when creating new experiments. Instead, PST recommends using Task Events to send markers to an external device via Chronos, a Parallel Port, a Serial Port, or a Socket Device. Please refer to INFO: How do I send a marker to an external device? [42521] for more information. The methods listed in this article should be used with E-Prime Professional 2.0.8.x or prior or with any version of E-Prime 2 Standard Edition only, since these releases do not support Task Events.
When working with an E-Prime version/edition that does not support Task Events, we recommend first adding one of the devices listed below to the experiment via the Devices tab on the Experiment Object Properties dialog:
E-Basic script can then be added on an InLine that references the available methods for the device. See the E-Prime Command Reference (ECR)for details on the device methods.
In older versions of E-Prime, some of the devices listed above are not available. In such cases, one of the deprecated methods described below must be used to send markers from E-Prime to another device.
Onset and Offset Signal Properties
This method sends markers through the specified parallel port. In E-Prime, Onset and Offset signal properties are available for any executable E-Object. These properties allow markers to be sent at an object's OnsetTime and cleared at the object's OffsetTime. These properties are documented under theRteRunnableInputObject topic in the E-Prime Command Reference. These properties include:
- X.OnsetSignalEnabled
- X.OnsetSignalPort
- X.OnsetSignalData
- X.OffsetSignalEnabled
- X.OffsetSignalPort
- X.OffsetSignalData
NOTE: "X" is the name of the object on which the property is being set.
There are 3 main components to sending markers using this method. First, the sending of markers must be enabled for the Onset or OffsetTime of an object. Second, the port address that the marker is being sent to must also be specified. The port address can be specified in either decimal or hexadecimal format. For example, the most common parallel port address is decimal 888, which translates in hexadecimal notation to 378. When using hexadecimal notation, E-Basic requires "&H" to be inserted prior to the address e.g., "&H378". Third, the value that is being sent must be specified (see: INFO: Choosing a marker value to send from E-Prime to an external device [42529]).
The example shown below assumes that the experiment includes objects named "Prime" and "Probe" and a parallel port address is &H378. The InLine script must be placed at the beginning of the experiment and results in the specified objects sending a marker to the parallel port at the object's OnsetTime:
'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.
Prime.OnsetSignalEnabled = True
Prime.OnsetSignalPort = &H378
Prime.OnsetSignalData = &H01
Probe.OnsetSignalEnabled = True
Probe.OnsetSignalPort = &H378
Probe.OnsetSignalData = &H02
When sending the same marker value for each object, the OnsetSignalData property only needs to be assigned once at the start of the experiment. If the OnsetSignalData value changes, for example based on the trial type, then an InLine needs to be inserted in the procedure that re-assigns the OnsetSignalData value prior to when the object runs.
The bit that is set high with OnsetSignalData remains high until it is reset. Enabling the OffSignal for the same object and specifying a value of 0 to all bits will reset the bits back to 0. In this case, the bit remains high for the specified Duration of the object, assuming PreRelease is set to 0. Refer to the sections on 'Object Execution' within TIMING: Timing of E-Objects [22852] for a description of the different timing intervals within the execution of an object in E-Prime. Bits can also be reset using the WritePort command as described in the section below.
NOTE: The current default E-Prime setting assigns PreRelease to "(same as duration)" which effects when the OffsetTime occurs. For more information, see TIMING: PreRelease defaults changed to promote better timing accuracy [17936].
WritePort
This method sends markers through the specified parallel or serial port. This method does not synchronize markers to a specific event such as an Object's OnsetTime. Instead, the marker is sent when the Inline containing the script executes in the procedure.
The WritePort method requires 2 parameters, the port address and a marker value.
- The port address must be specified as either a hexadecimal value, which is defined in E-Basic by using the "&H" prefix, or as a decimal value. For example, the most common parallel port address in decimal is 888. Therefore this address can be specified in the WritePort method as either (integer) 888 or as &H378 (hexadecimal).
- For information about how to select the correct marker value to send, please refer to INFO: Choosing a marker value to send from E-Prime to an external device [42529].
The example shown below sends the marker value 1, which sets the least significant bit on the parallel port high, to the port at hexadecimal address 378:
WritePort &H378, 1
This bit can be set low again with a second call to WritePort, specifying the same port address with a marker value of 0. When sending markers over the parallel port, we recommend keeping the bit value(s) high for a minimum of 10 ms, which can be accomplished with a Sleep statement. For example:
WritePort &H378, 1
Sleep 10
WritePort &H378, 0
Create a Socket Device in Script
This method should be used with E-Prime version 1.2 only. If using E-Prime 2.0 or later, add a Socket Device using the E-Studio GUI (DEVICE: Socket Device [26069]) instead of creating it in script. This method cannot be used in E-Prime 1.0/1.1; calling this method in E-Prime 1.0/1.1 results in a compiler error. Users who create a Socket Device in script for E-Prime 1.2 experiments are encouraged to us #if version tags to eliminate compilation error with earlier E-Prime versions.
Since E-Prime 1.2 does not support a GUI Socket Device, the device must be created in InLine script as shown below.
Declare an object variable in User Script:
Dim MySocket As SocketDevice
In an Inline at the beginning of the experiment, setup and open the device:
Set MySocket = New SocketDevice
MySocket.Name = "MySocket"
Dim theSocketDeviceInfo As SocketDeviceInfo
'can also be a DNS name of x.x.x.x IP address
theSocketDeviceInfo.Server = "192.168.100.1"
theSocketDeviceInfo.Port = 5000
theSocketDeviceInfo.SocketType - ebSocketTypeTcp
theSocketDeviceInfo.ByteOrdering = ebByteOrderingLittleEndian
'Open
MySocket.Open theSocketDeviceInfo
NOTE: For descriptions of the Device properties shown above, refer to DEVICE: Socket Device [26069].
To send a marker, place an Inline where the marker should be sent:
Dim strData As String
strData = "This is the data written"
MySocket.WriteString strData
NOTE: See the SocketDevice (Object) topic in the E-Prime Command Reference for information on other read and write methods.
The Socket Device must be closed when Socket communications are finished (e.g., at the end of the experiment) to avoid errors:
MySocket.FlushInputBuffer
MySocket.FlushOutputBuffer
Sleep 500
MySocket.Close
Set MySocket = Nothing
Port Device
The Port Device can be added to the experiment in the Experiment Object Properties. Once properly configured, it can be added to an E-Object as an Input Mask and receive markers from a parallel port or serial port without the need for any Inline script. Please refer to DEVICE: Port Device [17213].
See Also:
E-STUDIO: Using Task Events [22862]
E-STUDIO: Configuring Task Events [24789]
Parallel Port Configure [30031]
Parallel Port Communications [30027]
Comments
0 comments
Please sign in to leave a comment.