Page History: LPT Port Element
Compare Page Revisions
Page Revision: 2014/04/13 00:27
|
LPT Port Element
|
Info |
Category: |
Communications |
|
AddIn: |
Elements |
Creator: |
OkazoLab Team |
|
Scope: |
Parent Event |
Owns Snippets: |
Triggered |
|
Usage: |
Runtime Screen,Snippets |
LPT Port port element allows sending and receiving data via the parallel port (LTP) of a PC computer. The element can be used in standard experimental tasks, for example, for sending synchronization triggers to an EEG recording station.
Description
The LPT port element allows the use of the
parallel port (LTP) on PC computers for bidirectional data exchange. The LPT port can be described (at the software level) as a simple digital device that has 8 input and 8 output lines. Each line is binary, such that the ON/OFF status that can be set (for the output lines) or read (for the input lines) at any moment of time. Simplicity and instant access of the LPT port make it very useful in experimental scenarios that require a precise synchronization between experimental events and external hardware.
Snapshots
Practical Use
The parallel port element supports 3 different working modes. In the Manual I/O mode you have direct access to digital lines of the parallel port via the Input and Output element's properties and can program communications manually. In other working modes the element performs communications automatically, such that no or little coding is required.
Working Modes
'Manual I/O' mode
In this mode the element can be used for sending and receiving digital codes at arbitrary moments as defined by your code. The LPT Port element exposes two dedicated properties: Input and Output that are linked to the digital lines of the parallel port. The current port input can be always accessed by reading a value of the Input property in code snippets (Note that if you want to detect changes in the port input, the 'triggering on specific input' mode is more preferable, in which the element monitors all port input automatically) To produce the port output in the manual mode, you need to: 1) assign a digital code to the Output property b) invoke a sending action by assign 'true' to the Send Now property.
/// Code example on using the LPT Port Element in the 'Manual I/O' mode
//****** Reading the current port input *******
int NewInput=PortInput; // PortInput is a proxy variable linked to the Input property of the LPT Port element
//****** Sending data to port *******
if (N>5)
PortOutput=255; // PortOutput is a proxy variable linked to the Output property of the LPT Port element
else
PortOutput="10101010"; /// the output can be also set by a string encoding a binary state for each of 8 port lines
SendNow=true; /// initiate sending the a new port output, defined by the PortOutput variable
'Auto-output on event onset' mode
In this mode the element sets the port output lines synchronously with onset of the parent event. The status of each output line is chosen according to the current value of the Output property, for example "00101101". A new value can be assigned to the Output property at any runtime moment (use [proxy variables]), but the assignment does not causes an instant update of the output lines. The element will wait for the next onset of its parent event, when the assigned value to sent a port. This working mode is handy when you need to send an instant trigger to an external device every time, when some event occurs in an experiment. For example, if an event contains a visual stimulus and the Parallel port element, a digital marker will be sent as the stimulus is presented on the screen. You also can select a shape of such output signal in time relatively to the duration of the parent event:
- Level Change: -HIGH If this signal shape is selected, the element simply sets the output lines of the parallel port to the value defined by the Output property synchronously with activation of the parent event.
- Pulse: LOW-HIGH-LOW. If this signal shape is selected, the element performs a signal synchronization program consisting of 3 steps. Shortly before activation of the parent event the port output is set to the ground (each line is Off) level. When the parent event is actually activated the element sets the port output lines to the value defined by the Output property. Later, after a time interval defined by the Pulse Duration property, the element sets the port output back to the ground. If the pulse duration is greater than the actual duration of the parent event, the element grounds the signal pulse at deactivation of the parent event.
- TTL Pulse: LOW-HIGH. If this signal shape is selected, the element performs a signal synchronization program consisting just of 2 steps. Shortly before the parent event is activated, the element sets the current port output to the ground (zero) level. When the parent event is actually activated the element changes the port output to the value defined by the Output property. Subsequent port output changes can be done only with other parallel ports elements.
'Triggering on specific input' mode
In this working mode the parallel port element monitors selected or all input lines of the parallel port in order to detect changes in ports digital lines (at 1000Hz rate). The monitored lines and their sought states are specified by the Triggering Value property of the element. The element alerts about input changes by switching to the triggered state. The element also records the exact triggering time and invokes the Triggered snippet, if it contains code. This working mode allows you to use a specific port input for controlling the flow of your experiment, performing custom actions and collecting accurate input timing. Notice that in this working mode the element monitors the port input only while the parent event is active. You can use multiple LPT port elements in different events or in the same event but with different Triggering Input values. The elements also can be tuned to produce multiple triggering alerts, when the port input delivers repeated occurrences of the triggering value (by default, the element is triggered only once, as the triggering value is detected for the first time).
Notes
- If you need to detect any change in the port input use the 'Triggering on specific input' mode with the Triggering Input property set to '********', such that a change in any line would cause the element triggering.
- For better synchronization of the port output in the 'Auto-output on event onset' mode, move the LPT Port element at the top of the elements list in the parent event. Elements get to work one by one on the onset of the parent event, so the top position in the list will minimize possible delays.
- In the 'Triggering on specific input' mode the element does not get triggered, if the triggering value is already present in the port input on the onset of the parent event. A change of the port line is required to trigger the element.
Synchronized Element Actions
Mode | Experiment Start | Parent Event Onset | Status change between Onset/Offset | Parent Event Offset | Experiment End |
---|
Manual I/O | Hardware is enabled for communications | | as SentNow property receives 'true', the element sends the current Output value to a port. | | Hardware is disabled for communications |
Output on event onset | | Send chosen output values through the parallel port on the onset of the parent event. | | | |
Triggering on specific input | | Starts monitoring of port input at 1000Hz in a background thread. | When port input changes, a it's tested with Triggering Input mask. If test is passed the LPT port element becomes triggered. Triggering statistics,e.g. triggering time can be collected via the corresponding properties of the element: Is Triggered and Triggering Time. If the Triggered snippet exists, it's also invoked. | Stops listening. | |
Generic Properties
Name | Description | Constraints | Value Type | Upon Runtime Change |
---|
Port Settings |
Output Address | Address of the output gate in the parallel port. Default is 0x0378 (888) | | Int32 |
Input address | Address of the input gate in the parallel port. Default is 0x0379 (889) | | Int32 |
+=== Properties inherited from clParallelPortElement ===
Inherited properties of clParallelPort
Name | Description | Constraints | Value Type | Upon Runtime Change |
---|
Port Settings |
Working Mode | Defines a working mode for the element.Select the 'Output on event onset' mode for sending signals synchronously with an onset of the parent event,or 'Triggering on input' mode for catching the particular pattern in port input. For custom reading/writing scenarios use the 'Manual IO' mode, in which port communications can be controlled by your code. | | Int32 |
Output |
Test Output | Sends a test output signal through the port using the selected signal profile and the current Output Value. | |
Signal Profile | Defines the time-amplitude profile of the output signal. The 'Level Change', 'Pulse' and 'TTL' profiles are available. Last two can be used to send the EEG triggers. | | Int32 | |
Preface Duration | Defines the duration (ms) of the guarantied zero preface interval for the TTL or Pulse signals. Increase the preface duration marginally, if your recording hardware does not detect port signals. Note that a non-zero preface delays the onset of the actual signal. | | Double | |
Pulse Duration | Duration of an output pulse in ms. The value is applied only, if the Pulse signal profile is selected. | | UInt64 |
Output Value | Value to be sent through the port. Can be defined in integer or binary format, e.g. Output='01010000'; or Output=255; | | clBinaryInteger |
Send Now | Runtime command that that initiates an instant transfer of the current output value through the port. Manual command calls at runtime are only required, if the element works in the Manual I/O mode. | | Boolean | Execute the command by assigning true in code: SendNow=true; |
Input |
Test Input | Open a input monitor window showing real-time port input with the current settings. Use it for testing at designtime. | |
Input Value | Returns the current state of the port input lines. The property is not updated automatically. Manual reading of the property value in snippets is required to obtain the current input. The value can be read either to the integer or binary formats, e.g. 'string S=Input;' may return '01010101'. | | clBinaryInteger |
Triggering Input | eturns the current state of the port input lines. The property is not updated automatically. Manual reading of the property value in snippets is required to obtain the current input. The value can be read either to the integer or binary formats, e.g. 'string S=Input;' may return '01010101'. | | String |
Trigger Once | Returns the current state of the port input lines. The property is not updated automatically. Manual reading of the property value in snippets is required to obtain the current input. The value can be read either to the integer or binary formats, e.g. 'string S=Input;' may return '01010101' | | Boolean |
Runtime Status |
Is Triggered | Indicates whether the element has been triggered at least once, since activation of the parent event. Triggering occurs only in the 'Input Detection' working mode. | | Boolean |
Trigger Time | Indicates the local event time of the last element triggering. Triggering occurs only in the 'Input Detection' working mode. | | UInt64 |
+=== Properties inherited from clElement ===
Inherited properties of clElement
Name | Description | Constraints | Value Type | Upon Change |
---|
Control |
Is Enabled | If set to false the element is completely omitted when the experiment is run. | | Boolean |
|
Title | Title of the element. | | String |
|