Page History: LPT Port Element
Compare Page Revisions
Page Revision: 2011/08/23 03:35
|
LPT Port Element
|
Info |
Category: |
Communications |
|
AddIn: |
Elements |
Creator: |
OkazoLab Team |
|
Scope: |
Parent Event |
Owns Snippets: |
no |
|
Usage: |
Runtime Screen,Snippets |
Parallel port element allows using of the parallel port (LTP) of a PC computer.
Description
LPT port element allows using of the
parallel port (LTP) on PC computers. The LPT port can be described (at the software level) as a simple communication device that has 8 input and 8 output lines. Each line is binary- with ON/OFF status that can be set (for the output lines) or read (for the input lines) at any moment of time. Simplicity and fast access speed of the LPT port make it very useful in experimental scenarios that require a precise synchronization between experimental events and a work of the external devices.
Snapshots
Practical Use
The parallel port element provides a direct access to the lines of the parallel port at runtime: it can be done by reading or assigning value to a single variable in code snippets. The element also can be used to set up an automatic (latency is <1ms) signal exchange synchronized with particular events in your experiment. In general, you can select one of three working modes for the parallel port element:
Manual working mode
In this mode the element can be used for manual sending and receiving digital codes through the LTP port, at will moment. The element has two properties, [Input] and [Output], which are linked to the current input and output of the parallel port, correspondingly. The current port input can be always accessed by reading a value of the [Input] property in your code snippets. Notice that any changes of the port input between two subsequent property readings cannot be tracked in this working mode. Assigning a value to the [Output] property in code snippets causes an instant update of the port output lines with the new value.
AutoOutput working mode
In this mode the element sets the port output lines to a specific status synchronously with activation of the parent event. The status of output port lines is set according to the current value of the [Output] property. Notice that assigning a new value to the [Output] property does not causes an instant updates of the output lines as in the Manual Mode. This working mode is handy when you need to send an instant signal to an external device every time when some event occurs in experiment, for instance, a visual stimulus is presented on the screen. You also can choose a shape of such output signal in time relatively to the duration of the parent event:
- Level signal shape. If this signal shape is selected, the element simply sets the output lines of the parallel port to the value defined by [Output] property synchronously with activation of the parent event.
- Pulse signal shape. 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 [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.
- Trigger signal mode. 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 [Output] property. Subsequent port output changes can be done only with other parallel ports elements.
Notice that the element in this working mode has an action scope - the output can be set only when the parent event is activated.
InputTrigger working mode
In this working mode the parallel port element monitors one or several input lines of the parallel port in order to detect their changes into a specific binary state. The monitored lines and their sought states are defined by the [Trigger Value] property of the element. The element alerts a successful detection by switching to the triggered state. The element triggering is always accompanied with recording of the exact trigger time and executing of the dedicated code snippet (if present). Thus, you can use a specific port input for controlling a flow of your experiment, performing custom actions and collecting accurate input timing. Notice that the element in this working mode has an action scope - the input monitoring and triggering are possible only while the parent event is active. However, you can always share the same parallel port among multiple parallel port elements, and each element would seek for its own triggering input. The elements also can be set to have multiple triggering in case in the port input may contains multiple occurrences of the trigger string (by default, in this working mode the element is triggered only once on the first triggering input arrival).
Notes
- You can use multiple parallel port elements in your experiment but, if they share the same hardware port, you should take in account and resolve possible interferences, like tracking the actual status of output lines that cannot been read directly.
- For better synchronization of the port output (in AutoOutput and InputTrigger modes) move the Parallel Port element at the top of the elements list in the parent event. Elements there get to work one by one, as soon as the parent event is activated, so the top position in the list will minimize possible delays.
Generic Properties
Name | Description | Attributes | Value Type |
---|
Port settings |
Working mode | Defines the working mode for the element. One of three modes can be selected:
Manual – the port input and output are controlled manually, in code snippets, at will moment.
AutoOutput - the predefined port output is synchronized with activation of the parent event. The output is shaped in time according to the value of the [Signal shape] property.
InputTrigger - the element detects a specific port input, records its time and initiates custom triggering actions. | D | Int32 |
Output address | The address of the output gate of the computer LTP port. The default value is 888 (0x0378) | D | Int32 |
Input address | The address of the input gate in the computer LTP port. The default value is 889 (0x0379) | D | Int32 |
Output |
Test output | Sets the output port lines into the current value of the [Output] property. Use this action at the design time to check availability of the selected port settings. | Design-time action |
Output | Defines the requesting status of the port output lines. The status is coded by the clBinaryInteger struct, which represents a port output both in Int32 and binary strings formats. Each char in the binary string, like "01011111", corresponds to a single line of the parallel port, where the first line is denoted by the rightmost char. ("1" and "0" code ON and OFF states, correspondingly). The left part of assigned strings with length greater than 8 chars is ignored. The valid value range for the Number field is between 0 and 255. | D,R | Struct clBinaryInteger with two linked fields:
Int32 Number,
String Binary
Code examples:
a.Number=1;
a.Binary="00000001"; |
Signal shape | Defines the output signal shape when the element works in the AutoOutput mode. One of three signal shapes can be selected:
Level - the requesting output status is set synchronously with activation of the parent event without a reset of the current output lines.
Pulse - the requesting output status is set synchronously with activation of the parent event, plus, the element also performs "pre" and "post" reset of the port output to the ground level. The requesting output status is hold for the time defined by the [Pulse duration] property.
Trigger - the requesting output status is set synchronously with activation of the parent event, plus, it accompanied with a pre reset of the output lines to the ground. The requesting output is held after it is set until a new port output operation. | D | Int32 |
Pulse duration | Defines the duration (in ms) of the signal pulse- the time that the LTP port is holding the requesting output status when it is set with the Pulse Signal shape. In other cases this property is ignored. | D,R | UInt64 |
Input |
Test input | Requests the current status of the port input lines and store it in the [Input] property. Use this action at the design time to check availability of the selected port settings and the current port input. | Design-time action | |
Input port | The address of the input gate in the computer parallel port. The default value is 889 (0x0379) | D | Int32 |
Input | Represents the current status of the input lines of the LTP port. The status is coded by the clBinaryInteger struct, which represents a port input both in Int32 and binary strings formats. Each char in the binary string, like "01011111", corresponds to a single line of the parallel port, where the first line is denoted by the rightmost char. ("1" and "0" code ON and OFF states, correspondingly). The binary string always has a length 8 (as input lines number). | D,R, Read-Only | Struct clBinaryInteger with two linked fields:
Int32 Number,
String Binary
Code examples:
Int c=a.Number;
string s=a.Binary; |
Trigger value | Defines a binary status of the port input lines that has to be detected when the element works in the InputTrigger mode. The sought status is coded by string that cannot have more than 8 chars. Each char in the assigned binary string, like "0*01**11", corresponds to a single line of the parallel port, where the first port line is denoted by the rightmost char. ("1" and "0" code ON and OFF states, correspondingly). If char is set to "*", it means that the status of the corresponding line is irrelevant for detection. | D,R | String |
Trigger Once | Defines the triggering behavior when the element works in the InputTrigger mode. If the value is true, the element may be triggered only once, while the parent event is active. If the value is false, multiple triggering is allowed. | D | Boolean |
Runtime info |
Was Triggered | Indicates if the element has been triggered at least once starting from the current activation of the parent event | R, Read-Only | Boolean |
Trigger time | Indicates the latest event time when the element was triggered (in ms elapsed since activation of the parent event). The property is usable only when the element works in the InputTrigger mode. | R, Read-only | 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 |
|