IMDHMIControls LibraryShop main store

How-to

How a CJ2M protocol macro reads a 10-register Modbus block

Industrial networks Published 6 min read By IMDHMI controls team

Short answer

The short-read master function block stops at two registers, so the CJ2M must send the long-time protection request through an SCU protocol macro: one function 4 call for 10 registers, a receive sequence sized for the 20 data bytes, and a destination of ten consecutive words. A quantity below the full set returns an error, and the next poll waits for the macro's completion code.

On this page
  1. Can a CJ2M read the long-time protection block in one Modbus request?
  2. How many bytes does the block response carry?
  3. How do you build the function 4 request for the block?
  4. How do you size the protocol macro receive sequence?
  5. Where do the returned registers land in the CPU?
  6. How do you run the block read without breaking the short read?
  7. How do you verify the block arrived intact?
  8. Which path do you take for each read?
  9. Questions asked

The Omron CJ2M cannot fetch the Micrologic 5.2E long-time protection parameters with the short-read Modbus master function block, because that block reads one or two registers per poll and the trip unit's manual demands its long-time set as a single block of 10 registers. The block read goes through the serial unit's protocol macro instead: one function 4 request, a receive sequence sized for the whole response, and a destination that holds every returned word. The steps below build that sequence on a CJ2M CPU31 with an SCU21 or SCU41, keep the working short read as a diagnostic, and show the frame arithmetic you can check on the wire.

Can a CJ2M read the long-time protection block in one Modbus request? #

Yes: the SCU protocol macro sends one function 4 request for the whole set, while the short-read master function block stops at one or two registers per poll and cannot fetch it.

The Micrologic 5.2E documentation is explicit about the read shape. The long-time protection variables form one set, the set is read with Modbus function code 4 (read input registers), and a request for a partial set returns an error. On the wire, the breaker's Modbus communication interface is the slave: it collects the trip unit's data and answers with a single response frame.

The short-read ceiling belongs to the Easy Modbus RTU Master macro, not to Modbus itself; its receive logic was built for short replies. Give the block read its own sequence and leave the short read in place as a baseline. If the port answers nothing at all, fix the serial line first — the same class of fault as a CJ2M Modbus RTU master that gets no answer — before touching any macro.

How many bytes does the block response carry? #

The response carries 20 data bytes, so its byte-count field reads 20 decimal, and the whole frame is 25 bytes once the address, function, byte-count and CRC fields are added.

Worked example, standard Modbus RTU framing:

  • Request: 1 byte slave address + 1 byte function + 2 bytes start address + 2 bytes quantity + 2 bytes CRC = 8 bytes.
  • Response: 1 byte address + 1 byte function + 1 byte byte count + (10 × 2 = 20 bytes of data) + 2 bytes CRC = 25 bytes.

Read the byte-count field as bytes, not registers: it must equal twice the register count, and anything less means a truncated or partial answer. The receive side of the macro is where this bites, because a sequence built for a short reply fails on a good long one.

How do you build the function 4 request for the block? #

Transmit the slave address, function code 4, the start address the trip unit's map gives the long-time set, quantity 10 and the CRC, for 8 bytes on the wire.

  1. Copy the slave address and the serial settings from the working short read; change nothing at layer one for the block request.
  2. Set the function to 4, read input registers. Which area holds a value is fixed by the slave's map, and the difference covered in Modbus holding register vs input register: which one to use decides whether the read works at all.
  3. Set the quantity field to the block size, 0x000A as the two frame bytes.
  4. Take the start address from the long-time protection table of the trip unit's register map. This article does not print one: the address belongs to the map for your exact trip unit, and a guessed address reads the wrong variables.
  5. Let the macro calculate the CRC over the first six bytes of the request; Modbus RTU sends it low byte first.

How do you size the protocol macro receive sequence? #

Build the sequence in CX-Protocol with its receive step sized for the whole response frame and completion asserted only after the CRC lands, then run it from the CPU with PMCR (260).

Protocol macros are communications sequences created in CX-Protocol and downloaded to the serial unit; the instruction takes the sequence number as an operand. A receive message sized for a short reply reports a receive error on a good block response, so size it for the full frame length from the arithmetic above. Leave the existing short-read sequence untouched so it stays a working reference, and route the completion code — normal or Modbus exception — into the error-handling path the short read already uses.

Where do the returned registers land in the CPU? #

Reserve a run of consecutive D words the length of the block and aim the sequence at it, because the two fixed response words in the short-read macro cannot hold the set.

In the copy of the Easy Modbus RTU Master macro this example builds on, response data lands in D5004 and D5005, and the operand map marks D5006 as unused; where the Easy Modbus Master register area comes from shows how that macro's memory is laid out. That unused word can carry an indirect destination: load it with the first destination word, and the block sequence writes the returned words there while the established polling and error logic keeps running.

Audit the operand map in your own copy before assigning D5006, because the unused mark belongs to that macro revision, not to every project. Reserve ten consecutive words clear of command words, status words and any other poll's data, and set an invalid-data flag on error so application logic never reads stale words as a fresh answer.

How do you run the block read without breaking the short read? #

Run the known-good short read once for a clean baseline, then execute the new block sequence with PMCR (260) and hold the next poll until its completion code arrives.

  1. Confirm the short read still completes normally: right slave, right value, normal completion code.
  2. Load the indirect destination word, D5006 in this example, with the first of the reserved words.
  3. Trigger the block sequence by its sequence number.
  4. Wait for the completion code; a Modbus exception goes down the existing error path and sets the invalid-data flag.
  5. On normal completion, release the block's words to the application logic.
  6. Repeat only after completion: one transaction owns the serial port at a time, which is why Modbus RTU polling on one serial port is slow.

How do you verify the block arrived intact? #

The read passes when the frame is complete, the completion code is normal, exactly the reserved words change and every value matches what the trip unit itself reports.

  1. Frame: the response carries the same slave address, echoes function 4, and its byte count equals twice the register count.
  2. Completion: no exception code and no receive-length error.
  3. Memory: exactly the reserved words changed on the poll and the neighbouring words did not move.
  4. Values: compare each word with the trip unit's displayed settings, applying the documented word order to any value spread over two registers.

This poll only reads, and it stays that way: changing protection settings is a separate controlled procedure on the breaker itself, so no register write to a trip unit belongs in a polling loop.

Which path do you take for each read? #

Keep the short-read macro for small reads and give the long-time protection set its own protocol macro sequence: function 4, quantity 10 and a receive sized for the full frame.

Read you need Path What decides it
One or two registers Keep the Easy Modbus RTU Master short read It already works and stays as the diagnostic baseline
The long-time protection set Protocol macro sequence with the indirect destination The trip unit demands the whole block; a partial request errors
A block larger than the slave allows Expect an exception code The trip unit's published maximum governs, and this set cannot be split

Questions asked

Does Modbus itself limit how many registers one read can request?

Yes. The Modbus application protocol allows one function 3 or function 4 request to cover at most 125 registers, so the long-time set sits well inside the protocol's ceiling. The tighter limit is normally the slave: the trip unit's manual states which variables must be read together and its own block maximum, and a request above that maximum comes back as an exception code rather than data.

Can one PMCR instruction run both the short read and the block read?

Yes. PMCR (260) specifies the sequence number, so the same polling logic can call the existing short-read sequence for small reads and the block sequence for the long-time set. The sequences live on the serial unit, which holds 1,000 of them at most, so one added block sequence costs nothing that matters. Give each sequence its own number and keep the completion-code handling common to both.

How long does the block response take at 9600 baud?

About 29 ms for the response alone at 9600 baud. With 8 data bits, parity and one stop bit each character is 11 bits, and a 25-byte response is 275 bits: 275 divided by 9600 baud is 0.029 s, or 29 ms. The 8-byte request adds roughly 9 ms, and the slave's turnaround time sits between the two frames.

Do the returned values need word or byte swapping?

Check it on the first poll. Modbus sends each register high byte first, so a value held in one register lands correctly in one D word, but a 32-bit value spread over two registers may arrive with the low word first, depending on how the trip unit's map defines it. Compare the first block against the trip unit's display and apply its documented word order before trusting any scaled value.

Keep reading

  • Troubleshooting

    CB1241 reads zero on Modbus RTU while the transmitter works

    A CB1241 that reads zero while a USB-to-RS-485 converter reads the same transmitter is failing on the PLC side, and TIA Portal hides the cause: MB_MASTER completes with an error and the next scan's retry clears STATUS. Latch STATUS into a memory word when ERROR goes true, then fix the parity code, the unit ID, the 40001-based register number and the RS-485 bus, and keep the converter off the bus.

    Industrial networks

  • Troubleshooting

    Why a Modbus RTU frame gap before the CRC silences the slave

    Measure the idle time between the last request byte and the first CRC byte. Above 3.5 character times — 4.01 ms at 9600 baud with 11-bit characters — the slave ends the frame before the CRC, discards it without an exception reply, and treats the two CRC bytes as noise, so the master times out. The fix is a master driver that writes address, function, data and CRC in one continuous burst, not line tuning or a slower poll.

    Industrial networks

  • How-to

    How a PLC runs two Modbus networks at the same time

    Yes. Each serial port is its own independent link: the HMI polls the PLC on one port while the PLC acts as master, or slave, on a separate RS-485 Modbus RTU network. The two links share no settings — only their endpoints must match — and PLC copy logic moves any data between them.

    Industrial networks