Collapse
CollapsingX
  • - or -

Procedure for using the SerialPortWriter step


The following provides a basic methodology for using the SerialPortWriter step:

  1. Specify which serial port this SerialPortWriter step will use.

  2. Specify the Text to write to the runtime platform's serial port.

  3. Optionally, enable the Wait for acknowledgment property and specify the Mode as well as any required values.

Specify the text

Specify the Text to write to the runtime platform's serial port in the dropdown list. The text to be written can contain control characters if an escape sequence is used for new lines, for example \n or \r. Text can also contain control characters entered using hexcode (for example Esc = \0x001b).

Enter an expression to include the date or any calculated results. Optionally, you can specify the formatting of dates or numeric results using formatting codes.For more information on formatting result data and inline expressions, see the User-defined date/time and number formats section in Appendix A: Expression syntax.

To display a calculated result, use the Advanced editor to enter an expression. For more information about using expressions with string inputs, see the Strings subsection of the Data types section in Appendix A: Expression syntax.

Control characters

When typing in common control characters like tab, carriage return, and line feed, use their escape sequences \t, \r, \n, respectively. When typing in other ASCII control characters (such as the Esc character), you should send the hex code explicitly following the backslash. Hex codes should have 4 characters following the "x" (for example, \0x001b sends an Esc character). For a list of control characters, see the Strings subsection of the Data types section in Appendix A: Expression syntax.

Rarely is it necessary to send binary data over the serial port to a PLC. To send 8-bit characters, select Latin1 encoding. It is necessary to construct a lookup table to translate the raw data to characters because the \x notation described above cannot be embedded inside ARRAYTOSTRING or CONCAT functions.

Acknowledgment

You can ask the SerialPortWriter step to Wait for acknowledgment. This property can only be used with devices that respond to received commands with a return string such as OK. To use the acknowledgment option, perform the following:

  1. Enable the Wait for acknowledgment property.

  2. Select a Mode. Possible acknowledgment modes are:

    • Read up to expected text. This mode is used with devices that respond to received commands with a return string such as OK or a new line. The SerialPortWriter step will wait for the expected text before confirming that the write has been completed. Choose the appropriate escape sequence from the dropdown list (\n or \r), or specify one in the text box.

    • Read a fixed number of characters. This mode can be used to receive a buffer of confirmation data, such as current coordinates, or an error message. Specify the number of characters to read in the text box. Note that line feed (\n) and carriage return (\r) each count as a character.

  3. Set a Timeout value in ms to avoid waiting for a missed acknowledgment.