User Defined Communication
Communicates with external devices using frames that you define yourself. Serial, TCP, UDP, WebSocket, Bluetooth, and shared memory connections can be used, and connections are registered in Settings > User Defined Communication (Part 6).
User Defined Communication
Select the connection to use.
Commands
- Send (default): Sends the data composed in the frame.
- Receive: Receives data and interprets it according to the frame.
Receive Complete
Select a Digital variable that becomes true the moment new data is received and false otherwise. Displayed only when Command is Receive.
Frame
The data frame to send or receive is composed as a sequence of items added to the table. The frame works as follows.
- When sending: The data is composed from the items in order. Constants, variables, and integrity check items can be included; a variable contributes its value at the time of sending, and an integrity check item contributes its calculated result.
- When receiving: The received data is compared with the frame to check that it matches. A variable item parses the received data into the variable, and an integrity check item verifies that the calculated result of the received data matches.
Frame items
Name
Enter the name of the item. Any name can be used.
Type
- Digital (default): A true or false constant.
- Number: A numeric constant. The number format sets the byte size and whether it is an integer or a floating-point value.
- Text: A text constant.
- Byte Array: A byte array constant.
- Variable: Sends the value of a variable, or stores the received value in a variable. Only Digital, Number, Text, and Byte Array variables can be selected.
- Integrity Check: Calculates a check value over a range of the data and inserts it into the frame, or compares it with the received check value.
Value
Enter the constant value. Displayed only when Type is Digital, Number, Text, or Byte Array.
Variable
Select the variable to send or receive. Displayed only when Type is Variable.
Number Format
Select how the number is converted to bytes: 1-byte Integer (default), 1-byte Unsigned Integer, 2-byte Integer, 2-byte Unsigned Integer, 4-byte Integer, 4-byte Unsigned Integer, 4-byte Float, or 8-byte Double. Displayed only when Type is Number, or Variable with a Number variable selected.
Unknown Byte Size
Turn this on when the byte size of the data to receive is not known in advance. A frame can contain only one item of unknown size. Displayed only when Command is Receive and Type is Variable with a Text or Byte Array variable selected.
Byte Size
Enter the byte size of the data to receive, from 1 to 65535. That many bytes are parsed into the variable. Displayed only for Text or Byte Array variable items with Unknown Byte Size off.
Reverse Byte Order
Reverses the byte order of the data sent or received. Turn it on when the other device handles byte order (endianness) differently. Displayed only when the constant or variable type is Number, Text, or Byte Array.
Validation Method
Select the calculation used for the integrity check. The items from Start Data to End Data are the calculation range. Displayed only when Type is Integrity Check.
| Validation Method | Calculation |
|---|---|
| BYTE SUM | Sum of all bytes |
| WORD SUM | Sum in 16-bit words |
| BYTE XOR | XOR accumulated over all bytes |
| 7BIT SUM | Sum of the lower 7 bits of each byte, with the top bit removed |
| 7BIT XOR | XOR accumulated over the lower 7 bits of each byte, with the top bit removed |
| 7BIT SUM (0x20+) | 7-bit sum over only the bytes whose value is 0x20 (space) or higher |
| BYTE SUM (2's Complement) | Sum of all bytes converted to its two's complement |
| BYTE SUM (1's Complement) | Sum of all bytes converted to its one's complement (bit inversion) |
| CRC16 STANDARD | 16-bit CRC with the standard polynomial |
| CRC16 CCITT | 16-bit CRC with the CCITT polynomial (0x1021) |
| CRC16 MODBUS | 16-bit CRC with the Modbus polynomial (0x8005) |
Start Data, End Data
Select the first and last frame items of the range over which the integrity check is calculated. Displayed only when Type is Integrity Check.
Convert to ASCII
When on, the calculated check value is inserted as a hexadecimal string (for example, 0x9C becomes the string "9C"). Displayed only when Type is Integrity Check.