This article applies to:
There are three approaches you can take, depending on the degree of control you need over the signaling mechanism and which type of port device you need to use (parallel/digital I/O card vs serial communications).
Option 1 - Parallel Port Triggers
In E-Prime, onset and offset signal properties are available on E-Objects. 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:
'NOTE: "X" is the actual name of the object on which the property is being set.
You can find these properties fully documented under the RteRunnableInputObject topic in the E-Prime Command Reference. You will need to specify the address of your port via the xxxSignalPort property, and the value you are sending via the xxxSignalData. If you do not know how to find these values, please click here INFO: General Parallel Port Information .
The onset and offset signal properties direct E-Prime to internally send a specific value to a specified I/O port at the exact time a stimulus onsets or offsets. The I/O port used is typically a parallel digital I/O port rather than a serial port (i.e., each bit within the port has some assigned meaning by the researcher).
For this type of signaling you can typically use the built-in parallel port, or alternatively, install a register addressable digital I/O card. If you use the default parallel port there is typically no hardware initialization needed. If you use a third party digital I/O card, you often have to configure the card once at the beginning of the experiment by using the WritePort E-Basic command to send a value to a configuration value to a designated configuration port. This step typically programs the registers/ports on the card as input or output. Refer to your cards programming manual for specific instructions on this step.
Assume objects named "Prime" and "Probe", and a parallel port address of &H378 in the following example. 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:
'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
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 TIMING: Object Execution  for a description of the different timing intervals within the execution of an object in E-Prime.
Option 2 - Parallel or Serial Triggers before Stimulus
You can alternatively intersperse script between each object in the trial sequence and use either the WritePort command or the SerialDevice and 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):
WritePort address, val
If you were sending the signal to the serial port, you would use the script:
This assumes that the SerialDevice is added to the experiment and the serial communication properties port id, baud rate, start bits, parity, stop bits, etc. are configured the same on both machines. The strData parameter becomes the actual string representing the data to be written to the serial device. If you need general information on how to use the Serial Device in E-Prime, please click here DEVICE: Serial Device .
This approach attempts to send a signal a consistent 1 screen refresh before the stimulus. Again, the best you can hope to achieve using this secondary approach is some constant signal time before the stimulus. Note that this approach can also interact with the PreRelease mechanism in E-Prime and can even send the signal at the wrong time if you do not fully understand how PreRelease works in E-Prime and how to adjust for it. You can refer to TIMING: Using PreRelease to Maintain Millisecond Timing  for a thorough explanation of PreRelease in E-Prime.
Option 3 - Parallel or Serial Triggers after Stimulus
The final approach is send the signal after the stimulus is presented. This approach requires that you set the PreRelease property for the object to the same value as its Duration, which forces the object to exit its Run method as soon as the stimulus is finished being presented. You would then send the signal by inserting an InLine after each object in the trial sequence:
'For a parallel port device
WritePort address, val
'For a serial device
The down side of this approach is that each object will require a variable duration to complete the stimulus presentation and perform internal housekeeping duties prior to its Run method being exited. Thus, there can be a small amount of variability between the time the stimulus is presented and the time the signal is sent. This delay is typically constant for similar stimuli, but can vary from machine to machine.
For more information view the E-Prime Command Reference for specifics involving E-Basic (https://pstnet.com/ecr).
Legacy End User Comments
|The Task Events feature introduced in E-Prime 2.0.10 requires no inline code and in most cases provides a superior mechanism for outputting signals in coordination with stimulus events. See the New Features Guide, and E-Prime Knowledge Base #4803. You may still, however, need OnsetSignal, etc., to handle some specialized contingent output signals.|