Welcome
Guest
, you are in:
<root>
Elements
•
Login
EventIDE Wiki
Navigation
¶
Main Page
Random Page
Create a new Page
All Pages
Categories
Navigation Paths
Administration
File Management
Create Account
Search the wiki
Back
COM Port Element
Modified on 2018/07/16 21:55
by
Administrator
Categorized as
Base Elements
,
Communications
,
Elements
<div style="margin-right: 10px; margin-left: 16px; margin-bottom:10px; float: right; width: 500px; overflow: hidden; height: auto; padding: 0px; background: #fafafa; background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa));background: -moz-linear-gradient(top, #fbfbfb, #fafafa);border: 1px dashed #ddd;box-shadow: 0 0 0 3px #fff, 0 0 0 5px #ddd, 0 0 0 10px #fff, 0 0 2px 10px #eee;"> == Summary == {s:Element Info Panel | title=COM Port | category=Communication | icon=[image|Element Icon|{UP(Serial-Port-Element)}COM-Port-Element-Icon.png] | author= OkazoLab | addin= Base Elements | scope= Parent event | usage= Snippets | ownsnippets= None } == Properties == {| |- ! Name ! Description ! Constraints ! Type ! On<br/>runtime<br/>change |- | colspan="5" bgcolor="#AADDDDD" | Port Settings |- | Port Name | Defines the selected serial port by its name in the system. The name can be selected from the dropdown list, which queries the available serial ports. | {s:atDesign} | String | |- | Baud Rate | Defines the serial baud rate | {s:atDesign} | Int32 | |- | Stop Bits | Defines a number of stopbits per transferred byte | {s:atDesign} | StopBi.. | |- | Parity | Defines the parity-checking protocol | {s:atDesign} | Parity | |- | Data Bits Number | Defines the number of data bits in each transferred byte | {s:atDesign} | Int32 | |- | colspan="5" bgcolor="#AADDDDD" | Settings |- | Working Mode | Defines a working mode for the element. Select 'Auto Output' mode for sending data synchronously with an onset of the parent event, 'Input Detection' mode for catching the particular pattern in port input and 'Manual Output'/'Input Listener' modes for custom writing/reading scenarios controlled via snippets. | {s:atDesign} | stSeri.. | |- | Encoding | The encoding method that is used to convert raw port bytes into text strings and vice verse. The default encoding is ByteChar which converts each byte of data to a single char. | {s:atNormal} | stSeri.. | |- | Buffer Size | Size of the input circular buffer (in bytes) that stores all incoming port data when the element works in the 'Input Listener' mode. If the buffer is small, a part of the data can be lost before it is read by the program | {s:atDesign} | Int32 | |- | colspan="5" bgcolor="#AADDDDD" | Input |- | Test Input | Start a dialog window that monitors arriving port input in realtime. Use for verification of the selected port settings and encoding method. | {s:atDesign} | Boolean | |- | Input | Returns a string containing the most recent port input, when the element works in the input modes. The property value is refreshed on each Control Loop step, therefore, it should be read in the Control Loop snippet. | {s:atStatus} | String | |- | Triggering Input | When the element works in the 'Input Detection' mode, a value of this property defines the 'catching' input string. If such string is detected an incoming input at some moment, the element registers the detection time and becomes triggered. This property is essential for time-accurate registration of the specific input, e.g a button press, coming out of a external device. | {s:atNormal} | String | |- | Trigger Once | Defines whether the element can be triggered multiple times, while the parent event is active. If the property value is 'true', only the first triggering is registered. Triggering can occur only in the 'Triggering on specific input' working mode | {s:atDesign} | Boolean | |- | colspan="5" bgcolor="#AADDDDD" | Output |- | Output Buffer | Text buffer that accumulates data meant to be sent through the port. | {s:atNormal} | String | |- | Send Now | Runtime command sending the current output value through the port. The command is enabled, when the element works in the Manual Output mode. | {s:atRuntimeAction} | Boolean | |- | colspan="5" bgcolor="#AADDDDD" | Runtime Status |- | Is Triggered | Indicates whether the element has been triggered at least once, since activation of the parent event. Triggering can occur only in the 'Input Detection' working mode. | {s:atNormal} | Boolean | |- | Triggering Time | Returns a local event time of the last triggering on the element. Triggering can occur only in the 'Triggering on specific input' working mode. | {s:atStatus} | clTime | |- | colspan="5" bgcolor="#AADDDDD" | Control |- | Is Enabled | If set to false the element is completely omitted when the experiment is run | {s:atDesign} | Boolean | |- | Title | Title of the element | {s:atDesign} | String | |- |} == == </div> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> <!--*****************************************************************************************************************************************************************************--> '''COM Port Element''' provides bidirectional data exchange through the serial port (COM) on a PC computer. The element can be used for sending digital codes that are synchronized with events in your experiment. Also, the serial port element can be used for asynchronous data transfers to the external devices.{br}{br} {TOC} == Description == COM port is an element that provides bidirectional data exchange through the serial computer ports: COM ports and USB ports (with special drivers). Using the COM port element is very easy: you simply chose one of the existing serial ports on a computer, set up a few port settings and select the element working mode. The element supports four working modes that cover most of the typical usage scenarios in experiments. == Snapshots == {| | [imageleft||{UP(Serial-port-element)}SerialPort_sm.jpg|{UP(Serial-port-element)}SerialPort.png] | [imageleft||{UP}/pictures/Elements/COMport/COMport_sm.jpg|{UP}/pictures/Elements/COMport/COMport.png] |} == Practical Use == === Manual (output) === <nowiki>In this mode the serial port element can be used for sending data through the serial port at any chosen moment of time. You have to control this process manually in your code snippets in two steps. First, you should settle some data in an output buffer by assigning a string value to the [Output Buffer] property of the element. Then, the output buffer can be sent to the port immediately after you set the [Send now] property of the element to true (initiating the runtime action). You can perform these steps multiple times while your experiment is running (it not necessary to have the parent event active in this working mode).</nowiki> === Output on event Onset === <nowiki>In this mode the serial port element can be used for sending data through the serial port synchronously with activation of the parent event. Before the activation or in the design time you should settle data in an output buffer by a string value to the [Output Buffer] property of the element. Immediately after activation of the parent event the output buffer will be sent automatically through the serial port. The output buffer can be changed at the runtime at any time but each new sending will require reactivation of the parent event. </nowiki> === Triggering on specific Input === In this working mode the serial port element monitors all input coming through the serial port in order to detect a moment when the specific string value, the trigger string, arrives. The sought value is defined by the <nowiki>[Trigger String] </nowiki>property of the element. The serial port element signals the arrival moment by switching to the triggered state. Such triggering is always accompanied with recording of the exact trigger time and executing of the dedicated code snippet (if present). Thus, you can use the 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. This means the input monitoring and element triggering are possible only while the parent event is active.{br}{br}You can share the same port input among several serial port elements with each element seeking for its own trigger string. 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 trigger string arrival). === Manual Input Listening === In this working mode the serial port element simply collects all port input coming through the serial port while the parent event is active. The coming input is placed into the input buffer which can be accessed at runtime by reading the<nowiki> [Input Buffer] </nowiki>property of the element in code snippets. The input buffer is designed to be forcibly refreshed on every Running Cycle of the parent event. If you want to avoid data losses, you should take into account the expected input intensity and provide continuous reading of the input buffer. The best strategy is to read the input buffer in the OnRunning snippet of the parent event (a fresh data is guaranteed) and set the size of the input buffer to be always sufficient to store all input coming between two Running cycles. === Testing the serial port element === <nowiki>You can test a work of the serial port element with its current settings at designtime by initiating either of two design-time actions: [Test Output] and [Test Input]. EventIDE will try to simulate element's runtime behavior for a short time, while it can be checked with an external hardware or software. [TestOutput] action initiates a single transfer of the current output buffer through the port. [TestInput] action calls a text window that, while open, shows the coming port input. </nowiki> == Notes == # For better synchronization of output transfers (in AutoOutput mode), move the Serial Port element at the top of the elements list in the parent event. The elements in the list are activated one by one, as soon as the parent event is activated, so the top position in the list decreases possible time delays. # The serial port element always operates with input and output port data in the string format, performing string-binary conversion automatically. For the desired adequacy of this conversion the appropriate encoding has to be selected in the element port settings. # You can use multiple serial port elements that share the same serial port. However, in this case you should take in account possible performance issues, which are likely, for example, in cases of the intensive port input.
Meta Keywords:
Meta Description:
Change Comment:
ScrewTurn Wiki
version 5.2.0.8. Some of the icons created by
FamFamFam
.