MP STUDIO 2 · Communication · V1.3.0 and later
MP STUDIO 2 · User Protocol
The user protocol lets the PLC exchange data with devices that do not use Modbus, such as CO2 sensors, barcode and QR readers, inverters and temperature controllers that take ASCII commands, and numeric displays, in a byte format you define. In the User Protocol window, you define the format of the bytes and when they are sent, and the PLC runs that communication together with the program. You do not have to handle bytes one at a time with PUT and GET in the ladder, and received values are stored in the memory you specify only after the whole frame, checksum included, matches.
View examples Prepare the port
| Models | Communication ports | Version |
|---|---|---|
| MPS and MPA series | Comm Port 1–3 | V1.3.0 and later |
- Frames and transactions
Build a frame from fixed-byte, value, text, length and checksum fields, and group the frame to send and the frames to wait for into a transaction. - Four communication types
Request/response, Receive only, Respond on receive and Send only can be used together on one port. - Ladder triggers
TheUPTRIGfunction runs a transaction once at the moment you choose, and reports the result in the status word and the done bit. - Checking tools
Preview the bytes to send and decode received bytes, find the matching checksum, test with a virtual device in simulation, follow the comm log during monitoring, or exchange bytes with a device from a PC COM port (PC test).
On this page
Supported Products and Communication Ports
The user protocol is set on the serial channels of the PLC (Comm Port 1 to Comm Port 3). The number of communication ports available depends on the model.
| Communication port | Model |
|---|---|
| Comm Port 1 | MPS-8A4R(T)-S · MPS-8A8R(T)-S · MPS-16A8R(T)-R2 · MPS-16A16R(T) |
| Comm Port 1 to Comm Port 3 | MPS-8A8R · MPS-16A8R(T) · MPS-16A8R8T · MPA series |
For the terminals of each communication port (RS-232, RS-485 and UART) and the connector diagrams, see the product pages: MPS-8A4R-S · MPS-8A4T-S · MPS-8A8R-S · MPS-8A8T-S · MPS-16A16R · MPS-8A8R · MPS-16A8R · MPS-16A8R8T · MPA Series. On the MPA series, Comm Port 1 is RS-232, Comm Port 2 is RS-485 and Comm Port 3 is UART.
- The baud rate, data bits, parity and stop bits must match the device. You can also use 7 data bits (for example
7-E-1), which are common on ASCII devices. - The PLC switches the RS-485 terminals between sending and receiving, so the ladder does not need to handle this.
A 7-segment display turns off Comm Port 3 on the MPA
On the MPA series, running the 7-segment functionFINIturns off Comm Port 3 (Serial 3); see 7-Segment Display. When you also use a 7-segment display, set the user protocol on Comm Port 1 or Comm Port 2.
How It Works
The user protocol is defined for each communication port with frames and transactions.
- Frame: The format of one group of bytes that is sent or received. You build it by placing fields in order (Frames).
- Transaction: Defines which frame is sent when, and which frame is awaited. For each transaction, you can set the communication type, the trigger, the response timeout, the retries, and the status word and done bit that receive the result (Transactions).
There are four communication types.
- Request/response
Sends its Send frame and waits for a Receive frame.
Trigger: periodic, ladderUPTRIGor when a value changes
Typical uses: CO2 sensors, reading inverter status, temperature controllers - Receive only
Stores the values when a matching frame arrives. Sends nothing.
Trigger: always listening
Typical uses: barcode and QR readers, scales with continuous output - Respond on receive
Sends the defined response frame as soon as a matching frame arrives.
Trigger: always listening
Typical uses: PC programs, HMIs without Modbus - Send only
Sends its Send frame without waiting for a response.
Trigger: periodic, ladderUPTRIGor when a value changes
Typical uses: numeric displays, printers, setting commands
On the PLC, the user protocol runs as follows.
- Each communication port runs one transaction at a time. When several transactions are due, they run in turn in the order of the transaction list, and responses for Respond on receive transactions are sent first.
- Received bytes are stored in memory all at once, only after the whole frame matches. If the checksum or a value format does not match, none of the values in that frame are stored. The ladder reads the received values from the next scan on.
- If the received bytes match no frame, the first byte is dropped and matching starts again. Even if noise bytes come before a response, the response is received as long as a matching frame follows.
- The user protocol is downloaded to the PLC together with the program. Changes made in the window reach the PLC only after you click OK and download again.
Preparing the Communication Port
A serial channel used for the user protocol must be in User Protocol mode with Use this channel for download turned off.
- Select Settings → Communication Port, and on the tab of the serial channel you use (for example Serial 1), set the baud rate, data bits, parity and stop bits to match the device. To use a baud rate other than 115200, first turn off Use this channel for download.
- You can set the mode to
User Protocolin this window or leave it as it is. When you click OK in the User Protocol window, a port inNormalmode changes toUser Protocol, and download on that port is turned off.
- A port set to any mode other than
Normal(for exampleModbus RTU Slave) is not changed automatically. It changes only when you click Switch to User Protocol, which appears at the top of the User Protocol window. - A port whose user protocol you deleted returns to
Normalmode when you click OK. - Each item of the Communication Port window is described in Phase 6 · Communication Port.
Sharing a port with the Modbus device table stops both
A communication port used by the Modbus device table cannot also have a user protocol. If both read the receive buffer of one port, neither works, so move one of them to another communication port.
User Protocol Window
Opening the Window
- Select Settings → User Protocol… to open it.
- You can also open it with Open User Protocol in the number cell of
UPTRIGin the ladder (see below). - When you click an address used by the user protocol in the Inspector or the Used Data window, the window opens with the transaction, frame and field that use that address selected.
You can edit the ladder while the window stays open. If a communication port has no definition, + Create on this port and a list of templates are shown.
| Template | What it contains |
|---|---|
| CO2 / gas sensor — poll every second | A Request/response transaction (1-second period) and a Send only transaction that sends the zero command with UPTRIG 3. Binary value in D100, two's complement sum checksum |
| CO2 / gas sensor — receive only (sensor communication example · the sensor sends on its own) | A Receive only transaction that always listens for the same CO2 response frame without sending a request |
| Barcode / QR reader | A Receive only transaction. Stores the text up to the end characters CR LF from D200 and the number of characters in D190 |
| Inverter / temperature controller (ASCII station commands) | Request/response (0.5-second period). ASCII decimal and hex values, sum checksum (2 ASCII hex digits), NAK error response |
You can freely change the template names and addresses (D100, M100 and so on) after adding a template. You can also add templates to a port that already has a definition with + Load from a template…; if a name is already taken, a number is added to the end.
Window Layout
- ① Communication port tabs: Choose the communication port to define. A port with a definition shows User Protocol and its port settings (for example
9600 · 8-N-1). - ② Views: Choose Definition, PC test or Comm log. During simulation, Virtual device is added. Click Port settings… to open the Communication Port window.
- ③ Transactions: Each transaction card shows the name, the communication type, the trigger, the frame to send → the frame to receive, and the status word and done bit. During monitoring, it also shows the last result. Click + Add transaction and choose a communication type to add a transaction.
- ④ Frames: The frame list of this port. Each frame shows Send, Receive or Unused and its number of bytes. Add a frame with + Frame; select a frame to use Duplicate and Delete frame.
- ⑥ Transaction settings: Set the name, communication type, trigger, response timeout, retries, status word and done bit of the selected transaction (Transactions).
- ⑦ Field strips: The frame the transaction sends (Send) and the frames it waits for (Receive and Error response) are shown as fields (Frames).
- ⑧ Preview: Shows the bytes to send in hex, and decodes received bytes that you paste (see below).
- ⑨ Properties: Edit the properties of the selected field. When no field is selected, a description of the transaction or frame is shown.
- ⑩ RAM, flash and one exchange: The RAM and flash of the PLC used by the user protocol (as a percentage of the user area), and the calculated transmission time for one exchange of the selected transaction. The transmission time does not include the scan time or the processing time of the device. RAM and flash are not shown while there are errors.
- ⑪ Bottom bar: Shows the numbers of ports, transactions and frames, and the number of errors. Click OK to put the definition into the project, or Cancel to discard your changes. Save the project to keep them in the file.
Shortcut Keys and Undo
| Key | Action |
|---|---|
Ctrl+Enter | OK |
Esc | Closes the window. If there are changes, asks Discard your changes? |
Ctrl+Z / Ctrl+Y | Undoes or redoes changes made in the window, one step at a time. When there is nothing left to undo, it goes on to Undo and Redo for the whole program. |
Ctrl+S | Saves the project. Changes made in the window are not saved until you click OK. |
Ctrl+T / Ctrl+M | Download / Monitoring |
← → · Alt+← Alt+→ · Delete · Insert | In a field strip: move between fields · move a field · delete a field · add a field |
- In a text box,
Ctrl+Zundoes the typing in that box. Characters typed one after another in the same box are undone as one step. - OK counts as one Undo step for the whole program. After clicking OK, you can restore the previous definition with Edit → Undo (
Ctrl+Z).
Frames
A frame is made of fields placed in order from the first byte. The byte positions (counting from 1) are shown under the fields, and when you select a checksum field, the range it covers is highlighted on the strip. Click + at the end of the field strip and choose a field type to add a field.
| Field | When sending | When receiving |
|---|---|---|
| Fixed | Sends the entered bytes as they are. | The frame matches only if the bytes are the same (the field shows Must match). |
| Value | Converts the value at a PLC address into bytes in the set format and sends them. | Converts the bytes into a value and stores it at the PLC address. |
| Text | Sends the characters at the PLC address. | Stores the received characters at the PLC address. The number of characters can be stored separately. |
| Skip | Sends the set number of fill bytes. | Ignores the bytes at that position. |
| Length | Sends the number of bytes in the specified fields. | Checks it against the actual number of bytes, and sets where a variable-length frame ends. |
| Checksum | Calculates and inserts it. | Calculates and checks it (the field shows Checksum · checked). If it is wrong, no value is stored. |
Fixed Bytes
In the Bytes box, enter hex bytes, text in double quotes and control character names, separated by spaces. The actual bytes and the number of bytes are shown below.
| How to write | Example | Bytes |
|---|---|---|
| 2-digit hex | FF 01 86 | FF 01 86 |
| Text in double quotes (ASCII) | “01R” | 30 31 52 |
Control character names (NUL to US, SP, DEL) | STX ETX CR LF ACK NAK | 02 03 0D 0A 06 15 |
Repeat (*N, 1 to 255) | 00*5 | 00 00 00 00 00 |
One field can hold up to 255 bytes. Characters outside ASCII must be written in hex. FF is read as the hex byte 0xFF, not as the control character name for form feed.
Value
In PLC address, enter the address whose value is sent or received (for example D100), or a symbol name, and choose the Format.
| Format | Settings | Example |
|---|---|---|
| Binary | Bytes (1, 2 or 4), byte order (Big-endian or Little-endian), sign (None or Signed) | 2 bytes, Big-endian: 01 9A ↔ 410 |
| ASCII decimal | Digits (1 to 10; leave empty for a variable number), padding (Zeros or Spaces), sign (None, − for negatives only, or Always +/−), decimal places (0 to 9), decimal point (None or Insert) | 4 digits, zero-padded: 100 ↔ “0100” · 2 decimal places, point inserted: 1234 ↔ “12.34” |
| ASCII hex | Digits, letter case when sending (Uppercase or Lowercase) | 4 digits: 6699 ↔ “1A2B” |
| BCD | Bytes (1, 2 or 4), byte order | 2 bytes: 1234 ↔ 12 34 |
| REAL | Byte order (4-byte real number) | Exchanged with real-number addresses (such as R). |
- When ASCII decimal is received, leading and trailing spaces,
+and-, and fewer decimal places than set (“12.3”→ 1230) are accepted. If a non-digit character arrives, or more nonzero decimal places than set (“12.345”), nothing is stored and the status word becomes Value conversion failed (F4). With a variable number of digits, 1 to 12 characters are accepted when receiving. - If a received value is too large for the PLC address, nothing is stored and the status becomes F4. The field shows a warning when the settings allow this.
- With 7 data bits, bytes above
0x7Flose their top bit. On a port with 7 data bits, a field with a binary value or with a fixed byte above0x7Fturns red.
Text
- Starting at PLC address (first word), the characters are stored two per word, low byte first (the low byte of
D200= the first character). - Length: Until terminator · max N receives up to N characters, until the fixed field that follows (for example
CR LF) arrives. Fixed N characters always takes exactly N characters. N is 1 to 255. - Enter a word address in Received length address to store the number of characters received. Pad byte (hex) is the byte that fills the remaining places when the text is shorter than N characters.
Length
Set the Format (binary 1 byte, binary 2 bytes, ASCII decimal or ASCII hex) and the Counted range (from one field number to another). When sending, the number of bytes in that range is inserted; when receiving, it is checked against the actual number of bytes. If the device adds a fixed number to the byte count, enter that number in Offset (added).
Checksum
| Type | Calculation |
|---|---|
| Sum (8-bit) · Sum (16-bit) | The lower 8 or 16 bits of the sum of the bytes in the range |
| Two's complement sum | The two's complement of the byte sum (the sum subtracted from 0x100) |
| One's complement sum | The byte sum with all bits inverted |
| XOR (BCC) | The XOR of the bytes in the range |
| CRC-16 | One of the algorithms below, or custom values |
| LRC | The two's complement of the sum of the bytes made from the ASCII hex characters in the range, two characters per byte (the Modbus ASCII method) |
- Start at: Choose Byte 1 or Byte 2, or enter the byte number to start from. For a device that leaves the header byte (such as STX) out of the calculation, choose Byte 2.
- End at: The default is just before the checksum. Frames with end characters after the checksum can also keep this default.
- Format: 1 byte, 2 bytes (Big-endian or Little-endian), or 2 or 4 ASCII hex digits. For ASCII hex, you can choose Uppercase or Lowercase for sending; case is ignored when receiving.
CRC-16 is calculated differently from device to device. When you choose a CRC-16 algorithm, the five values (polynomial, initial value, reflect input, reflect output and final XOR) are filled in, and the check value calculated from the string “123456789” is shown. Choose the algorithm whose check value matches the check value in the device manual. If you change any of the five values, the algorithm becomes Custom.
| Algorithm | Polynomial | Initial value | Reflect (input, output) | Final XOR | Check value |
|---|---|---|---|---|---|
| MODBUS | 8005 | FFFF | Yes | 0000 | 4B37 |
| CCITT-FALSE | 1021 | FFFF | No | 0000 | 29B1 |
| XMODEM | 1021 | 0000 | No | 0000 | 31C3 |
| KERMIT | 1021 | 0000 | Yes | 0000 | 2189 |
| X-25 | 1021 | FFFF | Yes | FFFF | 906E |
| ARC | 8005 | 0000 | Yes | 0000 | BB3D |
| USB | 8005 | FFFF | Yes | FFFF | B4C8 |
| DNP | 3D65 | 0000 | Yes | FFFF | EA82 |
The default format is Little-endian for MODBUS and Big-endian for every other algorithm.
End of a Received Frame
The end of a received frame is set by the frame's format and is shown above the field strip as end: ….
| Shown as | What sets the end |
|---|---|
| end: fixed length N | Every field of the frame has a set length. |
| end: length field (field N) | The value of a length field earlier in the frame |
| end: terminator … | The fixed bytes right after a variable-length field (for example CR LF or ETX) |
| end: after N ms idle | No byte arrives for the End-of-frame idle (ms) time. |
| end: unknown | The end cannot be determined, so it is shown as an error. |
End-of-frame idle (ms) appears in the properties on the right when you select a frame, and can be set from 20 to 10000 ms (leave it empty to not use it). A last field of unknown length is treated as finished when nothing is received for this time. When partly received bytes are left and nothing is received for 100 ms or more, those bytes are also dropped from the front.
Preview and Decoding Received Bytes
The preview shows the bytes of the frame to send in hex (value fields as 0, length and checksum as calculated). Paste the bytes the device sent into the box below, one frame per line, and they are decoded as the frame to receive, with the value and result shown for each field. You can use both hex (FF 86 01) and fixed-byte notation such as STX “01” ETX.
| Result | Meaning |
|---|---|
| ✓ … | The fixed bytes, length and checksum all match. After ✓, the value to be stored is shown for each field (Figure 12). A frame with no value fields shows this frame matches. |
| … incomplete | More bytes must arrive before the frame ends. |
| ✕ … — byte N differs from the fixed bytes | The bytes do not belong to this frame. |
| ✕ checksum — expected … | The checksum is wrong. The calculated value is shown with it. |
| ✕ … — cannot be converted to a value | The data is not a number or does not fit the address. |
Finding the Matching Checksum
Use this when the device manual does not describe the checksum method or the check value does not match. Paste two or more frames that the device actually sent. When the checksum does not match, MP STUDIO 2 automatically tries each checksum type, CRC-16 algorithm, format and range start, and lists the combinations that fit every sample on the Find matching checksum line, each with a Change to “…” button. With only one sample, a combination can match by chance, so Change to “…” is enabled only when there are two or more samples. The change goes into the definition only when you click OK.
Transactions
When you select a transaction in the transaction list, its settings appear at the top center, with the field strips of the frame to send and the frame to receive below them.
| Item | Default | Description |
|---|---|---|
| Name | Communication type name | The name of the transaction. It must be unique within the port. |
| Communication type | — | Request/response, Receive only, Respond on receive or Send only |
| Trigger | Periodic | Request/response and Send only: Periodic, Ladder UPTRIG number or When a value changes · Receive only and Respond on receive: always listening |
| Period (ms) | 1000 | 10 ms to 1 hour, counted from the previous start |
| Number | 1 | The UPTRIG number in the ladder (1 to 255) |
| Watch address · Words | — | When a value changes: sends when any value in the given number of words (1 to 32), starting at the watch address, changes. Also sends once when the PLC starts. |
| Timeout (ms) | 200 | How long Request/response waits for a response (20 to 60000 ms) |
| Retries | 2 | How many times to send again when there is no response or only wrong responses arrive (0 to 10) |
| Status word | Empty (not used) | The word address that receives the result of the transaction (see below) |
| Done bit | Empty (not used) | The bit address that turns on for one scan when the transaction ends |
| Receive counter | Empty (not used) | Receive only and Respond on receive: a word address that increases by 1 each time a matching frame is received (65535 rolls over to 0) |
- Choose the frame to send and the frame to receive from the list at the head of each field strip. Choosing + New frame creates an empty frame. You can set two or more frames to receive with + Receive frame.
- In Request/response, you can define the device's error response frame with + Error response (NAK, etc.). When an error response is received, the transaction ends with Error response (F6).
- In Respond on receive, the Send frame is the response. The values in the response are read from PLC addresses.
Behavior by Communication Type
- Request/response: The transaction succeeds if a frame to receive arrives within the response timeout after sending. If there is no response, or only wrong responses arrive, the request is sent again after the full response timeout, and the transaction fails once all retries are used. If the device sends only wrong responses, one transaction takes “timeout × (retries + 1)”. When an error response arrives, the transaction ends at once without sending again.
- Send only: The transaction ends successfully when the whole frame has been sent.
- Receive only: In the scan in which a matching frame is received, the values are stored, success is written to the status word, the done bit turns on for one scan, and the receive counter increases by 1.
- Respond on receive: The values are stored as in Receive only, and the response frame is sent at once. If the received frame does not match (different header bytes or a wrong checksum), no response is sent.
Status Word
The status word is one word that shows the last result of the transaction.
| Value (hex) | Shown as | Meaning |
|---|---|---|
0000 | No successful run yet | This transaction has not finished even once since the PLC was turned on. The value is also 0 when this definition is not in the program on the PLC. |
0001 | Last transaction succeeded | The last transaction finished without an error. |
F000 | No response (F0) | No response arrived. |
F100 | Checksum error (F1) | A response with a wrong checksum arrived. |
F200 | Only unrecognized bytes arrived (F2) | Only bytes that do not match the format of the frame to receive arrived. |
F300 | Line busy (F3) | The frame could not be sent because transmission did not proceed. |
F400 | Value conversion failed (F4) | The received value is not a number or does not fit the address. F4 is also set when a value to send cannot be made into a frame. |
F500 | Receive buffer overflow (F5) | The receive buffer overflowed while waiting for a response. |
F600 | Error response (F6) | A frame defined as the error response (NAK and so on) was received. |
- A failed transaction does not change the addresses that receive values. The values received earlier remain.
- If bytes were dropped before the response timeout expired, the status shows one reason, chosen in priority order F1, F4, F2. If no bytes were dropped, the status is F0.
- Each transaction must use its own status word. A warning is shown if the status word overlaps an address that receives values.
Allow Gaps Between Characters
This is set for each port, and is on for a new port.
- On: Sends one byte per scan. The scan time does not grow, but a request goes out over as many scans as it has bytes (about 50 ms for 10 bytes at a 5 ms scan). Most ASCII devices accept gaps between characters.
- Off: Sends the whole frame in one go. That scan becomes longer by the time it takes to send the frame. It must be off for a device that discards requests with gaps between characters.
Starting from the Ladder (UPTRIG)
When you set the Trigger of a transaction to Ladder UPTRIG number, the UPTRIG function in the ladder runs that transaction. Use this to send a setting command only when a button is pressed, or to read a value only when you need it.
- Set the Trigger of the transaction to Ladder UPTRIG number and enter the Number (1 to 255). If needed, also enter the Done bit and the Status word.
- Click OK.
- Add an
UPTRIGfunction to the ladder and enter the same number. Choose UPTRIG: Start User Protocol Trigger in the Serial Port category of the Functions panel, or typeUPTRIG 3in the Insert Function window (Ctrl+E).
When you edit the number cell of UPTRIG, the trigger numbers defined in the user protocol are listed with their communication port and transaction name, and you can click one to choose it. Click Open User Protocol in the same place to open the User Protocol window.
- Each time the input of
UPTRIGchanges from off to on, the transaction with that number runs once. Keeping the input on does not run it again. - If the number is called several times before the transaction runs, it runs only once. If it is called while the transaction is running, the transaction runs once more after it finishes.
- The done bit turns on for one scan when the transaction ends, whether it succeeded or failed. You can check the reason for a failure in the status word.
- Transactions with the same number on the same communication port run together. The same number cannot be used for transactions on different communication ports.
- Transactions started by a trigger do not run automatically after the PLC is turned on or a program is downloaded.
- The
UPTRIGnumber must be a constant from 1 to 255, and the user protocol must have a transaction started by that number. Otherwise theUPTRIGbox turns red and the program cannot be compiled. Conversely, if a transaction has a trigger number but there is no matchingUPTRIGin the ladder, the warning “No UPTRIG box calls trigger number 3, so this transaction never starts.” is shown.
Checks and Warnings
The User Protocol window marks errors and warnings by turning fields and input boxes red or orange, and shows the first message in the bar at the bottom of the window. Click a message to go to that place, or click N more to expand all messages. While there are red errors, Errors: N — the program won't compile until they are fixed is shown and you cannot download. OK still works while there are errors, so you do not lose a definition in progress.
The ladder and other features are checked for the following cases.
| Case | Shown as |
|---|---|
PUT, GET, PUT_LEN or GET_LEN is used on the same communication port | An error (shown in red) if the channel is a constant, a warning if it is a variable. If two features read the same receive buffer, the bytes they exchange get mixed up. |
| The ladder writes to an address that the user protocol receives into | Warning. The value written by the ladder is overwritten at the next reception. |
| Receiving addresses overlap each other · a status word, done bit or receive counter overlaps a receiving address | Warning |
| Addresses overlap those used by the Modbus device table or the PLC clock (RTC) block | Warning |
The port mode is not User Protocol · the mode is User Protocol but there is no definition · download is turned on | Error. Clicking OK in the User Protocol window fixes most of these at once. |
| The PLC does not have enough RAM · the program does not fit in the flash | Error. Reduce the ports, transactions or frames, or the memory area sizes. |
| A frame is longer than 255 bytes or has more than 32 fields | Error |
| The send or receive buffer is smaller than a frame | Error. Enlarge the buffer in the SERIAL field of Settings → Data Memory, or shorten the frame. |
Addresses used by the user protocol also appear in Find, Replace all, the Used at list of the Inspector and Used Data. When you change an address with Replace all, the user protocol addresses change too.
Simulation
During simulation, a virtual device is attached to the user protocol of each communication port, and the Virtual device view is added to the window. You can check the ladder's behavior and the status word and done bit without a device.
- Transactions — status word · response example: Choose a transaction and what the virtual device does (Response, No response, Bad checksum or Error response). For Response, enter the values the PLC is to receive. Until a response example is set, there is no response (status word F0).
- Virtual device sends on its own — Receive only / Respond on receive: Enter the values of a frame to receive and click Inject to have the virtual device send that frame.
- Inject raw bytes (garbage / resync test): Injects the entered bytes as they are, so you can check that noise bytes are dropped and matching starts again.
- Comm log (virtual time): Shows the bytes sent by the PLC and the bytes sent by the virtual device, one line each.
Only definitions confirmed with OK are simulated. A definition with errors is not simulated. Line busy (F3) and receive buffer overflow (F5) are not simulated, and the scan time and the processing time of the device are not included. The virtual device settings are not saved.
Monitoring
Status on Transaction Cards
If you open the User Protocol window during monitoring, the card of each transaction that has a status word shows the last result. Receive only and Respond on receive transactions also show the value of the receive counter and the time since it last increased. Status is read only for the transactions of the selected communication port.
The card shows the same text as the “Shown as” column of the Status Word table. When the status shown cannot be trusted, the reason is shown in gray.
| Shown in gray | Meaning |
|---|---|
| Different program on PLC | The program on the PLC may differ from this project. The status is read after you download. |
| Not downloaded yet | The transaction was not in the definition when monitoring started. Click OK, download and restart monitoring to read it. |
| PLC not responding · value unknown · No new value · value unknown | No new values are arriving over the monitoring connection. |
| Limited monitoring · not read | While there are program check errors, status words in user memory are not read. |
| Not written by the runtime | The user protocol does not write this value. The program on the PLC is different, or the ladder writes to this address. |
During simulation, the card also shows Virtual. A transaction that has not been confirmed with OK shows Not applied yet, and a stopped simulation shows Simulation stopped · ….
Comm Log
Turn on Comm log while monitoring for a port, click OK and download. During monitoring, the Comm log view then shows the bytes the PLC sent and received on that communication port, one line each. Turning on the comm log uses a little more RAM and flash on the PLC.
- ① Direction and time:
→marks bytes the PLC sent, and←bytes it received. Lines are in the order in which the PLC exchanged them, and the time is when the PC read the log. - ② Bytes: The bytes exchanged. The line below shows the transaction and frame names and the decoded values (for example
✓ D100 = 410 · ✓ Checksum DF). - ③ Result: The result of those bytes. A sent line shows Success, Waiting for response, Resent N, Not sent or the reason for a failure, and a received line shows Response, Receive, Error response (F6), dropped and so on. dropped marks bytes that matched no frame.
- ④ Byte view: Choose Hex, Text or Both. In the text view, control characters are shown like
‹STX›. - ⑤ Copy and Clear log: Copy the lines shown as text, or clear the log on the screen. While the view is scrolled to the bottom, it follows new lines.
- If the program on the PLC was downloaded with the comm log off, or differs from this project, the log is not read and the reason is shown.
- If the PLC writes new records before the monitor reads them, “… N missed in between” is shown.
- During simulation, the same view shows the exchange with the virtual device in virtual time.
PC Test
The PC test exchanges data directly with a device through a COM port on the PC (through a USB-RS485 or USB-RS232 converter, for example) instead of the PLC. Use it to check that the frames and checksum are right before you connect the device to the PLC. The test uses the definition as edited in the window, before OK, and is available only in the desktop app.
- ① PC COM port: The list of COM ports on the PC. USB devices are shown with the device name, as in
COM10 — USB Serial Port, and Bluetooth ports are shown asCOM23 (Bluetooth). At first, (select a port) is shown; if a COM port was opened for this communication port last time, it is selected in advance. Refresh reads the list again. - ② Open and Close: Opens the selected COM port. The baud rate, data bits, parity and stop bits are taken from the settings of that communication port. Switching to another view or closing the window closes the port.
- ③ One transaction — Request/response, Send only: Choose a transaction on the left, enter the values to send (sample values) and click Send once. The PC makes one exchange, with the response timeout and retries handled the same way as on the PLC, and shows the result.
- ④ Listen — Receive only / Respond on receive: Click Start listening to receive and decode the bytes the device sends. Use it to see exactly what a barcode reader sends. For a Respond on receive transaction, the PC responds with the sample values entered in ③.
- ⑤ Comm log: The bytes exchanged are shown in the same form as in the Comm log view. When a response arrives with a wrong checksum, the Find matching checksum line shows the checksum candidates that fit; once two or more such responses have been collected, you can click Change to “…”.
- A COM port in use by monitoring or download is marked “— in use by monitoring/download” and cannot be opened. Open it after monitoring or download has ended.
- The download COM port in the communication settings is marked “— download port”, and choosing it shows a notice that the port may be connected to the PLC.
- The PC test checks the PC-side line and the device. Check any behavior that depends on the scan time again on the PLC.
Examples
In the examples below, three of the templates are set on Comm Port 1 to Comm Port 3 of MPS-8A8R, one template per port. On other models, you can follow the same steps with only the communication port numbers changed.
Example 1. Reading a CO2 Sensor Every Second
In this example, a CO2 sensor connected to Comm Port 1 (9600 · 8-N-1) is read every second for its concentration, and a button input sends the zero command.
- In Settings → Communication Port, set Serial 1 to a baud rate of 9600, 8 data bits, no parity and 1 stop bit.
- In Settings → User Protocol…, select the Comm Port 1 tab and click the template CO2 / gas sensor — poll every second.
- Click OK. Comm Port 1 changes to
User Protocolmode. - Add a rung to the ladder that sends the zero command.
| Rung | Input | Function | What it does |
|---|---|---|---|
| 0 | M3 (NO) | UPTRIG 3 | Sends the zero command once when M3 turns on. |
| Frame | Bytes |
|---|---|
| CO2 request | FF 01 86 00 00 00 00 00 79 (fixed FF, 01, 86 and 00*5 + two's complement sum starting at Byte 2) |
| CO2 response | FF 86 + concentration in 2 bytes (Big-endian → D100) + 4 skipped bytes + two's complement sum |
| Zero command | FF 01 87 00 00 00 00 00 78 |
When the sensor sends FF 86 01 9A 00 00 00 00 DF, D100 becomes 410 (ppm), the status word D101 becomes 0001 (1 in decimal), and the done bit M100 turns on for one scan.
Example 2. Receiving Text from a Barcode Reader
In this example, a barcode reader is connected to Comm Port 2 (9600 · 8-N-1), and the scanned text is received starting at D200.
- Set Serial 2 to 9600 · 8-N-1.
- On the Comm Port 2 tab of the User Protocol window, choose the template Barcode / QR reader and click OK.
| Item | Value |
|---|---|
| Frame “Barcode” | Text (D200 · until terminator · max 32 · received length in D190) + fixed CR LF |
| Transaction “Receive barcode” | Receive only · always listening · done bit M101 · receive counter D191 |
When the reader sends ILOGICS-1234 followed by CR LF, D190 becomes 12, and the characters are stored from D200 on, two per word (D200 = I and L). M101 turns on for one scan, and D191 increases by 1. An empty line (only CR LF) is received as a frame with 0 characters.
Example 3. Reading an Inverter Value with ASCII Station Commands
In this example, an ASCII command device with station number 01 is connected to Comm Port 3 (9600 · 7-E-1), and the value at address 100 is read into D11 every 0.5 seconds.
- Set Serial 3 to a baud rate of 9600, 7 data bits, even parity and 1 stop bit.
- On the Comm Port 3 tab of the User Protocol window, choose the template Inverter / temperature controller (ASCII station commands) and click OK.
- Add a rung to the ladder that sets the address to read.
| Rung | Input | Function | What it does |
|---|---|---|---|
| 0 | @ON | MOVE 100 D10 | Puts the address to read, 100, in D10. |
| Frame | Format | Example |
|---|---|---|
| Station request | STX “01” “R” + address (ASCII decimal, 4 digits · D10) + ETX + sum (8-bit) as 2 ASCII hex digits (starting at Byte 2) | 02 “01R0100” 03 “77” |
| Station response | ACK “01” “R” + value (ASCII hex, 4 digits · D11) + ETX + sum (8-bit) as 2 ASCII hex digits (starting at Byte 2) | 06 “01R03E8” 03 “96” → D11 = 1000 |
| Station error (NAK) | NAK “01” ETX | When it is received, the status word D12 = F600 |
The transaction “Read station” is Request/response, with a period of 500 ms, a response timeout of 300 ms, 3 retries and the status word D12. In this template, Allow gaps between characters is off, so the request is sent in one go.
Troubleshooting
| Symptom | What to check |
|---|---|
The status word stays at 0000 | Check that the downloaded program contains the user protocol. For a transaction started by a trigger, also check that the UPTRIG input in the ladder changed from off to on. |
F000 (no response) | Use the PC test to check whether the device responds to the same frame. If it does, check the communication port number and terminals (RS-232, RS-485 or UART), the + and - wiring of RS-485, and the communication settings. If the device is slow to respond, increase the Timeout (ms). |
F100 (checksum error) | Paste two or more frames that the device sent and check them with Finding the Matching Checksum. |
F200 (only unrecognized bytes) | Paste the bytes the device sent into the preview to see which byte differs. Check the station number, the header bytes, the data bits (7 or 8) and the parity. |
F400 (value conversion failed) | In the preview, check the format of the value field (digits, decimal places, hex) and the size of the PLC address. |
F500 (receive buffer overflow) | If the scan time is long for the baud rate, more bytes than the receive buffer holds pile up within one scan. Shorten the scan time, or enlarge the receive buffer in the SERIAL field of Settings → Data Memory. With a 128-byte buffer at 115200 bps, the scan time must not exceed about 11 ms. |
| Requests go out but the device does not respond (gaps between characters) | The device may not accept gaps between characters. Turn off Allow gaps between characters for the port, download and check again. |
| Only the end of a long barcode is stored | When a code longer than the maximum number of characters of the text field arrives, only its last characters, up to that maximum, are stored. Set N larger than the longest code. |
| Values are stored even though the line is noisy | The PLC does not check for parity errors. Define frames that include a checksum. |
| The port does not open in the PC test | Check that monitoring, download or another program is not using that COM port. |
Things to Check
Cannot be opened in V1.2.0 or earlier
An.mpxproject that uses the user protocol orUPTRIGcannot be opened in V1.2.0 or earlier.
Set up the ladder so that it only reads the addresses that receive values.


















